1 |
1 |
/******************************************************************************
|
2 |
2 |
** This file is an amalgamation of many separate C source files from SQLite
|
3 |
|
** version 3.7.7.1. By combining all the individual C code files into this
|
|
3 |
** version 3.7.8. By combining all the individual C code files into this
|
4 |
4 |
** single large file, the entire code can be compiled as a single translation
|
5 |
5 |
** unit. This allows many compilers to do optimizations that would not be
|
6 |
6 |
** possible if the files were compiled separately. Performance improvements
|
... | ... | |
387 |
387 |
** specify which memory allocation subsystem to use.
|
388 |
388 |
**
|
389 |
389 |
** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
|
|
390 |
** SQLITE_WIN32_MALLOC // Use Win32 native heap API
|
390 |
391 |
** SQLITE_MEMDEBUG // Debugging version of system malloc()
|
391 |
392 |
**
|
|
393 |
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
|
|
394 |
** assert() macro is enabled, each call into the Win32 native heap subsystem
|
|
395 |
** will cause HeapValidate to be called. If heap validation should fail, an
|
|
396 |
** assertion will be triggered.
|
|
397 |
**
|
392 |
398 |
** (Historical note: There used to be several other options, but we've
|
393 |
399 |
** pared it down to just these two.)
|
394 |
400 |
**
|
395 |
401 |
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
|
396 |
402 |
** the default.
|
397 |
403 |
*/
|
398 |
|
#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)>1
|
|
404 |
#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1
|
399 |
405 |
# error "At most one of the following compile-time configuration options\
|
400 |
|
is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG"
|
|
406 |
is allows: SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG"
|
401 |
407 |
#endif
|
402 |
|
#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)==0
|
|
408 |
#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)==0
|
403 |
409 |
# define SQLITE_SYSTEM_MALLOC 1
|
404 |
410 |
#endif
|
405 |
411 |
|
... | ... | |
650 |
656 |
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
651 |
657 |
** [sqlite_version()] and [sqlite_source_id()].
|
652 |
658 |
*/
|
653 |
|
#define SQLITE_VERSION "3.7.7.1"
|
654 |
|
#define SQLITE_VERSION_NUMBER 3007007
|
655 |
|
#define SQLITE_SOURCE_ID "2011-06-28 17:39:05 af0d91adf497f5f36ec3813f04235a6e195a605f"
|
|
659 |
#define SQLITE_VERSION "3.7.8"
|
|
660 |
#define SQLITE_VERSION_NUMBER 3007008
|
|
661 |
#define SQLITE_SOURCE_ID "2011-09-19 14:49:19 3e0da808d2f5b4d12046e05980ca04578f581177"
|
656 |
662 |
|
657 |
663 |
/*
|
658 |
664 |
** CAPI3REF: Run-Time Library Version Numbers
|
... | ... | |
1284 |
1290 |
** Applications should not call [sqlite3_file_control()] with this
|
1285 |
1291 |
** opcode as doing so may disrupt the operation of the specialized VFSes
|
1286 |
1292 |
** that do require it.
|
|
1293 |
**
|
|
1294 |
** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
|
|
1295 |
** retry counts and intervals for certain disk I/O operations for the
|
|
1296 |
** windows [VFS] in order to work to provide robustness against
|
|
1297 |
** anti-virus programs. By default, the windows VFS will retry file read,
|
|
1298 |
** file write, and file delete opertions up to 10 times, with a delay
|
|
1299 |
** of 25 milliseconds before the first retry and with the delay increasing
|
|
1300 |
** by an additional 25 milliseconds with each subsequent retry. This
|
|
1301 |
** opcode allows those to values (10 retries and 25 milliseconds of delay)
|
|
1302 |
** to be adjusted. The values are changed for all database connections
|
|
1303 |
** within the same process. The argument is a pointer to an array of two
|
|
1304 |
** integers where the first integer i the new retry count and the second
|
|
1305 |
** integer is the delay. If either integer is negative, then the setting
|
|
1306 |
** is not changed but instead the prior value of that setting is written
|
|
1307 |
** into the array entry, allowing the current retry settings to be
|
|
1308 |
** interrogated. The zDbName parameter is ignored.
|
|
1309 |
**
|
|
1310 |
** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
|
|
1311 |
** persistent [WAL | Write AHead Log] setting. By default, the auxiliary
|
|
1312 |
** write ahead log and shared memory files used for transaction control
|
|
1313 |
** are automatically deleted when the latest connection to the database
|
|
1314 |
** closes. Setting persistent WAL mode causes those files to persist after
|
|
1315 |
** close. Persisting the files is useful when other processes that do not
|
|
1316 |
** have write permission on the directory containing the database file want
|
|
1317 |
** to read the database file, as the WAL and shared memory files must exist
|
|
1318 |
** in order for the database to be readable. The fourth parameter to
|
|
1319 |
** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
|
|
1320 |
** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
|
|
1321 |
** WAL mode. If the integer is -1, then it is overwritten with the current
|
|
1322 |
** WAL persistence setting.
|
|
1323 |
**
|
1287 |
1324 |
*/
|
1288 |
1325 |
#define SQLITE_FCNTL_LOCKSTATE 1
|
1289 |
1326 |
#define SQLITE_GET_LOCKPROXYFILE 2
|
... | ... | |
1293 |
1330 |
#define SQLITE_FCNTL_CHUNK_SIZE 6
|
1294 |
1331 |
#define SQLITE_FCNTL_FILE_POINTER 7
|
1295 |
1332 |
#define SQLITE_FCNTL_SYNC_OMITTED 8
|
1296 |
|
|
|
1333 |
#define SQLITE_FCNTL_WIN32_AV_RETRY 9
|
|
1334 |
#define SQLITE_FCNTL_PERSIST_WAL 10
|
1297 |
1335 |
|
1298 |
1336 |
/*
|
1299 |
1337 |
** CAPI3REF: Mutex Handle
|
... | ... | |
1721 |
1759 |
** order to verify that SQLite recovers gracefully from such
|
1722 |
1760 |
** conditions.
|
1723 |
1761 |
**
|
1724 |
|
** The xMalloc and xFree methods must work like the
|
1725 |
|
** malloc() and free() functions from the standard C library.
|
1726 |
|
** The xRealloc method must work like realloc() from the standard C library
|
1727 |
|
** with the exception that if the second argument to xRealloc is zero,
|
1728 |
|
** xRealloc must be a no-op - it must not perform any allocation or
|
1729 |
|
** deallocation. ^SQLite guarantees that the second argument to
|
|
1762 |
** The xMalloc, xRealloc, and xFree methods must work like the
|
|
1763 |
** malloc(), realloc() and free() functions from the standard C library.
|
|
1764 |
** ^SQLite guarantees that the second argument to
|
1730 |
1765 |
** xRealloc is always a value returned by a prior call to xRoundup.
|
1731 |
|
** And so in cases where xRoundup always returns a positive number,
|
1732 |
|
** xRealloc can perform exactly as the standard library realloc() and
|
1733 |
|
** still be in compliance with this specification.
|
1734 |
1766 |
**
|
1735 |
1767 |
** xSize should return the allocated size of a memory allocation
|
1736 |
1768 |
** previously obtained from xMalloc or xRealloc. The allocated size
|
... | ... | |
8146 |
8178 |
*/
|
8147 |
8179 |
#ifndef _SQLITE_VDBE_H_
|
8148 |
8180 |
#define _SQLITE_VDBE_H_
|
|
8181 |
/* #include <stdio.h> */
|
8149 |
8182 |
|
8150 |
8183 |
/*
|
8151 |
8184 |
** A single VDBE is an opaque structure named "Vdbe". Only routines
|
... | ... | |
8189 |
8222 |
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
|
8190 |
8223 |
int *ai; /* Used when p4type is P4_INTARRAY */
|
8191 |
8224 |
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
|
|
8225 |
int (*xAdvance)(BtCursor *, int *);
|
8192 |
8226 |
} p4;
|
8193 |
8227 |
#ifdef SQLITE_DEBUG
|
8194 |
8228 |
char *zComment; /* Comment to improve readability */
|
... | ... | |
8244 |
8278 |
#define P4_INT32 (-14) /* P4 is a 32-bit signed integer */
|
8245 |
8279 |
#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
|
8246 |
8280 |
#define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */
|
|
8281 |
#define P4_ADVANCE (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */
|
8247 |
8282 |
|
8248 |
8283 |
/* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure
|
8249 |
8284 |
** is made. That copy is freed when the Vdbe is finalized. But if the
|
... | ... | |
8341 |
8376 |
#define OP_Or 68 /* same as TK_OR */
|
8342 |
8377 |
#define OP_Not 19 /* same as TK_NOT */
|
8343 |
8378 |
#define OP_BitNot 93 /* same as TK_BITNOT */
|
8344 |
|
#define OP_If 26
|
8345 |
|
#define OP_IfNot 27
|
|
8379 |
#define OP_Once 26
|
|
8380 |
#define OP_If 27
|
|
8381 |
#define OP_IfNot 28
|
8346 |
8382 |
#define OP_IsNull 73 /* same as TK_ISNULL */
|
8347 |
8383 |
#define OP_NotNull 74 /* same as TK_NOTNULL */
|
8348 |
|
#define OP_Column 28
|
8349 |
|
#define OP_Affinity 29
|
8350 |
|
#define OP_MakeRecord 30
|
8351 |
|
#define OP_Count 31
|
8352 |
|
#define OP_Savepoint 32
|
8353 |
|
#define OP_AutoCommit 33
|
8354 |
|
#define OP_Transaction 34
|
8355 |
|
#define OP_ReadCookie 35
|
8356 |
|
#define OP_SetCookie 36
|
8357 |
|
#define OP_VerifyCookie 37
|
8358 |
|
#define OP_OpenRead 38
|
8359 |
|
#define OP_OpenWrite 39
|
8360 |
|
#define OP_OpenAutoindex 40
|
8361 |
|
#define OP_OpenEphemeral 41
|
8362 |
|
#define OP_OpenPseudo 42
|
8363 |
|
#define OP_Close 43
|
8364 |
|
#define OP_SeekLt 44
|
8365 |
|
#define OP_SeekLe 45
|
8366 |
|
#define OP_SeekGe 46
|
8367 |
|
#define OP_SeekGt 47
|
8368 |
|
#define OP_Seek 48
|
8369 |
|
#define OP_NotFound 49
|
8370 |
|
#define OP_Found 50
|
8371 |
|
#define OP_IsUnique 51
|
8372 |
|
#define OP_NotExists 52
|
8373 |
|
#define OP_Sequence 53
|
8374 |
|
#define OP_NewRowid 54
|
8375 |
|
#define OP_Insert 55
|
8376 |
|
#define OP_InsertInt 56
|
8377 |
|
#define OP_Delete 57
|
8378 |
|
#define OP_ResetCount 58
|
8379 |
|
#define OP_RowKey 59
|
8380 |
|
#define OP_RowData 60
|
8381 |
|
#define OP_Rowid 61
|
8382 |
|
#define OP_NullRow 62
|
8383 |
|
#define OP_Last 63
|
8384 |
|
#define OP_Sort 64
|
8385 |
|
#define OP_Rewind 65
|
8386 |
|
#define OP_Prev 66
|
8387 |
|
#define OP_Next 67
|
8388 |
|
#define OP_IdxInsert 70
|
8389 |
|
#define OP_IdxDelete 71
|
8390 |
|
#define OP_IdxRowid 72
|
8391 |
|
#define OP_IdxLT 81
|
8392 |
|
#define OP_IdxGE 92
|
8393 |
|
#define OP_Destroy 95
|
8394 |
|
#define OP_Clear 96
|
8395 |
|
#define OP_CreateIndex 97
|
8396 |
|
#define OP_CreateTable 98
|
8397 |
|
#define OP_ParseSchema 99
|
8398 |
|
#define OP_LoadAnalysis 100
|
8399 |
|
#define OP_DropTable 101
|
8400 |
|
#define OP_DropIndex 102
|
8401 |
|
#define OP_DropTrigger 103
|
8402 |
|
#define OP_IntegrityCk 104
|
8403 |
|
#define OP_RowSetAdd 105
|
8404 |
|
#define OP_RowSetRead 106
|
8405 |
|
#define OP_RowSetTest 107
|
8406 |
|
#define OP_Program 108
|
8407 |
|
#define OP_Param 109
|
8408 |
|
#define OP_FkCounter 110
|
8409 |
|
#define OP_FkIfZero 111
|
8410 |
|
#define OP_MemMax 112
|
8411 |
|
#define OP_IfPos 113
|
8412 |
|
#define OP_IfNeg 114
|
8413 |
|
#define OP_IfZero 115
|
8414 |
|
#define OP_AggStep 116
|
8415 |
|
#define OP_AggFinal 117
|
8416 |
|
#define OP_Checkpoint 118
|
8417 |
|
#define OP_JournalMode 119
|
8418 |
|
#define OP_Vacuum 120
|
8419 |
|
#define OP_IncrVacuum 121
|
8420 |
|
#define OP_Expire 122
|
8421 |
|
#define OP_TableLock 123
|
8422 |
|
#define OP_VBegin 124
|
8423 |
|
#define OP_VCreate 125
|
8424 |
|
#define OP_VDestroy 126
|
8425 |
|
#define OP_VOpen 127
|
8426 |
|
#define OP_VFilter 128
|
8427 |
|
#define OP_VColumn 129
|
8428 |
|
#define OP_VNext 131
|
8429 |
|
#define OP_VRename 132
|
8430 |
|
#define OP_VUpdate 133
|
8431 |
|
#define OP_Pagecount 134
|
8432 |
|
#define OP_MaxPgcnt 135
|
8433 |
|
#define OP_Trace 136
|
8434 |
|
#define OP_Noop 137
|
8435 |
|
#define OP_Explain 138
|
8436 |
|
|
8437 |
|
/* The following opcode values are never used */
|
8438 |
|
#define OP_NotUsed_139 139
|
8439 |
|
#define OP_NotUsed_140 140
|
|
8384 |
#define OP_Column 29
|
|
8385 |
#define OP_Affinity 30
|
|
8386 |
#define OP_MakeRecord 31
|
|
8387 |
#define OP_Count 32
|
|
8388 |
#define OP_Savepoint 33
|
|
8389 |
#define OP_AutoCommit 34
|
|
8390 |
#define OP_Transaction 35
|
|
8391 |
#define OP_ReadCookie 36
|
|
8392 |
#define OP_SetCookie 37
|
|
8393 |
#define OP_VerifyCookie 38
|
|
8394 |
#define OP_OpenRead 39
|
|
8395 |
#define OP_OpenWrite 40
|
|
8396 |
#define OP_OpenAutoindex 41
|
|
8397 |
#define OP_OpenEphemeral 42
|
|
8398 |
#define OP_SorterOpen 43
|
|
8399 |
#define OP_OpenPseudo 44
|
|
8400 |
#define OP_Close 45
|
|
8401 |
#define OP_SeekLt 46
|
|
8402 |
#define OP_SeekLe 47
|
|
8403 |
#define OP_SeekGe 48
|
|
8404 |
#define OP_SeekGt 49
|
|
8405 |
#define OP_Seek 50
|
|
8406 |
#define OP_NotFound 51
|
|
8407 |
#define OP_Found 52
|
|
8408 |
#define OP_IsUnique 53
|
|
8409 |
#define OP_NotExists 54
|
|
8410 |
#define OP_Sequence 55
|
|
8411 |
#define OP_NewRowid 56
|
|
8412 |
#define OP_Insert 57
|
|
8413 |
#define OP_InsertInt 58
|
|
8414 |
#define OP_Delete 59
|
|
8415 |
#define OP_ResetCount 60
|
|
8416 |
#define OP_SorterCompare 61
|
|
8417 |
#define OP_SorterData 62
|
|
8418 |
#define OP_RowKey 63
|
|
8419 |
#define OP_RowData 64
|
|
8420 |
#define OP_Rowid 65
|
|
8421 |
#define OP_NullRow 66
|
|
8422 |
#define OP_Last 67
|
|
8423 |
#define OP_SorterSort 70
|
|
8424 |
#define OP_Sort 71
|
|
8425 |
#define OP_Rewind 72
|
|
8426 |
#define OP_SorterNext 81
|
|
8427 |
#define OP_Prev 92
|
|
8428 |
#define OP_Next 95
|
|
8429 |
#define OP_SorterInsert 96
|
|
8430 |
#define OP_IdxInsert 97
|
|
8431 |
#define OP_IdxDelete 98
|
|
8432 |
#define OP_IdxRowid 99
|
|
8433 |
#define OP_IdxLT 100
|
|
8434 |
#define OP_IdxGE 101
|
|
8435 |
#define OP_Destroy 102
|
|
8436 |
#define OP_Clear 103
|
|
8437 |
#define OP_CreateIndex 104
|
|
8438 |
#define OP_CreateTable 105
|
|
8439 |
#define OP_ParseSchema 106
|
|
8440 |
#define OP_LoadAnalysis 107
|
|
8441 |
#define OP_DropTable 108
|
|
8442 |
#define OP_DropIndex 109
|
|
8443 |
#define OP_DropTrigger 110
|
|
8444 |
#define OP_IntegrityCk 111
|
|
8445 |
#define OP_RowSetAdd 112
|
|
8446 |
#define OP_RowSetRead 113
|
|
8447 |
#define OP_RowSetTest 114
|
|
8448 |
#define OP_Program 115
|
|
8449 |
#define OP_Param 116
|
|
8450 |
#define OP_FkCounter 117
|
|
8451 |
#define OP_FkIfZero 118
|
|
8452 |
#define OP_MemMax 119
|
|
8453 |
#define OP_IfPos 120
|
|
8454 |
#define OP_IfNeg 121
|
|
8455 |
#define OP_IfZero 122
|
|
8456 |
#define OP_AggStep 123
|
|
8457 |
#define OP_AggFinal 124
|
|
8458 |
#define OP_Checkpoint 125
|
|
8459 |
#define OP_JournalMode 126
|
|
8460 |
#define OP_Vacuum 127
|
|
8461 |
#define OP_IncrVacuum 128
|
|
8462 |
#define OP_Expire 129
|
|
8463 |
#define OP_TableLock 131
|
|
8464 |
#define OP_VBegin 132
|
|
8465 |
#define OP_VCreate 133
|
|
8466 |
#define OP_VDestroy 134
|
|
8467 |
#define OP_VOpen 135
|
|
8468 |
#define OP_VFilter 136
|
|
8469 |
#define OP_VColumn 137
|
|
8470 |
#define OP_VNext 138
|
|
8471 |
#define OP_VRename 139
|
|
8472 |
#define OP_VUpdate 140
|
|
8473 |
#define OP_Pagecount 146
|
|
8474 |
#define OP_MaxPgcnt 147
|
|
8475 |
#define OP_Trace 148
|
|
8476 |
#define OP_Noop 149
|
|
8477 |
#define OP_Explain 150
|
8440 |
8478 |
|
8441 |
8479 |
|
8442 |
8480 |
/* Properties such as "out2" or "jump" that are specified in
|
... | ... | |
8454 |
8492 |
/* 0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02,\
|
8455 |
8493 |
/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x24, 0x24,\
|
8456 |
8494 |
/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
|
8457 |
|
/* 24 */ 0x00, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\
|
8458 |
|
/* 32 */ 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00,\
|
8459 |
|
/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\
|
8460 |
|
/* 48 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00,\
|
8461 |
|
/* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\
|
8462 |
|
/* 64 */ 0x01, 0x01, 0x01, 0x01, 0x4c, 0x4c, 0x08, 0x00,\
|
8463 |
|
/* 72 */ 0x02, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
|
|
8495 |
/* 24 */ 0x00, 0x01, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00,\
|
|
8496 |
/* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
|
|
8497 |
/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
|
|
8498 |
/* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
|
|
8499 |
/* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
|
|
8500 |
/* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
|
|
8501 |
/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
|
8464 |
8502 |
/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
|
8465 |
|
/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x02,\
|
8466 |
|
/* 96 */ 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
|
8467 |
|
/* 104 */ 0x00, 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01,\
|
8468 |
|
/* 112 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\
|
8469 |
|
/* 120 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
|
8470 |
|
/* 128 */ 0x01, 0x00, 0x02, 0x01, 0x00, 0x00, 0x02, 0x02,\
|
8471 |
|
/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
|
8472 |
|
/* 144 */ 0x04, 0x04,}
|
|
8503 |
/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
|
|
8504 |
/* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
|
|
8505 |
/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
|
|
8506 |
/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
|
|
8507 |
/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
|
|
8508 |
/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
|
|
8509 |
/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
|
|
8510 |
/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
|
8473 |
8511 |
|
8474 |
8512 |
/************** End of opcodes.h *********************************************/
|
8475 |
8513 |
/************** Continuing where we left off in vdbe.h ***********************/
|
... | ... | |
8487 |
8525 |
SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
|
8488 |
8526 |
SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
|
8489 |
8527 |
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
|
8490 |
|
SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
|
8491 |
|
SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
|
8492 |
|
SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
|
|
8528 |
SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
|
|
8529 |
SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
|
|
8530 |
SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
|
8493 |
8531 |
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
|
8494 |
8532 |
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
|
8495 |
|
SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N);
|
|
8533 |
SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr);
|
8496 |
8534 |
SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
|
8497 |
8535 |
SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
|
8498 |
8536 |
SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
|
... | ... | |
8524 |
8562 |
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
|
8525 |
8563 |
#endif
|
8526 |
8564 |
|
8527 |
|
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int);
|
8528 |
|
SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
|
|
8565 |
SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
|
8529 |
8566 |
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
|
|
8567 |
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
|
8530 |
8568 |
|
8531 |
8569 |
#ifndef SQLITE_OMIT_TRIGGER
|
8532 |
8570 |
SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
|
... | ... | |
9560 |
9598 |
#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */
|
9561 |
9599 |
#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */
|
9562 |
9600 |
#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */
|
|
9601 |
#define SQLITE_DistinctOpt 0x80 /* DISTINCT using indexes */
|
9563 |
9602 |
#define SQLITE_OptMask 0xff /* Mask of all disablable opts */
|
9564 |
9603 |
|
9565 |
9604 |
/*
|
... | ... | |
10139 |
10178 |
u8 useSortingIdx; /* In direct mode, reference the sorting index rather
|
10140 |
10179 |
** than the source table */
|
10141 |
10180 |
int sortingIdx; /* Cursor number of the sorting index */
|
|
10181 |
int sortingIdxPTab; /* Cursor number of pseudo-table */
|
10142 |
10182 |
ExprList *pGroupBy; /* The group by clause */
|
10143 |
10183 |
int nSortingColumn; /* Number of columns in the sorting index */
|
10144 |
10184 |
struct AggInfo_col { /* For each column used in source tables */
|
... | ... | |
10448 |
10488 |
char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
|
10449 |
10489 |
Table *pTab; /* An SQL table corresponding to zName */
|
10450 |
10490 |
Select *pSelect; /* A SELECT statement used in place of a table name */
|
10451 |
|
u8 isPopulated; /* Temporary table associated with SELECT is populated */
|
|
10491 |
int addrFillSub; /* Address of subroutine to manifest a subquery */
|
|
10492 |
int regReturn; /* Register holding return address of addrFillSub */
|
10452 |
10493 |
u8 jointype; /* Type of join between this able and the previous */
|
10453 |
10494 |
u8 notIndexed; /* True if there is a NOT INDEXED clause */
|
|
10495 |
u8 isCorrelated; /* True if sub-query is correlated */
|
10454 |
10496 |
#ifndef SQLITE_OMIT_EXPLAIN
|
10455 |
10497 |
u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
|
10456 |
10498 |
#endif
|
... | ... | |
10570 |
10612 |
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
|
10571 |
10613 |
u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */
|
10572 |
10614 |
u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
|
|
10615 |
u8 eDistinct;
|
10573 |
10616 |
SrcList *pTabList; /* List of tables in the join */
|
10574 |
10617 |
int iTop; /* The very beginning of the WHERE loop */
|
10575 |
10618 |
int iContinue; /* Jump here to continue with next record */
|
... | ... | |
10581 |
10624 |
WhereLevel a[1]; /* Information about each nest loop in WHERE */
|
10582 |
10625 |
};
|
10583 |
10626 |
|
|
10627 |
#define WHERE_DISTINCT_UNIQUE 1
|
|
10628 |
#define WHERE_DISTINCT_ORDERED 2
|
|
10629 |
|
10584 |
10630 |
/*
|
10585 |
10631 |
** A NameContext defines a context in which to resolve table and column
|
10586 |
10632 |
** names. The context consists of a list of tables (the pSrcList) field and
|
... | ... | |
10666 |
10712 |
#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
|
10667 |
10713 |
#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
|
10668 |
10714 |
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
|
|
10715 |
#define SF_UseSorter 0x0040 /* Sort using a sorter */
|
10669 |
10716 |
|
10670 |
10717 |
|
10671 |
10718 |
/*
|
... | ... | |
11342 |
11389 |
#endif
|
11343 |
11390 |
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
|
11344 |
11391 |
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
|
11345 |
|
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16);
|
|
11392 |
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
|
11346 |
11393 |
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
|
11347 |
11394 |
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
|
11348 |
11395 |
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
|
... | ... | |
11992 |
12039 |
SQLITE_THREADSAFE==1, /* bFullMutex */
|
11993 |
12040 |
SQLITE_USE_URI, /* bOpenUri */
|
11994 |
12041 |
0x7ffffffe, /* mxStrlen */
|
11995 |
|
100, /* szLookaside */
|
|
12042 |
128, /* szLookaside */
|
11996 |
12043 |
500, /* nLookaside */
|
11997 |
12044 |
{0,0,0,0,0,0,0,0}, /* m */
|
11998 |
12045 |
{0,0,0,0,0,0,0,0,0}, /* mutex */
|
... | ... | |
12215 |
12262 |
#ifdef SQLITE_LOCK_TRACE
|
12216 |
12263 |
"LOCK_TRACE",
|
12217 |
12264 |
#endif
|
|
12265 |
#ifdef SQLITE_MAX_SCHEMA_RETRY
|
|
12266 |
"MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
|
|
12267 |
#endif
|
12218 |
12268 |
#ifdef SQLITE_MEMDEBUG
|
12219 |
12269 |
"MEMDEBUG",
|
12220 |
12270 |
#endif
|
... | ... | |
12328 |
12378 |
#ifdef SQLITE_OMIT_MEMORYDB
|
12329 |
12379 |
"OMIT_MEMORYDB",
|
12330 |
12380 |
#endif
|
|
12381 |
#ifdef SQLITE_OMIT_MERGE_SORT
|
|
12382 |
"OMIT_MERGE_SORT",
|
|
12383 |
#endif
|
12331 |
12384 |
#ifdef SQLITE_OMIT_OR_OPTIMIZATION
|
12332 |
12385 |
"OMIT_OR_OPTIMIZATION",
|
12333 |
12386 |
#endif
|
... | ... | |
12394 |
12447 |
#ifdef SQLITE_OMIT_XFER_OPT
|
12395 |
12448 |
"OMIT_XFER_OPT",
|
12396 |
12449 |
#endif
|
|
12450 |
#ifdef SQLITE_PAGECACHE_BLOCKALLOC
|
|
12451 |
"PAGECACHE_BLOCKALLOC",
|
|
12452 |
#endif
|
12397 |
12453 |
#ifdef SQLITE_PERFORMANCE_TRACE
|
12398 |
12454 |
"PERFORMANCE_TRACE",
|
12399 |
12455 |
#endif
|
... | ... | |
12514 |
12570 |
*/
|
12515 |
12571 |
typedef unsigned char Bool;
|
12516 |
12572 |
|
|
12573 |
/* Opaque type used by code in vdbesort.c */
|
|
12574 |
typedef struct VdbeSorter VdbeSorter;
|
|
12575 |
|
12517 |
12576 |
/*
|
12518 |
12577 |
** A cursor is a pointer into a single BTree within a database file.
|
12519 |
12578 |
** The cursor can seek to a BTree entry with a particular key, or
|
... | ... | |
12540 |
12599 |
Bool isTable; /* True if a table requiring integer keys */
|
12541 |
12600 |
Bool isIndex; /* True if an index containing keys only - no data */
|
12542 |
12601 |
Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */
|
|
12602 |
Bool isSorter; /* True if a new-style sorter */
|
12543 |
12603 |
sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */
|
12544 |
12604 |
const sqlite3_module *pModule; /* Module for cursor pVtabCursor */
|
12545 |
12605 |
i64 seqCount; /* Sequence counter */
|
12546 |
12606 |
i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */
|
12547 |
12607 |
i64 lastRowid; /* Last rowid from a Next or NextIdx operation */
|
|
12608 |
VdbeSorter *pSorter; /* Sorter object for OP_SorterOpen cursors */
|
12548 |
12609 |
|
12549 |
12610 |
/* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or
|
12550 |
12611 |
** OP_IsUnique opcode on this cursor. */
|
... | ... | |
12864 |
12925 |
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
|
12865 |
12926 |
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
|
12866 |
12927 |
SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
|
|
12928 |
#define MemReleaseExt(X) \
|
|
12929 |
if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \
|
|
12930 |
sqlite3VdbeMemReleaseExternal(X);
|
12867 |
12931 |
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
|
12868 |
12932 |
SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
|
12869 |
12933 |
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
|
... | ... | |
12872 |
12936 |
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
|
12873 |
12937 |
SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
|
12874 |
12938 |
|
|
12939 |
#ifdef SQLITE_OMIT_MERGE_SORT
|
|
12940 |
# define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK
|
|
12941 |
# define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK
|
|
12942 |
# define sqlite3VdbeSorterClose(Y,Z)
|
|
12943 |
# define sqlite3VdbeSorterRowkey(Y,Z) SQLITE_OK
|
|
12944 |
# define sqlite3VdbeSorterRewind(X,Y,Z) SQLITE_OK
|
|
12945 |
# define sqlite3VdbeSorterNext(X,Y,Z) SQLITE_OK
|
|
12946 |
# define sqlite3VdbeSorterCompare(X,Y,Z) SQLITE_OK
|
|
12947 |
#else
|
|
12948 |
SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
|
|
12949 |
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
|
|
12950 |
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(VdbeCursor *, Mem *);
|
|
12951 |
SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, VdbeCursor *, int *);
|
|
12952 |
SQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, VdbeCursor *, int *);
|
|
12953 |
SQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, VdbeCursor *, Mem *);
|
|
12954 |
SQLITE_PRIVATE int sqlite3VdbeSorterCompare(VdbeCursor *, Mem *, int *);
|
|
12955 |
#endif
|
|
12956 |
|
12875 |
12957 |
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
|
12876 |
12958 |
SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*);
|
12877 |
12959 |
SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe*);
|
... | ... | |
13165 |
13247 |
** Willmann-Bell, Inc
|
13166 |
13248 |
** Richmond, Virginia (USA)
|
13167 |
13249 |
*/
|
|
13250 |
/* #include <stdlib.h> */
|
|
13251 |
/* #include <assert.h> */
|
13168 |
13252 |
#include <time.h>
|
13169 |
13253 |
|
13170 |
13254 |
#ifndef SQLITE_OMIT_DATETIME_FUNCS
|
... | ... | |
13546 |
13630 |
#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
|
13547 |
13631 |
&& (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
|
13548 |
13632 |
struct tm *pX;
|
|
13633 |
#if SQLITE_THREADSAFE>0
|
13549 |
13634 |
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
|
|
13635 |
#endif
|
13550 |
13636 |
sqlite3_mutex_enter(mutex);
|
13551 |
13637 |
pX = localtime(t);
|
13552 |
13638 |
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
... | ... | |
14380 |
14466 |
** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
|
14381 |
14467 |
** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
|
14382 |
14468 |
** reaching the VFS. */
|
14383 |
|
rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f3f, pFlagsOut);
|
|
14469 |
rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
|
14384 |
14470 |
assert( rc==SQLITE_OK || pFile->pMethods==0 );
|
14385 |
14471 |
return rc;
|
14386 |
14472 |
}
|
... | ... | |
14452 |
14538 |
){
|
14453 |
14539 |
int rc = SQLITE_NOMEM;
|
14454 |
14540 |
sqlite3_file *pFile;
|
14455 |
|
pFile = (sqlite3_file *)sqlite3Malloc(pVfs->szOsFile);
|
|
14541 |
pFile = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile);
|
14456 |
14542 |
if( pFile ){
|
14457 |
14543 |
rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags);
|
14458 |
14544 |
if( rc!=SQLITE_OK ){
|
... | ... | |
14916 |
15002 |
# define backtrace(A,B) 1
|
14917 |
15003 |
# define backtrace_symbols_fd(A,B,C)
|
14918 |
15004 |
#endif
|
|
15005 |
/* #include <stdio.h> */
|
14919 |
15006 |
|
14920 |
15007 |
/*
|
14921 |
15008 |
** Each memory allocation looks like this:
|
... | ... | |
15841 |
15928 |
** This function assumes that the necessary mutexes, if any, are
|
15842 |
15929 |
** already held by the caller. Hence "Unsafe".
|
15843 |
15930 |
*/
|
15844 |
|
void memsys3FreeUnsafe(void *pOld){
|
|
15931 |
static void memsys3FreeUnsafe(void *pOld){
|
15845 |
15932 |
Mem3Block *p = (Mem3Block*)pOld;
|
15846 |
15933 |
int i;
|
15847 |
15934 |
u32 size, x;
|
... | ... | |
15916 |
16003 |
/*
|
15917 |
16004 |
** Free memory.
|
15918 |
16005 |
*/
|
15919 |
|
void memsys3Free(void *pPrior){
|
|
16006 |
static void memsys3Free(void *pPrior){
|
15920 |
16007 |
assert( pPrior );
|
15921 |
16008 |
memsys3Enter();
|
15922 |
16009 |
memsys3FreeUnsafe(pPrior);
|
... | ... | |
15926 |
16013 |
/*
|
15927 |
16014 |
** Change the size of an existing memory allocation
|
15928 |
16015 |
*/
|
15929 |
|
void *memsys3Realloc(void *pPrior, int nBytes){
|
|
16016 |
static void *memsys3Realloc(void *pPrior, int nBytes){
|
15930 |
16017 |
int nOld;
|
15931 |
16018 |
void *p;
|
15932 |
16019 |
if( pPrior==0 ){
|
... | ... | |
18019 |
18106 |
**
|
18020 |
18107 |
** Memory allocation functions used throughout sqlite.
|
18021 |
18108 |
*/
|
|
18109 |
/* #include <stdarg.h> */
|
18022 |
18110 |
|
18023 |
18111 |
/*
|
18024 |
18112 |
** Attempt to release up to n bytes of non-essential memory currently
|
... | ... | |
19996 |
20084 |
** 0xfe 0xff big-endian utf-16 follows
|
19997 |
20085 |
**
|
19998 |
20086 |
*/
|
|
20087 |
/* #include <assert.h> */
|
19999 |
20088 |
|
20000 |
20089 |
#ifndef SQLITE_AMALGAMATION
|
20001 |
20090 |
/*
|
... | ... | |
20538 |
20627 |
** strings, and stuff like that.
|
20539 |
20628 |
**
|
20540 |
20629 |
*/
|
|
20630 |
/* #include <stdarg.h> */
|
20541 |
20631 |
#ifdef SQLITE_HAVE_ISNAN
|
20542 |
20632 |
# include <math.h>
|
20543 |
20633 |
#endif
|
... | ... | |
21670 |
21760 |
|
21671 |
21761 |
#ifdef SQLITE_ENABLE_8_3_NAMES
|
21672 |
21762 |
/*
|
21673 |
|
** If SQLITE_ENABLE_8_3_NAME is set at compile-time and if the database
|
|
21763 |
** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database
|
21674 |
21764 |
** filename in zBaseFilename is a URI with the "8_3_names=1" parameter and
|
21675 |
21765 |
** if filename in z[] has a suffix (a.k.a. "extension") that is longer than
|
21676 |
21766 |
** three characters, then shorten the suffix on z[] to be the last three
|
21677 |
21767 |
** characters of the original suffix.
|
21678 |
21768 |
**
|
|
21769 |
** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
|
|
21770 |
** do the suffix shortening regardless of URI parameter.
|
|
21771 |
**
|
21679 |
21772 |
** Examples:
|
21680 |
21773 |
**
|
21681 |
21774 |
** test.db-journal => test.nal
|
... | ... | |
21683 |
21776 |
** test.db-shm => test.shm
|
21684 |
21777 |
*/
|
21685 |
21778 |
SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
|
|
21779 |
#if SQLITE_ENABLE_8_3_NAMES<2
|
21686 |
21780 |
const char *zOk;
|
21687 |
21781 |
zOk = sqlite3_uri_parameter(zBaseFilename, "8_3_names");
|
21688 |
|
if( zOk && sqlite3GetBoolean(zOk) ){
|
|
21782 |
if( zOk && sqlite3GetBoolean(zOk) )
|
|
21783 |
#endif
|
|
21784 |
{
|
21689 |
21785 |
int i, sz;
|
21690 |
21786 |
sz = sqlite3Strlen30(z);
|
21691 |
21787 |
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
|
... | ... | |
21710 |
21806 |
** This is the implementation of generic hash-tables
|
21711 |
21807 |
** used in SQLite.
|
21712 |
21808 |
*/
|
|
21809 |
/* #include <assert.h> */
|
21713 |
21810 |
|
21714 |
21811 |
/* Turn bulk memory into a hash table object by initializing the
|
21715 |
21812 |
** fields of the Hash structure.
|
... | ... | |
22004 |
22101 |
/* 23 */ "Permutation",
|
22005 |
22102 |
/* 24 */ "Compare",
|
22006 |
22103 |
/* 25 */ "Jump",
|
22007 |
|
/* 26 */ "If",
|
22008 |
|
/* 27 */ "IfNot",
|
22009 |
|
/* 28 */ "Column",
|
22010 |
|
/* 29 */ "Affinity",
|
22011 |
|
/* 30 */ "MakeRecord",
|
22012 |
|
/* 31 */ "Count",
|
22013 |
|
/* 32 */ "Savepoint",
|
22014 |
|
/* 33 */ "AutoCommit",
|
22015 |
|
/* 34 */ "Transaction",
|
22016 |
|
/* 35 */ "ReadCookie",
|
22017 |
|
/* 36 */ "SetCookie",
|
22018 |
|
/* 37 */ "VerifyCookie",
|
22019 |
|
/* 38 */ "OpenRead",
|
22020 |
|
/* 39 */ "OpenWrite",
|
22021 |
|
/* 40 */ "OpenAutoindex",
|
22022 |
|
/* 41 */ "OpenEphemeral",
|
22023 |
|
/* 42 */ "OpenPseudo",
|
22024 |
|
/* 43 */ "Close",
|
22025 |
|
/* 44 */ "SeekLt",
|
22026 |
|
/* 45 */ "SeekLe",
|
22027 |
|
/* 46 */ "SeekGe",
|
22028 |
|
/* 47 */ "SeekGt",
|
22029 |
|
/* 48 */ "Seek",
|
22030 |
|
/* 49 */ "NotFound",
|
22031 |
|
/* 50 */ "Found",
|
22032 |
|
/* 51 */ "IsUnique",
|
22033 |
|
/* 52 */ "NotExists",
|
22034 |
|
/* 53 */ "Sequence",
|
22035 |
|
/* 54 */ "NewRowid",
|
22036 |
|
/* 55 */ "Insert",
|
22037 |
|
/* 56 */ "InsertInt",
|
22038 |
|
/* 57 */ "Delete",
|
22039 |
|
/* 58 */ "ResetCount",
|
22040 |
|
/* 59 */ "RowKey",
|
22041 |
|
/* 60 */ "RowData",
|
22042 |
|
/* 61 */ "Rowid",
|
22043 |
|
/* 62 */ "NullRow",
|
22044 |
|
/* 63 */ "Last",
|
22045 |
|
/* 64 */ "Sort",
|
22046 |
|
/* 65 */ "Rewind",
|
22047 |
|
/* 66 */ "Prev",
|
22048 |
|
/* 67 */ "Next",
|
|
22104 |
/* 26 */ "Once",
|
|
22105 |
/* 27 */ "If",
|
|
22106 |
/* 28 */ "IfNot",
|
|
22107 |
/* 29 */ "Column",
|
|
22108 |
/* 30 */ "Affinity",
|
|
22109 |
/* 31 */ "MakeRecord",
|
|
22110 |
/* 32 */ "Count",
|
|
22111 |
/* 33 */ "Savepoint",
|
|
22112 |
/* 34 */ "AutoCommit",
|
|
22113 |
/* 35 */ "Transaction",
|
|
22114 |
/* 36 */ "ReadCookie",
|
|
22115 |
/* 37 */ "SetCookie",
|
|
22116 |
/* 38 */ "VerifyCookie",
|
|
22117 |
/* 39 */ "OpenRead",
|
|
22118 |
/* 40 */ "OpenWrite",
|
|
22119 |
/* 41 */ "OpenAutoindex",
|
|
22120 |
/* 42 */ "OpenEphemeral",
|
|
22121 |
/* 43 */ "SorterOpen",
|
|
22122 |
/* 44 */ "OpenPseudo",
|
|
22123 |
/* 45 */ "Close",
|
|
22124 |
/* 46 */ "SeekLt",
|
|
22125 |
/* 47 */ "SeekLe",
|
|
22126 |
/* 48 */ "SeekGe",
|
|
22127 |
/* 49 */ "SeekGt",
|
|
22128 |
/* 50 */ "Seek",
|
|
22129 |
/* 51 */ "NotFound",
|
|
22130 |
/* 52 */ "Found",
|
|
22131 |
/* 53 */ "IsUnique",
|
|
22132 |
/* 54 */ "NotExists",
|
|
22133 |
/* 55 */ "Sequence",
|
|
22134 |
/* 56 */ "NewRowid",
|
|
22135 |
/* 57 */ "Insert",
|
|
22136 |
/* 58 */ "InsertInt",
|
|
22137 |
/* 59 */ "Delete",
|
|
22138 |
/* 60 */ "ResetCount",
|
|
22139 |
/* 61 */ "SorterCompare",
|
|
22140 |
/* 62 */ "SorterData",
|
|
22141 |
/* 63 */ "RowKey",
|
|
22142 |
/* 64 */ "RowData",
|
|
22143 |
/* 65 */ "Rowid",
|
|
22144 |
/* 66 */ "NullRow",
|
|
22145 |
/* 67 */ "Last",
|
22049 |
22146 |
/* 68 */ "Or",
|
22050 |
22147 |
/* 69 */ "And",
|
22051 |
|
/* 70 */ "IdxInsert",
|
22052 |
|
/* 71 */ "IdxDelete",
|
22053 |
|
/* 72 */ "IdxRowid",
|
|
22148 |
/* 70 */ "SorterSort",
|
|
22149 |
/* 71 */ "Sort",
|
|
22150 |
/* 72 */ "Rewind",
|
22054 |
22151 |
/* 73 */ "IsNull",
|
22055 |
22152 |
/* 74 */ "NotNull",
|
22056 |
22153 |
/* 75 */ "Ne",
|
... | ... | |
22059 |
22156 |
/* 78 */ "Le",
|
22060 |
22157 |
/* 79 */ "Lt",
|
22061 |
22158 |
/* 80 */ "Ge",
|
22062 |
|
/* 81 */ "IdxLT",
|
|
22159 |
/* 81 */ "SorterNext",
|
22063 |
22160 |
/* 82 */ "BitAnd",
|
22064 |
22161 |
/* 83 */ "BitOr",
|
22065 |
22162 |
/* 84 */ "ShiftLeft",
|
... | ... | |
22070 |
22167 |
/* 89 */ "Divide",
|
22071 |
22168 |
/* 90 */ "Remainder",
|
22072 |
22169 |
/* 91 */ "Concat",
|
22073 |
|
/* 92 */ "IdxGE",
|
|
22170 |
/* 92 */ "Prev",
|
22074 |
22171 |
/* 93 */ "BitNot",
|
22075 |
22172 |
/* 94 */ "String8",
|
22076 |
|
/* 95 */ "Destroy",
|
22077 |
|
/* 96 */ "Clear",
|
22078 |
|
/* 97 */ "CreateIndex",
|
22079 |
|
/* 98 */ "CreateTable",
|
22080 |
|
/* 99 */ "ParseSchema",
|
22081 |
|
/* 100 */ "LoadAnalysis",
|
22082 |
|
/* 101 */ "DropTable",
|
22083 |
|
/* 102 */ "DropIndex",
|
22084 |
|
/* 103 */ "DropTrigger",
|
22085 |
|
/* 104 */ "IntegrityCk",
|
22086 |
|
/* 105 */ "RowSetAdd",
|
22087 |
|
/* 106 */ "RowSetRead",
|
22088 |
|
/* 107 */ "RowSetTest",
|
22089 |
|
/* 108 */ "Program",
|
22090 |
|
/* 109 */ "Param",
|
22091 |
|
/* 110 */ "FkCounter",
|
22092 |
|
/* 111 */ "FkIfZero",
|
22093 |
|
/* 112 */ "MemMax",
|
22094 |
|
/* 113 */ "IfPos",
|
22095 |
|
/* 114 */ "IfNeg",
|
22096 |
|
/* 115 */ "IfZero",
|
22097 |
|
/* 116 */ "AggStep",
|
22098 |
|
/* 117 */ "AggFinal",
|
22099 |
|
/* 118 */ "Checkpoint",
|
22100 |
|
/* 119 */ "JournalMode",
|
22101 |
|
/* 120 */ "Vacuum",
|
22102 |
|
/* 121 */ "IncrVacuum",
|
22103 |
|
/* 122 */ "Expire",
|
22104 |
|
/* 123 */ "TableLock",
|
22105 |
|
/* 124 */ "VBegin",
|
22106 |
|
/* 125 */ "VCreate",
|
22107 |
|
/* 126 */ "VDestroy",
|
22108 |
|
/* 127 */ "VOpen",
|
22109 |
|
/* 128 */ "VFilter",
|
22110 |
|
/* 129 */ "VColumn",
|
|
22173 |
/* 95 */ "Next",
|
|
22174 |
/* 96 */ "SorterInsert",
|
|
22175 |
/* 97 */ "IdxInsert",
|
|
22176 |
/* 98 */ "IdxDelete",
|
|
22177 |
/* 99 */ "IdxRowid",
|
|
22178 |
/* 100 */ "IdxLT",
|
|
22179 |
/* 101 */ "IdxGE",
|
|
22180 |
/* 102 */ "Destroy",
|
|
22181 |
/* 103 */ "Clear",
|
|
22182 |
/* 104 */ "CreateIndex",
|
|
22183 |
/* 105 */ "CreateTable",
|
|
22184 |
/* 106 */ "ParseSchema",
|
|
22185 |
/* 107 */ "LoadAnalysis",
|
|
22186 |
/* 108 */ "DropTable",
|
|
22187 |
/* 109 */ "DropIndex",
|
|
22188 |
/* 110 */ "DropTrigger",
|
|
22189 |
/* 111 */ "IntegrityCk",
|
|
22190 |
/* 112 */ "RowSetAdd",
|
|
22191 |
/* 113 */ "RowSetRead",
|
|
22192 |
/* 114 */ "RowSetTest",
|
|
22193 |
/* 115 */ "Program",
|
|
22194 |
/* 116 */ "Param",
|
|
22195 |
/* 117 */ "FkCounter",
|
|
22196 |
/* 118 */ "FkIfZero",
|
|
22197 |
/* 119 */ "MemMax",
|
|
22198 |
/* 120 */ "IfPos",
|
|
22199 |
/* 121 */ "IfNeg",
|
|
22200 |
/* 122 */ "IfZero",
|
|
22201 |
/* 123 */ "AggStep",
|
|
22202 |
/* 124 */ "AggFinal",
|
|
22203 |
/* 125 */ "Checkpoint",
|
|
22204 |
/* 126 */ "JournalMode",
|
|
22205 |
/* 127 */ "Vacuum",
|
|
22206 |
/* 128 */ "IncrVacuum",
|
|
22207 |
/* 129 */ "Expire",
|
22111 |
22208 |
/* 130 */ "Real",
|
22112 |
|
/* 131 */ "VNext",
|
22113 |
|
/* 132 */ "VRename",
|
22114 |
|
/* 133 */ "VUpdate",
|
22115 |
|
/* 134 */ "Pagecount",
|
22116 |
|
/* 135 */ "MaxPgcnt",
|
22117 |
|
/* 136 */ "Trace",
|
22118 |
|
/* 137 */ "Noop",
|
22119 |
|
/* 138 */ "Explain",
|
22120 |
|
/* 139 */ "NotUsed_139",
|
22121 |
|
/* 140 */ "NotUsed_140",
|
|
22209 |
/* 131 */ "TableLock",
|
|
22210 |
/* 132 */ "VBegin",
|
|
22211 |
/* 133 */ "VCreate",
|
|
22212 |
/* 134 */ "VDestroy",
|
|
22213 |
/* 135 */ "VOpen",
|
|
22214 |
/* 136 */ "VFilter",
|
|
22215 |
/* 137 */ "VColumn",
|
|
22216 |
/* 138 */ "VNext",
|
|
22217 |
/* 139 */ "VRename",
|
|
22218 |
/* 140 */ "VUpdate",
|
22122 |
22219 |
/* 141 */ "ToText",
|
22123 |
22220 |
/* 142 */ "ToBlob",
|
22124 |
22221 |
/* 143 */ "ToNumeric",
|
22125 |
22222 |
/* 144 */ "ToInt",
|
22126 |
22223 |
/* 145 */ "ToReal",
|
|
22224 |
/* 146 */ "Pagecount",
|
|
22225 |
/* 147 */ "MaxPgcnt",
|
|
22226 |
/* 148 */ "Trace",
|
|
22227 |
/* 149 */ "Noop",
|
|
22228 |
/* 150 */ "Explain",
|
22127 |
22229 |
};
|
22128 |
22230 |
return azName[i];
|
22129 |
22231 |
}
|
... | ... | |
22218 |
22320 |
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
|
22219 |
22321 |
#endif
|
22220 |
22322 |
|
22221 |
|
#ifdef SQLITE_DEBUG
|
22222 |
|
SQLITE_PRIVATE int sqlite3OSTrace = 0;
|
22223 |
|
#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
|
|
22323 |
#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
|
|
22324 |
# ifndef SQLITE_DEBUG_OS_TRACE
|
|
22325 |
# define SQLITE_DEBUG_OS_TRACE 0
|
|
22326 |
# endif
|
|
22327 |
int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
|
|
22328 |
# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
|
22224 |
22329 |
#else
|
22225 |
|
#define OSTRACE(X)
|
|
22330 |
# define OSTRACE(X)
|
22226 |
22331 |
#endif
|
22227 |
22332 |
|
22228 |
22333 |
/*
|
... | ... | |
24379 |
24484 |
#include <sys/stat.h>
|
24380 |
24485 |
#include <fcntl.h>
|
24381 |
24486 |
#include <unistd.h>
|
|
24487 |
/* #include <time.h> */
|
24382 |
24488 |
#include <sys/time.h>
|
24383 |
24489 |
#include <errno.h>
|
24384 |
24490 |
#ifndef SQLITE_OMIT_WAL
|
... | ... | |
24414 |
24520 |
** the SQLITE_UNIX_THREADS macro.
|
24415 |
24521 |
*/
|
24416 |
24522 |
#if SQLITE_THREADSAFE
|
|
24523 |
/* # include <pthread.h> */
|
24417 |
24524 |
# define SQLITE_UNIX_THREADS 1
|
24418 |
24525 |
#endif
|
24419 |
24526 |
|
... | ... | |
24469 |
24576 |
sqlite3_io_methods const *pMethod; /* Always the first entry */
|
24470 |
24577 |
unixInodeInfo *pInode; /* Info about locks on this inode */
|
24471 |
24578 |
int h; /* The file descriptor */
|
24472 |
|
int dirfd; /* File descriptor for the directory */
|
24473 |
24579 |
unsigned char eFileLock; /* The type of lock held on this fd */
|
24474 |
24580 |
unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */
|
24475 |
24581 |
int lastErrno; /* The unix errno from last I/O error */
|
... | ... | |
24511 |
24617 |
/*
|
24512 |
24618 |
** Allowed values for the unixFile.ctrlFlags bitmask:
|
24513 |
24619 |
*/
|
24514 |
|
#define UNIXFILE_EXCL 0x01 /* Connections from one process only */
|
24515 |
|
#define UNIXFILE_RDONLY 0x02 /* Connection is read only */
|
|
24620 |
#define UNIXFILE_EXCL 0x01 /* Connections from one process only */
|
|
24621 |
#define UNIXFILE_RDONLY 0x02 /* Connection is read only */
|
|
24622 |
#define UNIXFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */
|
|
24623 |
#ifndef SQLITE_DISABLE_DIRSYNC
|
|
24624 |
# define UNIXFILE_DIRSYNC 0x08 /* Directory sync needed */
|
|
24625 |
#else
|
|
24626 |
# define UNIXFILE_DIRSYNC 0x00
|
|
24627 |
#endif
|
24516 |
24628 |
|
24517 |
24629 |
/*
|
24518 |
24630 |
** Include code that is common to all os_*.c files
|
... | ... | |
24550 |
24662 |
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
|
24551 |
24663 |
#endif
|
24552 |
24664 |
|
24553 |
|
#ifdef SQLITE_DEBUG
|
24554 |
|
SQLITE_PRIVATE int sqlite3OSTrace = 0;
|
24555 |
|
#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
|
|
24665 |
#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
|
|
24666 |
# ifndef SQLITE_DEBUG_OS_TRACE
|
|
24667 |
# define SQLITE_DEBUG_OS_TRACE 0
|
|
24668 |
# endif
|
|
24669 |
int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
|
|
24670 |
# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
|
24556 |
24671 |
#else
|
24557 |
|
#define OSTRACE(X)
|
|
24672 |
# define OSTRACE(X)
|
24558 |
24673 |
#endif
|
24559 |
24674 |
|
24560 |
24675 |
/*
|
... | ... | |
24763 |
24878 |
return open(zFile, flags, mode);
|
24764 |
24879 |
}
|
24765 |
24880 |
|
|
24881 |
/* Forward reference */
|
|
24882 |
static int openDirectory(const char*, int*);
|
|
24883 |
|
24766 |
24884 |
/*
|
24767 |
24885 |
** Many system calls are accessed through pointer-to-functions so that
|
24768 |
24886 |
** they may be overridden at runtime to facilitate fault injection during
|
... | ... | |
24859 |
24977 |
#endif
|
24860 |
24978 |
#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent)
|
24861 |
24979 |
|
|
24980 |
{ "unlink", (sqlite3_syscall_ptr)unlink, 0 },
|
|
24981 |
#define osUnlink ((int(*)(const char*))aSyscall[16].pCurrent)
|
|
24982 |
|
|
24983 |
{ "openDirectory", (sqlite3_syscall_ptr)openDirectory, 0 },
|
|
24984 |
#define osOpenDirectory ((int(*)(const char*,int*))aSyscall[17].pCurrent)
|
|
24985 |
|
24862 |
24986 |
}; /* End of the overrideable system calls */
|
24863 |
24987 |
|
24864 |
24988 |
/*
|
... | ... | |
25143 |
25267 |
case ENODEV:
|
25144 |
25268 |
case ENXIO:
|
25145 |
25269 |
case ENOENT:
|
|
25270 |
#ifdef ESTALE /* ESTALE is not defined on Interix systems */
|
25146 |
25271 |
case ESTALE:
|
|
25272 |
#endif
|
25147 |
25273 |
case ENOSYS:
|
25148 |
25274 |
/* these should force the client to close the file and reconnect */
|
25149 |
25275 |
|
... | ... | |
26213 |
26339 |
*/
|
26214 |
26340 |
static int closeUnixFile(sqlite3_file *id){
|
26215 |
26341 |
unixFile *pFile = (unixFile*)id;
|
26216 |
|
if( pFile->dirfd>=0 ){
|
26217 |
|
robust_close(pFile, pFile->dirfd, __LINE__);
|
26218 |
|
pFile->dirfd=-1;
|
26219 |
|
}
|
26220 |
26342 |
if( pFile->h>=0 ){
|
26221 |
26343 |
robust_close(pFile, pFile->h, __LINE__);
|
26222 |
26344 |
pFile->h = -1;
|
... | ... | |
26224 |
26346 |
#if OS_VXWORKS
|
26225 |
26347 |
if( pFile->pId ){
|
26226 |
26348 |
if( pFile->isDelete ){
|
26227 |
|
unlink(pFile->pId->zCanonicalName);
|
|
26349 |
osUnlink(pFile->pId->zCanonicalName);
|
26228 |
26350 |
}
|
26229 |
26351 |
vxworksReleaseFileId(pFile->pId);
|
26230 |
26352 |
pFile->pId = 0;
|
... | ... | |
26473 |
26595 |
|
26474 |
26596 |
/* To fully unlock the database, delete the lock file */
|
26475 |
26597 |
assert( eFileLock==NO_LOCK );
|
26476 |
|
if( unlink(zLockFile) ){
|
|
26598 |
if( osUnlink(zLockFile) ){
|
26477 |
26599 |
int rc = 0;
|
26478 |
26600 |
int tErrno = errno;
|
26479 |
26601 |
if( ENOENT != tErrno ){
|
... | ... | |
26979 |
27101 |
int rc = SQLITE_OK;
|
26980 |
27102 |
int reserved = 0;
|
26981 |
27103 |
unixFile *pFile = (unixFile*)id;
|
|
27104 |
afpLockingContext *context;
|
26982 |
27105 |
|
26983 |
27106 |
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
|
26984 |
27107 |
|
26985 |
27108 |
assert( pFile );
|
26986 |
|
afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
|
|
27109 |
context = (afpLockingContext *) pFile->lockingContext;
|
26987 |
27110 |
if( context->reserved ){
|
26988 |
27111 |
*pResOut = 1;
|
26989 |
27112 |
return SQLITE_OK;
|
... | ... | |
27123 |
27246 |
** operating system calls for the specified lock.
|
27124 |
27247 |
*/
|
27125 |
27248 |
if( eFileLock==SHARED_LOCK ){
|
27126 |
|
int lrc1, lrc2, lrc1Errno;
|
|
27249 |
int lrc1, lrc2, lrc1Errno = 0;
|
27127 |
27250 |
long lk, mask;
|
27128 |
27251 |
|
27129 |
27252 |
assert( pInode->nShared==0 );
|
... | ... | |
27497 |
27620 |
#elif defined(USE_PREAD64)
|
27498 |
27621 |
do{ got = osPwrite64(id->h, pBuf, cnt, offset);}while( got<0 && errno==EINTR);
|
27499 |
27622 |
#else
|
27500 |
|
newOffset = lseek(id->h, offset, SEEK_SET);
|
27501 |
|
SimulateIOError( newOffset-- );
|
27502 |
|
if( newOffset!=offset ){
|
27503 |
|
if( newOffset == -1 ){
|
27504 |
|
((unixFile*)id)->lastErrno = errno;
|
27505 |
|
}else{
|
27506 |
|
((unixFile*)id)->lastErrno = 0;
|
|
27623 |
do{
|
|
27624 |
newOffset = lseek(id->h, offset, SEEK_SET);
|
|
27625 |
SimulateIOError( newOffset-- );
|
|
27626 |
if( newOffset!=offset ){
|
|
27627 |
if( newOffset == -1 ){
|
|
27628 |
((unixFile*)id)->lastErrno = errno;
|
|
27629 |
}else{
|
|
27630 |
((unixFile*)id)->lastErrno = 0;
|
|
27631 |
}
|
|
27632 |
return -1;
|
27507 |
27633 |
}
|
27508 |
|
return -1;
|
27509 |
|
}
|
27510 |
|
do{ got = osWrite(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
|
|
27634 |
got = osWrite(id->h, pBuf, cnt);
|
|
27635 |
}while( got<0 && errno==EINTR );
|
27511 |
27636 |
#endif
|
27512 |
27637 |
TIMER_END;
|
27513 |
27638 |
if( got<0 ){
|
... | ... | |
27597 |
27722 |
|
27598 |
27723 |
/*
|
27599 |
27724 |
** We do not trust systems to provide a working fdatasync(). Some do.
|
27600 |
|
** Others do no. To be safe, we will stick with the (slower) fsync().
|
27601 |
|
** If you know that your system does support fdatasync() correctly,
|
|
27725 |
** Others do no. To be safe, we will stick with the (slightly slower)
|
|
27726 |
** fsync(). If you know that your system does support fdatasync() correctly,
|
27602 |
27727 |
** then simply compile with -Dfdatasync=fdatasync
|
27603 |
27728 |
*/
|
27604 |
|
#if !defined(fdatasync) && !defined(__linux__)
|
|
27729 |
#if !defined(fdatasync)
|
27605 |
27730 |
# define fdatasync fsync
|
27606 |
27731 |
#endif
|
27607 |
27732 |
|
... | ... | |
27710 |
27835 |
}
|
27711 |
27836 |
|
27712 |
27837 |
/*
|
|
27838 |
** Open a file descriptor to the directory containing file zFilename.
|
|
27839 |
** If successful, *pFd is set to the opened file descriptor and
|
|
27840 |
** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM
|
|
27841 |
** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined
|
|
27842 |
** value.
|
|
27843 |
**
|
|
27844 |
** The directory file descriptor is used for only one thing - to
|
|
27845 |
** fsync() a directory to make sure file creation and deletion events
|
|
27846 |
** are flushed to disk. Such fsyncs are not needed on newer
|
|
27847 |
** journaling filesystems, but are required on older filesystems.
|
|
27848 |
**
|
|
27849 |
** This routine can be overridden using the xSetSysCall interface.
|
|
27850 |
** The ability to override this routine was added in support of the
|
|
27851 |
** chromium sandbox. Opening a directory is a security risk (we are
|
|
27852 |
** told) so making it overrideable allows the chromium sandbox to
|
|
27853 |
** replace this routine with a harmless no-op. To make this routine
|
|
27854 |
** a no-op, replace it with a stub that returns SQLITE_OK but leaves
|
|
27855 |
** *pFd set to a negative number.
|
|
27856 |
**
|
|
27857 |
** If SQLITE_OK is returned, the caller is responsible for closing
|
|
27858 |
** the file descriptor *pFd using close().
|
|
27859 |
*/
|
|
27860 |
static int openDirectory(const char *zFilename, int *pFd){
|
|
27861 |
int ii;
|
|
27862 |
int fd = -1;
|
|
27863 |
char zDirname[MAX_PATHNAME+1];
|
|
27864 |
|
|
27865 |
sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
|
|
27866 |
for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);
|
|
27867 |
if( ii>0 ){
|
|
27868 |
zDirname[ii] = '\0';
|
|
27869 |
fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
|
|
27870 |
if( fd>=0 ){
|
|
27871 |
#ifdef FD_CLOEXEC
|
|
27872 |
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
|
|
27873 |
#endif
|
|
27874 |
OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
|
|
27875 |
}
|
|
27876 |
}
|
|
27877 |
*pFd = fd;
|
|
27878 |
return (fd>=0?SQLITE_OK:unixLogError(SQLITE_CANTOPEN_BKPT, "open", zDirname));
|
|
27879 |
}
|
|
27880 |
|
|
27881 |
/*
|
27713 |
27882 |
** Make sure all writes to a particular file are committed to disk.
|
27714 |
27883 |
**
|
27715 |
27884 |
** If dataOnly==0 then both the file itself and its metadata (file
|
... | ... | |
27749 |
27918 |
pFile->lastErrno = errno;
|
27750 |
27919 |
return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath);
|
27751 |
27920 |
}
|
27752 |
|
if( pFile->dirfd>=0 ){
|
27753 |
|
OSTRACE(("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
|
|
27921 |
|
|
27922 |
/* Also fsync the directory containing the file if the DIRSYNC flag
|
|
27923 |
** is set. This is a one-time occurrance. Many systems (examples: AIX)
|
|
27924 |
** are unable to fsync a directory, so ignore errors on the fsync.
|
|
27925 |
*/
|
|
27926 |
if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){
|
|
27927 |
int dirfd;
|
|
27928 |
OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath,
|
27754 |
27929 |
HAVE_FULLFSYNC, isFullsync));
|
27755 |
|
#ifndef SQLITE_DISABLE_DIRSYNC
|
27756 |
|
/* The directory sync is only attempted if full_fsync is
|
27757 |
|
** turned off or unavailable. If a full_fsync occurred above,
|
27758 |
|
** then the directory sync is superfluous.
|
27759 |
|
*/
|
27760 |
|
if( (!HAVE_FULLFSYNC || !isFullsync) && full_fsync(pFile->dirfd,0,0) ){
|
27761 |
|
/*
|
27762 |
|
** We have received multiple reports of fsync() returning
|
27763 |
|
** errors when applied to directories on certain file systems.
|
27764 |
|
** A failed directory sync is not a big deal. So it seems
|
27765 |
|
** better to ignore the error. Ticket #1657
|
27766 |
|
*/
|
27767 |
|
/* pFile->lastErrno = errno; */
|
27768 |
|
/* return SQLITE_IOERR; */
|
|
27930 |
rc = osOpenDirectory(pFile->zPath, &dirfd);
|
|
27931 |
if( rc==SQLITE_OK && dirfd>=0 ){
|
|
27932 |
full_fsync(dirfd, 0, 0);
|
|
27933 |
robust_close(pFile, dirfd, __LINE__);
|
|
27934 |
}else if( rc==SQLITE_CANTOPEN ){
|
|
27935 |
rc = SQLITE_OK;
|
27769 |
27936 |
}
|
27770 |
|
#endif
|
27771 |
|
/* Only need to sync once, so close the directory when we are done */
|
27772 |
|
robust_close(pFile, pFile->dirfd, __LINE__);
|
27773 |
|
pFile->dirfd = -1;
|
|
27937 |
pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;
|
27774 |
27938 |
}
|
27775 |
27939 |
return rc;
|
27776 |
27940 |
}
|
... | ... | |
27852 |
28016 |
|
27853 |
28017 |
/*
|
27854 |
28018 |
** This function is called to handle the SQLITE_FCNTL_SIZE_HINT
|
27855 |
|
** file-control operation.
|
27856 |
|
**
|
27857 |
|
** If the user has configured a chunk-size for this file, it could be
|
27858 |
|
** that the file needs to be extended at this point. Otherwise, the
|
27859 |
|
** SQLITE_FCNTL_SIZE_HINT operation is a no-op for Unix.
|
|
28019 |
** file-control operation. Enlarge the database to nBytes in size
|
|
28020 |
** (rounded up to the next chunk-size). If the database is already
|
|
28021 |
** nBytes or larger, this routine is a no-op.
|
27860 |
28022 |
*/
|
27861 |
28023 |
static int fcntlSizeHint(unixFile *pFile, i64 nByte){
|
27862 |
|
if( pFile->szChunk ){
|
|
28024 |
if( pFile->szChunk>0 ){
|
27863 |
28025 |
i64 nSize; /* Required file size */
|
27864 |
28026 |
struct stat buf; /* Used to hold return values of fstat() */
|
27865 |
28027 |
|
... | ... | |
27908 |
28070 |
** Information and control of an open file handle.
|
27909 |
28071 |
*/
|
27910 |
28072 |
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
|
|
28073 |
unixFile *pFile = (unixFile*)id;
|
27911 |
28074 |
switch( op ){
|
27912 |
28075 |
case SQLITE_FCNTL_LOCKSTATE: {
|
27913 |
|
*(int*)pArg = ((unixFile*)id)->eFileLock;
|
|
28076 |
*(int*)pArg = pFile->eFileLock;
|
27914 |
28077 |
return SQLITE_OK;
|
27915 |
28078 |
}
|
27916 |
28079 |
case SQLITE_LAST_ERRNO: {
|
27917 |
|
*(int*)pArg = ((unixFile*)id)->lastErrno;
|
|
28080 |
*(int*)pArg = pFile->lastErrno;
|
27918 |
28081 |
return SQLITE_OK;
|
27919 |
28082 |
}
|
27920 |
28083 |
case SQLITE_FCNTL_CHUNK_SIZE: {
|
27921 |
|
((unixFile*)id)->szChunk = *(int *)pArg;
|
|
28084 |
pFile->szChunk = *(int *)pArg;
|
27922 |
28085 |
return SQLITE_OK;
|
27923 |
28086 |
}
|
27924 |
28087 |
case SQLITE_FCNTL_SIZE_HINT: {
|
27925 |
|
return fcntlSizeHint((unixFile *)id, *(i64 *)pArg);
|
|
28088 |
int rc;
|
|
28089 |
SimulateIOErrorBenign(1);
|
|
28090 |
rc = fcntlSizeHint(pFile, *(i64 *)pArg);
|
|
28091 |
SimulateIOErrorBenign(0);
|
|
28092 |
return rc;
|
|
28093 |
}
|
|
28094 |
case SQLITE_FCNTL_PERSIST_WAL: {
|
|
28095 |
int bPersist = *(int*)pArg;
|
|
28096 |
if( bPersist<0 ){
|
|
28097 |
*(int*)pArg = (pFile->ctrlFlags & UNIXFILE_PERSIST_WAL)!=0;
|
|
28098 |
}else if( bPersist==0 ){
|
|
28099 |
pFile->ctrlFlags &= ~UNIXFILE_PERSIST_WAL;
|
|
28100 |
}else{
|
|
28101 |
pFile->ctrlFlags |= UNIXFILE_PERSIST_WAL;
|
|
28102 |
}
|
|
28103 |
return SQLITE_OK;
|
27926 |
28104 |
}
|
27927 |
28105 |
#ifndef NDEBUG
|
27928 |
28106 |
/* The pager calls this method to signal that it has done
|
... | ... | |
28038 |
28216 |
unixShmNode *pShmNode; /* The underlying unixShmNode object */
|
28039 |
28217 |
unixShm *pNext; /* Next unixShm with the same unixShmNode */
|
28040 |
28218 |
u8 hasMutex; /* True if holding the unixShmNode mutex */
|
|
28219 |
u8 id; /* Id of this connection within its unixShmNode */
|
28041 |
28220 |
u16 sharedMask; /* Mask of shared locks held */
|
28042 |
28221 |
u16 exclMask; /* Mask of exclusive locks held */
|
28043 |
|
#ifdef SQLITE_DEBUG
|
28044 |
|
u8 id; /* Id of this connection within its unixShmNode */
|
28045 |
|
#endif
|
28046 |
28222 |
};
|
28047 |
28223 |
|
28048 |
28224 |
/*
|
... | ... | |
28138 |
28314 |
if( p && p->nRef==0 ){
|
28139 |
28315 |
int i;
|
28140 |
28316 |
assert( p->pInode==pFd->pInode );
|
28141 |
|
if( p->mutex ) sqlite3_mutex_free(p->mutex);
|
|
28317 |
sqlite3_mutex_free(p->mutex);
|
28142 |
28318 |
for(i=0; i<p->nRegion; i++){
|
28143 |
28319 |
if( p->h>=0 ){
|
28144 |
28320 |
munmap(p->apRegion[i], p->szRegion);
|
... | ... | |
28607 |
28783 |
assert( pShmNode->nRef>0 );
|
28608 |
28784 |
pShmNode->nRef--;
|
28609 |
28785 |
if( pShmNode->nRef==0 ){
|
28610 |
|
if( deleteFlag && pShmNode->h>=0 ) unlink(pShmNode->zFilename);
|
|
28786 |
if( deleteFlag && pShmNode->h>=0 ) osUnlink(pShmNode->zFilename);
|
28611 |
28787 |
unixShmPurge(pDbFd);
|
28612 |
28788 |
}
|
28613 |
28789 |
unixLeaveMutex();
|
... | ... | |
28920 |
29096 |
static int fillInUnixFile(
|
28921 |
29097 |
sqlite3_vfs *pVfs, /* Pointer to vfs object */
|
28922 |
29098 |
int h, /* Open file descriptor of file being opened */
|
28923 |
|
int dirfd, /* Directory file descriptor */
|
|
29099 |
int syncDir, /* True to sync directory on first sync */
|
28924 |
29100 |
sqlite3_file *pId, /* Write to the unixFile structure here */
|
28925 |
29101 |
const char *zFilename, /* Name of the file being opened */
|
28926 |
29102 |
int noLock, /* Omit locking if true */
|
... | ... | |
28951 |
29127 |
|
28952 |
29128 |
OSTRACE(("OPEN %-3d %s\n", h, zFilename));
|
28953 |
29129 |
pNew->h = h;
|
28954 |
|
pNew->dirfd = dirfd;
|
28955 |
29130 |
pNew->zPath = zFilename;
|
28956 |
29131 |
if( memcmp(pVfs->zName,"unix-excl",10)==0 ){
|
28957 |
29132 |
pNew->ctrlFlags = UNIXFILE_EXCL;
|
... | ... | |
28961 |
29136 |
if( isReadOnly ){
|
28962 |
29137 |
pNew->ctrlFlags |= UNIXFILE_RDONLY;
|
28963 |
29138 |
}
|
|
29139 |
if( syncDir ){
|
|
29140 |
pNew->ctrlFlags |= UNIXFILE_DIRSYNC;
|
|
29141 |
}
|
28964 |
29142 |
|
28965 |
29143 |
#if OS_VXWORKS
|
28966 |
29144 |
pNew->pId = vxworksFindFileId(zFilename);
|
... | ... | |
29087 |
29265 |
if( rc!=SQLITE_OK ){
|
29088 |
29266 |
if( h>=0 ) robust_close(pNew, h, __LINE__);
|
29089 |
29267 |
h = -1;
|
29090 |
|
unlink(zFilename);
|
|
29268 |
osUnlink(zFilename);
|
29091 |
29269 |
isDelete = 0;
|
29092 |
29270 |
}
|
29093 |
29271 |
pNew->isDelete = isDelete;
|
29094 |
29272 |
#endif
|
29095 |
29273 |
if( rc!=SQLITE_OK ){
|
29096 |
|
if( dirfd>=0 ) robust_close(pNew, dirfd, __LINE__);
|
29097 |
29274 |
if( h>=0 ) robust_close(pNew, h, __LINE__);
|
29098 |
29275 |
}else{
|
29099 |
29276 |
pNew->pMethod = pLockingStyle;
|
... | ... | |
29103 |
29280 |
}
|
29104 |
29281 |
|
29105 |
29282 |
/*
|
29106 |
|
** Open a file descriptor to the directory containing file zFilename.
|
29107 |
|
** If successful, *pFd is set to the opened file descriptor and
|
29108 |
|
** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM
|
29109 |
|
** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined
|
29110 |
|
** value.
|
29111 |
|
**
|
29112 |
|
** If SQLITE_OK is returned, the caller is responsible for closing
|
29113 |
|
** the file descriptor *pFd using close().
|
29114 |
|
*/
|
29115 |
|
static int openDirectory(const char *zFilename, int *pFd){
|
29116 |
|
int ii;
|
29117 |
|
int fd = -1;
|
29118 |
|
char zDirname[MAX_PATHNAME+1];
|
29119 |
|
|
29120 |
|
sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
|
29121 |
|
for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);
|
29122 |
|
if( ii>0 ){
|
29123 |
|
zDirname[ii] = '\0';
|
29124 |
|
fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
|
29125 |
|
if( fd>=0 ){
|
29126 |
|
#ifdef FD_CLOEXEC
|
29127 |
|
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
|
29128 |
|
#endif
|
29129 |
|
OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
|
29130 |
|
}
|
29131 |
|
}
|
29132 |
|
*pFd = fd;
|
29133 |
|
return (fd>=0?SQLITE_OK:unixLogError(SQLITE_CANTOPEN_BKPT, "open", zDirname));
|
29134 |
|
}
|
29135 |
|
|
29136 |
|
/*
|
29137 |
29283 |
** Return the name of a directory in which to put temporary files.
|
29138 |
29284 |
** If no suitable temporary file directory can be found, return NULL.
|
29139 |
29285 |
*/
|
... | ... | |
29247 |
29393 |
**
|
29248 |
29394 |
** Even if a subsequent open() call does succeed, the consequences of
|
29249 |
29395 |
** not searching for a resusable file descriptor are not dire. */
|
29250 |
|
if( 0==stat(zPath, &sStat) ){
|
|
29396 |
if( 0==osStat(zPath, &sStat) ){
|
29251 |
29397 |
unixInodeInfo *pInode;
|
29252 |
29398 |
|
29253 |
29399 |
unixEnterMutex();
|
... | ... | |
29323 |
29469 |
memcpy(zDb, zPath, nDb);
|
29324 |
29470 |
zDb[nDb] = '\0';
|
29325 |
29471 |
|
29326 |
|
if( 0==stat(zDb, &sStat) ){
|
|
29472 |
if( 0==osStat(zDb, &sStat) ){
|
29327 |
29473 |
*pMode = sStat.st_mode & 0777;
|
29328 |
29474 |
}else{
|
29329 |
29475 |
rc = SQLITE_IOERR_FSTAT;
|
... | ... | |
29365 |
29511 |
){
|
29366 |
29512 |
unixFile *p = (unixFile *)pFile;
|
29367 |
29513 |
int fd = -1; /* File descriptor returned by open() */
|
29368 |
|
int dirfd = -1; /* Directory file descriptor */
|
29369 |
29514 |
int openFlags = 0; /* Flags to pass to open() */
|
29370 |
29515 |
int eType = flags&0xFFFFFF00; /* Type of file to open */
|
29371 |
29516 |
int noLock; /* True to omit locking primitives */
|
... | ... | |
29379 |
29524 |
#if SQLITE_ENABLE_LOCKING_STYLE
|
29380 |
29525 |
int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY);
|
29381 |
29526 |
#endif
|
|
29527 |
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
|
|
29528 |
struct statfs fsInfo;
|
|
29529 |
#endif
|
29382 |
29530 |
|
29383 |
29531 |
/* If creating a master or main-file journal, this function will open
|
29384 |
29532 |
** a file-descriptor on the directory too. The first time unixSync()
|
29385 |
29533 |
** is called the directory file descriptor will be fsync()ed and close()d.
|
29386 |
29534 |
*/
|
29387 |
|
int isOpenDirectory = (isCreate && (
|
|
29535 |
int syncDir = (isCreate && (
|
29388 |
29536 |
eType==SQLITE_OPEN_MASTER_JOURNAL
|
29389 |
29537 |
|| eType==SQLITE_OPEN_MAIN_JOURNAL
|
29390 |
29538 |
|| eType==SQLITE_OPEN_WAL
|
... | ... | |
29438 |
29586 |
p->pUnused = pUnused;
|
29439 |
29587 |
}else if( !zName ){
|
29440 |
29588 |
/* If zName is NULL, the upper layer is requesting a temp file. */
|
29441 |
|
assert(isDelete && !isOpenDirectory);
|
|
29589 |
assert(isDelete && !syncDir);
|
29442 |
29590 |
rc = unixGetTempname(MAX_PATHNAME+1, zTmpname);
|
29443 |
29591 |
if( rc!=SQLITE_OK ){
|
29444 |
29592 |
return rc;
|
... | ... | |
29494 |
29642 |
#if OS_VXWORKS
|
29495 |
29643 |
zPath = zName;
|
29496 |
29644 |
#else
|
29497 |
|
unlink(zName);
|
|
29645 |
osUnlink(zName);
|
29498 |
29646 |
#endif
|
29499 |
29647 |
}
|
29500 |
29648 |
#if SQLITE_ENABLE_LOCKING_STYLE
|
... | ... | |
29503 |
29651 |
}
|
29504 |
29652 |
#endif
|
29505 |
29653 |
|
29506 |
|
if( isOpenDirectory ){
|
29507 |
|
rc = openDirectory(zPath, &dirfd);
|
29508 |
|
if( rc!=SQLITE_OK ){
|
29509 |
|
/* It is safe to close fd at this point, because it is guaranteed not
|
29510 |
|
** to be open on a database file. If it were open on a database file,
|
29511 |
|
** it would not be safe to close as this would release any locks held
|
29512 |
|
** on the file by this process. */
|
29513 |
|
assert( eType!=SQLITE_OPEN_MAIN_DB );
|
29514 |
|
robust_close(p, fd, __LINE__);
|
29515 |
|
goto open_finished;
|
29516 |
|
}
|
29517 |
|
}
|
29518 |
|
|
29519 |
29654 |
#ifdef FD_CLOEXEC
|
29520 |
29655 |
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
|
29521 |
29656 |
#endif
|
... | ... | |
29524 |
29659 |
|
29525 |
29660 |
|
29526 |
29661 |
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
|
29527 |
|
struct statfs fsInfo;
|
29528 |
29662 |
if( fstatfs(fd, &fsInfo) == -1 ){
|
29529 |
29663 |
((unixFile*)pFile)->lastErrno = errno;
|
29530 |
|
if( dirfd>=0 ) robust_close(p, dirfd, __LINE__);
|
29531 |
29664 |
robust_close(p, fd, __LINE__);
|
29532 |
29665 |
return SQLITE_IOERR_ACCESS;
|
29533 |
29666 |
}
|
... | ... | |
29549 |
29682 |
if( envforce!=NULL ){
|
29550 |
29683 |
useProxy = atoi(envforce)>0;
|
29551 |
29684 |
}else{
|