Fossil SCM
Update the built-in SQLite to the latest 3.7.10 beta.
Commit
8a8685d1035b4cc8d50b5a564dc44774b0932831
Parent
058e287edbef894…
2 files changed
+119
-213
+19
-22
+119
-213
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -657,11 +657,11 @@ | ||
| 657 | 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | 659 | */ |
| 660 | 660 | #define SQLITE_VERSION "3.7.10" |
| 661 | 661 | #define SQLITE_VERSION_NUMBER 3007010 |
| 662 | -#define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22" | |
| 662 | +#define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983" | |
| 663 | 663 | |
| 664 | 664 | /* |
| 665 | 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | 667 | ** |
| @@ -725,11 +725,11 @@ | ||
| 725 | 725 | |
| 726 | 726 | /* |
| 727 | 727 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 728 | 728 | ** |
| 729 | 729 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 730 | -** SQLite was compiled mutexing code omitted due to the | |
| 730 | +** SQLite was compiled with mutexing code omitted due to the | |
| 731 | 731 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 732 | 732 | ** |
| 733 | 733 | ** SQLite can be compiled with or without mutexes. When |
| 734 | 734 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 735 | 735 | ** are enabled and SQLite is threadsafe. When the |
| @@ -919,11 +919,11 @@ | ||
| 919 | 919 | ** CAPI3REF: Result Codes |
| 920 | 920 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 921 | 921 | ** KEYWORDS: {result code} {result codes} |
| 922 | 922 | ** |
| 923 | 923 | ** Many SQLite functions return an integer result code from the set shown |
| 924 | -** here in order to indicates success or failure. | |
| 924 | +** here in order to indicate success or failure. | |
| 925 | 925 | ** |
| 926 | 926 | ** New error codes may be added in future versions of SQLite. |
| 927 | 927 | ** |
| 928 | 928 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 929 | 929 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -1058,17 +1058,14 @@ | ||
| 1058 | 1058 | ** that when data is appended to a file, the data is appended |
| 1059 | 1059 | ** first then the size of the file is extended, never the other |
| 1060 | 1060 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 1061 | 1061 | ** information is written to disk in the same order as calls |
| 1062 | 1062 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 1063 | -** after reboot following a crash or power loss, the value of | |
| 1064 | -** each byte in a file is a value that was actually written | |
| 1065 | -** into that byte at some point. In other words, a crash will | |
| 1066 | -** not cause unwritten bytes of the file to change nor introduce | |
| 1067 | -** randomness into a file nor zero out parts of the file, and any byte of | |
| 1068 | -** a file that are never written will not change values due to | |
| 1069 | -** writes to nearby bytes. | |
| 1063 | +** after reboot following a crash or power loss, the only bytes in a | |
| 1064 | +** file that were written at the application level might have changed | |
| 1065 | +** and that adjacent bytes, even bytes within the same sector are | |
| 1066 | +** guaranteed to be unchanged. | |
| 1070 | 1067 | */ |
| 1071 | 1068 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 1072 | 1069 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 1073 | 1070 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 1074 | 1071 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -1300,16 +1297,16 @@ | ||
| 1300 | 1297 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 1301 | 1298 | ** that do require it. |
| 1302 | 1299 | ** |
| 1303 | 1300 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 1304 | 1301 | ** retry counts and intervals for certain disk I/O operations for the |
| 1305 | -** windows [VFS] in order to work to provide robustness against | |
| 1302 | +** windows [VFS] in order to provide robustness in the presence of | |
| 1306 | 1303 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 1307 | 1304 | ** file write, and file delete operations up to 10 times, with a delay |
| 1308 | 1305 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 1309 | 1306 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 1310 | -** opcode allows those to values (10 retries and 25 milliseconds of delay) | |
| 1307 | +** opcode allows these two values (10 retries and 25 milliseconds of delay) | |
| 1311 | 1308 | ** to be adjusted. The values are changed for all database connections |
| 1312 | 1309 | ** within the same process. The argument is a pointer to an array of two |
| 1313 | 1310 | ** integers where the first integer i the new retry count and the second |
| 1314 | 1311 | ** integer is the delay. If either integer is negative, then the setting |
| 1315 | 1312 | ** is not changed but instead the prior value of that setting is written |
| @@ -1420,11 +1417,11 @@ | ||
| 1420 | 1417 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 1421 | 1418 | ** is either a NULL pointer or string obtained |
| 1422 | 1419 | ** from xFullPathname() with an optional suffix added. |
| 1423 | 1420 | ** ^If a suffix is added to the zFilename parameter, it will |
| 1424 | 1421 | ** consist of a single "-" character followed by no more than |
| 1425 | -** 10 alphanumeric and/or "-" characters. | |
| 1422 | +** 11 alphanumeric and/or "-" characters. | |
| 1426 | 1423 | ** ^SQLite further guarantees that |
| 1427 | 1424 | ** the string will be valid and unchanged until xClose() is |
| 1428 | 1425 | ** called. Because of the previous sentence, |
| 1429 | 1426 | ** the [sqlite3_file] can safely store a pointer to the |
| 1430 | 1427 | ** filename if it needs to remember the filename for some reason. |
| @@ -2571,11 +2568,11 @@ | ||
| 2571 | 2568 | ** These routines all implement some additional formatting |
| 2572 | 2569 | ** options that are useful for constructing SQL statements. |
| 2573 | 2570 | ** All of the usual printf() formatting options apply. In addition, there |
| 2574 | 2571 | ** is are "%q", "%Q", and "%z" options. |
| 2575 | 2572 | ** |
| 2576 | -** ^(The %q option works like %s in that it substitutes a null-terminated | |
| 2573 | +** ^(The %q option works like %s in that it substitutes a nul-terminated | |
| 2577 | 2574 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2578 | 2575 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2579 | 2576 | ** character it escapes that character and allows it to be inserted into |
| 2580 | 2577 | ** the string. |
| 2581 | 2578 | ** |
| @@ -4091,11 +4088,11 @@ | ||
| 4091 | 4088 | ** of the string. ^For clarity: the values returned by |
| 4092 | 4089 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 4093 | 4090 | ** bytes in the string, not the number of characters. |
| 4094 | 4091 | ** |
| 4095 | 4092 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 4096 | -** even empty strings, are always zero terminated. ^The return | |
| 4093 | +** even empty strings, are always zero-terminated. ^The return | |
| 4097 | 4094 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 4098 | 4095 | ** |
| 4099 | 4096 | ** ^The object returned by [sqlite3_column_value()] is an |
| 4100 | 4097 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 4101 | 4098 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -5171,11 +5168,11 @@ | ||
| 5171 | 5168 | SQLITE_API int sqlite3_release_memory(int); |
| 5172 | 5169 | |
| 5173 | 5170 | /* |
| 5174 | 5171 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 5175 | 5172 | ** |
| 5176 | -** ^The sqlite3_db_shrink(D) interface attempts to free as much heap | |
| 5173 | +** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap | |
| 5177 | 5174 | ** memory as possible from database connection D. Unlike the |
| 5178 | 5175 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 5179 | 5176 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 5180 | 5177 | ** omitted. |
| 5181 | 5178 | ** |
| @@ -5954,19 +5951,19 @@ | ||
| 5954 | 5951 | ** is selected automatically at compile-time. ^(The following |
| 5955 | 5952 | ** implementations are available in the SQLite core: |
| 5956 | 5953 | ** |
| 5957 | 5954 | ** <ul> |
| 5958 | 5955 | ** <li> SQLITE_MUTEX_OS2 |
| 5959 | -** <li> SQLITE_MUTEX_PTHREAD | |
| 5956 | +** <li> SQLITE_MUTEX_PTHREADS | |
| 5960 | 5957 | ** <li> SQLITE_MUTEX_W32 |
| 5961 | 5958 | ** <li> SQLITE_MUTEX_NOOP |
| 5962 | 5959 | ** </ul>)^ |
| 5963 | 5960 | ** |
| 5964 | 5961 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5965 | 5962 | ** that does no real locking and is appropriate for use in |
| 5966 | 5963 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5967 | -** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations | |
| 5964 | +** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations | |
| 5968 | 5965 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5969 | 5966 | ** |
| 5970 | 5967 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5971 | 5968 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5972 | 5969 | ** implementation is included with the library. In this case the |
| @@ -6152,11 +6149,11 @@ | ||
| 6152 | 6149 | ** defined and if NDEBUG is not defined. |
| 6153 | 6150 | ** |
| 6154 | 6151 | ** ^These routines should return true if the mutex in their argument |
| 6155 | 6152 | ** is held or not held, respectively, by the calling thread. |
| 6156 | 6153 | ** |
| 6157 | -** ^The implementation is not required to provided versions of these | |
| 6154 | +** ^The implementation is not required to provide versions of these | |
| 6158 | 6155 | ** routines that actually work. If the implementation does not provide working |
| 6159 | 6156 | ** versions of these routines, it should at least provide stubs that always |
| 6160 | 6157 | ** return true so that one does not get spurious assertion failures. |
| 6161 | 6158 | ** |
| 6162 | 6159 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6634,11 +6631,11 @@ | ||
| 6634 | 6631 | ** |
| 6635 | 6632 | ** [[the xInit() page cache method]] |
| 6636 | 6633 | ** ^(The xInit() method is called once for each effective |
| 6637 | 6634 | ** call to [sqlite3_initialize()])^ |
| 6638 | 6635 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6639 | -** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ | |
| 6636 | +** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ | |
| 6640 | 6637 | ** The intent of the xInit() method is to set up global data structures |
| 6641 | 6638 | ** required by the custom page cache implementation. |
| 6642 | 6639 | ** ^(If the xInit() method is NULL, then the |
| 6643 | 6640 | ** built-in default page cache is used instead of the application defined |
| 6644 | 6641 | ** page cache.)^ |
| @@ -6660,11 +6657,11 @@ | ||
| 6660 | 6657 | ** |
| 6661 | 6658 | ** [[the xCreate() page cache methods]] |
| 6662 | 6659 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6663 | 6660 | ** SQLite will typically create one cache instance for each open database file, |
| 6664 | 6661 | ** though this is not guaranteed. ^The |
| 6665 | -** parameter parameter, szPage, is the size in bytes of the pages that must | |
| 6662 | +** first parameter, szPage, is the size in bytes of the pages that must | |
| 6666 | 6663 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6667 | 6664 | ** second parameter szExtra is a number of bytes of extra storage |
| 6668 | 6665 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6669 | 6666 | ** a number less than 250. SQLite will use the |
| 6670 | 6667 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6755,11 +6752,11 @@ | ||
| 6755 | 6752 | ** |
| 6756 | 6753 | ** [[the xDestroy() page cache method]] |
| 6757 | 6754 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6758 | 6755 | ** All resources associated with the specified cache should be freed. ^After |
| 6759 | 6756 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6760 | -** handle invalid, and will not use it with any other sqlite3_pcache_methods | |
| 6757 | +** handle invalid, and will not use it with any other sqlite3_pcache_methods2 | |
| 6761 | 6758 | ** functions. |
| 6762 | 6759 | ** |
| 6763 | 6760 | ** [[the xShrink() page cache method]] |
| 6764 | 6761 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6765 | 6762 | ** free up as much of heap memory as possible. The page cache implementation |
| @@ -9266,11 +9263,11 @@ | ||
| 9266 | 9263 | |
| 9267 | 9264 | /* |
| 9268 | 9265 | ** The default size of a disk sector |
| 9269 | 9266 | */ |
| 9270 | 9267 | #ifndef SQLITE_DEFAULT_SECTOR_SIZE |
| 9271 | -# define SQLITE_DEFAULT_SECTOR_SIZE 512 | |
| 9268 | +# define SQLITE_DEFAULT_SECTOR_SIZE 4096 | |
| 9272 | 9269 | #endif |
| 9273 | 9270 | |
| 9274 | 9271 | /* |
| 9275 | 9272 | ** Temporary files are named starting with this prefix followed by 16 random |
| 9276 | 9273 | ** alphanumeric characters, and no file extension. They are stored in the |
| @@ -13190,11 +13187,11 @@ | ||
| 13190 | 13187 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 13191 | 13188 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 13192 | 13189 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*); |
| 13193 | 13190 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 13194 | 13191 | SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p); |
| 13195 | -#define MemReleaseExt(X) \ | |
| 13192 | +#define VdbeMemRelease(X) \ | |
| 13196 | 13193 | if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \ |
| 13197 | 13194 | sqlite3VdbeMemReleaseExternal(X); |
| 13198 | 13195 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 13199 | 13196 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int); |
| 13200 | 13197 | SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); |
| @@ -13229,11 +13226,11 @@ | ||
| 13229 | 13226 | # define sqlite3VdbeEnter(X) |
| 13230 | 13227 | # define sqlite3VdbeLeave(X) |
| 13231 | 13228 | #endif |
| 13232 | 13229 | |
| 13233 | 13230 | #ifdef SQLITE_DEBUG |
| 13234 | -SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*); | |
| 13231 | +SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*); | |
| 13235 | 13232 | #endif |
| 13236 | 13233 | |
| 13237 | 13234 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 13238 | 13235 | SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int); |
| 13239 | 13236 | #else |
| @@ -14762,11 +14759,11 @@ | ||
| 14762 | 14759 | int flags, |
| 14763 | 14760 | int *pFlagsOut |
| 14764 | 14761 | ){ |
| 14765 | 14762 | int rc; |
| 14766 | 14763 | DO_OS_MALLOC_TEST(0); |
| 14767 | - /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed | |
| 14764 | + /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed | |
| 14768 | 14765 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 14769 | 14766 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 14770 | 14767 | ** reaching the VFS. */ |
| 14771 | 14768 | rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 14772 | 14769 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| @@ -17316,11 +17313,11 @@ | ||
| 17316 | 17313 | SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){ |
| 17317 | 17314 | return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p); |
| 17318 | 17315 | } |
| 17319 | 17316 | #endif |
| 17320 | 17317 | |
| 17321 | -#endif /* SQLITE_MUTEX_OMIT */ | |
| 17318 | +#endif /* !defined(SQLITE_MUTEX_OMIT) */ | |
| 17322 | 17319 | |
| 17323 | 17320 | /************** End of mutex.c ***********************************************/ |
| 17324 | 17321 | /************** Begin file mutex_noop.c **************************************/ |
| 17325 | 17322 | /* |
| 17326 | 17323 | ** 2008 October 07 |
| @@ -17523,12 +17520,12 @@ | ||
| 17523 | 17520 | */ |
| 17524 | 17521 | #ifdef SQLITE_MUTEX_NOOP |
| 17525 | 17522 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ |
| 17526 | 17523 | return sqlite3NoopMutex(); |
| 17527 | 17524 | } |
| 17528 | -#endif /* SQLITE_MUTEX_NOOP */ | |
| 17529 | -#endif /* SQLITE_MUTEX_OMIT */ | |
| 17525 | +#endif /* defined(SQLITE_MUTEX_NOOP) */ | |
| 17526 | +#endif /* !defined(SQLITE_MUTEX_OMIT) */ | |
| 17530 | 17527 | |
| 17531 | 17528 | /************** End of mutex_noop.c ******************************************/ |
| 17532 | 17529 | /************** Begin file mutex_os2.c ***************************************/ |
| 17533 | 17530 | /* |
| 17534 | 17531 | ** 2007 August 28 |
| @@ -18153,11 +18150,11 @@ | ||
| 18153 | 18150 | }; |
| 18154 | 18151 | |
| 18155 | 18152 | return &sMutex; |
| 18156 | 18153 | } |
| 18157 | 18154 | |
| 18158 | -#endif /* SQLITE_MUTEX_PTHREAD */ | |
| 18155 | +#endif /* SQLITE_MUTEX_PTHREADS */ | |
| 18159 | 18156 | |
| 18160 | 18157 | /************** End of mutex_unix.c ******************************************/ |
| 18161 | 18158 | /************** Begin file mutex_w32.c ***************************************/ |
| 18162 | 18159 | /* |
| 18163 | 18160 | ** 2007 August 14 |
| @@ -22116,26 +22113,31 @@ | ||
| 22116 | 22113 | ** characters of the original suffix. |
| 22117 | 22114 | ** |
| 22118 | 22115 | ** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always |
| 22119 | 22116 | ** do the suffix shortening regardless of URI parameter. |
| 22120 | 22117 | ** |
| 22118 | +** Assume that zBaseFilename contains two \000 terminator bytes (so that | |
| 22119 | +** it can be harmlessly passed into sqlite3_uri_parameter()) and copy both | |
| 22120 | +** zero terminator bytes into the end of the revised name. | |
| 22121 | +** | |
| 22121 | 22122 | ** Examples: |
| 22122 | 22123 | ** |
| 22123 | 22124 | ** test.db-journal => test.nal |
| 22124 | 22125 | ** test.db-wal => test.wal |
| 22125 | 22126 | ** test.db-shm => test.shm |
| 22126 | 22127 | ** test.db-mj7f3319fa => test.9fa |
| 22127 | 22128 | */ |
| 22128 | 22129 | SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){ |
| 22130 | + assert( zBaseFilename[strlen(zBaseFilename)+1]==0 ); | |
| 22129 | 22131 | #if SQLITE_ENABLE_8_3_NAMES<2 |
| 22130 | - if( sqlite3_uri_boolean(zBaseFilename, "8_3_names") ) | |
| 22132 | + if( sqlite3_uri_boolean(zBaseFilename, "8_3_names", 0) ) | |
| 22131 | 22133 | #endif |
| 22132 | 22134 | { |
| 22133 | 22135 | int i, sz; |
| 22134 | 22136 | sz = sqlite3Strlen30(z); |
| 22135 | 22137 | for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} |
| 22136 | - if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4); | |
| 22138 | + if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 5); | |
| 22137 | 22139 | } |
| 22138 | 22140 | } |
| 22139 | 22141 | #endif |
| 22140 | 22142 | |
| 22141 | 22143 | /************** End of util.c ************************************************/ |
| @@ -24836,13 +24838,10 @@ | ||
| 24836 | 24838 | #include <sys/time.h> |
| 24837 | 24839 | #include <errno.h> |
| 24838 | 24840 | #ifndef SQLITE_OMIT_WAL |
| 24839 | 24841 | #include <sys/mman.h> |
| 24840 | 24842 | #endif |
| 24841 | -#ifndef MISSING_STATVFS | |
| 24842 | -#include <sys/statvfs.h> | |
| 24843 | -#endif | |
| 24844 | 24843 | |
| 24845 | 24844 | |
| 24846 | 24845 | #if SQLITE_ENABLE_LOCKING_STYLE |
| 24847 | 24846 | # include <sys/ioctl.h> |
| 24848 | 24847 | # if OS_VXWORKS |
| @@ -24929,11 +24928,10 @@ | ||
| 24929 | 24928 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24930 | 24929 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24931 | 24930 | int h; /* The file descriptor */ |
| 24932 | 24931 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24933 | 24932 | unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ |
| 24934 | - unsigned char szSector; /* Sectorsize/512 */ | |
| 24935 | 24933 | int lastErrno; /* The unix errno from last I/O error */ |
| 24936 | 24934 | void *lockingContext; /* Locking style specific state */ |
| 24937 | 24935 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24938 | 24936 | const char *zPath; /* Name of the file */ |
| 24939 | 24937 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25342,18 +25340,10 @@ | ||
| 25342 | 25340 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25343 | 25341 | |
| 25344 | 25342 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25345 | 25343 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25346 | 25344 | |
| 25347 | -#if defined(MISSING_STATVFS) | |
| 25348 | - { "statvfs", (sqlite3_syscall_ptr)0, 0 }, | |
| 25349 | -#define osStatvfs ((int(*)(const char*,void*))aSyscall[20].pCurrent) | |
| 25350 | -#else | |
| 25351 | - { "statvfs", (sqlite3_syscall_ptr)statvfs, 0 }, | |
| 25352 | -#define osStatvfs ((int(*)(const char*,struct statvfs*))aSyscall[20].pCurrent) | |
| 25353 | -#endif | |
| 25354 | - | |
| 25355 | 25345 | }; /* End of the overrideable system calls */ |
| 25356 | 25346 | |
| 25357 | 25347 | /* |
| 25358 | 25348 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25359 | 25349 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -28504,13 +28494,10 @@ | ||
| 28504 | 28494 | case SQLITE_SET_LOCKPROXYFILE: |
| 28505 | 28495 | case SQLITE_GET_LOCKPROXYFILE: { |
| 28506 | 28496 | return proxyFileControl(id,op,pArg); |
| 28507 | 28497 | } |
| 28508 | 28498 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 28509 | - case SQLITE_FCNTL_SYNC_OMITTED: { | |
| 28510 | - return SQLITE_OK; /* A no-op */ | |
| 28511 | - } | |
| 28512 | 28499 | } |
| 28513 | 28500 | return SQLITE_NOTFOUND; |
| 28514 | 28501 | } |
| 28515 | 28502 | |
| 28516 | 28503 | /* |
| @@ -28522,27 +28509,12 @@ | ||
| 28522 | 28509 | ** if two files are created in the same file-system directory (i.e. |
| 28523 | 28510 | ** a database and its journal file) that the sector size will be the |
| 28524 | 28511 | ** same for both. |
| 28525 | 28512 | */ |
| 28526 | 28513 | static int unixSectorSize(sqlite3_file *pFile){ |
| 28527 | - unixFile *p = (unixFile*)pFile; | |
| 28528 | - if( p->szSector==0 ){ | |
| 28529 | -#ifdef MISSING_STATVFS | |
| 28530 | - p->szSector = SQLITE_DEFAULT_SECTOR_SIZE/512; | |
| 28531 | -#else | |
| 28532 | - struct statvfs x; | |
| 28533 | - int sz; | |
| 28534 | - memset(&x, 0, sizeof(x)); | |
| 28535 | - osStatvfs(p->zPath, &x); | |
| 28536 | - sz = (int)x.f_frsize; | |
| 28537 | - if( sz<512 || sz>65536 || (sz&(sz-1))!=0 ){ | |
| 28538 | - sz = SQLITE_DEFAULT_SECTOR_SIZE; | |
| 28539 | - } | |
| 28540 | - p->szSector = sz/512; | |
| 28541 | -#endif | |
| 28542 | - } | |
| 28543 | - return p->szSector*512; | |
| 28514 | + (void)pFile; | |
| 28515 | + return SQLITE_DEFAULT_SECTOR_SIZE; | |
| 28544 | 28516 | } |
| 28545 | 28517 | |
| 28546 | 28518 | /* |
| 28547 | 28519 | ** Return the device characteristics for the file. |
| 28548 | 28520 | ** |
| @@ -28815,13 +28787,13 @@ | ||
| 28815 | 28787 | rc = SQLITE_IOERR_FSTAT; |
| 28816 | 28788 | goto shm_open_err; |
| 28817 | 28789 | } |
| 28818 | 28790 | |
| 28819 | 28791 | #ifdef SQLITE_SHM_DIRECTORY |
| 28820 | - nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30; | |
| 28792 | + nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31; | |
| 28821 | 28793 | #else |
| 28822 | - nShmFilename = 5 + (int)strlen(pDbFd->zPath); | |
| 28794 | + nShmFilename = 6 + (int)strlen(pDbFd->zPath); | |
| 28823 | 28795 | #endif |
| 28824 | 28796 | pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename ); |
| 28825 | 28797 | if( pShmNode==0 ){ |
| 28826 | 28798 | rc = SQLITE_NOMEM; |
| 28827 | 28799 | goto shm_open_err; |
| @@ -31755,11 +31727,11 @@ | ||
| 31755 | 31727 | }; |
| 31756 | 31728 | unsigned int i; /* Loop counter */ |
| 31757 | 31729 | |
| 31758 | 31730 | /* Double-check that the aSyscall[] array has been constructed |
| 31759 | 31731 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31760 | - assert( ArraySize(aSyscall)==21 ); | |
| 31732 | + assert( ArraySize(aSyscall)==20 ); | |
| 31761 | 31733 | |
| 31762 | 31734 | /* Register all VFSes defined in the aVfs[] array */ |
| 31763 | 31735 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31764 | 31736 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31765 | 31737 | } |
| @@ -32049,11 +32021,10 @@ | ||
| 32049 | 32021 | HANDLE h; /* Handle for accessing the file */ |
| 32050 | 32022 | u8 locktype; /* Type of lock currently held on this file */ |
| 32051 | 32023 | short sharedLockByte; /* Randomly chosen byte used as a shared lock */ |
| 32052 | 32024 | u8 ctrlFlags; /* Flags. See WINFILE_* below */ |
| 32053 | 32025 | DWORD lastErrno; /* The Windows errno from the last I/O error */ |
| 32054 | - DWORD sectorSize; /* Sector size of the device file is on */ | |
| 32055 | 32026 | winShm *pShm; /* Instance of shared memory on this file */ |
| 32056 | 32027 | const char *zPath; /* Full pathname of this file */ |
| 32057 | 32028 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32058 | 32029 | #if SQLITE_OS_WINCE |
| 32059 | 32030 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| @@ -32139,18 +32110,10 @@ | ||
| 32139 | 32110 | static void winMemShutdown(void *pAppData); |
| 32140 | 32111 | |
| 32141 | 32112 | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void); |
| 32142 | 32113 | #endif /* SQLITE_WIN32_MALLOC */ |
| 32143 | 32114 | |
| 32144 | -/* | |
| 32145 | -** Forward prototypes. | |
| 32146 | -*/ | |
| 32147 | -static int getSectorSize( | |
| 32148 | - sqlite3_vfs *pVfs, | |
| 32149 | - const char *zRelative /* UTF-8 file name */ | |
| 32150 | -); | |
| 32151 | - | |
| 32152 | 32115 | /* |
| 32153 | 32116 | ** The following variable is (normally) set once and never changes |
| 32154 | 32117 | ** thereafter. It records whether the operating system is Win9x |
| 32155 | 32118 | ** or WinNT. |
| 32156 | 32119 | ** |
| @@ -34181,13 +34144,10 @@ | ||
| 34181 | 34144 | } |
| 34182 | 34145 | case SQLITE_FCNTL_VFSNAME: { |
| 34183 | 34146 | *(char**)pArg = sqlite3_mprintf("win32"); |
| 34184 | 34147 | return SQLITE_OK; |
| 34185 | 34148 | } |
| 34186 | - case SQLITE_FCNTL_SYNC_OMITTED: { | |
| 34187 | - return SQLITE_OK; | |
| 34188 | - } | |
| 34189 | 34149 | case SQLITE_FCNTL_WIN32_AV_RETRY: { |
| 34190 | 34150 | int *a = (int*)pArg; |
| 34191 | 34151 | if( a[0]>0 ){ |
| 34192 | 34152 | win32IoerrRetry = a[0]; |
| 34193 | 34153 | }else{ |
| @@ -34213,12 +34173,12 @@ | ||
| 34213 | 34173 | ** if two files are created in the same file-system directory (i.e. |
| 34214 | 34174 | ** a database and its journal file) that the sector size will be the |
| 34215 | 34175 | ** same for both. |
| 34216 | 34176 | */ |
| 34217 | 34177 | static int winSectorSize(sqlite3_file *id){ |
| 34218 | - assert( id!=0 ); | |
| 34219 | - return (int)(((winFile*)id)->sectorSize); | |
| 34178 | + (void)id; | |
| 34179 | + return SQLITE_DEFAULT_SECTOR_SIZE; | |
| 34220 | 34180 | } |
| 34221 | 34181 | |
| 34222 | 34182 | /* |
| 34223 | 34183 | ** Return a vector of device characteristics. |
| 34224 | 34184 | */ |
| @@ -34463,11 +34423,11 @@ | ||
| 34463 | 34423 | */ |
| 34464 | 34424 | p = sqlite3_malloc( sizeof(*p) ); |
| 34465 | 34425 | if( p==0 ) return SQLITE_IOERR_NOMEM; |
| 34466 | 34426 | memset(p, 0, sizeof(*p)); |
| 34467 | 34427 | nName = sqlite3Strlen30(pDbFd->zPath); |
| 34468 | - pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 15 ); | |
| 34428 | + pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 16 ); | |
| 34469 | 34429 | if( pNew==0 ){ |
| 34470 | 34430 | sqlite3_free(p); |
| 34471 | 34431 | return SQLITE_IOERR_NOMEM; |
| 34472 | 34432 | } |
| 34473 | 34433 | memset(pNew, 0, sizeof(*pNew)); |
| @@ -35191,11 +35151,10 @@ | ||
| 35191 | 35151 | pFile->pShm = 0; |
| 35192 | 35152 | pFile->zPath = zName; |
| 35193 | 35153 | if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ |
| 35194 | 35154 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 35195 | 35155 | } |
| 35196 | - pFile->sectorSize = getSectorSize(pVfs, zUtf8Name); | |
| 35197 | 35156 | |
| 35198 | 35157 | #if SQLITE_OS_WINCE |
| 35199 | 35158 | if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB |
| 35200 | 35159 | && !winceCreateLock(zName, pFile) |
| 35201 | 35160 | ){ |
| @@ -35436,85 +35395,10 @@ | ||
| 35436 | 35395 | return SQLITE_IOERR_NOMEM; |
| 35437 | 35396 | } |
| 35438 | 35397 | #endif |
| 35439 | 35398 | } |
| 35440 | 35399 | |
| 35441 | -/* | |
| 35442 | -** Get the sector size of the device used to store | |
| 35443 | -** file. | |
| 35444 | -*/ | |
| 35445 | -static int getSectorSize( | |
| 35446 | - sqlite3_vfs *pVfs, | |
| 35447 | - const char *zRelative /* UTF-8 file name */ | |
| 35448 | -){ | |
| 35449 | - DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; | |
| 35450 | - /* GetDiskFreeSpace is not supported under WINCE */ | |
| 35451 | -#if SQLITE_OS_WINCE | |
| 35452 | - UNUSED_PARAMETER(pVfs); | |
| 35453 | - UNUSED_PARAMETER(zRelative); | |
| 35454 | -#else | |
| 35455 | - char zFullpath[MAX_PATH+1]; | |
| 35456 | - int rc; | |
| 35457 | - DWORD dwRet = 0; | |
| 35458 | - DWORD dwDummy; | |
| 35459 | - | |
| 35460 | - /* | |
| 35461 | - ** We need to get the full path name of the file | |
| 35462 | - ** to get the drive letter to look up the sector | |
| 35463 | - ** size. | |
| 35464 | - */ | |
| 35465 | - SimulateIOErrorBenign(1); | |
| 35466 | - sqlite3BeginBenignMalloc(); | |
| 35467 | - rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath); | |
| 35468 | - sqlite3EndBenignMalloc(); | |
| 35469 | - SimulateIOErrorBenign(0); | |
| 35470 | - if( rc == SQLITE_OK ) | |
| 35471 | - { | |
| 35472 | - void *zConverted; | |
| 35473 | - sqlite3BeginBenignMalloc(); | |
| 35474 | - zConverted = convertUtf8Filename(zFullpath); | |
| 35475 | - sqlite3EndBenignMalloc(); | |
| 35476 | - if( zConverted ){ | |
| 35477 | - if( isNT() ){ | |
| 35478 | - /* trim path to just drive reference */ | |
| 35479 | - LPWSTR p = zConverted; | |
| 35480 | - for(;*p;p++){ | |
| 35481 | - if( *p == '\\' ){ | |
| 35482 | - *p = '\0'; | |
| 35483 | - break; | |
| 35484 | - } | |
| 35485 | - } | |
| 35486 | - dwRet = osGetDiskFreeSpaceW((LPCWSTR)zConverted, | |
| 35487 | - &dwDummy, | |
| 35488 | - &bytesPerSector, | |
| 35489 | - &dwDummy, | |
| 35490 | - &dwDummy); | |
| 35491 | - }else{ | |
| 35492 | - /* trim path to just drive reference */ | |
| 35493 | - char *p = (char *)zConverted; | |
| 35494 | - for(;*p;p++){ | |
| 35495 | - if( *p == '\\' ){ | |
| 35496 | - *p = '\0'; | |
| 35497 | - break; | |
| 35498 | - } | |
| 35499 | - } | |
| 35500 | - dwRet = osGetDiskFreeSpaceA((char*)zConverted, | |
| 35501 | - &dwDummy, | |
| 35502 | - &bytesPerSector, | |
| 35503 | - &dwDummy, | |
| 35504 | - &dwDummy); | |
| 35505 | - } | |
| 35506 | - sqlite3_free(zConverted); | |
| 35507 | - } | |
| 35508 | - if( !dwRet ){ | |
| 35509 | - bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; | |
| 35510 | - } | |
| 35511 | - } | |
| 35512 | -#endif | |
| 35513 | - return (int) bytesPerSector; | |
| 35514 | -} | |
| 35515 | - | |
| 35516 | 35400 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 35517 | 35401 | /* |
| 35518 | 35402 | ** Interfaces for opening a shared library, finding entry points |
| 35519 | 35403 | ** within the shared library, and closing the shared library. |
| 35520 | 35404 | */ |
| @@ -36381,11 +36265,11 @@ | ||
| 36381 | 36265 | */ |
| 36382 | 36266 | static int numberOfCachePages(PCache *p){ |
| 36383 | 36267 | if( p->szCache>=0 ){ |
| 36384 | 36268 | return p->szCache; |
| 36385 | 36269 | }else{ |
| 36386 | - return (-1024*p->szCache)/(p->szPage+p->szExtra); | |
| 36270 | + return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); | |
| 36387 | 36271 | } |
| 36388 | 36272 | } |
| 36389 | 36273 | |
| 36390 | 36274 | /* |
| 36391 | 36275 | ** Try to obtain a page from the cache. |
| @@ -36845,14 +36729,14 @@ | ||
| 36845 | 36729 | ** PGroup which is the pcache1.grp global variable and its mutex is |
| 36846 | 36730 | ** SQLITE_MUTEX_STATIC_LRU. |
| 36847 | 36731 | */ |
| 36848 | 36732 | struct PGroup { |
| 36849 | 36733 | sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ |
| 36850 | - int nMaxPage; /* Sum of nMax for purgeable caches */ | |
| 36851 | - int nMinPage; /* Sum of nMin for purgeable caches */ | |
| 36852 | - int mxPinned; /* nMaxpage + 10 - nMinPage */ | |
| 36853 | - int nCurrentPage; /* Number of purgeable pages allocated */ | |
| 36734 | + unsigned int nMaxPage; /* Sum of nMax for purgeable caches */ | |
| 36735 | + unsigned int nMinPage; /* Sum of nMin for purgeable caches */ | |
| 36736 | + unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */ | |
| 36737 | + unsigned int nCurrentPage; /* Number of purgeable pages allocated */ | |
| 36854 | 36738 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 36855 | 36739 | }; |
| 36856 | 36740 | |
| 36857 | 36741 | /* Each page cache is an instance of the following object. Every |
| 36858 | 36742 | ** open database file (including each in-memory database and each |
| @@ -37511,11 +37395,11 @@ | ||
| 37511 | 37395 | static sqlite3_pcache_page *pcache1Fetch( |
| 37512 | 37396 | sqlite3_pcache *p, |
| 37513 | 37397 | unsigned int iKey, |
| 37514 | 37398 | int createFlag |
| 37515 | 37399 | ){ |
| 37516 | - int nPinned; | |
| 37400 | + unsigned int nPinned; | |
| 37517 | 37401 | PCache1 *pCache = (PCache1 *)p; |
| 37518 | 37402 | PGroup *pGroup; |
| 37519 | 37403 | PgHdr1 *pPage = 0; |
| 37520 | 37404 | |
| 37521 | 37405 | assert( pCache->bPurgeable || createFlag!=1 ); |
| @@ -37546,17 +37430,17 @@ | ||
| 37546 | 37430 | #ifdef SQLITE_MUTEX_OMIT |
| 37547 | 37431 | pGroup = pCache->pGroup; |
| 37548 | 37432 | #endif |
| 37549 | 37433 | |
| 37550 | 37434 | /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ |
| 37435 | + assert( pCache->nPage >= pCache->nRecyclable ); | |
| 37551 | 37436 | nPinned = pCache->nPage - pCache->nRecyclable; |
| 37552 | - assert( nPinned>=0 ); | |
| 37553 | 37437 | assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage ); |
| 37554 | 37438 | assert( pCache->n90pct == pCache->nMax*9/10 ); |
| 37555 | 37439 | if( createFlag==1 && ( |
| 37556 | 37440 | nPinned>=pGroup->mxPinned |
| 37557 | - || nPinned>=(int)pCache->n90pct | |
| 37441 | + || nPinned>=pCache->n90pct | |
| 37558 | 37442 | || pcache1UnderMemoryPressure(pCache) |
| 37559 | 37443 | )){ |
| 37560 | 37444 | goto fetch_out; |
| 37561 | 37445 | } |
| 37562 | 37446 | |
| @@ -37725,11 +37609,13 @@ | ||
| 37725 | 37609 | PCache1 *pCache = (PCache1 *)p; |
| 37726 | 37610 | PGroup *pGroup = pCache->pGroup; |
| 37727 | 37611 | assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); |
| 37728 | 37612 | pcache1EnterMutex(pGroup); |
| 37729 | 37613 | pcache1TruncateUnsafe(pCache, 0); |
| 37614 | + assert( pGroup->nMaxPage >= pCache->nMax ); | |
| 37730 | 37615 | pGroup->nMaxPage -= pCache->nMax; |
| 37616 | + assert( pGroup->nMinPage >= pCache->nMin ); | |
| 37731 | 37617 | pGroup->nMinPage -= pCache->nMin; |
| 37732 | 37618 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 37733 | 37619 | pcache1EnforceMaxPage(pGroup); |
| 37734 | 37620 | pcache1LeaveMutex(pGroup); |
| 37735 | 37621 | sqlite3_free(pCache->apHash); |
| @@ -37807,12 +37693,12 @@ | ||
| 37807 | 37693 | int nRecyclable = 0; |
| 37808 | 37694 | for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ |
| 37809 | 37695 | nRecyclable++; |
| 37810 | 37696 | } |
| 37811 | 37697 | *pnCurrent = pcache1.grp.nCurrentPage; |
| 37812 | - *pnMax = pcache1.grp.nMaxPage; | |
| 37813 | - *pnMin = pcache1.grp.nMinPage; | |
| 37698 | + *pnMax = (int)pcache1.grp.nMaxPage; | |
| 37699 | + *pnMin = (int)pcache1.grp.nMinPage; | |
| 37814 | 37700 | *pnRecyclable = nRecyclable; |
| 37815 | 37701 | } |
| 37816 | 37702 | #endif |
| 37817 | 37703 | |
| 37818 | 37704 | /************** End of pcache1.c *********************************************/ |
| @@ -38282,10 +38168,16 @@ | ||
| 38282 | 38168 | |
| 38283 | 38169 | #ifndef _WAL_H_ |
| 38284 | 38170 | #define _WAL_H_ |
| 38285 | 38171 | |
| 38286 | 38172 | |
| 38173 | +/* Additional values that can be added to the sync_flags argument of | |
| 38174 | +** sqlite3WalFrames(): | |
| 38175 | +*/ | |
| 38176 | +#define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ | |
| 38177 | +#define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */ | |
| 38178 | + | |
| 38287 | 38179 | #ifdef SQLITE_OMIT_WAL |
| 38288 | 38180 | # define sqlite3WalOpen(x,y,z) 0 |
| 38289 | 38181 | # define sqlite3WalLimit(x,y) |
| 38290 | 38182 | # define sqlite3WalClose(w,x,y,z) 0 |
| 38291 | 38183 | # define sqlite3WalBeginReadTransaction(y,z) 0 |
| @@ -38350,16 +38242,10 @@ | ||
| 38350 | 38242 | SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData); |
| 38351 | 38243 | |
| 38352 | 38244 | /* Write a frame or frames to the log. */ |
| 38353 | 38245 | SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int); |
| 38354 | 38246 | |
| 38355 | -/* Additional values that can be added to the sync_flags argument of | |
| 38356 | -** sqlite3WalFrames(): | |
| 38357 | -*/ | |
| 38358 | -#define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ | |
| 38359 | -#define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */ | |
| 38360 | - | |
| 38361 | 38247 | /* Copy pages from the log to the database file */ |
| 38362 | 38248 | SQLITE_PRIVATE int sqlite3WalCheckpoint( |
| 38363 | 38249 | Wal *pWal, /* Write-ahead log connection */ |
| 38364 | 38250 | int eMode, /* One of PASSIVE, FULL and RESTART */ |
| 38365 | 38251 | int (*xBusy)(void*), /* Function to call when busy */ |
| @@ -42400,11 +42286,13 @@ | ||
| 42400 | 42286 | ** file size will be. |
| 42401 | 42287 | */ |
| 42402 | 42288 | assert( rc!=SQLITE_OK || isOpen(pPager->fd) ); |
| 42403 | 42289 | if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){ |
| 42404 | 42290 | sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize; |
| 42291 | + sqlite3BeginBenignMalloc(); | |
| 42405 | 42292 | sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile); |
| 42293 | + sqlite3EndBenignMalloc(); | |
| 42406 | 42294 | pPager->dbHintSize = pPager->dbSize; |
| 42407 | 42295 | } |
| 42408 | 42296 | |
| 42409 | 42297 | while( rc==SQLITE_OK && pList ){ |
| 42410 | 42298 | Pgno pgno = pList->pgno; |
| @@ -42741,11 +42629,12 @@ | ||
| 42741 | 42629 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 42742 | 42630 | while( *z ){ |
| 42743 | 42631 | z += sqlite3Strlen30(z)+1; |
| 42744 | 42632 | z += sqlite3Strlen30(z)+1; |
| 42745 | 42633 | } |
| 42746 | - nUri = &z[1] - zUri; | |
| 42634 | + nUri = (int)(&z[1] - zUri); | |
| 42635 | + assert( nUri>=0 ); | |
| 42747 | 42636 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 42748 | 42637 | /* This branch is taken when the journal path required by |
| 42749 | 42638 | ** the database being opened will be more than pVfs->mxPathname |
| 42750 | 42639 | ** bytes in length. This means the database cannot be opened, |
| 42751 | 42640 | ** as it will not be possible to open the journal file or even |
| @@ -42775,13 +42664,13 @@ | ||
| 42775 | 42664 | ROUND8(sizeof(*pPager)) + /* Pager structure */ |
| 42776 | 42665 | ROUND8(pcacheSize) + /* PCache object */ |
| 42777 | 42666 | ROUND8(pVfs->szOsFile) + /* The main db file */ |
| 42778 | 42667 | journalFileSize * 2 + /* The two journal files */ |
| 42779 | 42668 | nPathname + 1 + nUri + /* zFilename */ |
| 42780 | - nPathname + 8 + 1 /* zJournal */ | |
| 42669 | + nPathname + 8 + 2 /* zJournal */ | |
| 42781 | 42670 | #ifndef SQLITE_OMIT_WAL |
| 42782 | - + nPathname + 4 + 1 /* zWal */ | |
| 42671 | + + nPathname + 4 + 2 /* zWal */ | |
| 42783 | 42672 | #endif |
| 42784 | 42673 | ); |
| 42785 | 42674 | assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); |
| 42786 | 42675 | if( !pPtr ){ |
| 42787 | 42676 | sqlite3_free(zPathname); |
| @@ -42800,16 +42689,16 @@ | ||
| 42800 | 42689 | assert( nPathname>0 ); |
| 42801 | 42690 | pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); |
| 42802 | 42691 | memcpy(pPager->zFilename, zPathname, nPathname); |
| 42803 | 42692 | memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); |
| 42804 | 42693 | memcpy(pPager->zJournal, zPathname, nPathname); |
| 42805 | - memcpy(&pPager->zJournal[nPathname], "-journal", 8); | |
| 42694 | + memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+1); | |
| 42806 | 42695 | sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); |
| 42807 | 42696 | #ifndef SQLITE_OMIT_WAL |
| 42808 | 42697 | pPager->zWal = &pPager->zJournal[nPathname+8+1]; |
| 42809 | 42698 | memcpy(pPager->zWal, zPathname, nPathname); |
| 42810 | - memcpy(&pPager->zWal[nPathname], "-wal", 4); | |
| 42699 | + memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1); | |
| 42811 | 42700 | sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); |
| 42812 | 42701 | #endif |
| 42813 | 42702 | sqlite3_free(zPathname); |
| 42814 | 42703 | } |
| 42815 | 42704 | pPager->pVfs = pVfs; |
| @@ -44064,11 +43953,14 @@ | ||
| 44064 | 43953 | if( !pPager->noSync ){ |
| 44065 | 43954 | assert( !MEMDB ); |
| 44066 | 43955 | rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); |
| 44067 | 43956 | }else if( isOpen(pPager->fd) ){ |
| 44068 | 43957 | assert( !MEMDB ); |
| 44069 | - sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc); | |
| 43958 | + rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, 0); | |
| 43959 | + if( rc==SQLITE_NOTFOUND ){ | |
| 43960 | + rc = SQLITE_OK; | |
| 43961 | + } | |
| 44070 | 43962 | } |
| 44071 | 43963 | return rc; |
| 44072 | 43964 | } |
| 44073 | 43965 | |
| 44074 | 43966 | /* |
| @@ -48125,11 +48017,11 @@ | ||
| 48125 | 48017 | iFrame = pWal->hdr.mxFrame; |
| 48126 | 48018 | for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){ |
| 48127 | 48019 | iFrame++; |
| 48128 | 48020 | rc = walIndexAppend(pWal, iFrame, p->pgno); |
| 48129 | 48021 | } |
| 48130 | - while( nExtra>0 && rc==SQLITE_OK ){ | |
| 48022 | + while( rc==SQLITE_OK && nExtra>0 ){ | |
| 48131 | 48023 | iFrame++; |
| 48132 | 48024 | nExtra--; |
| 48133 | 48025 | rc = walIndexAppend(pWal, iFrame, pLast->pgno); |
| 48134 | 48026 | } |
| 48135 | 48027 | |
| @@ -48726,11 +48618,11 @@ | ||
| 48726 | 48618 | #define TRANS_WRITE 2 |
| 48727 | 48619 | |
| 48728 | 48620 | /* |
| 48729 | 48621 | ** An instance of this object represents a single database file. |
| 48730 | 48622 | ** |
| 48731 | -** A single database file can be in use as the same time by two | |
| 48623 | +** A single database file can be in use at the same time by two | |
| 48732 | 48624 | ** or more database connections. When two or more connections are |
| 48733 | 48625 | ** sharing the same database file, each connection has it own |
| 48734 | 48626 | ** private Btree object for the file and each of those Btrees points |
| 48735 | 48627 | ** to this one BtShared object. BtShared.nRef is the number of |
| 48736 | 48628 | ** connections currently sharing this database file. |
| @@ -48832,11 +48724,11 @@ | ||
| 48832 | 48724 | ** b-tree within a database file. |
| 48833 | 48725 | ** |
| 48834 | 48726 | ** The entry is identified by its MemPage and the index in |
| 48835 | 48727 | ** MemPage.aCell[] of the entry. |
| 48836 | 48728 | ** |
| 48837 | -** A single database file can shared by two more database connections, | |
| 48729 | +** A single database file can be shared by two more database connections, | |
| 48838 | 48730 | ** but cursors cannot be shared. Each cursor is associated with a |
| 48839 | 48731 | ** particular database connection identified BtCursor.pBtree.db. |
| 48840 | 48732 | ** |
| 48841 | 48733 | ** Fields in this structure are accessed under the BtShared.mutex |
| 48842 | 48734 | ** found at self->pBt->mutex. |
| @@ -48993,11 +48885,11 @@ | ||
| 48993 | 48885 | int mallocFailed; /* A memory allocation error has occurred */ |
| 48994 | 48886 | StrAccum errMsg; /* Accumulate the error message text here */ |
| 48995 | 48887 | }; |
| 48996 | 48888 | |
| 48997 | 48889 | /* |
| 48998 | -** Read or write a two- and four-byte big-endian integer values. | |
| 48890 | +** Routines to read or write a two- and four-byte big-endian integer values. | |
| 48999 | 48891 | */ |
| 49000 | 48892 | #define get2byte(x) ((x)[0]<<8 | (x)[1]) |
| 49001 | 48893 | #define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) |
| 49002 | 48894 | #define get4byte sqlite3Get4byte |
| 49003 | 48895 | #define put4byte sqlite3Put4byte |
| @@ -55478,12 +55370,18 @@ | ||
| 55478 | 55370 | } |
| 55479 | 55371 | |
| 55480 | 55372 | /* Either we found one or more cells (cntnew[0])>0) or pPage is |
| 55481 | 55373 | ** a virtual root page. A virtual root page is when the real root |
| 55482 | 55374 | ** page is page 1 and we are the only child of that page. |
| 55375 | + ** | |
| 55376 | + ** UPDATE: The assert() below is not necessarily true if the database | |
| 55377 | + ** file is corrupt. The corruption will be detected and reported later | |
| 55378 | + ** in this procedure so there is no need to act upon it now. | |
| 55483 | 55379 | */ |
| 55380 | +#if 0 | |
| 55484 | 55381 | assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) ); |
| 55382 | +#endif | |
| 55485 | 55383 | |
| 55486 | 55384 | TRACE(("BALANCE: old: %d %d %d ", |
| 55487 | 55385 | apOld[0]->pgno, |
| 55488 | 55386 | nOld>=2 ? apOld[1]->pgno : 0, |
| 55489 | 55387 | nOld>=3 ? apOld[2]->pgno : 0 |
| @@ -58194,11 +58092,13 @@ | ||
| 58194 | 58092 | |
| 58195 | 58093 | assert( sqlite3BtreeIsInTrans(pTo) ); |
| 58196 | 58094 | pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); |
| 58197 | 58095 | if( pFd->pMethods ){ |
| 58198 | 58096 | i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); |
| 58097 | + sqlite3BeginBenignMalloc(); | |
| 58199 | 58098 | sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); |
| 58099 | + sqlite3EndBenignMalloc(); | |
| 58200 | 58100 | } |
| 58201 | 58101 | |
| 58202 | 58102 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 58203 | 58103 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 58204 | 58104 | ** and sqlite3_backup_finish() to detect that they are being called |
| @@ -58525,11 +58425,11 @@ | ||
| 58525 | 58425 | ** Release any memory held by the Mem. This may leave the Mem in an |
| 58526 | 58426 | ** inconsistent state, for example with (Mem.z==0) and |
| 58527 | 58427 | ** (Mem.type==SQLITE_TEXT). |
| 58528 | 58428 | */ |
| 58529 | 58429 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){ |
| 58530 | - MemReleaseExt(p); | |
| 58430 | + VdbeMemRelease(p); | |
| 58531 | 58431 | sqlite3DbFree(p->db, p->zMalloc); |
| 58532 | 58432 | p->z = 0; |
| 58533 | 58433 | p->zMalloc = 0; |
| 58534 | 58434 | p->xDel = 0; |
| 58535 | 58435 | } |
| @@ -58821,11 +58721,11 @@ | ||
| 58821 | 58721 | ** copies of this cell as invalid. |
| 58822 | 58722 | ** |
| 58823 | 58723 | ** This is used for testing and debugging only - to make sure shallow |
| 58824 | 58724 | ** copies are not misused. |
| 58825 | 58725 | */ |
| 58826 | -SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe *pVdbe, Mem *pMem){ | |
| 58726 | +SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ | |
| 58827 | 58727 | int i; |
| 58828 | 58728 | Mem *pX; |
| 58829 | 58729 | for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){ |
| 58830 | 58730 | if( pX->pScopyFrom==pMem ){ |
| 58831 | 58731 | pX->flags |= MEM_Invalid; |
| @@ -58847,11 +58747,11 @@ | ||
| 58847 | 58747 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| 58848 | 58748 | ** and flags gets srcType (either MEM_Ephem or MEM_Static). |
| 58849 | 58749 | */ |
| 58850 | 58750 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ |
| 58851 | 58751 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58852 | - MemReleaseExt(pTo); | |
| 58752 | + VdbeMemRelease(pTo); | |
| 58853 | 58753 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58854 | 58754 | pTo->xDel = 0; |
| 58855 | 58755 | if( (pFrom->flags&MEM_Static)==0 ){ |
| 58856 | 58756 | pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem); |
| 58857 | 58757 | assert( srcType==MEM_Ephem || srcType==MEM_Static ); |
| @@ -58865,11 +58765,11 @@ | ||
| 58865 | 58765 | */ |
| 58866 | 58766 | SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){ |
| 58867 | 58767 | int rc = SQLITE_OK; |
| 58868 | 58768 | |
| 58869 | 58769 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58870 | - MemReleaseExt(pTo); | |
| 58770 | + VdbeMemRelease(pTo); | |
| 58871 | 58771 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58872 | 58772 | pTo->flags &= ~MEM_Dyn; |
| 58873 | 58773 | |
| 58874 | 58774 | if( pTo->flags&(MEM_Str|MEM_Blob) ){ |
| 58875 | 58775 | if( 0==(pFrom->flags&MEM_Static) ){ |
| @@ -59202,11 +59102,11 @@ | ||
| 59202 | 59102 | assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 ); |
| 59203 | 59103 | if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){ |
| 59204 | 59104 | return 0; |
| 59205 | 59105 | } |
| 59206 | 59106 | } |
| 59207 | - sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */ | |
| 59107 | + sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */ | |
| 59208 | 59108 | }else{ |
| 59209 | 59109 | assert( (pVal->flags&MEM_Blob)==0 ); |
| 59210 | 59110 | sqlite3VdbeMemStringify(pVal, enc); |
| 59211 | 59111 | assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); |
| 59212 | 59112 | } |
| @@ -59583,11 +59483,12 @@ | ||
| 59583 | 59483 | return addr; |
| 59584 | 59484 | } |
| 59585 | 59485 | |
| 59586 | 59486 | /* |
| 59587 | 59487 | ** Add an OP_ParseSchema opcode. This routine is broken out from |
| 59588 | -** sqlite3VdbeAddOp4() since it needs to also local all btrees. | |
| 59488 | +** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees | |
| 59489 | +** as having been used. | |
| 59589 | 59490 | ** |
| 59590 | 59491 | ** The zWhere string must have been obtained from sqlite3_malloc(). |
| 59591 | 59492 | ** This routine will take ownership of the allocated memory. |
| 59592 | 59493 | */ |
| 59593 | 59494 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ |
| @@ -60350,12 +60251,13 @@ | ||
| 60350 | 60251 | |
| 60351 | 60252 | /* |
| 60352 | 60253 | ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. |
| 60353 | 60254 | ** |
| 60354 | 60255 | ** The prepared statements need to know in advance the complete set of |
| 60355 | -** attached databases that they will be using. A mask of these databases | |
| 60356 | -** is maintained in p->btreeMask and is used for locking and other purposes. | |
| 60256 | +** attached databases that will be use. A mask of these databases | |
| 60257 | +** is maintained in p->btreeMask. The p->lockMask value is the subset of | |
| 60258 | +** p->btreeMask of databases that will require a lock. | |
| 60357 | 60259 | */ |
| 60358 | 60260 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){ |
| 60359 | 60261 | assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 ); |
| 60360 | 60262 | assert( i<(int)sizeof(p->btreeMask)*8 ); |
| 60361 | 60263 | p->btreeMask |= ((yDbMask)1)<<i; |
| @@ -60874,10 +60776,11 @@ | ||
| 60874 | 60776 | nVar = pParse->nVar; |
| 60875 | 60777 | nMem = pParse->nMem; |
| 60876 | 60778 | nCursor = pParse->nTab; |
| 60877 | 60779 | nArg = pParse->nMaxArg; |
| 60878 | 60780 | nOnce = pParse->nOnce; |
| 60781 | + if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */ | |
| 60879 | 60782 | |
| 60880 | 60783 | /* For each cursor required, also allocate a memory cell. Memory |
| 60881 | 60784 | ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by |
| 60882 | 60785 | ** the vdbe program. Instead they are used to allocate space for |
| 60883 | 60786 | ** VdbeCursor/BtCursor structures. The blob of memory associated with |
| @@ -61225,11 +61128,11 @@ | ||
| 61225 | 61128 | int retryCount = 0; |
| 61226 | 61129 | int nMainFile; |
| 61227 | 61130 | |
| 61228 | 61131 | /* Select a master journal file name */ |
| 61229 | 61132 | nMainFile = sqlite3Strlen30(zMainFile); |
| 61230 | - zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XX", zMainFile); | |
| 61133 | + zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile); | |
| 61231 | 61134 | if( zMaster==0 ) return SQLITE_NOMEM; |
| 61232 | 61135 | do { |
| 61233 | 61136 | u32 iRandom; |
| 61234 | 61137 | if( retryCount ){ |
| 61235 | 61138 | if( retryCount>100 ){ |
| @@ -63013,11 +62916,11 @@ | ||
| 63013 | 62916 | ** since any application that receives an SQLITE_MISUSE is broken by |
| 63014 | 62917 | ** definition. |
| 63015 | 62918 | ** |
| 63016 | 62919 | ** Nevertheless, some published applications that were originally written |
| 63017 | 62920 | ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE |
| 63018 | - ** returns, and the so were broken by the automatic-reset change. As a | |
| 62921 | + ** returns, and those were broken by the automatic-reset change. As a | |
| 63019 | 62922 | ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the |
| 63020 | 62923 | ** legacy behavior of returning SQLITE_MISUSE for cases where the |
| 63021 | 62924 | ** previous sqlite3_step() returned something other than a SQLITE_LOCKED |
| 63022 | 62925 | ** or SQLITE_BUSY error. |
| 63023 | 62926 | */ |
| @@ -63359,17 +63262,17 @@ | ||
| 63359 | 63262 | pOut = &pVm->pResultSet[i]; |
| 63360 | 63263 | }else{ |
| 63361 | 63264 | /* If the value passed as the second argument is out of range, return |
| 63362 | 63265 | ** a pointer to the following static Mem object which contains the |
| 63363 | 63266 | ** value SQL NULL. Even though the Mem structure contains an element |
| 63364 | - ** of type i64, on certain architecture (x86) with certain compiler | |
| 63267 | + ** of type i64, on certain architectures (x86) with certain compiler | |
| 63365 | 63268 | ** switches (-Os), gcc may align this Mem object on a 4-byte boundary |
| 63366 | 63269 | ** instead of an 8-byte one. This all works fine, except that when |
| 63367 | 63270 | ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s |
| 63368 | 63271 | ** that a Mem structure is located on an 8-byte boundary. To prevent |
| 63369 | - ** this assert() from failing, when building with SQLITE_DEBUG defined | |
| 63370 | - ** using gcc, force nullMem to be 8-byte aligned using the magical | |
| 63272 | + ** these assert()s from failing, when building with SQLITE_DEBUG defined | |
| 63273 | + ** using gcc, we force nullMem to be 8-byte aligned using the magical | |
| 63371 | 63274 | ** __attribute__((aligned(8))) macro. */ |
| 63372 | 63275 | static const Mem nullMem |
| 63373 | 63276 | #if defined(SQLITE_DEBUG) && defined(__GNUC__) |
| 63374 | 63277 | __attribute__((aligned(8))) |
| 63375 | 63278 | #endif |
| @@ -64298,11 +64201,11 @@ | ||
| 64298 | 64201 | ** Invoke this macro on memory cells just prior to changing the |
| 64299 | 64202 | ** value of the cell. This macro verifies that shallow copies are |
| 64300 | 64203 | ** not misused. |
| 64301 | 64204 | */ |
| 64302 | 64205 | #ifdef SQLITE_DEBUG |
| 64303 | -# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) | |
| 64206 | +# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M) | |
| 64304 | 64207 | #else |
| 64305 | 64208 | # define memAboutToChange(P,M) |
| 64306 | 64209 | #endif |
| 64307 | 64210 | |
| 64308 | 64211 | /* |
| @@ -64316,12 +64219,12 @@ | ||
| 64316 | 64219 | SQLITE_API int sqlite3_search_count = 0; |
| 64317 | 64220 | #endif |
| 64318 | 64221 | |
| 64319 | 64222 | /* |
| 64320 | 64223 | ** When this global variable is positive, it gets decremented once before |
| 64321 | -** each instruction in the VDBE. When reaches zero, the u1.isInterrupted | |
| 64322 | -** field of the sqlite3 structure is set in order to simulate and interrupt. | |
| 64224 | +** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted | |
| 64225 | +** field of the sqlite3 structure is set in order to simulate an interrupt. | |
| 64323 | 64226 | ** |
| 64324 | 64227 | ** This facility is used for testing purposes only. It does not function |
| 64325 | 64228 | ** in an ordinary build. |
| 64326 | 64229 | */ |
| 64327 | 64230 | #ifdef SQLITE_TEST |
| @@ -64442,11 +64345,11 @@ | ||
| 64442 | 64345 | */ |
| 64443 | 64346 | static VdbeCursor *allocateCursor( |
| 64444 | 64347 | Vdbe *p, /* The virtual machine */ |
| 64445 | 64348 | int iCur, /* Index of the new VdbeCursor */ |
| 64446 | 64349 | int nField, /* Number of fields in the table or index */ |
| 64447 | - int iDb, /* When database the cursor belongs to, or -1 */ | |
| 64350 | + int iDb, /* Database the cursor belongs to, or -1 */ | |
| 64448 | 64351 | int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ |
| 64449 | 64352 | ){ |
| 64450 | 64353 | /* Find the memory cell that will be used to store the blob of memory |
| 64451 | 64354 | ** required for this VdbeCursor structure. It is convenient to use a |
| 64452 | 64355 | ** vdbe memory cell to manage the memory allocation required for a |
| @@ -64813,11 +64716,11 @@ | ||
| 64813 | 64716 | ** sqlite3_interrupt() routine has been called. If it has been, then |
| 64814 | 64717 | ** processing of the VDBE program is interrupted. |
| 64815 | 64718 | ** |
| 64816 | 64719 | ** This macro added to every instruction that does a jump in order to |
| 64817 | 64720 | ** implement a loop. This test used to be on every single instruction, |
| 64818 | -** but that meant we more testing that we needed. By only testing the | |
| 64721 | +** but that meant we more testing than we needed. By only testing the | |
| 64819 | 64722 | ** flag on jump instructions, we get a (small) speed improvement. |
| 64820 | 64723 | */ |
| 64821 | 64724 | #define CHECK_FOR_INTERRUPT \ |
| 64822 | 64725 | if( db->u1.isInterrupted ) goto abort_due_to_interrupt; |
| 64823 | 64726 | |
| @@ -65430,11 +65333,11 @@ | ||
| 65430 | 65333 | if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){ |
| 65431 | 65334 | assert( pOp->p2>0 ); |
| 65432 | 65335 | assert( pOp->p2<=p->nMem ); |
| 65433 | 65336 | pOut = &aMem[pOp->p2]; |
| 65434 | 65337 | memAboutToChange(p, pOut); |
| 65435 | - MemReleaseExt(pOut); | |
| 65338 | + VdbeMemRelease(pOut); | |
| 65436 | 65339 | pOut->flags = MEM_Int; |
| 65437 | 65340 | } |
| 65438 | 65341 | |
| 65439 | 65342 | /* Sanity checking on other operands */ |
| 65440 | 65343 | #ifdef SQLITE_DEBUG |
| @@ -65738,11 +65641,11 @@ | ||
| 65738 | 65641 | assert( pOp->p3<=p->nMem ); |
| 65739 | 65642 | pOut->flags = MEM_Null; |
| 65740 | 65643 | while( u.ab.cnt>0 ){ |
| 65741 | 65644 | pOut++; |
| 65742 | 65645 | memAboutToChange(p, pOut); |
| 65743 | - MemReleaseExt(pOut); | |
| 65646 | + VdbeMemRelease(pOut); | |
| 65744 | 65647 | pOut->flags = MEM_Null; |
| 65745 | 65648 | u.ab.cnt--; |
| 65746 | 65649 | } |
| 65747 | 65650 | break; |
| 65748 | 65651 | } |
| @@ -65919,11 +65822,11 @@ | ||
| 65919 | 65822 | /* Invalidate all ephemeral cursor row caches */ |
| 65920 | 65823 | p->cacheCtr = (p->cacheCtr + 2)|1; |
| 65921 | 65824 | |
| 65922 | 65825 | /* Make sure the results of the current row are \000 terminated |
| 65923 | 65826 | ** and have an assigned type. The results are de-ephemeralized as |
| 65924 | - ** as side effect. | |
| 65827 | + ** a side effect. | |
| 65925 | 65828 | */ |
| 65926 | 65829 | u.ae.pMem = p->pResultSet = &aMem[pOp->p1]; |
| 65927 | 65830 | for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){ |
| 65928 | 65831 | assert( memIsValid(&u.ae.pMem[u.ae.i]) ); |
| 65929 | 65832 | Deephemeralize(&u.ae.pMem[u.ae.i]); |
| @@ -67160,11 +67063,11 @@ | ||
| 67160 | 67063 | ** a pointer to a Mem object. |
| 67161 | 67064 | */ |
| 67162 | 67065 | if( u.an.aOffset[u.an.p2] ){ |
| 67163 | 67066 | assert( rc==SQLITE_OK ); |
| 67164 | 67067 | if( u.an.zRec ){ |
| 67165 | - MemReleaseExt(u.an.pDest); | |
| 67068 | + VdbeMemRelease(u.an.pDest); | |
| 67166 | 67069 | sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest); |
| 67167 | 67070 | }else{ |
| 67168 | 67071 | u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]); |
| 67169 | 67072 | sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest); |
| 67170 | 67073 | rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem); |
| @@ -83758,11 +83661,11 @@ | ||
| 83758 | 83661 | ** Allocate the index structure. |
| 83759 | 83662 | */ |
| 83760 | 83663 | nName = sqlite3Strlen30(zName); |
| 83761 | 83664 | nCol = pList->nExpr; |
| 83762 | 83665 | pIndex = sqlite3DbMallocZero(db, |
| 83763 | - sizeof(Index) + /* Index structure */ | |
| 83666 | + ROUND8(sizeof(Index)) + /* Index structure */ | |
| 83764 | 83667 | ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */ |
| 83765 | 83668 | sizeof(char *)*nCol + /* Index.azColl */ |
| 83766 | 83669 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 83767 | 83670 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 83768 | 83671 | nName + 1 + /* Index.zName */ |
| @@ -83769,11 +83672,12 @@ | ||
| 83769 | 83672 | nExtra /* Collation sequence names */ |
| 83770 | 83673 | ); |
| 83771 | 83674 | if( db->mallocFailed ){ |
| 83772 | 83675 | goto exit_create_index; |
| 83773 | 83676 | } |
| 83774 | - pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]); | |
| 83677 | + zExtra = (char*)pIndex; | |
| 83678 | + pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))]; | |
| 83775 | 83679 | pIndex->azColl = (char**) |
| 83776 | 83680 | ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1)); |
| 83777 | 83681 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) ); |
| 83778 | 83682 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); |
| 83779 | 83683 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| @@ -89966,11 +89870,11 @@ | ||
| 89966 | 89870 | ** any ABORT Back out changes from the current command |
| 89967 | 89871 | ** only (do not do a complete rollback) then |
| 89968 | 89872 | ** cause sqlite3_exec() to return immediately |
| 89969 | 89873 | ** with SQLITE_CONSTRAINT. |
| 89970 | 89874 | ** |
| 89971 | -** any FAIL Sqlite_exec() returns immediately with a | |
| 89875 | +** any FAIL Sqlite3_exec() returns immediately with a | |
| 89972 | 89876 | ** return code of SQLITE_CONSTRAINT. The |
| 89973 | 89877 | ** transaction is not rolled back and any |
| 89974 | 89878 | ** prior changes are retained. |
| 89975 | 89879 | ** |
| 89976 | 89880 | ** any IGNORE The record number and data is popped from |
| @@ -111450,11 +111354,11 @@ | ||
| 111450 | 111354 | *tokenType = TK_SPACE; |
| 111451 | 111355 | return i; |
| 111452 | 111356 | } |
| 111453 | 111357 | case '-': { |
| 111454 | 111358 | if( z[1]=='-' ){ |
| 111455 | - /* IMP: R-15891-05542 -- syntax diagram for comments */ | |
| 111359 | + /* IMP: R-50417-27976 -- syntax diagram for comments */ | |
| 111456 | 111360 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 111457 | 111361 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111458 | 111362 | return i; |
| 111459 | 111363 | } |
| 111460 | 111364 | *tokenType = TK_MINUS; |
| @@ -111483,11 +111387,11 @@ | ||
| 111483 | 111387 | case '/': { |
| 111484 | 111388 | if( z[1]!='*' || z[2]==0 ){ |
| 111485 | 111389 | *tokenType = TK_SLASH; |
| 111486 | 111390 | return 1; |
| 111487 | 111391 | } |
| 111488 | - /* IMP: R-15891-05542 -- syntax diagram for comments */ | |
| 111392 | + /* IMP: R-50417-27976 -- syntax diagram for comments */ | |
| 111489 | 111393 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 111490 | 111394 | if( c ) i++; |
| 111491 | 111395 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111492 | 111396 | return i; |
| 111493 | 111397 | } |
| @@ -112277,12 +112181,12 @@ | ||
| 112277 | 112181 | /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function |
| 112278 | 112182 | ** returns an integer equal to SQLITE_VERSION_NUMBER. |
| 112279 | 112183 | */ |
| 112280 | 112184 | SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } |
| 112281 | 112185 | |
| 112282 | -/* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns | |
| 112283 | -** zero if and only if SQLite was compiled mutexing code omitted due to | |
| 112186 | +/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns | |
| 112187 | +** zero if and only if SQLite was compiled with mutexing code omitted due to | |
| 112284 | 112188 | ** the SQLITE_THREADSAFE compile-time option being set to 0. |
| 112285 | 112189 | */ |
| 112286 | 112190 | SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } |
| 112287 | 112191 | |
| 112288 | 112192 | #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) |
| @@ -112768,19 +112672,21 @@ | ||
| 112768 | 112672 | ** Free up as much memory as we can from the given database |
| 112769 | 112673 | ** connection. |
| 112770 | 112674 | */ |
| 112771 | 112675 | SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){ |
| 112772 | 112676 | int i; |
| 112677 | + sqlite3_mutex_enter(db->mutex); | |
| 112773 | 112678 | sqlite3BtreeEnterAll(db); |
| 112774 | 112679 | for(i=0; i<db->nDb; i++){ |
| 112775 | 112680 | Btree *pBt = db->aDb[i].pBt; |
| 112776 | 112681 | if( pBt ){ |
| 112777 | 112682 | Pager *pPager = sqlite3BtreePager(pBt); |
| 112778 | 112683 | sqlite3PagerShrink(pPager); |
| 112779 | 112684 | } |
| 112780 | 112685 | } |
| 112781 | 112686 | sqlite3BtreeLeaveAll(db); |
| 112687 | + sqlite3_mutex_leave(db->mutex); | |
| 112782 | 112688 | return SQLITE_OK; |
| 112783 | 112689 | } |
| 112784 | 112690 | |
| 112785 | 112691 | /* |
| 112786 | 112692 | ** Configuration settings for an individual database connection |
| 112787 | 112693 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -657,11 +657,11 @@ | |
| 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | */ |
| 660 | #define SQLITE_VERSION "3.7.10" |
| 661 | #define SQLITE_VERSION_NUMBER 3007010 |
| 662 | #define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22" |
| 663 | |
| 664 | /* |
| 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | ** |
| @@ -725,11 +725,11 @@ | |
| 725 | |
| 726 | /* |
| 727 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 728 | ** |
| 729 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 730 | ** SQLite was compiled mutexing code omitted due to the |
| 731 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 732 | ** |
| 733 | ** SQLite can be compiled with or without mutexes. When |
| 734 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 735 | ** are enabled and SQLite is threadsafe. When the |
| @@ -919,11 +919,11 @@ | |
| 919 | ** CAPI3REF: Result Codes |
| 920 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 921 | ** KEYWORDS: {result code} {result codes} |
| 922 | ** |
| 923 | ** Many SQLite functions return an integer result code from the set shown |
| 924 | ** here in order to indicates success or failure. |
| 925 | ** |
| 926 | ** New error codes may be added in future versions of SQLite. |
| 927 | ** |
| 928 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 929 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -1058,17 +1058,14 @@ | |
| 1058 | ** that when data is appended to a file, the data is appended |
| 1059 | ** first then the size of the file is extended, never the other |
| 1060 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 1061 | ** information is written to disk in the same order as calls |
| 1062 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 1063 | ** after reboot following a crash or power loss, the value of |
| 1064 | ** each byte in a file is a value that was actually written |
| 1065 | ** into that byte at some point. In other words, a crash will |
| 1066 | ** not cause unwritten bytes of the file to change nor introduce |
| 1067 | ** randomness into a file nor zero out parts of the file, and any byte of |
| 1068 | ** a file that are never written will not change values due to |
| 1069 | ** writes to nearby bytes. |
| 1070 | */ |
| 1071 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 1072 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 1073 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 1074 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -1300,16 +1297,16 @@ | |
| 1300 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 1301 | ** that do require it. |
| 1302 | ** |
| 1303 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 1304 | ** retry counts and intervals for certain disk I/O operations for the |
| 1305 | ** windows [VFS] in order to work to provide robustness against |
| 1306 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 1307 | ** file write, and file delete operations up to 10 times, with a delay |
| 1308 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 1309 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 1310 | ** opcode allows those to values (10 retries and 25 milliseconds of delay) |
| 1311 | ** to be adjusted. The values are changed for all database connections |
| 1312 | ** within the same process. The argument is a pointer to an array of two |
| 1313 | ** integers where the first integer i the new retry count and the second |
| 1314 | ** integer is the delay. If either integer is negative, then the setting |
| 1315 | ** is not changed but instead the prior value of that setting is written |
| @@ -1420,11 +1417,11 @@ | |
| 1420 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 1421 | ** is either a NULL pointer or string obtained |
| 1422 | ** from xFullPathname() with an optional suffix added. |
| 1423 | ** ^If a suffix is added to the zFilename parameter, it will |
| 1424 | ** consist of a single "-" character followed by no more than |
| 1425 | ** 10 alphanumeric and/or "-" characters. |
| 1426 | ** ^SQLite further guarantees that |
| 1427 | ** the string will be valid and unchanged until xClose() is |
| 1428 | ** called. Because of the previous sentence, |
| 1429 | ** the [sqlite3_file] can safely store a pointer to the |
| 1430 | ** filename if it needs to remember the filename for some reason. |
| @@ -2571,11 +2568,11 @@ | |
| 2571 | ** These routines all implement some additional formatting |
| 2572 | ** options that are useful for constructing SQL statements. |
| 2573 | ** All of the usual printf() formatting options apply. In addition, there |
| 2574 | ** is are "%q", "%Q", and "%z" options. |
| 2575 | ** |
| 2576 | ** ^(The %q option works like %s in that it substitutes a null-terminated |
| 2577 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2578 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2579 | ** character it escapes that character and allows it to be inserted into |
| 2580 | ** the string. |
| 2581 | ** |
| @@ -4091,11 +4088,11 @@ | |
| 4091 | ** of the string. ^For clarity: the values returned by |
| 4092 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 4093 | ** bytes in the string, not the number of characters. |
| 4094 | ** |
| 4095 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 4096 | ** even empty strings, are always zero terminated. ^The return |
| 4097 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 4098 | ** |
| 4099 | ** ^The object returned by [sqlite3_column_value()] is an |
| 4100 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 4101 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -5171,11 +5168,11 @@ | |
| 5171 | SQLITE_API int sqlite3_release_memory(int); |
| 5172 | |
| 5173 | /* |
| 5174 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 5175 | ** |
| 5176 | ** ^The sqlite3_db_shrink(D) interface attempts to free as much heap |
| 5177 | ** memory as possible from database connection D. Unlike the |
| 5178 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 5179 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 5180 | ** omitted. |
| 5181 | ** |
| @@ -5954,19 +5951,19 @@ | |
| 5954 | ** is selected automatically at compile-time. ^(The following |
| 5955 | ** implementations are available in the SQLite core: |
| 5956 | ** |
| 5957 | ** <ul> |
| 5958 | ** <li> SQLITE_MUTEX_OS2 |
| 5959 | ** <li> SQLITE_MUTEX_PTHREAD |
| 5960 | ** <li> SQLITE_MUTEX_W32 |
| 5961 | ** <li> SQLITE_MUTEX_NOOP |
| 5962 | ** </ul>)^ |
| 5963 | ** |
| 5964 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5965 | ** that does no real locking and is appropriate for use in |
| 5966 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5967 | ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
| 5968 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5969 | ** |
| 5970 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5971 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5972 | ** implementation is included with the library. In this case the |
| @@ -6152,11 +6149,11 @@ | |
| 6152 | ** defined and if NDEBUG is not defined. |
| 6153 | ** |
| 6154 | ** ^These routines should return true if the mutex in their argument |
| 6155 | ** is held or not held, respectively, by the calling thread. |
| 6156 | ** |
| 6157 | ** ^The implementation is not required to provided versions of these |
| 6158 | ** routines that actually work. If the implementation does not provide working |
| 6159 | ** versions of these routines, it should at least provide stubs that always |
| 6160 | ** return true so that one does not get spurious assertion failures. |
| 6161 | ** |
| 6162 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6634,11 +6631,11 @@ | |
| 6634 | ** |
| 6635 | ** [[the xInit() page cache method]] |
| 6636 | ** ^(The xInit() method is called once for each effective |
| 6637 | ** call to [sqlite3_initialize()])^ |
| 6638 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6639 | ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ |
| 6640 | ** The intent of the xInit() method is to set up global data structures |
| 6641 | ** required by the custom page cache implementation. |
| 6642 | ** ^(If the xInit() method is NULL, then the |
| 6643 | ** built-in default page cache is used instead of the application defined |
| 6644 | ** page cache.)^ |
| @@ -6660,11 +6657,11 @@ | |
| 6660 | ** |
| 6661 | ** [[the xCreate() page cache methods]] |
| 6662 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6663 | ** SQLite will typically create one cache instance for each open database file, |
| 6664 | ** though this is not guaranteed. ^The |
| 6665 | ** parameter parameter, szPage, is the size in bytes of the pages that must |
| 6666 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6667 | ** second parameter szExtra is a number of bytes of extra storage |
| 6668 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6669 | ** a number less than 250. SQLite will use the |
| 6670 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6755,11 +6752,11 @@ | |
| 6755 | ** |
| 6756 | ** [[the xDestroy() page cache method]] |
| 6757 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6758 | ** All resources associated with the specified cache should be freed. ^After |
| 6759 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6760 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods |
| 6761 | ** functions. |
| 6762 | ** |
| 6763 | ** [[the xShrink() page cache method]] |
| 6764 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6765 | ** free up as much of heap memory as possible. The page cache implementation |
| @@ -9266,11 +9263,11 @@ | |
| 9266 | |
| 9267 | /* |
| 9268 | ** The default size of a disk sector |
| 9269 | */ |
| 9270 | #ifndef SQLITE_DEFAULT_SECTOR_SIZE |
| 9271 | # define SQLITE_DEFAULT_SECTOR_SIZE 512 |
| 9272 | #endif |
| 9273 | |
| 9274 | /* |
| 9275 | ** Temporary files are named starting with this prefix followed by 16 random |
| 9276 | ** alphanumeric characters, and no file extension. They are stored in the |
| @@ -13190,11 +13187,11 @@ | |
| 13190 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 13191 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 13192 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*); |
| 13193 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 13194 | SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p); |
| 13195 | #define MemReleaseExt(X) \ |
| 13196 | if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \ |
| 13197 | sqlite3VdbeMemReleaseExternal(X); |
| 13198 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 13199 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int); |
| 13200 | SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); |
| @@ -13229,11 +13226,11 @@ | |
| 13229 | # define sqlite3VdbeEnter(X) |
| 13230 | # define sqlite3VdbeLeave(X) |
| 13231 | #endif |
| 13232 | |
| 13233 | #ifdef SQLITE_DEBUG |
| 13234 | SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*); |
| 13235 | #endif |
| 13236 | |
| 13237 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 13238 | SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int); |
| 13239 | #else |
| @@ -14762,11 +14759,11 @@ | |
| 14762 | int flags, |
| 14763 | int *pFlagsOut |
| 14764 | ){ |
| 14765 | int rc; |
| 14766 | DO_OS_MALLOC_TEST(0); |
| 14767 | /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| 14768 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 14769 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 14770 | ** reaching the VFS. */ |
| 14771 | rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 14772 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| @@ -17316,11 +17313,11 @@ | |
| 17316 | SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){ |
| 17317 | return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p); |
| 17318 | } |
| 17319 | #endif |
| 17320 | |
| 17321 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17322 | |
| 17323 | /************** End of mutex.c ***********************************************/ |
| 17324 | /************** Begin file mutex_noop.c **************************************/ |
| 17325 | /* |
| 17326 | ** 2008 October 07 |
| @@ -17523,12 +17520,12 @@ | |
| 17523 | */ |
| 17524 | #ifdef SQLITE_MUTEX_NOOP |
| 17525 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ |
| 17526 | return sqlite3NoopMutex(); |
| 17527 | } |
| 17528 | #endif /* SQLITE_MUTEX_NOOP */ |
| 17529 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17530 | |
| 17531 | /************** End of mutex_noop.c ******************************************/ |
| 17532 | /************** Begin file mutex_os2.c ***************************************/ |
| 17533 | /* |
| 17534 | ** 2007 August 28 |
| @@ -18153,11 +18150,11 @@ | |
| 18153 | }; |
| 18154 | |
| 18155 | return &sMutex; |
| 18156 | } |
| 18157 | |
| 18158 | #endif /* SQLITE_MUTEX_PTHREAD */ |
| 18159 | |
| 18160 | /************** End of mutex_unix.c ******************************************/ |
| 18161 | /************** Begin file mutex_w32.c ***************************************/ |
| 18162 | /* |
| 18163 | ** 2007 August 14 |
| @@ -22116,26 +22113,31 @@ | |
| 22116 | ** characters of the original suffix. |
| 22117 | ** |
| 22118 | ** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always |
| 22119 | ** do the suffix shortening regardless of URI parameter. |
| 22120 | ** |
| 22121 | ** Examples: |
| 22122 | ** |
| 22123 | ** test.db-journal => test.nal |
| 22124 | ** test.db-wal => test.wal |
| 22125 | ** test.db-shm => test.shm |
| 22126 | ** test.db-mj7f3319fa => test.9fa |
| 22127 | */ |
| 22128 | SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){ |
| 22129 | #if SQLITE_ENABLE_8_3_NAMES<2 |
| 22130 | if( sqlite3_uri_boolean(zBaseFilename, "8_3_names") ) |
| 22131 | #endif |
| 22132 | { |
| 22133 | int i, sz; |
| 22134 | sz = sqlite3Strlen30(z); |
| 22135 | for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} |
| 22136 | if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4); |
| 22137 | } |
| 22138 | } |
| 22139 | #endif |
| 22140 | |
| 22141 | /************** End of util.c ************************************************/ |
| @@ -24836,13 +24838,10 @@ | |
| 24836 | #include <sys/time.h> |
| 24837 | #include <errno.h> |
| 24838 | #ifndef SQLITE_OMIT_WAL |
| 24839 | #include <sys/mman.h> |
| 24840 | #endif |
| 24841 | #ifndef MISSING_STATVFS |
| 24842 | #include <sys/statvfs.h> |
| 24843 | #endif |
| 24844 | |
| 24845 | |
| 24846 | #if SQLITE_ENABLE_LOCKING_STYLE |
| 24847 | # include <sys/ioctl.h> |
| 24848 | # if OS_VXWORKS |
| @@ -24929,11 +24928,10 @@ | |
| 24929 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24930 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24931 | int h; /* The file descriptor */ |
| 24932 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24933 | unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ |
| 24934 | unsigned char szSector; /* Sectorsize/512 */ |
| 24935 | int lastErrno; /* The unix errno from last I/O error */ |
| 24936 | void *lockingContext; /* Locking style specific state */ |
| 24937 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24938 | const char *zPath; /* Name of the file */ |
| 24939 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25342,18 +25340,10 @@ | |
| 25342 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25343 | |
| 25344 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25345 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25346 | |
| 25347 | #if defined(MISSING_STATVFS) |
| 25348 | { "statvfs", (sqlite3_syscall_ptr)0, 0 }, |
| 25349 | #define osStatvfs ((int(*)(const char*,void*))aSyscall[20].pCurrent) |
| 25350 | #else |
| 25351 | { "statvfs", (sqlite3_syscall_ptr)statvfs, 0 }, |
| 25352 | #define osStatvfs ((int(*)(const char*,struct statvfs*))aSyscall[20].pCurrent) |
| 25353 | #endif |
| 25354 | |
| 25355 | }; /* End of the overrideable system calls */ |
| 25356 | |
| 25357 | /* |
| 25358 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25359 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -28504,13 +28494,10 @@ | |
| 28504 | case SQLITE_SET_LOCKPROXYFILE: |
| 28505 | case SQLITE_GET_LOCKPROXYFILE: { |
| 28506 | return proxyFileControl(id,op,pArg); |
| 28507 | } |
| 28508 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 28509 | case SQLITE_FCNTL_SYNC_OMITTED: { |
| 28510 | return SQLITE_OK; /* A no-op */ |
| 28511 | } |
| 28512 | } |
| 28513 | return SQLITE_NOTFOUND; |
| 28514 | } |
| 28515 | |
| 28516 | /* |
| @@ -28522,27 +28509,12 @@ | |
| 28522 | ** if two files are created in the same file-system directory (i.e. |
| 28523 | ** a database and its journal file) that the sector size will be the |
| 28524 | ** same for both. |
| 28525 | */ |
| 28526 | static int unixSectorSize(sqlite3_file *pFile){ |
| 28527 | unixFile *p = (unixFile*)pFile; |
| 28528 | if( p->szSector==0 ){ |
| 28529 | #ifdef MISSING_STATVFS |
| 28530 | p->szSector = SQLITE_DEFAULT_SECTOR_SIZE/512; |
| 28531 | #else |
| 28532 | struct statvfs x; |
| 28533 | int sz; |
| 28534 | memset(&x, 0, sizeof(x)); |
| 28535 | osStatvfs(p->zPath, &x); |
| 28536 | sz = (int)x.f_frsize; |
| 28537 | if( sz<512 || sz>65536 || (sz&(sz-1))!=0 ){ |
| 28538 | sz = SQLITE_DEFAULT_SECTOR_SIZE; |
| 28539 | } |
| 28540 | p->szSector = sz/512; |
| 28541 | #endif |
| 28542 | } |
| 28543 | return p->szSector*512; |
| 28544 | } |
| 28545 | |
| 28546 | /* |
| 28547 | ** Return the device characteristics for the file. |
| 28548 | ** |
| @@ -28815,13 +28787,13 @@ | |
| 28815 | rc = SQLITE_IOERR_FSTAT; |
| 28816 | goto shm_open_err; |
| 28817 | } |
| 28818 | |
| 28819 | #ifdef SQLITE_SHM_DIRECTORY |
| 28820 | nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30; |
| 28821 | #else |
| 28822 | nShmFilename = 5 + (int)strlen(pDbFd->zPath); |
| 28823 | #endif |
| 28824 | pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename ); |
| 28825 | if( pShmNode==0 ){ |
| 28826 | rc = SQLITE_NOMEM; |
| 28827 | goto shm_open_err; |
| @@ -31755,11 +31727,11 @@ | |
| 31755 | }; |
| 31756 | unsigned int i; /* Loop counter */ |
| 31757 | |
| 31758 | /* Double-check that the aSyscall[] array has been constructed |
| 31759 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31760 | assert( ArraySize(aSyscall)==21 ); |
| 31761 | |
| 31762 | /* Register all VFSes defined in the aVfs[] array */ |
| 31763 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31764 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31765 | } |
| @@ -32049,11 +32021,10 @@ | |
| 32049 | HANDLE h; /* Handle for accessing the file */ |
| 32050 | u8 locktype; /* Type of lock currently held on this file */ |
| 32051 | short sharedLockByte; /* Randomly chosen byte used as a shared lock */ |
| 32052 | u8 ctrlFlags; /* Flags. See WINFILE_* below */ |
| 32053 | DWORD lastErrno; /* The Windows errno from the last I/O error */ |
| 32054 | DWORD sectorSize; /* Sector size of the device file is on */ |
| 32055 | winShm *pShm; /* Instance of shared memory on this file */ |
| 32056 | const char *zPath; /* Full pathname of this file */ |
| 32057 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32058 | #if SQLITE_OS_WINCE |
| 32059 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| @@ -32139,18 +32110,10 @@ | |
| 32139 | static void winMemShutdown(void *pAppData); |
| 32140 | |
| 32141 | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void); |
| 32142 | #endif /* SQLITE_WIN32_MALLOC */ |
| 32143 | |
| 32144 | /* |
| 32145 | ** Forward prototypes. |
| 32146 | */ |
| 32147 | static int getSectorSize( |
| 32148 | sqlite3_vfs *pVfs, |
| 32149 | const char *zRelative /* UTF-8 file name */ |
| 32150 | ); |
| 32151 | |
| 32152 | /* |
| 32153 | ** The following variable is (normally) set once and never changes |
| 32154 | ** thereafter. It records whether the operating system is Win9x |
| 32155 | ** or WinNT. |
| 32156 | ** |
| @@ -34181,13 +34144,10 @@ | |
| 34181 | } |
| 34182 | case SQLITE_FCNTL_VFSNAME: { |
| 34183 | *(char**)pArg = sqlite3_mprintf("win32"); |
| 34184 | return SQLITE_OK; |
| 34185 | } |
| 34186 | case SQLITE_FCNTL_SYNC_OMITTED: { |
| 34187 | return SQLITE_OK; |
| 34188 | } |
| 34189 | case SQLITE_FCNTL_WIN32_AV_RETRY: { |
| 34190 | int *a = (int*)pArg; |
| 34191 | if( a[0]>0 ){ |
| 34192 | win32IoerrRetry = a[0]; |
| 34193 | }else{ |
| @@ -34213,12 +34173,12 @@ | |
| 34213 | ** if two files are created in the same file-system directory (i.e. |
| 34214 | ** a database and its journal file) that the sector size will be the |
| 34215 | ** same for both. |
| 34216 | */ |
| 34217 | static int winSectorSize(sqlite3_file *id){ |
| 34218 | assert( id!=0 ); |
| 34219 | return (int)(((winFile*)id)->sectorSize); |
| 34220 | } |
| 34221 | |
| 34222 | /* |
| 34223 | ** Return a vector of device characteristics. |
| 34224 | */ |
| @@ -34463,11 +34423,11 @@ | |
| 34463 | */ |
| 34464 | p = sqlite3_malloc( sizeof(*p) ); |
| 34465 | if( p==0 ) return SQLITE_IOERR_NOMEM; |
| 34466 | memset(p, 0, sizeof(*p)); |
| 34467 | nName = sqlite3Strlen30(pDbFd->zPath); |
| 34468 | pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 15 ); |
| 34469 | if( pNew==0 ){ |
| 34470 | sqlite3_free(p); |
| 34471 | return SQLITE_IOERR_NOMEM; |
| 34472 | } |
| 34473 | memset(pNew, 0, sizeof(*pNew)); |
| @@ -35191,11 +35151,10 @@ | |
| 35191 | pFile->pShm = 0; |
| 35192 | pFile->zPath = zName; |
| 35193 | if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ |
| 35194 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 35195 | } |
| 35196 | pFile->sectorSize = getSectorSize(pVfs, zUtf8Name); |
| 35197 | |
| 35198 | #if SQLITE_OS_WINCE |
| 35199 | if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB |
| 35200 | && !winceCreateLock(zName, pFile) |
| 35201 | ){ |
| @@ -35436,85 +35395,10 @@ | |
| 35436 | return SQLITE_IOERR_NOMEM; |
| 35437 | } |
| 35438 | #endif |
| 35439 | } |
| 35440 | |
| 35441 | /* |
| 35442 | ** Get the sector size of the device used to store |
| 35443 | ** file. |
| 35444 | */ |
| 35445 | static int getSectorSize( |
| 35446 | sqlite3_vfs *pVfs, |
| 35447 | const char *zRelative /* UTF-8 file name */ |
| 35448 | ){ |
| 35449 | DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; |
| 35450 | /* GetDiskFreeSpace is not supported under WINCE */ |
| 35451 | #if SQLITE_OS_WINCE |
| 35452 | UNUSED_PARAMETER(pVfs); |
| 35453 | UNUSED_PARAMETER(zRelative); |
| 35454 | #else |
| 35455 | char zFullpath[MAX_PATH+1]; |
| 35456 | int rc; |
| 35457 | DWORD dwRet = 0; |
| 35458 | DWORD dwDummy; |
| 35459 | |
| 35460 | /* |
| 35461 | ** We need to get the full path name of the file |
| 35462 | ** to get the drive letter to look up the sector |
| 35463 | ** size. |
| 35464 | */ |
| 35465 | SimulateIOErrorBenign(1); |
| 35466 | sqlite3BeginBenignMalloc(); |
| 35467 | rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath); |
| 35468 | sqlite3EndBenignMalloc(); |
| 35469 | SimulateIOErrorBenign(0); |
| 35470 | if( rc == SQLITE_OK ) |
| 35471 | { |
| 35472 | void *zConverted; |
| 35473 | sqlite3BeginBenignMalloc(); |
| 35474 | zConverted = convertUtf8Filename(zFullpath); |
| 35475 | sqlite3EndBenignMalloc(); |
| 35476 | if( zConverted ){ |
| 35477 | if( isNT() ){ |
| 35478 | /* trim path to just drive reference */ |
| 35479 | LPWSTR p = zConverted; |
| 35480 | for(;*p;p++){ |
| 35481 | if( *p == '\\' ){ |
| 35482 | *p = '\0'; |
| 35483 | break; |
| 35484 | } |
| 35485 | } |
| 35486 | dwRet = osGetDiskFreeSpaceW((LPCWSTR)zConverted, |
| 35487 | &dwDummy, |
| 35488 | &bytesPerSector, |
| 35489 | &dwDummy, |
| 35490 | &dwDummy); |
| 35491 | }else{ |
| 35492 | /* trim path to just drive reference */ |
| 35493 | char *p = (char *)zConverted; |
| 35494 | for(;*p;p++){ |
| 35495 | if( *p == '\\' ){ |
| 35496 | *p = '\0'; |
| 35497 | break; |
| 35498 | } |
| 35499 | } |
| 35500 | dwRet = osGetDiskFreeSpaceA((char*)zConverted, |
| 35501 | &dwDummy, |
| 35502 | &bytesPerSector, |
| 35503 | &dwDummy, |
| 35504 | &dwDummy); |
| 35505 | } |
| 35506 | sqlite3_free(zConverted); |
| 35507 | } |
| 35508 | if( !dwRet ){ |
| 35509 | bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; |
| 35510 | } |
| 35511 | } |
| 35512 | #endif |
| 35513 | return (int) bytesPerSector; |
| 35514 | } |
| 35515 | |
| 35516 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 35517 | /* |
| 35518 | ** Interfaces for opening a shared library, finding entry points |
| 35519 | ** within the shared library, and closing the shared library. |
| 35520 | */ |
| @@ -36381,11 +36265,11 @@ | |
| 36381 | */ |
| 36382 | static int numberOfCachePages(PCache *p){ |
| 36383 | if( p->szCache>=0 ){ |
| 36384 | return p->szCache; |
| 36385 | }else{ |
| 36386 | return (-1024*p->szCache)/(p->szPage+p->szExtra); |
| 36387 | } |
| 36388 | } |
| 36389 | |
| 36390 | /* |
| 36391 | ** Try to obtain a page from the cache. |
| @@ -36845,14 +36729,14 @@ | |
| 36845 | ** PGroup which is the pcache1.grp global variable and its mutex is |
| 36846 | ** SQLITE_MUTEX_STATIC_LRU. |
| 36847 | */ |
| 36848 | struct PGroup { |
| 36849 | sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ |
| 36850 | int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 36851 | int nMinPage; /* Sum of nMin for purgeable caches */ |
| 36852 | int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 36853 | int nCurrentPage; /* Number of purgeable pages allocated */ |
| 36854 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 36855 | }; |
| 36856 | |
| 36857 | /* Each page cache is an instance of the following object. Every |
| 36858 | ** open database file (including each in-memory database and each |
| @@ -37511,11 +37395,11 @@ | |
| 37511 | static sqlite3_pcache_page *pcache1Fetch( |
| 37512 | sqlite3_pcache *p, |
| 37513 | unsigned int iKey, |
| 37514 | int createFlag |
| 37515 | ){ |
| 37516 | int nPinned; |
| 37517 | PCache1 *pCache = (PCache1 *)p; |
| 37518 | PGroup *pGroup; |
| 37519 | PgHdr1 *pPage = 0; |
| 37520 | |
| 37521 | assert( pCache->bPurgeable || createFlag!=1 ); |
| @@ -37546,17 +37430,17 @@ | |
| 37546 | #ifdef SQLITE_MUTEX_OMIT |
| 37547 | pGroup = pCache->pGroup; |
| 37548 | #endif |
| 37549 | |
| 37550 | /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ |
| 37551 | nPinned = pCache->nPage - pCache->nRecyclable; |
| 37552 | assert( nPinned>=0 ); |
| 37553 | assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage ); |
| 37554 | assert( pCache->n90pct == pCache->nMax*9/10 ); |
| 37555 | if( createFlag==1 && ( |
| 37556 | nPinned>=pGroup->mxPinned |
| 37557 | || nPinned>=(int)pCache->n90pct |
| 37558 | || pcache1UnderMemoryPressure(pCache) |
| 37559 | )){ |
| 37560 | goto fetch_out; |
| 37561 | } |
| 37562 | |
| @@ -37725,11 +37609,13 @@ | |
| 37725 | PCache1 *pCache = (PCache1 *)p; |
| 37726 | PGroup *pGroup = pCache->pGroup; |
| 37727 | assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); |
| 37728 | pcache1EnterMutex(pGroup); |
| 37729 | pcache1TruncateUnsafe(pCache, 0); |
| 37730 | pGroup->nMaxPage -= pCache->nMax; |
| 37731 | pGroup->nMinPage -= pCache->nMin; |
| 37732 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 37733 | pcache1EnforceMaxPage(pGroup); |
| 37734 | pcache1LeaveMutex(pGroup); |
| 37735 | sqlite3_free(pCache->apHash); |
| @@ -37807,12 +37693,12 @@ | |
| 37807 | int nRecyclable = 0; |
| 37808 | for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ |
| 37809 | nRecyclable++; |
| 37810 | } |
| 37811 | *pnCurrent = pcache1.grp.nCurrentPage; |
| 37812 | *pnMax = pcache1.grp.nMaxPage; |
| 37813 | *pnMin = pcache1.grp.nMinPage; |
| 37814 | *pnRecyclable = nRecyclable; |
| 37815 | } |
| 37816 | #endif |
| 37817 | |
| 37818 | /************** End of pcache1.c *********************************************/ |
| @@ -38282,10 +38168,16 @@ | |
| 38282 | |
| 38283 | #ifndef _WAL_H_ |
| 38284 | #define _WAL_H_ |
| 38285 | |
| 38286 | |
| 38287 | #ifdef SQLITE_OMIT_WAL |
| 38288 | # define sqlite3WalOpen(x,y,z) 0 |
| 38289 | # define sqlite3WalLimit(x,y) |
| 38290 | # define sqlite3WalClose(w,x,y,z) 0 |
| 38291 | # define sqlite3WalBeginReadTransaction(y,z) 0 |
| @@ -38350,16 +38242,10 @@ | |
| 38350 | SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData); |
| 38351 | |
| 38352 | /* Write a frame or frames to the log. */ |
| 38353 | SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int); |
| 38354 | |
| 38355 | /* Additional values that can be added to the sync_flags argument of |
| 38356 | ** sqlite3WalFrames(): |
| 38357 | */ |
| 38358 | #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| 38359 | #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */ |
| 38360 | |
| 38361 | /* Copy pages from the log to the database file */ |
| 38362 | SQLITE_PRIVATE int sqlite3WalCheckpoint( |
| 38363 | Wal *pWal, /* Write-ahead log connection */ |
| 38364 | int eMode, /* One of PASSIVE, FULL and RESTART */ |
| 38365 | int (*xBusy)(void*), /* Function to call when busy */ |
| @@ -42400,11 +42286,13 @@ | |
| 42400 | ** file size will be. |
| 42401 | */ |
| 42402 | assert( rc!=SQLITE_OK || isOpen(pPager->fd) ); |
| 42403 | if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){ |
| 42404 | sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize; |
| 42405 | sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile); |
| 42406 | pPager->dbHintSize = pPager->dbSize; |
| 42407 | } |
| 42408 | |
| 42409 | while( rc==SQLITE_OK && pList ){ |
| 42410 | Pgno pgno = pList->pgno; |
| @@ -42741,11 +42629,12 @@ | |
| 42741 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 42742 | while( *z ){ |
| 42743 | z += sqlite3Strlen30(z)+1; |
| 42744 | z += sqlite3Strlen30(z)+1; |
| 42745 | } |
| 42746 | nUri = &z[1] - zUri; |
| 42747 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 42748 | /* This branch is taken when the journal path required by |
| 42749 | ** the database being opened will be more than pVfs->mxPathname |
| 42750 | ** bytes in length. This means the database cannot be opened, |
| 42751 | ** as it will not be possible to open the journal file or even |
| @@ -42775,13 +42664,13 @@ | |
| 42775 | ROUND8(sizeof(*pPager)) + /* Pager structure */ |
| 42776 | ROUND8(pcacheSize) + /* PCache object */ |
| 42777 | ROUND8(pVfs->szOsFile) + /* The main db file */ |
| 42778 | journalFileSize * 2 + /* The two journal files */ |
| 42779 | nPathname + 1 + nUri + /* zFilename */ |
| 42780 | nPathname + 8 + 1 /* zJournal */ |
| 42781 | #ifndef SQLITE_OMIT_WAL |
| 42782 | + nPathname + 4 + 1 /* zWal */ |
| 42783 | #endif |
| 42784 | ); |
| 42785 | assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); |
| 42786 | if( !pPtr ){ |
| 42787 | sqlite3_free(zPathname); |
| @@ -42800,16 +42689,16 @@ | |
| 42800 | assert( nPathname>0 ); |
| 42801 | pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); |
| 42802 | memcpy(pPager->zFilename, zPathname, nPathname); |
| 42803 | memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); |
| 42804 | memcpy(pPager->zJournal, zPathname, nPathname); |
| 42805 | memcpy(&pPager->zJournal[nPathname], "-journal", 8); |
| 42806 | sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); |
| 42807 | #ifndef SQLITE_OMIT_WAL |
| 42808 | pPager->zWal = &pPager->zJournal[nPathname+8+1]; |
| 42809 | memcpy(pPager->zWal, zPathname, nPathname); |
| 42810 | memcpy(&pPager->zWal[nPathname], "-wal", 4); |
| 42811 | sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); |
| 42812 | #endif |
| 42813 | sqlite3_free(zPathname); |
| 42814 | } |
| 42815 | pPager->pVfs = pVfs; |
| @@ -44064,11 +43953,14 @@ | |
| 44064 | if( !pPager->noSync ){ |
| 44065 | assert( !MEMDB ); |
| 44066 | rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); |
| 44067 | }else if( isOpen(pPager->fd) ){ |
| 44068 | assert( !MEMDB ); |
| 44069 | sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc); |
| 44070 | } |
| 44071 | return rc; |
| 44072 | } |
| 44073 | |
| 44074 | /* |
| @@ -48125,11 +48017,11 @@ | |
| 48125 | iFrame = pWal->hdr.mxFrame; |
| 48126 | for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){ |
| 48127 | iFrame++; |
| 48128 | rc = walIndexAppend(pWal, iFrame, p->pgno); |
| 48129 | } |
| 48130 | while( nExtra>0 && rc==SQLITE_OK ){ |
| 48131 | iFrame++; |
| 48132 | nExtra--; |
| 48133 | rc = walIndexAppend(pWal, iFrame, pLast->pgno); |
| 48134 | } |
| 48135 | |
| @@ -48726,11 +48618,11 @@ | |
| 48726 | #define TRANS_WRITE 2 |
| 48727 | |
| 48728 | /* |
| 48729 | ** An instance of this object represents a single database file. |
| 48730 | ** |
| 48731 | ** A single database file can be in use as the same time by two |
| 48732 | ** or more database connections. When two or more connections are |
| 48733 | ** sharing the same database file, each connection has it own |
| 48734 | ** private Btree object for the file and each of those Btrees points |
| 48735 | ** to this one BtShared object. BtShared.nRef is the number of |
| 48736 | ** connections currently sharing this database file. |
| @@ -48832,11 +48724,11 @@ | |
| 48832 | ** b-tree within a database file. |
| 48833 | ** |
| 48834 | ** The entry is identified by its MemPage and the index in |
| 48835 | ** MemPage.aCell[] of the entry. |
| 48836 | ** |
| 48837 | ** A single database file can shared by two more database connections, |
| 48838 | ** but cursors cannot be shared. Each cursor is associated with a |
| 48839 | ** particular database connection identified BtCursor.pBtree.db. |
| 48840 | ** |
| 48841 | ** Fields in this structure are accessed under the BtShared.mutex |
| 48842 | ** found at self->pBt->mutex. |
| @@ -48993,11 +48885,11 @@ | |
| 48993 | int mallocFailed; /* A memory allocation error has occurred */ |
| 48994 | StrAccum errMsg; /* Accumulate the error message text here */ |
| 48995 | }; |
| 48996 | |
| 48997 | /* |
| 48998 | ** Read or write a two- and four-byte big-endian integer values. |
| 48999 | */ |
| 49000 | #define get2byte(x) ((x)[0]<<8 | (x)[1]) |
| 49001 | #define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) |
| 49002 | #define get4byte sqlite3Get4byte |
| 49003 | #define put4byte sqlite3Put4byte |
| @@ -55478,12 +55370,18 @@ | |
| 55478 | } |
| 55479 | |
| 55480 | /* Either we found one or more cells (cntnew[0])>0) or pPage is |
| 55481 | ** a virtual root page. A virtual root page is when the real root |
| 55482 | ** page is page 1 and we are the only child of that page. |
| 55483 | */ |
| 55484 | assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) ); |
| 55485 | |
| 55486 | TRACE(("BALANCE: old: %d %d %d ", |
| 55487 | apOld[0]->pgno, |
| 55488 | nOld>=2 ? apOld[1]->pgno : 0, |
| 55489 | nOld>=3 ? apOld[2]->pgno : 0 |
| @@ -58194,11 +58092,13 @@ | |
| 58194 | |
| 58195 | assert( sqlite3BtreeIsInTrans(pTo) ); |
| 58196 | pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); |
| 58197 | if( pFd->pMethods ){ |
| 58198 | i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); |
| 58199 | sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); |
| 58200 | } |
| 58201 | |
| 58202 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 58203 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 58204 | ** and sqlite3_backup_finish() to detect that they are being called |
| @@ -58525,11 +58425,11 @@ | |
| 58525 | ** Release any memory held by the Mem. This may leave the Mem in an |
| 58526 | ** inconsistent state, for example with (Mem.z==0) and |
| 58527 | ** (Mem.type==SQLITE_TEXT). |
| 58528 | */ |
| 58529 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){ |
| 58530 | MemReleaseExt(p); |
| 58531 | sqlite3DbFree(p->db, p->zMalloc); |
| 58532 | p->z = 0; |
| 58533 | p->zMalloc = 0; |
| 58534 | p->xDel = 0; |
| 58535 | } |
| @@ -58821,11 +58721,11 @@ | |
| 58821 | ** copies of this cell as invalid. |
| 58822 | ** |
| 58823 | ** This is used for testing and debugging only - to make sure shallow |
| 58824 | ** copies are not misused. |
| 58825 | */ |
| 58826 | SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe *pVdbe, Mem *pMem){ |
| 58827 | int i; |
| 58828 | Mem *pX; |
| 58829 | for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){ |
| 58830 | if( pX->pScopyFrom==pMem ){ |
| 58831 | pX->flags |= MEM_Invalid; |
| @@ -58847,11 +58747,11 @@ | |
| 58847 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| 58848 | ** and flags gets srcType (either MEM_Ephem or MEM_Static). |
| 58849 | */ |
| 58850 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ |
| 58851 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58852 | MemReleaseExt(pTo); |
| 58853 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58854 | pTo->xDel = 0; |
| 58855 | if( (pFrom->flags&MEM_Static)==0 ){ |
| 58856 | pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem); |
| 58857 | assert( srcType==MEM_Ephem || srcType==MEM_Static ); |
| @@ -58865,11 +58765,11 @@ | |
| 58865 | */ |
| 58866 | SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){ |
| 58867 | int rc = SQLITE_OK; |
| 58868 | |
| 58869 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58870 | MemReleaseExt(pTo); |
| 58871 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58872 | pTo->flags &= ~MEM_Dyn; |
| 58873 | |
| 58874 | if( pTo->flags&(MEM_Str|MEM_Blob) ){ |
| 58875 | if( 0==(pFrom->flags&MEM_Static) ){ |
| @@ -59202,11 +59102,11 @@ | |
| 59202 | assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 ); |
| 59203 | if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){ |
| 59204 | return 0; |
| 59205 | } |
| 59206 | } |
| 59207 | sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */ |
| 59208 | }else{ |
| 59209 | assert( (pVal->flags&MEM_Blob)==0 ); |
| 59210 | sqlite3VdbeMemStringify(pVal, enc); |
| 59211 | assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); |
| 59212 | } |
| @@ -59583,11 +59483,12 @@ | |
| 59583 | return addr; |
| 59584 | } |
| 59585 | |
| 59586 | /* |
| 59587 | ** Add an OP_ParseSchema opcode. This routine is broken out from |
| 59588 | ** sqlite3VdbeAddOp4() since it needs to also local all btrees. |
| 59589 | ** |
| 59590 | ** The zWhere string must have been obtained from sqlite3_malloc(). |
| 59591 | ** This routine will take ownership of the allocated memory. |
| 59592 | */ |
| 59593 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ |
| @@ -60350,12 +60251,13 @@ | |
| 60350 | |
| 60351 | /* |
| 60352 | ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. |
| 60353 | ** |
| 60354 | ** The prepared statements need to know in advance the complete set of |
| 60355 | ** attached databases that they will be using. A mask of these databases |
| 60356 | ** is maintained in p->btreeMask and is used for locking and other purposes. |
| 60357 | */ |
| 60358 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){ |
| 60359 | assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 ); |
| 60360 | assert( i<(int)sizeof(p->btreeMask)*8 ); |
| 60361 | p->btreeMask |= ((yDbMask)1)<<i; |
| @@ -60874,10 +60776,11 @@ | |
| 60874 | nVar = pParse->nVar; |
| 60875 | nMem = pParse->nMem; |
| 60876 | nCursor = pParse->nTab; |
| 60877 | nArg = pParse->nMaxArg; |
| 60878 | nOnce = pParse->nOnce; |
| 60879 | |
| 60880 | /* For each cursor required, also allocate a memory cell. Memory |
| 60881 | ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by |
| 60882 | ** the vdbe program. Instead they are used to allocate space for |
| 60883 | ** VdbeCursor/BtCursor structures. The blob of memory associated with |
| @@ -61225,11 +61128,11 @@ | |
| 61225 | int retryCount = 0; |
| 61226 | int nMainFile; |
| 61227 | |
| 61228 | /* Select a master journal file name */ |
| 61229 | nMainFile = sqlite3Strlen30(zMainFile); |
| 61230 | zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XX", zMainFile); |
| 61231 | if( zMaster==0 ) return SQLITE_NOMEM; |
| 61232 | do { |
| 61233 | u32 iRandom; |
| 61234 | if( retryCount ){ |
| 61235 | if( retryCount>100 ){ |
| @@ -63013,11 +62916,11 @@ | |
| 63013 | ** since any application that receives an SQLITE_MISUSE is broken by |
| 63014 | ** definition. |
| 63015 | ** |
| 63016 | ** Nevertheless, some published applications that were originally written |
| 63017 | ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE |
| 63018 | ** returns, and the so were broken by the automatic-reset change. As a |
| 63019 | ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the |
| 63020 | ** legacy behavior of returning SQLITE_MISUSE for cases where the |
| 63021 | ** previous sqlite3_step() returned something other than a SQLITE_LOCKED |
| 63022 | ** or SQLITE_BUSY error. |
| 63023 | */ |
| @@ -63359,17 +63262,17 @@ | |
| 63359 | pOut = &pVm->pResultSet[i]; |
| 63360 | }else{ |
| 63361 | /* If the value passed as the second argument is out of range, return |
| 63362 | ** a pointer to the following static Mem object which contains the |
| 63363 | ** value SQL NULL. Even though the Mem structure contains an element |
| 63364 | ** of type i64, on certain architecture (x86) with certain compiler |
| 63365 | ** switches (-Os), gcc may align this Mem object on a 4-byte boundary |
| 63366 | ** instead of an 8-byte one. This all works fine, except that when |
| 63367 | ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s |
| 63368 | ** that a Mem structure is located on an 8-byte boundary. To prevent |
| 63369 | ** this assert() from failing, when building with SQLITE_DEBUG defined |
| 63370 | ** using gcc, force nullMem to be 8-byte aligned using the magical |
| 63371 | ** __attribute__((aligned(8))) macro. */ |
| 63372 | static const Mem nullMem |
| 63373 | #if defined(SQLITE_DEBUG) && defined(__GNUC__) |
| 63374 | __attribute__((aligned(8))) |
| 63375 | #endif |
| @@ -64298,11 +64201,11 @@ | |
| 64298 | ** Invoke this macro on memory cells just prior to changing the |
| 64299 | ** value of the cell. This macro verifies that shallow copies are |
| 64300 | ** not misused. |
| 64301 | */ |
| 64302 | #ifdef SQLITE_DEBUG |
| 64303 | # define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) |
| 64304 | #else |
| 64305 | # define memAboutToChange(P,M) |
| 64306 | #endif |
| 64307 | |
| 64308 | /* |
| @@ -64316,12 +64219,12 @@ | |
| 64316 | SQLITE_API int sqlite3_search_count = 0; |
| 64317 | #endif |
| 64318 | |
| 64319 | /* |
| 64320 | ** When this global variable is positive, it gets decremented once before |
| 64321 | ** each instruction in the VDBE. When reaches zero, the u1.isInterrupted |
| 64322 | ** field of the sqlite3 structure is set in order to simulate and interrupt. |
| 64323 | ** |
| 64324 | ** This facility is used for testing purposes only. It does not function |
| 64325 | ** in an ordinary build. |
| 64326 | */ |
| 64327 | #ifdef SQLITE_TEST |
| @@ -64442,11 +64345,11 @@ | |
| 64442 | */ |
| 64443 | static VdbeCursor *allocateCursor( |
| 64444 | Vdbe *p, /* The virtual machine */ |
| 64445 | int iCur, /* Index of the new VdbeCursor */ |
| 64446 | int nField, /* Number of fields in the table or index */ |
| 64447 | int iDb, /* When database the cursor belongs to, or -1 */ |
| 64448 | int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ |
| 64449 | ){ |
| 64450 | /* Find the memory cell that will be used to store the blob of memory |
| 64451 | ** required for this VdbeCursor structure. It is convenient to use a |
| 64452 | ** vdbe memory cell to manage the memory allocation required for a |
| @@ -64813,11 +64716,11 @@ | |
| 64813 | ** sqlite3_interrupt() routine has been called. If it has been, then |
| 64814 | ** processing of the VDBE program is interrupted. |
| 64815 | ** |
| 64816 | ** This macro added to every instruction that does a jump in order to |
| 64817 | ** implement a loop. This test used to be on every single instruction, |
| 64818 | ** but that meant we more testing that we needed. By only testing the |
| 64819 | ** flag on jump instructions, we get a (small) speed improvement. |
| 64820 | */ |
| 64821 | #define CHECK_FOR_INTERRUPT \ |
| 64822 | if( db->u1.isInterrupted ) goto abort_due_to_interrupt; |
| 64823 | |
| @@ -65430,11 +65333,11 @@ | |
| 65430 | if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){ |
| 65431 | assert( pOp->p2>0 ); |
| 65432 | assert( pOp->p2<=p->nMem ); |
| 65433 | pOut = &aMem[pOp->p2]; |
| 65434 | memAboutToChange(p, pOut); |
| 65435 | MemReleaseExt(pOut); |
| 65436 | pOut->flags = MEM_Int; |
| 65437 | } |
| 65438 | |
| 65439 | /* Sanity checking on other operands */ |
| 65440 | #ifdef SQLITE_DEBUG |
| @@ -65738,11 +65641,11 @@ | |
| 65738 | assert( pOp->p3<=p->nMem ); |
| 65739 | pOut->flags = MEM_Null; |
| 65740 | while( u.ab.cnt>0 ){ |
| 65741 | pOut++; |
| 65742 | memAboutToChange(p, pOut); |
| 65743 | MemReleaseExt(pOut); |
| 65744 | pOut->flags = MEM_Null; |
| 65745 | u.ab.cnt--; |
| 65746 | } |
| 65747 | break; |
| 65748 | } |
| @@ -65919,11 +65822,11 @@ | |
| 65919 | /* Invalidate all ephemeral cursor row caches */ |
| 65920 | p->cacheCtr = (p->cacheCtr + 2)|1; |
| 65921 | |
| 65922 | /* Make sure the results of the current row are \000 terminated |
| 65923 | ** and have an assigned type. The results are de-ephemeralized as |
| 65924 | ** as side effect. |
| 65925 | */ |
| 65926 | u.ae.pMem = p->pResultSet = &aMem[pOp->p1]; |
| 65927 | for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){ |
| 65928 | assert( memIsValid(&u.ae.pMem[u.ae.i]) ); |
| 65929 | Deephemeralize(&u.ae.pMem[u.ae.i]); |
| @@ -67160,11 +67063,11 @@ | |
| 67160 | ** a pointer to a Mem object. |
| 67161 | */ |
| 67162 | if( u.an.aOffset[u.an.p2] ){ |
| 67163 | assert( rc==SQLITE_OK ); |
| 67164 | if( u.an.zRec ){ |
| 67165 | MemReleaseExt(u.an.pDest); |
| 67166 | sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest); |
| 67167 | }else{ |
| 67168 | u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]); |
| 67169 | sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest); |
| 67170 | rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem); |
| @@ -83758,11 +83661,11 @@ | |
| 83758 | ** Allocate the index structure. |
| 83759 | */ |
| 83760 | nName = sqlite3Strlen30(zName); |
| 83761 | nCol = pList->nExpr; |
| 83762 | pIndex = sqlite3DbMallocZero(db, |
| 83763 | sizeof(Index) + /* Index structure */ |
| 83764 | ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */ |
| 83765 | sizeof(char *)*nCol + /* Index.azColl */ |
| 83766 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 83767 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 83768 | nName + 1 + /* Index.zName */ |
| @@ -83769,11 +83672,12 @@ | |
| 83769 | nExtra /* Collation sequence names */ |
| 83770 | ); |
| 83771 | if( db->mallocFailed ){ |
| 83772 | goto exit_create_index; |
| 83773 | } |
| 83774 | pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]); |
| 83775 | pIndex->azColl = (char**) |
| 83776 | ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1)); |
| 83777 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) ); |
| 83778 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); |
| 83779 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| @@ -89966,11 +89870,11 @@ | |
| 89966 | ** any ABORT Back out changes from the current command |
| 89967 | ** only (do not do a complete rollback) then |
| 89968 | ** cause sqlite3_exec() to return immediately |
| 89969 | ** with SQLITE_CONSTRAINT. |
| 89970 | ** |
| 89971 | ** any FAIL Sqlite_exec() returns immediately with a |
| 89972 | ** return code of SQLITE_CONSTRAINT. The |
| 89973 | ** transaction is not rolled back and any |
| 89974 | ** prior changes are retained. |
| 89975 | ** |
| 89976 | ** any IGNORE The record number and data is popped from |
| @@ -111450,11 +111354,11 @@ | |
| 111450 | *tokenType = TK_SPACE; |
| 111451 | return i; |
| 111452 | } |
| 111453 | case '-': { |
| 111454 | if( z[1]=='-' ){ |
| 111455 | /* IMP: R-15891-05542 -- syntax diagram for comments */ |
| 111456 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 111457 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111458 | return i; |
| 111459 | } |
| 111460 | *tokenType = TK_MINUS; |
| @@ -111483,11 +111387,11 @@ | |
| 111483 | case '/': { |
| 111484 | if( z[1]!='*' || z[2]==0 ){ |
| 111485 | *tokenType = TK_SLASH; |
| 111486 | return 1; |
| 111487 | } |
| 111488 | /* IMP: R-15891-05542 -- syntax diagram for comments */ |
| 111489 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 111490 | if( c ) i++; |
| 111491 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111492 | return i; |
| 111493 | } |
| @@ -112277,12 +112181,12 @@ | |
| 112277 | /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function |
| 112278 | ** returns an integer equal to SQLITE_VERSION_NUMBER. |
| 112279 | */ |
| 112280 | SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } |
| 112281 | |
| 112282 | /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns |
| 112283 | ** zero if and only if SQLite was compiled mutexing code omitted due to |
| 112284 | ** the SQLITE_THREADSAFE compile-time option being set to 0. |
| 112285 | */ |
| 112286 | SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } |
| 112287 | |
| 112288 | #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) |
| @@ -112768,19 +112672,21 @@ | |
| 112768 | ** Free up as much memory as we can from the given database |
| 112769 | ** connection. |
| 112770 | */ |
| 112771 | SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){ |
| 112772 | int i; |
| 112773 | sqlite3BtreeEnterAll(db); |
| 112774 | for(i=0; i<db->nDb; i++){ |
| 112775 | Btree *pBt = db->aDb[i].pBt; |
| 112776 | if( pBt ){ |
| 112777 | Pager *pPager = sqlite3BtreePager(pBt); |
| 112778 | sqlite3PagerShrink(pPager); |
| 112779 | } |
| 112780 | } |
| 112781 | sqlite3BtreeLeaveAll(db); |
| 112782 | return SQLITE_OK; |
| 112783 | } |
| 112784 | |
| 112785 | /* |
| 112786 | ** Configuration settings for an individual database connection |
| 112787 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -657,11 +657,11 @@ | |
| 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | */ |
| 660 | #define SQLITE_VERSION "3.7.10" |
| 661 | #define SQLITE_VERSION_NUMBER 3007010 |
| 662 | #define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983" |
| 663 | |
| 664 | /* |
| 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | ** |
| @@ -725,11 +725,11 @@ | |
| 725 | |
| 726 | /* |
| 727 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 728 | ** |
| 729 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 730 | ** SQLite was compiled with mutexing code omitted due to the |
| 731 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 732 | ** |
| 733 | ** SQLite can be compiled with or without mutexes. When |
| 734 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 735 | ** are enabled and SQLite is threadsafe. When the |
| @@ -919,11 +919,11 @@ | |
| 919 | ** CAPI3REF: Result Codes |
| 920 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 921 | ** KEYWORDS: {result code} {result codes} |
| 922 | ** |
| 923 | ** Many SQLite functions return an integer result code from the set shown |
| 924 | ** here in order to indicate success or failure. |
| 925 | ** |
| 926 | ** New error codes may be added in future versions of SQLite. |
| 927 | ** |
| 928 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 929 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -1058,17 +1058,14 @@ | |
| 1058 | ** that when data is appended to a file, the data is appended |
| 1059 | ** first then the size of the file is extended, never the other |
| 1060 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 1061 | ** information is written to disk in the same order as calls |
| 1062 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 1063 | ** after reboot following a crash or power loss, the only bytes in a |
| 1064 | ** file that were written at the application level might have changed |
| 1065 | ** and that adjacent bytes, even bytes within the same sector are |
| 1066 | ** guaranteed to be unchanged. |
| 1067 | */ |
| 1068 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 1069 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 1070 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 1071 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -1300,16 +1297,16 @@ | |
| 1297 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 1298 | ** that do require it. |
| 1299 | ** |
| 1300 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 1301 | ** retry counts and intervals for certain disk I/O operations for the |
| 1302 | ** windows [VFS] in order to provide robustness in the presence of |
| 1303 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 1304 | ** file write, and file delete operations up to 10 times, with a delay |
| 1305 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 1306 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 1307 | ** opcode allows these two values (10 retries and 25 milliseconds of delay) |
| 1308 | ** to be adjusted. The values are changed for all database connections |
| 1309 | ** within the same process. The argument is a pointer to an array of two |
| 1310 | ** integers where the first integer i the new retry count and the second |
| 1311 | ** integer is the delay. If either integer is negative, then the setting |
| 1312 | ** is not changed but instead the prior value of that setting is written |
| @@ -1420,11 +1417,11 @@ | |
| 1417 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 1418 | ** is either a NULL pointer or string obtained |
| 1419 | ** from xFullPathname() with an optional suffix added. |
| 1420 | ** ^If a suffix is added to the zFilename parameter, it will |
| 1421 | ** consist of a single "-" character followed by no more than |
| 1422 | ** 11 alphanumeric and/or "-" characters. |
| 1423 | ** ^SQLite further guarantees that |
| 1424 | ** the string will be valid and unchanged until xClose() is |
| 1425 | ** called. Because of the previous sentence, |
| 1426 | ** the [sqlite3_file] can safely store a pointer to the |
| 1427 | ** filename if it needs to remember the filename for some reason. |
| @@ -2571,11 +2568,11 @@ | |
| 2568 | ** These routines all implement some additional formatting |
| 2569 | ** options that are useful for constructing SQL statements. |
| 2570 | ** All of the usual printf() formatting options apply. In addition, there |
| 2571 | ** is are "%q", "%Q", and "%z" options. |
| 2572 | ** |
| 2573 | ** ^(The %q option works like %s in that it substitutes a nul-terminated |
| 2574 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2575 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2576 | ** character it escapes that character and allows it to be inserted into |
| 2577 | ** the string. |
| 2578 | ** |
| @@ -4091,11 +4088,11 @@ | |
| 4088 | ** of the string. ^For clarity: the values returned by |
| 4089 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 4090 | ** bytes in the string, not the number of characters. |
| 4091 | ** |
| 4092 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 4093 | ** even empty strings, are always zero-terminated. ^The return |
| 4094 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 4095 | ** |
| 4096 | ** ^The object returned by [sqlite3_column_value()] is an |
| 4097 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 4098 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -5171,11 +5168,11 @@ | |
| 5168 | SQLITE_API int sqlite3_release_memory(int); |
| 5169 | |
| 5170 | /* |
| 5171 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 5172 | ** |
| 5173 | ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap |
| 5174 | ** memory as possible from database connection D. Unlike the |
| 5175 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 5176 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 5177 | ** omitted. |
| 5178 | ** |
| @@ -5954,19 +5951,19 @@ | |
| 5951 | ** is selected automatically at compile-time. ^(The following |
| 5952 | ** implementations are available in the SQLite core: |
| 5953 | ** |
| 5954 | ** <ul> |
| 5955 | ** <li> SQLITE_MUTEX_OS2 |
| 5956 | ** <li> SQLITE_MUTEX_PTHREADS |
| 5957 | ** <li> SQLITE_MUTEX_W32 |
| 5958 | ** <li> SQLITE_MUTEX_NOOP |
| 5959 | ** </ul>)^ |
| 5960 | ** |
| 5961 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5962 | ** that does no real locking and is appropriate for use in |
| 5963 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5964 | ** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations |
| 5965 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5966 | ** |
| 5967 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5968 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5969 | ** implementation is included with the library. In this case the |
| @@ -6152,11 +6149,11 @@ | |
| 6149 | ** defined and if NDEBUG is not defined. |
| 6150 | ** |
| 6151 | ** ^These routines should return true if the mutex in their argument |
| 6152 | ** is held or not held, respectively, by the calling thread. |
| 6153 | ** |
| 6154 | ** ^The implementation is not required to provide versions of these |
| 6155 | ** routines that actually work. If the implementation does not provide working |
| 6156 | ** versions of these routines, it should at least provide stubs that always |
| 6157 | ** return true so that one does not get spurious assertion failures. |
| 6158 | ** |
| 6159 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6634,11 +6631,11 @@ | |
| 6631 | ** |
| 6632 | ** [[the xInit() page cache method]] |
| 6633 | ** ^(The xInit() method is called once for each effective |
| 6634 | ** call to [sqlite3_initialize()])^ |
| 6635 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6636 | ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ |
| 6637 | ** The intent of the xInit() method is to set up global data structures |
| 6638 | ** required by the custom page cache implementation. |
| 6639 | ** ^(If the xInit() method is NULL, then the |
| 6640 | ** built-in default page cache is used instead of the application defined |
| 6641 | ** page cache.)^ |
| @@ -6660,11 +6657,11 @@ | |
| 6657 | ** |
| 6658 | ** [[the xCreate() page cache methods]] |
| 6659 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6660 | ** SQLite will typically create one cache instance for each open database file, |
| 6661 | ** though this is not guaranteed. ^The |
| 6662 | ** first parameter, szPage, is the size in bytes of the pages that must |
| 6663 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6664 | ** second parameter szExtra is a number of bytes of extra storage |
| 6665 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6666 | ** a number less than 250. SQLite will use the |
| 6667 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6755,11 +6752,11 @@ | |
| 6752 | ** |
| 6753 | ** [[the xDestroy() page cache method]] |
| 6754 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6755 | ** All resources associated with the specified cache should be freed. ^After |
| 6756 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6757 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods2 |
| 6758 | ** functions. |
| 6759 | ** |
| 6760 | ** [[the xShrink() page cache method]] |
| 6761 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6762 | ** free up as much of heap memory as possible. The page cache implementation |
| @@ -9266,11 +9263,11 @@ | |
| 9263 | |
| 9264 | /* |
| 9265 | ** The default size of a disk sector |
| 9266 | */ |
| 9267 | #ifndef SQLITE_DEFAULT_SECTOR_SIZE |
| 9268 | # define SQLITE_DEFAULT_SECTOR_SIZE 4096 |
| 9269 | #endif |
| 9270 | |
| 9271 | /* |
| 9272 | ** Temporary files are named starting with this prefix followed by 16 random |
| 9273 | ** alphanumeric characters, and no file extension. They are stored in the |
| @@ -13190,11 +13187,11 @@ | |
| 13187 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 13188 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 13189 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*); |
| 13190 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 13191 | SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p); |
| 13192 | #define VdbeMemRelease(X) \ |
| 13193 | if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \ |
| 13194 | sqlite3VdbeMemReleaseExternal(X); |
| 13195 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 13196 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int); |
| 13197 | SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); |
| @@ -13229,11 +13226,11 @@ | |
| 13226 | # define sqlite3VdbeEnter(X) |
| 13227 | # define sqlite3VdbeLeave(X) |
| 13228 | #endif |
| 13229 | |
| 13230 | #ifdef SQLITE_DEBUG |
| 13231 | SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*); |
| 13232 | #endif |
| 13233 | |
| 13234 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 13235 | SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int); |
| 13236 | #else |
| @@ -14762,11 +14759,11 @@ | |
| 14759 | int flags, |
| 14760 | int *pFlagsOut |
| 14761 | ){ |
| 14762 | int rc; |
| 14763 | DO_OS_MALLOC_TEST(0); |
| 14764 | /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| 14765 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 14766 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 14767 | ** reaching the VFS. */ |
| 14768 | rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 14769 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| @@ -17316,11 +17313,11 @@ | |
| 17313 | SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){ |
| 17314 | return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p); |
| 17315 | } |
| 17316 | #endif |
| 17317 | |
| 17318 | #endif /* !defined(SQLITE_MUTEX_OMIT) */ |
| 17319 | |
| 17320 | /************** End of mutex.c ***********************************************/ |
| 17321 | /************** Begin file mutex_noop.c **************************************/ |
| 17322 | /* |
| 17323 | ** 2008 October 07 |
| @@ -17523,12 +17520,12 @@ | |
| 17520 | */ |
| 17521 | #ifdef SQLITE_MUTEX_NOOP |
| 17522 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ |
| 17523 | return sqlite3NoopMutex(); |
| 17524 | } |
| 17525 | #endif /* defined(SQLITE_MUTEX_NOOP) */ |
| 17526 | #endif /* !defined(SQLITE_MUTEX_OMIT) */ |
| 17527 | |
| 17528 | /************** End of mutex_noop.c ******************************************/ |
| 17529 | /************** Begin file mutex_os2.c ***************************************/ |
| 17530 | /* |
| 17531 | ** 2007 August 28 |
| @@ -18153,11 +18150,11 @@ | |
| 18150 | }; |
| 18151 | |
| 18152 | return &sMutex; |
| 18153 | } |
| 18154 | |
| 18155 | #endif /* SQLITE_MUTEX_PTHREADS */ |
| 18156 | |
| 18157 | /************** End of mutex_unix.c ******************************************/ |
| 18158 | /************** Begin file mutex_w32.c ***************************************/ |
| 18159 | /* |
| 18160 | ** 2007 August 14 |
| @@ -22116,26 +22113,31 @@ | |
| 22113 | ** characters of the original suffix. |
| 22114 | ** |
| 22115 | ** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always |
| 22116 | ** do the suffix shortening regardless of URI parameter. |
| 22117 | ** |
| 22118 | ** Assume that zBaseFilename contains two \000 terminator bytes (so that |
| 22119 | ** it can be harmlessly passed into sqlite3_uri_parameter()) and copy both |
| 22120 | ** zero terminator bytes into the end of the revised name. |
| 22121 | ** |
| 22122 | ** Examples: |
| 22123 | ** |
| 22124 | ** test.db-journal => test.nal |
| 22125 | ** test.db-wal => test.wal |
| 22126 | ** test.db-shm => test.shm |
| 22127 | ** test.db-mj7f3319fa => test.9fa |
| 22128 | */ |
| 22129 | SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){ |
| 22130 | assert( zBaseFilename[strlen(zBaseFilename)+1]==0 ); |
| 22131 | #if SQLITE_ENABLE_8_3_NAMES<2 |
| 22132 | if( sqlite3_uri_boolean(zBaseFilename, "8_3_names", 0) ) |
| 22133 | #endif |
| 22134 | { |
| 22135 | int i, sz; |
| 22136 | sz = sqlite3Strlen30(z); |
| 22137 | for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} |
| 22138 | if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 5); |
| 22139 | } |
| 22140 | } |
| 22141 | #endif |
| 22142 | |
| 22143 | /************** End of util.c ************************************************/ |
| @@ -24836,13 +24838,10 @@ | |
| 24838 | #include <sys/time.h> |
| 24839 | #include <errno.h> |
| 24840 | #ifndef SQLITE_OMIT_WAL |
| 24841 | #include <sys/mman.h> |
| 24842 | #endif |
| 24843 | |
| 24844 | |
| 24845 | #if SQLITE_ENABLE_LOCKING_STYLE |
| 24846 | # include <sys/ioctl.h> |
| 24847 | # if OS_VXWORKS |
| @@ -24929,11 +24928,10 @@ | |
| 24928 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24929 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24930 | int h; /* The file descriptor */ |
| 24931 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24932 | unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ |
| 24933 | int lastErrno; /* The unix errno from last I/O error */ |
| 24934 | void *lockingContext; /* Locking style specific state */ |
| 24935 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24936 | const char *zPath; /* Name of the file */ |
| 24937 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25342,18 +25340,10 @@ | |
| 25340 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25341 | |
| 25342 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25343 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25344 | |
| 25345 | }; /* End of the overrideable system calls */ |
| 25346 | |
| 25347 | /* |
| 25348 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25349 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -28504,13 +28494,10 @@ | |
| 28494 | case SQLITE_SET_LOCKPROXYFILE: |
| 28495 | case SQLITE_GET_LOCKPROXYFILE: { |
| 28496 | return proxyFileControl(id,op,pArg); |
| 28497 | } |
| 28498 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 28499 | } |
| 28500 | return SQLITE_NOTFOUND; |
| 28501 | } |
| 28502 | |
| 28503 | /* |
| @@ -28522,27 +28509,12 @@ | |
| 28509 | ** if two files are created in the same file-system directory (i.e. |
| 28510 | ** a database and its journal file) that the sector size will be the |
| 28511 | ** same for both. |
| 28512 | */ |
| 28513 | static int unixSectorSize(sqlite3_file *pFile){ |
| 28514 | (void)pFile; |
| 28515 | return SQLITE_DEFAULT_SECTOR_SIZE; |
| 28516 | } |
| 28517 | |
| 28518 | /* |
| 28519 | ** Return the device characteristics for the file. |
| 28520 | ** |
| @@ -28815,13 +28787,13 @@ | |
| 28787 | rc = SQLITE_IOERR_FSTAT; |
| 28788 | goto shm_open_err; |
| 28789 | } |
| 28790 | |
| 28791 | #ifdef SQLITE_SHM_DIRECTORY |
| 28792 | nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31; |
| 28793 | #else |
| 28794 | nShmFilename = 6 + (int)strlen(pDbFd->zPath); |
| 28795 | #endif |
| 28796 | pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename ); |
| 28797 | if( pShmNode==0 ){ |
| 28798 | rc = SQLITE_NOMEM; |
| 28799 | goto shm_open_err; |
| @@ -31755,11 +31727,11 @@ | |
| 31727 | }; |
| 31728 | unsigned int i; /* Loop counter */ |
| 31729 | |
| 31730 | /* Double-check that the aSyscall[] array has been constructed |
| 31731 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31732 | assert( ArraySize(aSyscall)==20 ); |
| 31733 | |
| 31734 | /* Register all VFSes defined in the aVfs[] array */ |
| 31735 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31736 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31737 | } |
| @@ -32049,11 +32021,10 @@ | |
| 32021 | HANDLE h; /* Handle for accessing the file */ |
| 32022 | u8 locktype; /* Type of lock currently held on this file */ |
| 32023 | short sharedLockByte; /* Randomly chosen byte used as a shared lock */ |
| 32024 | u8 ctrlFlags; /* Flags. See WINFILE_* below */ |
| 32025 | DWORD lastErrno; /* The Windows errno from the last I/O error */ |
| 32026 | winShm *pShm; /* Instance of shared memory on this file */ |
| 32027 | const char *zPath; /* Full pathname of this file */ |
| 32028 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32029 | #if SQLITE_OS_WINCE |
| 32030 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| @@ -32139,18 +32110,10 @@ | |
| 32110 | static void winMemShutdown(void *pAppData); |
| 32111 | |
| 32112 | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void); |
| 32113 | #endif /* SQLITE_WIN32_MALLOC */ |
| 32114 | |
| 32115 | /* |
| 32116 | ** The following variable is (normally) set once and never changes |
| 32117 | ** thereafter. It records whether the operating system is Win9x |
| 32118 | ** or WinNT. |
| 32119 | ** |
| @@ -34181,13 +34144,10 @@ | |
| 34144 | } |
| 34145 | case SQLITE_FCNTL_VFSNAME: { |
| 34146 | *(char**)pArg = sqlite3_mprintf("win32"); |
| 34147 | return SQLITE_OK; |
| 34148 | } |
| 34149 | case SQLITE_FCNTL_WIN32_AV_RETRY: { |
| 34150 | int *a = (int*)pArg; |
| 34151 | if( a[0]>0 ){ |
| 34152 | win32IoerrRetry = a[0]; |
| 34153 | }else{ |
| @@ -34213,12 +34173,12 @@ | |
| 34173 | ** if two files are created in the same file-system directory (i.e. |
| 34174 | ** a database and its journal file) that the sector size will be the |
| 34175 | ** same for both. |
| 34176 | */ |
| 34177 | static int winSectorSize(sqlite3_file *id){ |
| 34178 | (void)id; |
| 34179 | return SQLITE_DEFAULT_SECTOR_SIZE; |
| 34180 | } |
| 34181 | |
| 34182 | /* |
| 34183 | ** Return a vector of device characteristics. |
| 34184 | */ |
| @@ -34463,11 +34423,11 @@ | |
| 34423 | */ |
| 34424 | p = sqlite3_malloc( sizeof(*p) ); |
| 34425 | if( p==0 ) return SQLITE_IOERR_NOMEM; |
| 34426 | memset(p, 0, sizeof(*p)); |
| 34427 | nName = sqlite3Strlen30(pDbFd->zPath); |
| 34428 | pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 16 ); |
| 34429 | if( pNew==0 ){ |
| 34430 | sqlite3_free(p); |
| 34431 | return SQLITE_IOERR_NOMEM; |
| 34432 | } |
| 34433 | memset(pNew, 0, sizeof(*pNew)); |
| @@ -35191,11 +35151,10 @@ | |
| 35151 | pFile->pShm = 0; |
| 35152 | pFile->zPath = zName; |
| 35153 | if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ |
| 35154 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 35155 | } |
| 35156 | |
| 35157 | #if SQLITE_OS_WINCE |
| 35158 | if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB |
| 35159 | && !winceCreateLock(zName, pFile) |
| 35160 | ){ |
| @@ -35436,85 +35395,10 @@ | |
| 35395 | return SQLITE_IOERR_NOMEM; |
| 35396 | } |
| 35397 | #endif |
| 35398 | } |
| 35399 | |
| 35400 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 35401 | /* |
| 35402 | ** Interfaces for opening a shared library, finding entry points |
| 35403 | ** within the shared library, and closing the shared library. |
| 35404 | */ |
| @@ -36381,11 +36265,11 @@ | |
| 36265 | */ |
| 36266 | static int numberOfCachePages(PCache *p){ |
| 36267 | if( p->szCache>=0 ){ |
| 36268 | return p->szCache; |
| 36269 | }else{ |
| 36270 | return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); |
| 36271 | } |
| 36272 | } |
| 36273 | |
| 36274 | /* |
| 36275 | ** Try to obtain a page from the cache. |
| @@ -36845,14 +36729,14 @@ | |
| 36729 | ** PGroup which is the pcache1.grp global variable and its mutex is |
| 36730 | ** SQLITE_MUTEX_STATIC_LRU. |
| 36731 | */ |
| 36732 | struct PGroup { |
| 36733 | sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ |
| 36734 | unsigned int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 36735 | unsigned int nMinPage; /* Sum of nMin for purgeable caches */ |
| 36736 | unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 36737 | unsigned int nCurrentPage; /* Number of purgeable pages allocated */ |
| 36738 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 36739 | }; |
| 36740 | |
| 36741 | /* Each page cache is an instance of the following object. Every |
| 36742 | ** open database file (including each in-memory database and each |
| @@ -37511,11 +37395,11 @@ | |
| 37395 | static sqlite3_pcache_page *pcache1Fetch( |
| 37396 | sqlite3_pcache *p, |
| 37397 | unsigned int iKey, |
| 37398 | int createFlag |
| 37399 | ){ |
| 37400 | unsigned int nPinned; |
| 37401 | PCache1 *pCache = (PCache1 *)p; |
| 37402 | PGroup *pGroup; |
| 37403 | PgHdr1 *pPage = 0; |
| 37404 | |
| 37405 | assert( pCache->bPurgeable || createFlag!=1 ); |
| @@ -37546,17 +37430,17 @@ | |
| 37430 | #ifdef SQLITE_MUTEX_OMIT |
| 37431 | pGroup = pCache->pGroup; |
| 37432 | #endif |
| 37433 | |
| 37434 | /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ |
| 37435 | assert( pCache->nPage >= pCache->nRecyclable ); |
| 37436 | nPinned = pCache->nPage - pCache->nRecyclable; |
| 37437 | assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage ); |
| 37438 | assert( pCache->n90pct == pCache->nMax*9/10 ); |
| 37439 | if( createFlag==1 && ( |
| 37440 | nPinned>=pGroup->mxPinned |
| 37441 | || nPinned>=pCache->n90pct |
| 37442 | || pcache1UnderMemoryPressure(pCache) |
| 37443 | )){ |
| 37444 | goto fetch_out; |
| 37445 | } |
| 37446 | |
| @@ -37725,11 +37609,13 @@ | |
| 37609 | PCache1 *pCache = (PCache1 *)p; |
| 37610 | PGroup *pGroup = pCache->pGroup; |
| 37611 | assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); |
| 37612 | pcache1EnterMutex(pGroup); |
| 37613 | pcache1TruncateUnsafe(pCache, 0); |
| 37614 | assert( pGroup->nMaxPage >= pCache->nMax ); |
| 37615 | pGroup->nMaxPage -= pCache->nMax; |
| 37616 | assert( pGroup->nMinPage >= pCache->nMin ); |
| 37617 | pGroup->nMinPage -= pCache->nMin; |
| 37618 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 37619 | pcache1EnforceMaxPage(pGroup); |
| 37620 | pcache1LeaveMutex(pGroup); |
| 37621 | sqlite3_free(pCache->apHash); |
| @@ -37807,12 +37693,12 @@ | |
| 37693 | int nRecyclable = 0; |
| 37694 | for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ |
| 37695 | nRecyclable++; |
| 37696 | } |
| 37697 | *pnCurrent = pcache1.grp.nCurrentPage; |
| 37698 | *pnMax = (int)pcache1.grp.nMaxPage; |
| 37699 | *pnMin = (int)pcache1.grp.nMinPage; |
| 37700 | *pnRecyclable = nRecyclable; |
| 37701 | } |
| 37702 | #endif |
| 37703 | |
| 37704 | /************** End of pcache1.c *********************************************/ |
| @@ -38282,10 +38168,16 @@ | |
| 38168 | |
| 38169 | #ifndef _WAL_H_ |
| 38170 | #define _WAL_H_ |
| 38171 | |
| 38172 | |
| 38173 | /* Additional values that can be added to the sync_flags argument of |
| 38174 | ** sqlite3WalFrames(): |
| 38175 | */ |
| 38176 | #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| 38177 | #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */ |
| 38178 | |
| 38179 | #ifdef SQLITE_OMIT_WAL |
| 38180 | # define sqlite3WalOpen(x,y,z) 0 |
| 38181 | # define sqlite3WalLimit(x,y) |
| 38182 | # define sqlite3WalClose(w,x,y,z) 0 |
| 38183 | # define sqlite3WalBeginReadTransaction(y,z) 0 |
| @@ -38350,16 +38242,10 @@ | |
| 38242 | SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData); |
| 38243 | |
| 38244 | /* Write a frame or frames to the log. */ |
| 38245 | SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int); |
| 38246 | |
| 38247 | /* Copy pages from the log to the database file */ |
| 38248 | SQLITE_PRIVATE int sqlite3WalCheckpoint( |
| 38249 | Wal *pWal, /* Write-ahead log connection */ |
| 38250 | int eMode, /* One of PASSIVE, FULL and RESTART */ |
| 38251 | int (*xBusy)(void*), /* Function to call when busy */ |
| @@ -42400,11 +42286,13 @@ | |
| 42286 | ** file size will be. |
| 42287 | */ |
| 42288 | assert( rc!=SQLITE_OK || isOpen(pPager->fd) ); |
| 42289 | if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){ |
| 42290 | sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize; |
| 42291 | sqlite3BeginBenignMalloc(); |
| 42292 | sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile); |
| 42293 | sqlite3EndBenignMalloc(); |
| 42294 | pPager->dbHintSize = pPager->dbSize; |
| 42295 | } |
| 42296 | |
| 42297 | while( rc==SQLITE_OK && pList ){ |
| 42298 | Pgno pgno = pList->pgno; |
| @@ -42741,11 +42629,12 @@ | |
| 42629 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 42630 | while( *z ){ |
| 42631 | z += sqlite3Strlen30(z)+1; |
| 42632 | z += sqlite3Strlen30(z)+1; |
| 42633 | } |
| 42634 | nUri = (int)(&z[1] - zUri); |
| 42635 | assert( nUri>=0 ); |
| 42636 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 42637 | /* This branch is taken when the journal path required by |
| 42638 | ** the database being opened will be more than pVfs->mxPathname |
| 42639 | ** bytes in length. This means the database cannot be opened, |
| 42640 | ** as it will not be possible to open the journal file or even |
| @@ -42775,13 +42664,13 @@ | |
| 42664 | ROUND8(sizeof(*pPager)) + /* Pager structure */ |
| 42665 | ROUND8(pcacheSize) + /* PCache object */ |
| 42666 | ROUND8(pVfs->szOsFile) + /* The main db file */ |
| 42667 | journalFileSize * 2 + /* The two journal files */ |
| 42668 | nPathname + 1 + nUri + /* zFilename */ |
| 42669 | nPathname + 8 + 2 /* zJournal */ |
| 42670 | #ifndef SQLITE_OMIT_WAL |
| 42671 | + nPathname + 4 + 2 /* zWal */ |
| 42672 | #endif |
| 42673 | ); |
| 42674 | assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); |
| 42675 | if( !pPtr ){ |
| 42676 | sqlite3_free(zPathname); |
| @@ -42800,16 +42689,16 @@ | |
| 42689 | assert( nPathname>0 ); |
| 42690 | pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); |
| 42691 | memcpy(pPager->zFilename, zPathname, nPathname); |
| 42692 | memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); |
| 42693 | memcpy(pPager->zJournal, zPathname, nPathname); |
| 42694 | memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+1); |
| 42695 | sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); |
| 42696 | #ifndef SQLITE_OMIT_WAL |
| 42697 | pPager->zWal = &pPager->zJournal[nPathname+8+1]; |
| 42698 | memcpy(pPager->zWal, zPathname, nPathname); |
| 42699 | memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1); |
| 42700 | sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); |
| 42701 | #endif |
| 42702 | sqlite3_free(zPathname); |
| 42703 | } |
| 42704 | pPager->pVfs = pVfs; |
| @@ -44064,11 +43953,14 @@ | |
| 43953 | if( !pPager->noSync ){ |
| 43954 | assert( !MEMDB ); |
| 43955 | rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); |
| 43956 | }else if( isOpen(pPager->fd) ){ |
| 43957 | assert( !MEMDB ); |
| 43958 | rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, 0); |
| 43959 | if( rc==SQLITE_NOTFOUND ){ |
| 43960 | rc = SQLITE_OK; |
| 43961 | } |
| 43962 | } |
| 43963 | return rc; |
| 43964 | } |
| 43965 | |
| 43966 | /* |
| @@ -48125,11 +48017,11 @@ | |
| 48017 | iFrame = pWal->hdr.mxFrame; |
| 48018 | for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){ |
| 48019 | iFrame++; |
| 48020 | rc = walIndexAppend(pWal, iFrame, p->pgno); |
| 48021 | } |
| 48022 | while( rc==SQLITE_OK && nExtra>0 ){ |
| 48023 | iFrame++; |
| 48024 | nExtra--; |
| 48025 | rc = walIndexAppend(pWal, iFrame, pLast->pgno); |
| 48026 | } |
| 48027 | |
| @@ -48726,11 +48618,11 @@ | |
| 48618 | #define TRANS_WRITE 2 |
| 48619 | |
| 48620 | /* |
| 48621 | ** An instance of this object represents a single database file. |
| 48622 | ** |
| 48623 | ** A single database file can be in use at the same time by two |
| 48624 | ** or more database connections. When two or more connections are |
| 48625 | ** sharing the same database file, each connection has it own |
| 48626 | ** private Btree object for the file and each of those Btrees points |
| 48627 | ** to this one BtShared object. BtShared.nRef is the number of |
| 48628 | ** connections currently sharing this database file. |
| @@ -48832,11 +48724,11 @@ | |
| 48724 | ** b-tree within a database file. |
| 48725 | ** |
| 48726 | ** The entry is identified by its MemPage and the index in |
| 48727 | ** MemPage.aCell[] of the entry. |
| 48728 | ** |
| 48729 | ** A single database file can be shared by two more database connections, |
| 48730 | ** but cursors cannot be shared. Each cursor is associated with a |
| 48731 | ** particular database connection identified BtCursor.pBtree.db. |
| 48732 | ** |
| 48733 | ** Fields in this structure are accessed under the BtShared.mutex |
| 48734 | ** found at self->pBt->mutex. |
| @@ -48993,11 +48885,11 @@ | |
| 48885 | int mallocFailed; /* A memory allocation error has occurred */ |
| 48886 | StrAccum errMsg; /* Accumulate the error message text here */ |
| 48887 | }; |
| 48888 | |
| 48889 | /* |
| 48890 | ** Routines to read or write a two- and four-byte big-endian integer values. |
| 48891 | */ |
| 48892 | #define get2byte(x) ((x)[0]<<8 | (x)[1]) |
| 48893 | #define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) |
| 48894 | #define get4byte sqlite3Get4byte |
| 48895 | #define put4byte sqlite3Put4byte |
| @@ -55478,12 +55370,18 @@ | |
| 55370 | } |
| 55371 | |
| 55372 | /* Either we found one or more cells (cntnew[0])>0) or pPage is |
| 55373 | ** a virtual root page. A virtual root page is when the real root |
| 55374 | ** page is page 1 and we are the only child of that page. |
| 55375 | ** |
| 55376 | ** UPDATE: The assert() below is not necessarily true if the database |
| 55377 | ** file is corrupt. The corruption will be detected and reported later |
| 55378 | ** in this procedure so there is no need to act upon it now. |
| 55379 | */ |
| 55380 | #if 0 |
| 55381 | assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) ); |
| 55382 | #endif |
| 55383 | |
| 55384 | TRACE(("BALANCE: old: %d %d %d ", |
| 55385 | apOld[0]->pgno, |
| 55386 | nOld>=2 ? apOld[1]->pgno : 0, |
| 55387 | nOld>=3 ? apOld[2]->pgno : 0 |
| @@ -58194,11 +58092,13 @@ | |
| 58092 | |
| 58093 | assert( sqlite3BtreeIsInTrans(pTo) ); |
| 58094 | pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); |
| 58095 | if( pFd->pMethods ){ |
| 58096 | i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); |
| 58097 | sqlite3BeginBenignMalloc(); |
| 58098 | sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); |
| 58099 | sqlite3EndBenignMalloc(); |
| 58100 | } |
| 58101 | |
| 58102 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 58103 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 58104 | ** and sqlite3_backup_finish() to detect that they are being called |
| @@ -58525,11 +58425,11 @@ | |
| 58425 | ** Release any memory held by the Mem. This may leave the Mem in an |
| 58426 | ** inconsistent state, for example with (Mem.z==0) and |
| 58427 | ** (Mem.type==SQLITE_TEXT). |
| 58428 | */ |
| 58429 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){ |
| 58430 | VdbeMemRelease(p); |
| 58431 | sqlite3DbFree(p->db, p->zMalloc); |
| 58432 | p->z = 0; |
| 58433 | p->zMalloc = 0; |
| 58434 | p->xDel = 0; |
| 58435 | } |
| @@ -58821,11 +58721,11 @@ | |
| 58721 | ** copies of this cell as invalid. |
| 58722 | ** |
| 58723 | ** This is used for testing and debugging only - to make sure shallow |
| 58724 | ** copies are not misused. |
| 58725 | */ |
| 58726 | SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ |
| 58727 | int i; |
| 58728 | Mem *pX; |
| 58729 | for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){ |
| 58730 | if( pX->pScopyFrom==pMem ){ |
| 58731 | pX->flags |= MEM_Invalid; |
| @@ -58847,11 +58747,11 @@ | |
| 58747 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| 58748 | ** and flags gets srcType (either MEM_Ephem or MEM_Static). |
| 58749 | */ |
| 58750 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ |
| 58751 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58752 | VdbeMemRelease(pTo); |
| 58753 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58754 | pTo->xDel = 0; |
| 58755 | if( (pFrom->flags&MEM_Static)==0 ){ |
| 58756 | pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem); |
| 58757 | assert( srcType==MEM_Ephem || srcType==MEM_Static ); |
| @@ -58865,11 +58765,11 @@ | |
| 58765 | */ |
| 58766 | SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){ |
| 58767 | int rc = SQLITE_OK; |
| 58768 | |
| 58769 | assert( (pFrom->flags & MEM_RowSet)==0 ); |
| 58770 | VdbeMemRelease(pTo); |
| 58771 | memcpy(pTo, pFrom, MEMCELLSIZE); |
| 58772 | pTo->flags &= ~MEM_Dyn; |
| 58773 | |
| 58774 | if( pTo->flags&(MEM_Str|MEM_Blob) ){ |
| 58775 | if( 0==(pFrom->flags&MEM_Static) ){ |
| @@ -59202,11 +59102,11 @@ | |
| 59102 | assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 ); |
| 59103 | if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){ |
| 59104 | return 0; |
| 59105 | } |
| 59106 | } |
| 59107 | sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */ |
| 59108 | }else{ |
| 59109 | assert( (pVal->flags&MEM_Blob)==0 ); |
| 59110 | sqlite3VdbeMemStringify(pVal, enc); |
| 59111 | assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); |
| 59112 | } |
| @@ -59583,11 +59483,12 @@ | |
| 59483 | return addr; |
| 59484 | } |
| 59485 | |
| 59486 | /* |
| 59487 | ** Add an OP_ParseSchema opcode. This routine is broken out from |
| 59488 | ** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees |
| 59489 | ** as having been used. |
| 59490 | ** |
| 59491 | ** The zWhere string must have been obtained from sqlite3_malloc(). |
| 59492 | ** This routine will take ownership of the allocated memory. |
| 59493 | */ |
| 59494 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ |
| @@ -60350,12 +60251,13 @@ | |
| 60251 | |
| 60252 | /* |
| 60253 | ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. |
| 60254 | ** |
| 60255 | ** The prepared statements need to know in advance the complete set of |
| 60256 | ** attached databases that will be use. A mask of these databases |
| 60257 | ** is maintained in p->btreeMask. The p->lockMask value is the subset of |
| 60258 | ** p->btreeMask of databases that will require a lock. |
| 60259 | */ |
| 60260 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){ |
| 60261 | assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 ); |
| 60262 | assert( i<(int)sizeof(p->btreeMask)*8 ); |
| 60263 | p->btreeMask |= ((yDbMask)1)<<i; |
| @@ -60874,10 +60776,11 @@ | |
| 60776 | nVar = pParse->nVar; |
| 60777 | nMem = pParse->nMem; |
| 60778 | nCursor = pParse->nTab; |
| 60779 | nArg = pParse->nMaxArg; |
| 60780 | nOnce = pParse->nOnce; |
| 60781 | if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */ |
| 60782 | |
| 60783 | /* For each cursor required, also allocate a memory cell. Memory |
| 60784 | ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by |
| 60785 | ** the vdbe program. Instead they are used to allocate space for |
| 60786 | ** VdbeCursor/BtCursor structures. The blob of memory associated with |
| @@ -61225,11 +61128,11 @@ | |
| 61128 | int retryCount = 0; |
| 61129 | int nMainFile; |
| 61130 | |
| 61131 | /* Select a master journal file name */ |
| 61132 | nMainFile = sqlite3Strlen30(zMainFile); |
| 61133 | zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile); |
| 61134 | if( zMaster==0 ) return SQLITE_NOMEM; |
| 61135 | do { |
| 61136 | u32 iRandom; |
| 61137 | if( retryCount ){ |
| 61138 | if( retryCount>100 ){ |
| @@ -63013,11 +62916,11 @@ | |
| 62916 | ** since any application that receives an SQLITE_MISUSE is broken by |
| 62917 | ** definition. |
| 62918 | ** |
| 62919 | ** Nevertheless, some published applications that were originally written |
| 62920 | ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE |
| 62921 | ** returns, and those were broken by the automatic-reset change. As a |
| 62922 | ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the |
| 62923 | ** legacy behavior of returning SQLITE_MISUSE for cases where the |
| 62924 | ** previous sqlite3_step() returned something other than a SQLITE_LOCKED |
| 62925 | ** or SQLITE_BUSY error. |
| 62926 | */ |
| @@ -63359,17 +63262,17 @@ | |
| 63262 | pOut = &pVm->pResultSet[i]; |
| 63263 | }else{ |
| 63264 | /* If the value passed as the second argument is out of range, return |
| 63265 | ** a pointer to the following static Mem object which contains the |
| 63266 | ** value SQL NULL. Even though the Mem structure contains an element |
| 63267 | ** of type i64, on certain architectures (x86) with certain compiler |
| 63268 | ** switches (-Os), gcc may align this Mem object on a 4-byte boundary |
| 63269 | ** instead of an 8-byte one. This all works fine, except that when |
| 63270 | ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s |
| 63271 | ** that a Mem structure is located on an 8-byte boundary. To prevent |
| 63272 | ** these assert()s from failing, when building with SQLITE_DEBUG defined |
| 63273 | ** using gcc, we force nullMem to be 8-byte aligned using the magical |
| 63274 | ** __attribute__((aligned(8))) macro. */ |
| 63275 | static const Mem nullMem |
| 63276 | #if defined(SQLITE_DEBUG) && defined(__GNUC__) |
| 63277 | __attribute__((aligned(8))) |
| 63278 | #endif |
| @@ -64298,11 +64201,11 @@ | |
| 64201 | ** Invoke this macro on memory cells just prior to changing the |
| 64202 | ** value of the cell. This macro verifies that shallow copies are |
| 64203 | ** not misused. |
| 64204 | */ |
| 64205 | #ifdef SQLITE_DEBUG |
| 64206 | # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M) |
| 64207 | #else |
| 64208 | # define memAboutToChange(P,M) |
| 64209 | #endif |
| 64210 | |
| 64211 | /* |
| @@ -64316,12 +64219,12 @@ | |
| 64219 | SQLITE_API int sqlite3_search_count = 0; |
| 64220 | #endif |
| 64221 | |
| 64222 | /* |
| 64223 | ** When this global variable is positive, it gets decremented once before |
| 64224 | ** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted |
| 64225 | ** field of the sqlite3 structure is set in order to simulate an interrupt. |
| 64226 | ** |
| 64227 | ** This facility is used for testing purposes only. It does not function |
| 64228 | ** in an ordinary build. |
| 64229 | */ |
| 64230 | #ifdef SQLITE_TEST |
| @@ -64442,11 +64345,11 @@ | |
| 64345 | */ |
| 64346 | static VdbeCursor *allocateCursor( |
| 64347 | Vdbe *p, /* The virtual machine */ |
| 64348 | int iCur, /* Index of the new VdbeCursor */ |
| 64349 | int nField, /* Number of fields in the table or index */ |
| 64350 | int iDb, /* Database the cursor belongs to, or -1 */ |
| 64351 | int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ |
| 64352 | ){ |
| 64353 | /* Find the memory cell that will be used to store the blob of memory |
| 64354 | ** required for this VdbeCursor structure. It is convenient to use a |
| 64355 | ** vdbe memory cell to manage the memory allocation required for a |
| @@ -64813,11 +64716,11 @@ | |
| 64716 | ** sqlite3_interrupt() routine has been called. If it has been, then |
| 64717 | ** processing of the VDBE program is interrupted. |
| 64718 | ** |
| 64719 | ** This macro added to every instruction that does a jump in order to |
| 64720 | ** implement a loop. This test used to be on every single instruction, |
| 64721 | ** but that meant we more testing than we needed. By only testing the |
| 64722 | ** flag on jump instructions, we get a (small) speed improvement. |
| 64723 | */ |
| 64724 | #define CHECK_FOR_INTERRUPT \ |
| 64725 | if( db->u1.isInterrupted ) goto abort_due_to_interrupt; |
| 64726 | |
| @@ -65430,11 +65333,11 @@ | |
| 65333 | if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){ |
| 65334 | assert( pOp->p2>0 ); |
| 65335 | assert( pOp->p2<=p->nMem ); |
| 65336 | pOut = &aMem[pOp->p2]; |
| 65337 | memAboutToChange(p, pOut); |
| 65338 | VdbeMemRelease(pOut); |
| 65339 | pOut->flags = MEM_Int; |
| 65340 | } |
| 65341 | |
| 65342 | /* Sanity checking on other operands */ |
| 65343 | #ifdef SQLITE_DEBUG |
| @@ -65738,11 +65641,11 @@ | |
| 65641 | assert( pOp->p3<=p->nMem ); |
| 65642 | pOut->flags = MEM_Null; |
| 65643 | while( u.ab.cnt>0 ){ |
| 65644 | pOut++; |
| 65645 | memAboutToChange(p, pOut); |
| 65646 | VdbeMemRelease(pOut); |
| 65647 | pOut->flags = MEM_Null; |
| 65648 | u.ab.cnt--; |
| 65649 | } |
| 65650 | break; |
| 65651 | } |
| @@ -65919,11 +65822,11 @@ | |
| 65822 | /* Invalidate all ephemeral cursor row caches */ |
| 65823 | p->cacheCtr = (p->cacheCtr + 2)|1; |
| 65824 | |
| 65825 | /* Make sure the results of the current row are \000 terminated |
| 65826 | ** and have an assigned type. The results are de-ephemeralized as |
| 65827 | ** a side effect. |
| 65828 | */ |
| 65829 | u.ae.pMem = p->pResultSet = &aMem[pOp->p1]; |
| 65830 | for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){ |
| 65831 | assert( memIsValid(&u.ae.pMem[u.ae.i]) ); |
| 65832 | Deephemeralize(&u.ae.pMem[u.ae.i]); |
| @@ -67160,11 +67063,11 @@ | |
| 67063 | ** a pointer to a Mem object. |
| 67064 | */ |
| 67065 | if( u.an.aOffset[u.an.p2] ){ |
| 67066 | assert( rc==SQLITE_OK ); |
| 67067 | if( u.an.zRec ){ |
| 67068 | VdbeMemRelease(u.an.pDest); |
| 67069 | sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest); |
| 67070 | }else{ |
| 67071 | u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]); |
| 67072 | sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest); |
| 67073 | rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem); |
| @@ -83758,11 +83661,11 @@ | |
| 83661 | ** Allocate the index structure. |
| 83662 | */ |
| 83663 | nName = sqlite3Strlen30(zName); |
| 83664 | nCol = pList->nExpr; |
| 83665 | pIndex = sqlite3DbMallocZero(db, |
| 83666 | ROUND8(sizeof(Index)) + /* Index structure */ |
| 83667 | ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */ |
| 83668 | sizeof(char *)*nCol + /* Index.azColl */ |
| 83669 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 83670 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 83671 | nName + 1 + /* Index.zName */ |
| @@ -83769,11 +83672,12 @@ | |
| 83672 | nExtra /* Collation sequence names */ |
| 83673 | ); |
| 83674 | if( db->mallocFailed ){ |
| 83675 | goto exit_create_index; |
| 83676 | } |
| 83677 | zExtra = (char*)pIndex; |
| 83678 | pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))]; |
| 83679 | pIndex->azColl = (char**) |
| 83680 | ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1)); |
| 83681 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) ); |
| 83682 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); |
| 83683 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| @@ -89966,11 +89870,11 @@ | |
| 89870 | ** any ABORT Back out changes from the current command |
| 89871 | ** only (do not do a complete rollback) then |
| 89872 | ** cause sqlite3_exec() to return immediately |
| 89873 | ** with SQLITE_CONSTRAINT. |
| 89874 | ** |
| 89875 | ** any FAIL Sqlite3_exec() returns immediately with a |
| 89876 | ** return code of SQLITE_CONSTRAINT. The |
| 89877 | ** transaction is not rolled back and any |
| 89878 | ** prior changes are retained. |
| 89879 | ** |
| 89880 | ** any IGNORE The record number and data is popped from |
| @@ -111450,11 +111354,11 @@ | |
| 111354 | *tokenType = TK_SPACE; |
| 111355 | return i; |
| 111356 | } |
| 111357 | case '-': { |
| 111358 | if( z[1]=='-' ){ |
| 111359 | /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 111360 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 111361 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111362 | return i; |
| 111363 | } |
| 111364 | *tokenType = TK_MINUS; |
| @@ -111483,11 +111387,11 @@ | |
| 111387 | case '/': { |
| 111388 | if( z[1]!='*' || z[2]==0 ){ |
| 111389 | *tokenType = TK_SLASH; |
| 111390 | return 1; |
| 111391 | } |
| 111392 | /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 111393 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 111394 | if( c ) i++; |
| 111395 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 111396 | return i; |
| 111397 | } |
| @@ -112277,12 +112181,12 @@ | |
| 112181 | /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function |
| 112182 | ** returns an integer equal to SQLITE_VERSION_NUMBER. |
| 112183 | */ |
| 112184 | SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } |
| 112185 | |
| 112186 | /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns |
| 112187 | ** zero if and only if SQLite was compiled with mutexing code omitted due to |
| 112188 | ** the SQLITE_THREADSAFE compile-time option being set to 0. |
| 112189 | */ |
| 112190 | SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } |
| 112191 | |
| 112192 | #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) |
| @@ -112768,19 +112672,21 @@ | |
| 112672 | ** Free up as much memory as we can from the given database |
| 112673 | ** connection. |
| 112674 | */ |
| 112675 | SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){ |
| 112676 | int i; |
| 112677 | sqlite3_mutex_enter(db->mutex); |
| 112678 | sqlite3BtreeEnterAll(db); |
| 112679 | for(i=0; i<db->nDb; i++){ |
| 112680 | Btree *pBt = db->aDb[i].pBt; |
| 112681 | if( pBt ){ |
| 112682 | Pager *pPager = sqlite3BtreePager(pBt); |
| 112683 | sqlite3PagerShrink(pPager); |
| 112684 | } |
| 112685 | } |
| 112686 | sqlite3BtreeLeaveAll(db); |
| 112687 | sqlite3_mutex_leave(db->mutex); |
| 112688 | return SQLITE_OK; |
| 112689 | } |
| 112690 | |
| 112691 | /* |
| 112692 | ** Configuration settings for an individual database connection |
| 112693 |
+19
-22
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.10" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007010 |
| 112 | -#define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22" | |
| 112 | +#define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -175,11 +175,11 @@ | ||
| 175 | 175 | |
| 176 | 176 | /* |
| 177 | 177 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 178 | 178 | ** |
| 179 | 179 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 180 | -** SQLite was compiled mutexing code omitted due to the | |
| 180 | +** SQLite was compiled with mutexing code omitted due to the | |
| 181 | 181 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 182 | 182 | ** |
| 183 | 183 | ** SQLite can be compiled with or without mutexes. When |
| 184 | 184 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 185 | 185 | ** are enabled and SQLite is threadsafe. When the |
| @@ -369,11 +369,11 @@ | ||
| 369 | 369 | ** CAPI3REF: Result Codes |
| 370 | 370 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 371 | 371 | ** KEYWORDS: {result code} {result codes} |
| 372 | 372 | ** |
| 373 | 373 | ** Many SQLite functions return an integer result code from the set shown |
| 374 | -** here in order to indicates success or failure. | |
| 374 | +** here in order to indicate success or failure. | |
| 375 | 375 | ** |
| 376 | 376 | ** New error codes may be added in future versions of SQLite. |
| 377 | 377 | ** |
| 378 | 378 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 379 | 379 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -508,17 +508,14 @@ | ||
| 508 | 508 | ** that when data is appended to a file, the data is appended |
| 509 | 509 | ** first then the size of the file is extended, never the other |
| 510 | 510 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 511 | 511 | ** information is written to disk in the same order as calls |
| 512 | 512 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 513 | -** after reboot following a crash or power loss, the value of | |
| 514 | -** each byte in a file is a value that was actually written | |
| 515 | -** into that byte at some point. In other words, a crash will | |
| 516 | -** not cause unwritten bytes of the file to change nor introduce | |
| 517 | -** randomness into a file nor zero out parts of the file, and any byte of | |
| 518 | -** a file that are never written will not change values due to | |
| 519 | -** writes to nearby bytes. | |
| 513 | +** after reboot following a crash or power loss, the only bytes in a | |
| 514 | +** file that were written at the application level might have changed | |
| 515 | +** and that adjacent bytes, even bytes within the same sector are | |
| 516 | +** guaranteed to be unchanged. | |
| 520 | 517 | */ |
| 521 | 518 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 522 | 519 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 523 | 520 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 524 | 521 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -750,16 +747,16 @@ | ||
| 750 | 747 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 751 | 748 | ** that do require it. |
| 752 | 749 | ** |
| 753 | 750 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 754 | 751 | ** retry counts and intervals for certain disk I/O operations for the |
| 755 | -** windows [VFS] in order to work to provide robustness against | |
| 752 | +** windows [VFS] in order to provide robustness in the presence of | |
| 756 | 753 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 757 | 754 | ** file write, and file delete operations up to 10 times, with a delay |
| 758 | 755 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 759 | 756 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 760 | -** opcode allows those to values (10 retries and 25 milliseconds of delay) | |
| 757 | +** opcode allows these two values (10 retries and 25 milliseconds of delay) | |
| 761 | 758 | ** to be adjusted. The values are changed for all database connections |
| 762 | 759 | ** within the same process. The argument is a pointer to an array of two |
| 763 | 760 | ** integers where the first integer i the new retry count and the second |
| 764 | 761 | ** integer is the delay. If either integer is negative, then the setting |
| 765 | 762 | ** is not changed but instead the prior value of that setting is written |
| @@ -870,11 +867,11 @@ | ||
| 870 | 867 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 871 | 868 | ** is either a NULL pointer or string obtained |
| 872 | 869 | ** from xFullPathname() with an optional suffix added. |
| 873 | 870 | ** ^If a suffix is added to the zFilename parameter, it will |
| 874 | 871 | ** consist of a single "-" character followed by no more than |
| 875 | -** 10 alphanumeric and/or "-" characters. | |
| 872 | +** 11 alphanumeric and/or "-" characters. | |
| 876 | 873 | ** ^SQLite further guarantees that |
| 877 | 874 | ** the string will be valid and unchanged until xClose() is |
| 878 | 875 | ** called. Because of the previous sentence, |
| 879 | 876 | ** the [sqlite3_file] can safely store a pointer to the |
| 880 | 877 | ** filename if it needs to remember the filename for some reason. |
| @@ -2021,11 +2018,11 @@ | ||
| 2021 | 2018 | ** These routines all implement some additional formatting |
| 2022 | 2019 | ** options that are useful for constructing SQL statements. |
| 2023 | 2020 | ** All of the usual printf() formatting options apply. In addition, there |
| 2024 | 2021 | ** is are "%q", "%Q", and "%z" options. |
| 2025 | 2022 | ** |
| 2026 | -** ^(The %q option works like %s in that it substitutes a null-terminated | |
| 2023 | +** ^(The %q option works like %s in that it substitutes a nul-terminated | |
| 2027 | 2024 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2028 | 2025 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2029 | 2026 | ** character it escapes that character and allows it to be inserted into |
| 2030 | 2027 | ** the string. |
| 2031 | 2028 | ** |
| @@ -3541,11 +3538,11 @@ | ||
| 3541 | 3538 | ** of the string. ^For clarity: the values returned by |
| 3542 | 3539 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 3543 | 3540 | ** bytes in the string, not the number of characters. |
| 3544 | 3541 | ** |
| 3545 | 3542 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 3546 | -** even empty strings, are always zero terminated. ^The return | |
| 3543 | +** even empty strings, are always zero-terminated. ^The return | |
| 3547 | 3544 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 3548 | 3545 | ** |
| 3549 | 3546 | ** ^The object returned by [sqlite3_column_value()] is an |
| 3550 | 3547 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 3551 | 3548 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -4621,11 +4618,11 @@ | ||
| 4621 | 4618 | SQLITE_API int sqlite3_release_memory(int); |
| 4622 | 4619 | |
| 4623 | 4620 | /* |
| 4624 | 4621 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 4625 | 4622 | ** |
| 4626 | -** ^The sqlite3_db_shrink(D) interface attempts to free as much heap | |
| 4623 | +** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap | |
| 4627 | 4624 | ** memory as possible from database connection D. Unlike the |
| 4628 | 4625 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 4629 | 4626 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 4630 | 4627 | ** omitted. |
| 4631 | 4628 | ** |
| @@ -5404,19 +5401,19 @@ | ||
| 5404 | 5401 | ** is selected automatically at compile-time. ^(The following |
| 5405 | 5402 | ** implementations are available in the SQLite core: |
| 5406 | 5403 | ** |
| 5407 | 5404 | ** <ul> |
| 5408 | 5405 | ** <li> SQLITE_MUTEX_OS2 |
| 5409 | -** <li> SQLITE_MUTEX_PTHREAD | |
| 5406 | +** <li> SQLITE_MUTEX_PTHREADS | |
| 5410 | 5407 | ** <li> SQLITE_MUTEX_W32 |
| 5411 | 5408 | ** <li> SQLITE_MUTEX_NOOP |
| 5412 | 5409 | ** </ul>)^ |
| 5413 | 5410 | ** |
| 5414 | 5411 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5415 | 5412 | ** that does no real locking and is appropriate for use in |
| 5416 | 5413 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5417 | -** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations | |
| 5414 | +** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations | |
| 5418 | 5415 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5419 | 5416 | ** |
| 5420 | 5417 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5421 | 5418 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5422 | 5419 | ** implementation is included with the library. In this case the |
| @@ -5602,11 +5599,11 @@ | ||
| 5602 | 5599 | ** defined and if NDEBUG is not defined. |
| 5603 | 5600 | ** |
| 5604 | 5601 | ** ^These routines should return true if the mutex in their argument |
| 5605 | 5602 | ** is held or not held, respectively, by the calling thread. |
| 5606 | 5603 | ** |
| 5607 | -** ^The implementation is not required to provided versions of these | |
| 5604 | +** ^The implementation is not required to provide versions of these | |
| 5608 | 5605 | ** routines that actually work. If the implementation does not provide working |
| 5609 | 5606 | ** versions of these routines, it should at least provide stubs that always |
| 5610 | 5607 | ** return true so that one does not get spurious assertion failures. |
| 5611 | 5608 | ** |
| 5612 | 5609 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6084,11 +6081,11 @@ | ||
| 6084 | 6081 | ** |
| 6085 | 6082 | ** [[the xInit() page cache method]] |
| 6086 | 6083 | ** ^(The xInit() method is called once for each effective |
| 6087 | 6084 | ** call to [sqlite3_initialize()])^ |
| 6088 | 6085 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6089 | -** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ | |
| 6086 | +** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ | |
| 6090 | 6087 | ** The intent of the xInit() method is to set up global data structures |
| 6091 | 6088 | ** required by the custom page cache implementation. |
| 6092 | 6089 | ** ^(If the xInit() method is NULL, then the |
| 6093 | 6090 | ** built-in default page cache is used instead of the application defined |
| 6094 | 6091 | ** page cache.)^ |
| @@ -6110,11 +6107,11 @@ | ||
| 6110 | 6107 | ** |
| 6111 | 6108 | ** [[the xCreate() page cache methods]] |
| 6112 | 6109 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6113 | 6110 | ** SQLite will typically create one cache instance for each open database file, |
| 6114 | 6111 | ** though this is not guaranteed. ^The |
| 6115 | -** parameter parameter, szPage, is the size in bytes of the pages that must | |
| 6112 | +** first parameter, szPage, is the size in bytes of the pages that must | |
| 6116 | 6113 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6117 | 6114 | ** second parameter szExtra is a number of bytes of extra storage |
| 6118 | 6115 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6119 | 6116 | ** a number less than 250. SQLite will use the |
| 6120 | 6117 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6205,11 +6202,11 @@ | ||
| 6205 | 6202 | ** |
| 6206 | 6203 | ** [[the xDestroy() page cache method]] |
| 6207 | 6204 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6208 | 6205 | ** All resources associated with the specified cache should be freed. ^After |
| 6209 | 6206 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6210 | -** handle invalid, and will not use it with any other sqlite3_pcache_methods | |
| 6207 | +** handle invalid, and will not use it with any other sqlite3_pcache_methods2 | |
| 6211 | 6208 | ** functions. |
| 6212 | 6209 | ** |
| 6213 | 6210 | ** [[the xShrink() page cache method]] |
| 6214 | 6211 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6215 | 6212 | ** free up as much of heap memory as possible. The page cache implementation |
| 6216 | 6213 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.10" |
| 111 | #define SQLITE_VERSION_NUMBER 3007010 |
| 112 | #define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -175,11 +175,11 @@ | |
| 175 | |
| 176 | /* |
| 177 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 178 | ** |
| 179 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 180 | ** SQLite was compiled mutexing code omitted due to the |
| 181 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 182 | ** |
| 183 | ** SQLite can be compiled with or without mutexes. When |
| 184 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 185 | ** are enabled and SQLite is threadsafe. When the |
| @@ -369,11 +369,11 @@ | |
| 369 | ** CAPI3REF: Result Codes |
| 370 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 371 | ** KEYWORDS: {result code} {result codes} |
| 372 | ** |
| 373 | ** Many SQLite functions return an integer result code from the set shown |
| 374 | ** here in order to indicates success or failure. |
| 375 | ** |
| 376 | ** New error codes may be added in future versions of SQLite. |
| 377 | ** |
| 378 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 379 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -508,17 +508,14 @@ | |
| 508 | ** that when data is appended to a file, the data is appended |
| 509 | ** first then the size of the file is extended, never the other |
| 510 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 511 | ** information is written to disk in the same order as calls |
| 512 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 513 | ** after reboot following a crash or power loss, the value of |
| 514 | ** each byte in a file is a value that was actually written |
| 515 | ** into that byte at some point. In other words, a crash will |
| 516 | ** not cause unwritten bytes of the file to change nor introduce |
| 517 | ** randomness into a file nor zero out parts of the file, and any byte of |
| 518 | ** a file that are never written will not change values due to |
| 519 | ** writes to nearby bytes. |
| 520 | */ |
| 521 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 522 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 523 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 524 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -750,16 +747,16 @@ | |
| 750 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 751 | ** that do require it. |
| 752 | ** |
| 753 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 754 | ** retry counts and intervals for certain disk I/O operations for the |
| 755 | ** windows [VFS] in order to work to provide robustness against |
| 756 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 757 | ** file write, and file delete operations up to 10 times, with a delay |
| 758 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 759 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 760 | ** opcode allows those to values (10 retries and 25 milliseconds of delay) |
| 761 | ** to be adjusted. The values are changed for all database connections |
| 762 | ** within the same process. The argument is a pointer to an array of two |
| 763 | ** integers where the first integer i the new retry count and the second |
| 764 | ** integer is the delay. If either integer is negative, then the setting |
| 765 | ** is not changed but instead the prior value of that setting is written |
| @@ -870,11 +867,11 @@ | |
| 870 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 871 | ** is either a NULL pointer or string obtained |
| 872 | ** from xFullPathname() with an optional suffix added. |
| 873 | ** ^If a suffix is added to the zFilename parameter, it will |
| 874 | ** consist of a single "-" character followed by no more than |
| 875 | ** 10 alphanumeric and/or "-" characters. |
| 876 | ** ^SQLite further guarantees that |
| 877 | ** the string will be valid and unchanged until xClose() is |
| 878 | ** called. Because of the previous sentence, |
| 879 | ** the [sqlite3_file] can safely store a pointer to the |
| 880 | ** filename if it needs to remember the filename for some reason. |
| @@ -2021,11 +2018,11 @@ | |
| 2021 | ** These routines all implement some additional formatting |
| 2022 | ** options that are useful for constructing SQL statements. |
| 2023 | ** All of the usual printf() formatting options apply. In addition, there |
| 2024 | ** is are "%q", "%Q", and "%z" options. |
| 2025 | ** |
| 2026 | ** ^(The %q option works like %s in that it substitutes a null-terminated |
| 2027 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2028 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2029 | ** character it escapes that character and allows it to be inserted into |
| 2030 | ** the string. |
| 2031 | ** |
| @@ -3541,11 +3538,11 @@ | |
| 3541 | ** of the string. ^For clarity: the values returned by |
| 3542 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 3543 | ** bytes in the string, not the number of characters. |
| 3544 | ** |
| 3545 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 3546 | ** even empty strings, are always zero terminated. ^The return |
| 3547 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 3548 | ** |
| 3549 | ** ^The object returned by [sqlite3_column_value()] is an |
| 3550 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 3551 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -4621,11 +4618,11 @@ | |
| 4621 | SQLITE_API int sqlite3_release_memory(int); |
| 4622 | |
| 4623 | /* |
| 4624 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 4625 | ** |
| 4626 | ** ^The sqlite3_db_shrink(D) interface attempts to free as much heap |
| 4627 | ** memory as possible from database connection D. Unlike the |
| 4628 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 4629 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 4630 | ** omitted. |
| 4631 | ** |
| @@ -5404,19 +5401,19 @@ | |
| 5404 | ** is selected automatically at compile-time. ^(The following |
| 5405 | ** implementations are available in the SQLite core: |
| 5406 | ** |
| 5407 | ** <ul> |
| 5408 | ** <li> SQLITE_MUTEX_OS2 |
| 5409 | ** <li> SQLITE_MUTEX_PTHREAD |
| 5410 | ** <li> SQLITE_MUTEX_W32 |
| 5411 | ** <li> SQLITE_MUTEX_NOOP |
| 5412 | ** </ul>)^ |
| 5413 | ** |
| 5414 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5415 | ** that does no real locking and is appropriate for use in |
| 5416 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5417 | ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
| 5418 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5419 | ** |
| 5420 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5421 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5422 | ** implementation is included with the library. In this case the |
| @@ -5602,11 +5599,11 @@ | |
| 5602 | ** defined and if NDEBUG is not defined. |
| 5603 | ** |
| 5604 | ** ^These routines should return true if the mutex in their argument |
| 5605 | ** is held or not held, respectively, by the calling thread. |
| 5606 | ** |
| 5607 | ** ^The implementation is not required to provided versions of these |
| 5608 | ** routines that actually work. If the implementation does not provide working |
| 5609 | ** versions of these routines, it should at least provide stubs that always |
| 5610 | ** return true so that one does not get spurious assertion failures. |
| 5611 | ** |
| 5612 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6084,11 +6081,11 @@ | |
| 6084 | ** |
| 6085 | ** [[the xInit() page cache method]] |
| 6086 | ** ^(The xInit() method is called once for each effective |
| 6087 | ** call to [sqlite3_initialize()])^ |
| 6088 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6089 | ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ |
| 6090 | ** The intent of the xInit() method is to set up global data structures |
| 6091 | ** required by the custom page cache implementation. |
| 6092 | ** ^(If the xInit() method is NULL, then the |
| 6093 | ** built-in default page cache is used instead of the application defined |
| 6094 | ** page cache.)^ |
| @@ -6110,11 +6107,11 @@ | |
| 6110 | ** |
| 6111 | ** [[the xCreate() page cache methods]] |
| 6112 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6113 | ** SQLite will typically create one cache instance for each open database file, |
| 6114 | ** though this is not guaranteed. ^The |
| 6115 | ** parameter parameter, szPage, is the size in bytes of the pages that must |
| 6116 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6117 | ** second parameter szExtra is a number of bytes of extra storage |
| 6118 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6119 | ** a number less than 250. SQLite will use the |
| 6120 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6205,11 +6202,11 @@ | |
| 6205 | ** |
| 6206 | ** [[the xDestroy() page cache method]] |
| 6207 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6208 | ** All resources associated with the specified cache should be freed. ^After |
| 6209 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6210 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods |
| 6211 | ** functions. |
| 6212 | ** |
| 6213 | ** [[the xShrink() page cache method]] |
| 6214 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6215 | ** free up as much of heap memory as possible. The page cache implementation |
| 6216 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.10" |
| 111 | #define SQLITE_VERSION_NUMBER 3007010 |
| 112 | #define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -175,11 +175,11 @@ | |
| 175 | |
| 176 | /* |
| 177 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 178 | ** |
| 179 | ** ^The sqlite3_threadsafe() function returns zero if and only if |
| 180 | ** SQLite was compiled with mutexing code omitted due to the |
| 181 | ** [SQLITE_THREADSAFE] compile-time option being set to 0. |
| 182 | ** |
| 183 | ** SQLite can be compiled with or without mutexes. When |
| 184 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 185 | ** are enabled and SQLite is threadsafe. When the |
| @@ -369,11 +369,11 @@ | |
| 369 | ** CAPI3REF: Result Codes |
| 370 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 371 | ** KEYWORDS: {result code} {result codes} |
| 372 | ** |
| 373 | ** Many SQLite functions return an integer result code from the set shown |
| 374 | ** here in order to indicate success or failure. |
| 375 | ** |
| 376 | ** New error codes may be added in future versions of SQLite. |
| 377 | ** |
| 378 | ** See also: [SQLITE_IOERR_READ | extended result codes], |
| 379 | ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. |
| @@ -508,17 +508,14 @@ | |
| 508 | ** that when data is appended to a file, the data is appended |
| 509 | ** first then the size of the file is extended, never the other |
| 510 | ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
| 511 | ** information is written to disk in the same order as calls |
| 512 | ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
| 513 | ** after reboot following a crash or power loss, the only bytes in a |
| 514 | ** file that were written at the application level might have changed |
| 515 | ** and that adjacent bytes, even bytes within the same sector are |
| 516 | ** guaranteed to be unchanged. |
| 517 | */ |
| 518 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 519 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| 520 | #define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
| 521 | #define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
| @@ -750,16 +747,16 @@ | |
| 747 | ** opcode as doing so may disrupt the operation of the specialized VFSes |
| 748 | ** that do require it. |
| 749 | ** |
| 750 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| 751 | ** retry counts and intervals for certain disk I/O operations for the |
| 752 | ** windows [VFS] in order to provide robustness in the presence of |
| 753 | ** anti-virus programs. By default, the windows VFS will retry file read, |
| 754 | ** file write, and file delete operations up to 10 times, with a delay |
| 755 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 756 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 757 | ** opcode allows these two values (10 retries and 25 milliseconds of delay) |
| 758 | ** to be adjusted. The values are changed for all database connections |
| 759 | ** within the same process. The argument is a pointer to an array of two |
| 760 | ** integers where the first integer i the new retry count and the second |
| 761 | ** integer is the delay. If either integer is negative, then the setting |
| 762 | ** is not changed but instead the prior value of that setting is written |
| @@ -870,11 +867,11 @@ | |
| 867 | ** ^SQLite guarantees that the zFilename parameter to xOpen |
| 868 | ** is either a NULL pointer or string obtained |
| 869 | ** from xFullPathname() with an optional suffix added. |
| 870 | ** ^If a suffix is added to the zFilename parameter, it will |
| 871 | ** consist of a single "-" character followed by no more than |
| 872 | ** 11 alphanumeric and/or "-" characters. |
| 873 | ** ^SQLite further guarantees that |
| 874 | ** the string will be valid and unchanged until xClose() is |
| 875 | ** called. Because of the previous sentence, |
| 876 | ** the [sqlite3_file] can safely store a pointer to the |
| 877 | ** filename if it needs to remember the filename for some reason. |
| @@ -2021,11 +2018,11 @@ | |
| 2018 | ** These routines all implement some additional formatting |
| 2019 | ** options that are useful for constructing SQL statements. |
| 2020 | ** All of the usual printf() formatting options apply. In addition, there |
| 2021 | ** is are "%q", "%Q", and "%z" options. |
| 2022 | ** |
| 2023 | ** ^(The %q option works like %s in that it substitutes a nul-terminated |
| 2024 | ** string from the argument list. But %q also doubles every '\'' character. |
| 2025 | ** %q is designed for use inside a string literal.)^ By doubling each '\'' |
| 2026 | ** character it escapes that character and allows it to be inserted into |
| 2027 | ** the string. |
| 2028 | ** |
| @@ -3541,11 +3538,11 @@ | |
| 3538 | ** of the string. ^For clarity: the values returned by |
| 3539 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| 3540 | ** bytes in the string, not the number of characters. |
| 3541 | ** |
| 3542 | ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
| 3543 | ** even empty strings, are always zero-terminated. ^The return |
| 3544 | ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
| 3545 | ** |
| 3546 | ** ^The object returned by [sqlite3_column_value()] is an |
| 3547 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 3548 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| @@ -4621,11 +4618,11 @@ | |
| 4618 | SQLITE_API int sqlite3_release_memory(int); |
| 4619 | |
| 4620 | /* |
| 4621 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 4622 | ** |
| 4623 | ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap |
| 4624 | ** memory as possible from database connection D. Unlike the |
| 4625 | ** [sqlite3_release_memory()] interface, this interface is effect even |
| 4626 | ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 4627 | ** omitted. |
| 4628 | ** |
| @@ -5404,19 +5401,19 @@ | |
| 5401 | ** is selected automatically at compile-time. ^(The following |
| 5402 | ** implementations are available in the SQLite core: |
| 5403 | ** |
| 5404 | ** <ul> |
| 5405 | ** <li> SQLITE_MUTEX_OS2 |
| 5406 | ** <li> SQLITE_MUTEX_PTHREADS |
| 5407 | ** <li> SQLITE_MUTEX_W32 |
| 5408 | ** <li> SQLITE_MUTEX_NOOP |
| 5409 | ** </ul>)^ |
| 5410 | ** |
| 5411 | ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
| 5412 | ** that does no real locking and is appropriate for use in |
| 5413 | ** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
| 5414 | ** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations |
| 5415 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5416 | ** |
| 5417 | ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
| 5418 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5419 | ** implementation is included with the library. In this case the |
| @@ -5602,11 +5599,11 @@ | |
| 5599 | ** defined and if NDEBUG is not defined. |
| 5600 | ** |
| 5601 | ** ^These routines should return true if the mutex in their argument |
| 5602 | ** is held or not held, respectively, by the calling thread. |
| 5603 | ** |
| 5604 | ** ^The implementation is not required to provide versions of these |
| 5605 | ** routines that actually work. If the implementation does not provide working |
| 5606 | ** versions of these routines, it should at least provide stubs that always |
| 5607 | ** return true so that one does not get spurious assertion failures. |
| 5608 | ** |
| 5609 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| @@ -6084,11 +6081,11 @@ | |
| 6081 | ** |
| 6082 | ** [[the xInit() page cache method]] |
| 6083 | ** ^(The xInit() method is called once for each effective |
| 6084 | ** call to [sqlite3_initialize()])^ |
| 6085 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6086 | ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ |
| 6087 | ** The intent of the xInit() method is to set up global data structures |
| 6088 | ** required by the custom page cache implementation. |
| 6089 | ** ^(If the xInit() method is NULL, then the |
| 6090 | ** built-in default page cache is used instead of the application defined |
| 6091 | ** page cache.)^ |
| @@ -6110,11 +6107,11 @@ | |
| 6107 | ** |
| 6108 | ** [[the xCreate() page cache methods]] |
| 6109 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 6110 | ** SQLite will typically create one cache instance for each open database file, |
| 6111 | ** though this is not guaranteed. ^The |
| 6112 | ** first parameter, szPage, is the size in bytes of the pages that must |
| 6113 | ** be allocated by the cache. ^szPage will always a power of two. ^The |
| 6114 | ** second parameter szExtra is a number of bytes of extra storage |
| 6115 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6116 | ** a number less than 250. SQLite will use the |
| 6117 | ** extra szExtra bytes on each page to store metadata about the underlying |
| @@ -6205,11 +6202,11 @@ | |
| 6202 | ** |
| 6203 | ** [[the xDestroy() page cache method]] |
| 6204 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 6205 | ** All resources associated with the specified cache should be freed. ^After |
| 6206 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 6207 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods2 |
| 6208 | ** functions. |
| 6209 | ** |
| 6210 | ** [[the xShrink() page cache method]] |
| 6211 | ** ^SQLite invokes the xShrink() method when it wants the page cache to |
| 6212 | ** free up as much of heap memory as possible. The page cache implementation |
| 6213 |