Fossil SCM
Update the built-in SQLite sources to the latest 3.7.16.1 beta for the purpose of testing SQLite.
Commit
2e9be37f502f5d973250ecc019104517613033ec
Parent
79f7eb2fc5c906c…
2 files changed
+173
-168
+12
-8
+173
-168
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.7.16. By combining all the individual C code files into this | |
| 3 | +** version 3.7.16.1. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -676,13 +676,13 @@ | ||
| 676 | 676 | ** |
| 677 | 677 | ** See also: [sqlite3_libversion()], |
| 678 | 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | 680 | */ |
| 681 | -#define SQLITE_VERSION "3.7.16" | |
| 681 | +#define SQLITE_VERSION "3.7.16.1" | |
| 682 | 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | -#define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" | |
| 683 | +#define SQLITE_SOURCE_ID "2013-03-27 20:41:15 274d2a22660c7b34b8bbd85f3c29cbafbcb1b4e7" | |
| 684 | 684 | |
| 685 | 685 | /* |
| 686 | 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | 688 | ** |
| @@ -3249,11 +3249,11 @@ | ||
| 3249 | 3249 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 3250 | 3250 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 3251 | 3251 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 3252 | 3252 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 3253 | 3253 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 3254 | -** a URI filename, its value overrides any behaviour requested by setting | |
| 3254 | +** a URI filename, its value overrides any behavior requested by setting | |
| 3255 | 3255 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 3256 | 3256 | ** </ul> |
| 3257 | 3257 | ** |
| 3258 | 3258 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 3259 | 3259 | ** error. Future versions of SQLite might understand additional query |
| @@ -4567,11 +4567,12 @@ | ||
| 4567 | 4567 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 4568 | 4568 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 4569 | 4569 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 4570 | 4570 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4571 | 4571 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4572 | -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); | |
| 4572 | +SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), | |
| 4573 | + void*,sqlite3_int64); | |
| 4573 | 4574 | #endif |
| 4574 | 4575 | |
| 4575 | 4576 | /* |
| 4576 | 4577 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4577 | 4578 | ** |
| @@ -4647,18 +4648,21 @@ | ||
| 4647 | 4648 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4648 | 4649 | ** implementation is never called and xFinal() is called exactly once. |
| 4649 | 4650 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4650 | 4651 | ** first time from within xFinal().)^ |
| 4651 | 4652 | ** |
| 4652 | -** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is | |
| 4653 | -** less than or equal to zero or if a memory allocate error occurs. | |
| 4653 | +** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer | |
| 4654 | +** when first called if N is less than or equal to zero or if a memory | |
| 4655 | +** allocate error occurs. | |
| 4654 | 4656 | ** |
| 4655 | 4657 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4656 | 4658 | ** determined by the N parameter on first successful call. Changing the |
| 4657 | 4659 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4658 | 4660 | ** the same aggregate function instance will not resize the memory |
| 4659 | -** allocation.)^ | |
| 4661 | +** allocation.)^ Within the xFinal callback, it is customary to set | |
| 4662 | +** N=0 in calls to sqlite3_aggregate_context(C,N) so that no | |
| 4663 | +** pointless memory allocations occur. | |
| 4660 | 4664 | ** |
| 4661 | 4665 | ** ^SQLite automatically frees the memory allocated by |
| 4662 | 4666 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4663 | 4667 | ** |
| 4664 | 4668 | ** The first parameter must be a copy of the |
| @@ -6948,11 +6952,11 @@ | ||
| 6948 | 6952 | ** intact. If the requested page is not already in the cache, then the |
| 6949 | 6953 | ** cache implementation should use the value of the createFlag |
| 6950 | 6954 | ** parameter to help it determined what action to take: |
| 6951 | 6955 | ** |
| 6952 | 6956 | ** <table border=1 width=85% align=center> |
| 6953 | -** <tr><th> createFlag <th> Behaviour when page is not already in cache | |
| 6957 | +** <tr><th> createFlag <th> Behavior when page is not already in cache | |
| 6954 | 6958 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6955 | 6959 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6956 | 6960 | ** Otherwise return NULL. |
| 6957 | 6961 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6958 | 6962 | ** NULL if allocating a new page is effectively impossible. |
| @@ -7753,11 +7757,11 @@ | ||
| 7753 | 7757 | ** May you do good and not evil. |
| 7754 | 7758 | ** May you find forgiveness for yourself and forgive others. |
| 7755 | 7759 | ** May you share freely, never taking more than you give. |
| 7756 | 7760 | ** |
| 7757 | 7761 | ************************************************************************* |
| 7758 | -** This is the header file for the generic hash-table implemenation | |
| 7762 | +** This is the header file for the generic hash-table implementation | |
| 7759 | 7763 | ** used in SQLite. |
| 7760 | 7764 | */ |
| 7761 | 7765 | #ifndef _SQLITE_HASH_H_ |
| 7762 | 7766 | #define _SQLITE_HASH_H_ |
| 7763 | 7767 | |
| @@ -12943,13 +12947,10 @@ | ||
| 12943 | 12947 | "OMIT_LOOKASIDE", |
| 12944 | 12948 | #endif |
| 12945 | 12949 | #ifdef SQLITE_OMIT_MEMORYDB |
| 12946 | 12950 | "OMIT_MEMORYDB", |
| 12947 | 12951 | #endif |
| 12948 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 12949 | - "OMIT_MERGE_SORT", | |
| 12950 | -#endif | |
| 12951 | 12952 | #ifdef SQLITE_OMIT_OR_OPTIMIZATION |
| 12952 | 12953 | "OMIT_OR_OPTIMIZATION", |
| 12953 | 12954 | #endif |
| 12954 | 12955 | #ifdef SQLITE_OMIT_PAGER_PRAGMAS |
| 12955 | 12956 | "OMIT_PAGER_PRAGMAS", |
| @@ -13534,27 +13535,17 @@ | ||
| 13534 | 13535 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); |
| 13535 | 13536 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); |
| 13536 | 13537 | SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem); |
| 13537 | 13538 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 13538 | 13539 | |
| 13539 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 13540 | -# define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK | |
| 13541 | -# define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK | |
| 13542 | -# define sqlite3VdbeSorterClose(Y,Z) | |
| 13543 | -# define sqlite3VdbeSorterRowkey(Y,Z) SQLITE_OK | |
| 13544 | -# define sqlite3VdbeSorterRewind(X,Y,Z) SQLITE_OK | |
| 13545 | -# define sqlite3VdbeSorterNext(X,Y,Z) SQLITE_OK | |
| 13546 | -# define sqlite3VdbeSorterCompare(X,Y,Z) SQLITE_OK | |
| 13547 | -#else | |
| 13548 | 13540 | SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *); |
| 13549 | 13541 | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); |
| 13550 | 13542 | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); |
| 13551 | 13543 | SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *); |
| 13552 | 13544 | SQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *); |
| 13553 | 13545 | SQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *); |
| 13554 | 13546 | SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *); |
| 13555 | -#endif | |
| 13556 | 13547 | |
| 13557 | 13548 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 |
| 13558 | 13549 | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*); |
| 13559 | 13550 | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe*); |
| 13560 | 13551 | #else |
| @@ -21334,11 +21325,11 @@ | ||
| 21334 | 21325 | ** returns FALSE but it still converts the prefix and writes the result |
| 21335 | 21326 | ** into *pResult. |
| 21336 | 21327 | */ |
| 21337 | 21328 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 21338 | 21329 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 21339 | - int incr = (enc==SQLITE_UTF8?1:2); | |
| 21330 | + int incr; | |
| 21340 | 21331 | const char *zEnd = z + length; |
| 21341 | 21332 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 21342 | 21333 | int sign = 1; /* sign of significand */ |
| 21343 | 21334 | i64 s = 0; /* significand */ |
| 21344 | 21335 | int d = 0; /* adjust exponent for shifting decimal point */ |
| @@ -21345,14 +21336,26 @@ | ||
| 21345 | 21336 | int esign = 1; /* sign of exponent */ |
| 21346 | 21337 | int e = 0; /* exponent */ |
| 21347 | 21338 | int eValid = 1; /* True exponent is either not used or is well-formed */ |
| 21348 | 21339 | double result; |
| 21349 | 21340 | int nDigits = 0; |
| 21341 | + int nonNum = 0; | |
| 21350 | 21342 | |
| 21343 | + assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); | |
| 21351 | 21344 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 21352 | 21345 | |
| 21353 | - if( enc==SQLITE_UTF16BE ) z++; | |
| 21346 | + if( enc==SQLITE_UTF8 ){ | |
| 21347 | + incr = 1; | |
| 21348 | + }else{ | |
| 21349 | + int i; | |
| 21350 | + incr = 2; | |
| 21351 | + assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); | |
| 21352 | + for(i=3-enc; i<length && z[i]==0; i+=2){} | |
| 21353 | + nonNum = i<length; | |
| 21354 | + zEnd = z+i+enc-3; | |
| 21355 | + z += (enc&1); | |
| 21356 | + } | |
| 21354 | 21357 | |
| 21355 | 21358 | /* skip leading spaces */ |
| 21356 | 21359 | while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; |
| 21357 | 21360 | if( z>=zEnd ) return 0; |
| 21358 | 21361 | |
| @@ -21481,11 +21484,11 @@ | ||
| 21481 | 21484 | |
| 21482 | 21485 | /* store the result */ |
| 21483 | 21486 | *pResult = result; |
| 21484 | 21487 | |
| 21485 | 21488 | /* return true if number and no extra non-whitespace chracters after */ |
| 21486 | - return z>=zEnd && nDigits>0 && eValid; | |
| 21489 | + return z>=zEnd && nDigits>0 && eValid && nonNum==0; | |
| 21487 | 21490 | #else |
| 21488 | 21491 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 21489 | 21492 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 21490 | 21493 | } |
| 21491 | 21494 | |
| @@ -21530,25 +21533,37 @@ | ||
| 21530 | 21533 | ** If zNum is exactly 9223372036854665808, return 2. This special |
| 21531 | 21534 | ** case is broken out because while 9223372036854665808 cannot be a |
| 21532 | 21535 | ** signed 64-bit integer, its negative -9223372036854665808 can be. |
| 21533 | 21536 | ** |
| 21534 | 21537 | ** If zNum is too big for a 64-bit integer and is not |
| 21535 | -** 9223372036854665808 then return 1. | |
| 21538 | +** 9223372036854665808 or if zNum contains any non-numeric text, | |
| 21539 | +** then return 1. | |
| 21536 | 21540 | ** |
| 21537 | 21541 | ** length is the number of bytes in the string (bytes, not characters). |
| 21538 | 21542 | ** The string is not necessarily zero-terminated. The encoding is |
| 21539 | 21543 | ** given by enc. |
| 21540 | 21544 | */ |
| 21541 | 21545 | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ |
| 21542 | - int incr = (enc==SQLITE_UTF8?1:2); | |
| 21546 | + int incr; | |
| 21543 | 21547 | u64 u = 0; |
| 21544 | 21548 | int neg = 0; /* assume positive */ |
| 21545 | 21549 | int i; |
| 21546 | 21550 | int c = 0; |
| 21551 | + int nonNum = 0; | |
| 21547 | 21552 | const char *zStart; |
| 21548 | 21553 | const char *zEnd = zNum + length; |
| 21549 | - if( enc==SQLITE_UTF16BE ) zNum++; | |
| 21554 | + assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); | |
| 21555 | + if( enc==SQLITE_UTF8 ){ | |
| 21556 | + incr = 1; | |
| 21557 | + }else{ | |
| 21558 | + incr = 2; | |
| 21559 | + assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); | |
| 21560 | + for(i=3-enc; i<length && zNum[i]==0; i+=2){} | |
| 21561 | + nonNum = i<length; | |
| 21562 | + zEnd = zNum+i+enc-3; | |
| 21563 | + zNum += (enc&1); | |
| 21564 | + } | |
| 21550 | 21565 | while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr; |
| 21551 | 21566 | if( zNum<zEnd ){ |
| 21552 | 21567 | if( *zNum=='-' ){ |
| 21553 | 21568 | neg = 1; |
| 21554 | 21569 | zNum+=incr; |
| @@ -21569,11 +21584,11 @@ | ||
| 21569 | 21584 | *pNum = (i64)u; |
| 21570 | 21585 | } |
| 21571 | 21586 | testcase( i==18 ); |
| 21572 | 21587 | testcase( i==19 ); |
| 21573 | 21588 | testcase( i==20 ); |
| 21574 | - if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ | |
| 21589 | + if( (c+nonNum!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ | |
| 21575 | 21590 | /* zNum is empty or contains non-numeric text or is longer |
| 21576 | 21591 | ** than 19 digits (thus guaranteeing that it is too large) */ |
| 21577 | 21592 | return 1; |
| 21578 | 21593 | }else if( i<19*incr ){ |
| 21579 | 21594 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| @@ -23250,11 +23265,11 @@ | ||
| 23250 | 23265 | ** they may be overridden at runtime to facilitate fault injection during |
| 23251 | 23266 | ** testing and sandboxing. The following array holds the names and pointers |
| 23252 | 23267 | ** to all overrideable system calls. |
| 23253 | 23268 | */ |
| 23254 | 23269 | static struct unix_syscall { |
| 23255 | - const char *zName; /* Name of the sytem call */ | |
| 23270 | + const char *zName; /* Name of the system call */ | |
| 23256 | 23271 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 23257 | 23272 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 23258 | 23273 | } aSyscall[] = { |
| 23259 | 23274 | { "open", (sqlite3_syscall_ptr)posixOpen, 0 }, |
| 23260 | 23275 | #define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent) |
| @@ -24822,11 +24837,11 @@ | ||
| 24822 | 24837 | ******************************************************************************/ |
| 24823 | 24838 | |
| 24824 | 24839 | /****************************************************************************** |
| 24825 | 24840 | ************************* Begin dot-file Locking ****************************** |
| 24826 | 24841 | ** |
| 24827 | -** The dotfile locking implementation uses the existance of separate lock | |
| 24842 | +** The dotfile locking implementation uses the existence of separate lock | |
| 24828 | 24843 | ** files (really a directory) to control access to the database. This works |
| 24829 | 24844 | ** on just about every filesystem imaginable. But there are serious downsides: |
| 24830 | 24845 | ** |
| 24831 | 24846 | ** (1) There is zero concurrency. A single reader blocks all other |
| 24832 | 24847 | ** connections from reading or writing the database. |
| @@ -24837,11 +24852,11 @@ | ||
| 24837 | 24852 | ** Nevertheless, a dotlock is an appropriate locking mode for use if no |
| 24838 | 24853 | ** other locking strategy is available. |
| 24839 | 24854 | ** |
| 24840 | 24855 | ** Dotfile locking works by creating a subdirectory in the same directory as |
| 24841 | 24856 | ** the database and with the same name but with a ".lock" extension added. |
| 24842 | -** The existance of a lock directory implies an EXCLUSIVE lock. All other | |
| 24857 | +** The existence of a lock directory implies an EXCLUSIVE lock. All other | |
| 24843 | 24858 | ** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE. |
| 24844 | 24859 | */ |
| 24845 | 24860 | |
| 24846 | 24861 | /* |
| 24847 | 24862 | ** The file suffix added to the data base filename in order to create the |
| @@ -26326,11 +26341,11 @@ | ||
| 26326 | 26341 | pFile->lastErrno = errno; |
| 26327 | 26342 | return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath); |
| 26328 | 26343 | } |
| 26329 | 26344 | |
| 26330 | 26345 | /* Also fsync the directory containing the file if the DIRSYNC flag |
| 26331 | - ** is set. This is a one-time occurrance. Many systems (examples: AIX) | |
| 26346 | + ** is set. This is a one-time occurrence. Many systems (examples: AIX) | |
| 26332 | 26347 | ** are unable to fsync a directory, so ignore errors on the fsync. |
| 26333 | 26348 | */ |
| 26334 | 26349 | if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){ |
| 26335 | 26350 | int dirfd; |
| 26336 | 26351 | OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath, |
| @@ -27700,11 +27715,11 @@ | ||
| 27700 | 27715 | #endif |
| 27701 | 27716 | ){ |
| 27702 | 27717 | unixEnterMutex(); |
| 27703 | 27718 | rc = findInodeInfo(pNew, &pNew->pInode); |
| 27704 | 27719 | if( rc!=SQLITE_OK ){ |
| 27705 | - /* If an error occured in findInodeInfo(), close the file descriptor | |
| 27720 | + /* If an error occurred in findInodeInfo(), close the file descriptor | |
| 27706 | 27721 | ** immediately, before releasing the mutex. findInodeInfo() may fail |
| 27707 | 27722 | ** in two scenarios: |
| 27708 | 27723 | ** |
| 27709 | 27724 | ** (a) A call to fstat() failed. |
| 27710 | 27725 | ** (b) A malloc failed. |
| @@ -28338,11 +28353,11 @@ | ||
| 28338 | 28353 | #endif |
| 28339 | 28354 | return rc; |
| 28340 | 28355 | } |
| 28341 | 28356 | |
| 28342 | 28357 | /* |
| 28343 | -** Test the existance of or access permissions of file zPath. The | |
| 28358 | +** Test the existence of or access permissions of file zPath. The | |
| 28344 | 28359 | ** test performed depends on the value of flags: |
| 28345 | 28360 | ** |
| 28346 | 28361 | ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists |
| 28347 | 28362 | ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. |
| 28348 | 28363 | ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. |
| @@ -30442,11 +30457,11 @@ | ||
| 30442 | 30457 | ** they may be overridden at runtime to facilitate fault injection during |
| 30443 | 30458 | ** testing and sandboxing. The following array holds the names and pointers |
| 30444 | 30459 | ** to all overrideable system calls. |
| 30445 | 30460 | */ |
| 30446 | 30461 | static struct win_syscall { |
| 30447 | - const char *zName; /* Name of the sytem call */ | |
| 30462 | + const char *zName; /* Name of the system call */ | |
| 30448 | 30463 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 30449 | 30464 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 30450 | 30465 | } aSyscall[] = { |
| 30451 | 30466 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 30452 | 30467 | { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 }, |
| @@ -32159,11 +32174,11 @@ | ||
| 32159 | 32174 | |
| 32160 | 32175 | /* API oddity: If successful, SetFilePointer() returns a dword |
| 32161 | 32176 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 32162 | 32177 | ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, |
| 32163 | 32178 | ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine |
| 32164 | - ** whether an error has actually occured, it is also necessary to call | |
| 32179 | + ** whether an error has actually occurred, it is also necessary to call | |
| 32165 | 32180 | ** GetLastError(). |
| 32166 | 32181 | */ |
| 32167 | 32182 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 32168 | 32183 | |
| 32169 | 32184 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -32305,11 +32320,11 @@ | ||
| 32305 | 32320 | sqlite3_file *id, /* File to write into */ |
| 32306 | 32321 | const void *pBuf, /* The bytes to be written */ |
| 32307 | 32322 | int amt, /* Number of bytes to write */ |
| 32308 | 32323 | sqlite3_int64 offset /* Offset into the file to begin writing at */ |
| 32309 | 32324 | ){ |
| 32310 | - int rc = 0; /* True if error has occured, else false */ | |
| 32325 | + int rc = 0; /* True if error has occurred, else false */ | |
| 32311 | 32326 | winFile *pFile = (winFile*)id; /* File handle */ |
| 32312 | 32327 | int nRetry = 0; /* Number of retries */ |
| 32313 | 32328 | |
| 32314 | 32329 | assert( amt>0 ); |
| 32315 | 32330 | assert( pFile ); |
| @@ -34127,11 +34142,11 @@ | ||
| 34127 | 34142 | OSTRACE(("DELETE \"%s\" %s\n", zFilename, (rc ? "failed" : "ok" ))); |
| 34128 | 34143 | return rc; |
| 34129 | 34144 | } |
| 34130 | 34145 | |
| 34131 | 34146 | /* |
| 34132 | -** Check the existance and status of a file. | |
| 34147 | +** Check the existence and status of a file. | |
| 34133 | 34148 | */ |
| 34134 | 34149 | static int winAccess( |
| 34135 | 34150 | sqlite3_vfs *pVfs, /* Not used on win32 */ |
| 34136 | 34151 | const char *zFilename, /* Name of file to check */ |
| 34137 | 34152 | int flags, /* Type of test to make on this file */ |
| @@ -34736,11 +34751,11 @@ | ||
| 34736 | 34751 | |
| 34737 | 34752 | |
| 34738 | 34753 | /* |
| 34739 | 34754 | ** A bitmap is an instance of the following structure. |
| 34740 | 34755 | ** |
| 34741 | -** This bitmap records the existance of zero or more bits | |
| 34756 | +** This bitmap records the existence of zero or more bits | |
| 34742 | 34757 | ** with values between 1 and iSize, inclusive. |
| 34743 | 34758 | ** |
| 34744 | 34759 | ** There are three possible representations of the bitmap. |
| 34745 | 34760 | ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight |
| 34746 | 34761 | ** bitmap. The least significant bit is bit 1. |
| @@ -37638,11 +37653,11 @@ | ||
| 37638 | 37653 | ** layer must either commit or rollback the transaction. |
| 37639 | 37654 | ** |
| 37640 | 37655 | ** * A write transaction is active. |
| 37641 | 37656 | ** * An EXCLUSIVE or greater lock is held on the database file. |
| 37642 | 37657 | ** * All writing and syncing of journal and database data has finished. |
| 37643 | -** If no error occured, all that remains is to finalize the journal to | |
| 37658 | +** If no error occurred, all that remains is to finalize the journal to | |
| 37644 | 37659 | ** commit the transaction. If an error did occur, the caller will need |
| 37645 | 37660 | ** to rollback the transaction. |
| 37646 | 37661 | ** |
| 37647 | 37662 | ** ERROR: |
| 37648 | 37663 | ** |
| @@ -37886,11 +37901,11 @@ | ||
| 37886 | 37901 | ** journal file from being successfully finalized, the setMaster flag |
| 37887 | 37902 | ** is cleared anyway (and the pager will move to ERROR state). |
| 37888 | 37903 | ** |
| 37889 | 37904 | ** doNotSpill, doNotSyncSpill |
| 37890 | 37905 | ** |
| 37891 | -** These two boolean variables control the behaviour of cache-spills | |
| 37906 | +** These two boolean variables control the behavior of cache-spills | |
| 37892 | 37907 | ** (calls made by the pcache module to the pagerStress() routine to |
| 37893 | 37908 | ** write cached data to the file-system in order to free up memory). |
| 37894 | 37909 | ** |
| 37895 | 37910 | ** When doNotSpill is non-zero, writing to the database from pagerStress() |
| 37896 | 37911 | ** is disabled altogether. This is done in a very obscure case that |
| @@ -38764,11 +38779,11 @@ | ||
| 38764 | 38779 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 38765 | 38780 | }else{ |
| 38766 | 38781 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 38767 | 38782 | } |
| 38768 | 38783 | |
| 38769 | - /* The random check-hash initialiser */ | |
| 38784 | + /* The random check-hash initializer */ | |
| 38770 | 38785 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); |
| 38771 | 38786 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 38772 | 38787 | /* The initial database size */ |
| 38773 | 38788 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 38774 | 38789 | /* The assumed sector size for this process */ |
| @@ -41096,11 +41111,11 @@ | ||
| 41096 | 41111 | ** |
| 41097 | 41112 | ** If the condition asserted by this function were not true, and the |
| 41098 | 41113 | ** dirty page were to be discarded from the cache via the pagerStress() |
| 41099 | 41114 | ** routine, pagerStress() would not write the current page content to |
| 41100 | 41115 | ** the database file. If a savepoint transaction were rolled back after |
| 41101 | -** this happened, the correct behaviour would be to restore the current | |
| 41116 | +** this happened, the correct behavior would be to restore the current | |
| 41102 | 41117 | ** content of the page. However, since this content is not present in either |
| 41103 | 41118 | ** the database file or the portion of the rollback journal and |
| 41104 | 41119 | ** sub-journal rolled back the content could not be restored and the |
| 41105 | 41120 | ** database image would become corrupt. It is therefore fortunate that |
| 41106 | 41121 | ** this circumstance cannot arise. |
| @@ -48938,10 +48953,23 @@ | ||
| 48938 | 48953 | */ |
| 48939 | 48954 | static void btreeClearHasContent(BtShared *pBt){ |
| 48940 | 48955 | sqlite3BitvecDestroy(pBt->pHasContent); |
| 48941 | 48956 | pBt->pHasContent = 0; |
| 48942 | 48957 | } |
| 48958 | + | |
| 48959 | +/* | |
| 48960 | +** Release all of the apPage[] pages for a cursor. | |
| 48961 | +*/ | |
| 48962 | +static void btreeReleaseAllCursorPages(BtCursor *pCur){ | |
| 48963 | + int i; | |
| 48964 | + for(i=0; i<=pCur->iPage; i++){ | |
| 48965 | + releasePage(pCur->apPage[i]); | |
| 48966 | + pCur->apPage[i] = 0; | |
| 48967 | + } | |
| 48968 | + pCur->iPage = -1; | |
| 48969 | +} | |
| 48970 | + | |
| 48943 | 48971 | |
| 48944 | 48972 | /* |
| 48945 | 48973 | ** Save the current cursor position in the variables BtCursor.nKey |
| 48946 | 48974 | ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. |
| 48947 | 48975 | ** |
| @@ -48978,16 +49006,11 @@ | ||
| 48978 | 49006 | } |
| 48979 | 49007 | } |
| 48980 | 49008 | assert( !pCur->apPage[0]->intKey || !pCur->pKey ); |
| 48981 | 49009 | |
| 48982 | 49010 | if( rc==SQLITE_OK ){ |
| 48983 | - int i; | |
| 48984 | - for(i=0; i<=pCur->iPage; i++){ | |
| 48985 | - releasePage(pCur->apPage[i]); | |
| 48986 | - pCur->apPage[i] = 0; | |
| 48987 | - } | |
| 48988 | - pCur->iPage = -1; | |
| 49011 | + btreeReleaseAllCursorPages(pCur); | |
| 48989 | 49012 | pCur->eState = CURSOR_REQUIRESEEK; |
| 48990 | 49013 | } |
| 48991 | 49014 | |
| 48992 | 49015 | invalidateOverflowCache(pCur); |
| 48993 | 49016 | return rc; |
| @@ -49001,15 +49024,19 @@ | ||
| 49001 | 49024 | static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){ |
| 49002 | 49025 | BtCursor *p; |
| 49003 | 49026 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 49004 | 49027 | assert( pExcept==0 || pExcept->pBt==pBt ); |
| 49005 | 49028 | for(p=pBt->pCursor; p; p=p->pNext){ |
| 49006 | - if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) && | |
| 49007 | - p->eState==CURSOR_VALID ){ | |
| 49008 | - int rc = saveCursorPosition(p); | |
| 49009 | - if( SQLITE_OK!=rc ){ | |
| 49010 | - return rc; | |
| 49029 | + if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){ | |
| 49030 | + if( p->eState==CURSOR_VALID ){ | |
| 49031 | + int rc = saveCursorPosition(p); | |
| 49032 | + if( SQLITE_OK!=rc ){ | |
| 49033 | + return rc; | |
| 49034 | + } | |
| 49035 | + }else{ | |
| 49036 | + testcase( p->iPage>0 ); | |
| 49037 | + btreeReleaseAllCursorPages(p); | |
| 49011 | 49038 | } |
| 49012 | 49039 | } |
| 49013 | 49040 | } |
| 49014 | 49041 | return SQLITE_OK; |
| 49015 | 49042 | } |
| @@ -50593,11 +50620,11 @@ | ||
| 50593 | 50620 | ** |
| 50594 | 50621 | ** This is useful in one special case in the backup API code where it is |
| 50595 | 50622 | ** known that the shared b-tree mutex is held, but the mutex on the |
| 50596 | 50623 | ** database handle that owns *p is not. In this case if sqlite3BtreeEnter() |
| 50597 | 50624 | ** were to be called, it might collide with some other operation on the |
| 50598 | -** database handle that owns *p, causing undefined behaviour. | |
| 50625 | +** database handle that owns *p, causing undefined behavior. | |
| 50599 | 50626 | */ |
| 50600 | 50627 | SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){ |
| 50601 | 50628 | assert( sqlite3_mutex_held(p->pBt->mutex) ); |
| 50602 | 50629 | return p->pBt->pageSize - p->pBt->usableSize; |
| 50603 | 50630 | } |
| @@ -53873,11 +53900,11 @@ | ||
| 53873 | 53900 | ** for that page now. |
| 53874 | 53901 | ** |
| 53875 | 53902 | ** If this is the first overflow page, then write a partial entry |
| 53876 | 53903 | ** to the pointer-map. If we write nothing to this pointer-map slot, |
| 53877 | 53904 | ** then the optimistic overflow chain processing in clearCell() |
| 53878 | - ** may misinterpret the uninitialised values and delete the | |
| 53905 | + ** may misinterpret the uninitialized values and delete the | |
| 53879 | 53906 | ** wrong pages from the database. |
| 53880 | 53907 | */ |
| 53881 | 53908 | if( pBt->autoVacuum && rc==SQLITE_OK ){ |
| 53882 | 53909 | u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1); |
| 53883 | 53910 | ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc); |
| @@ -55346,11 +55373,11 @@ | ||
| 55346 | 55373 | assert( pPage->leaf ); |
| 55347 | 55374 | } |
| 55348 | 55375 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 55349 | 55376 | assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); |
| 55350 | 55377 | |
| 55351 | - /* If no error has occured and pPage has an overflow cell, call balance() | |
| 55378 | + /* If no error has occurred and pPage has an overflow cell, call balance() | |
| 55352 | 55379 | ** to redistribute the cells within the tree. Since balance() may move |
| 55353 | 55380 | ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey |
| 55354 | 55381 | ** variables. |
| 55355 | 55382 | ** |
| 55356 | 55383 | ** Previous versions of SQLite called moveToRoot() to move the cursor |
| @@ -59080,11 +59107,11 @@ | ||
| 59080 | 59107 | break; |
| 59081 | 59108 | } |
| 59082 | 59109 | } |
| 59083 | 59110 | sqlite3DbFree(v->db, sIter.apSub); |
| 59084 | 59111 | |
| 59085 | - /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. | |
| 59112 | + /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred. | |
| 59086 | 59113 | ** If malloc failed, then the while() loop above may not have iterated |
| 59087 | 59114 | ** through all opcodes and hasAbort may be set incorrectly. Return |
| 59088 | 59115 | ** true for this case to prevent the assert() in the callers frame |
| 59089 | 59116 | ** from failing. */ |
| 59090 | 59117 | return ( v->db->mallocFailed || hasAbort==mayAbort ); |
| @@ -60712,11 +60739,11 @@ | ||
| 60712 | 60739 | sqlite3 *const db = p->db; |
| 60713 | 60740 | int rc = SQLITE_OK; |
| 60714 | 60741 | |
| 60715 | 60742 | /* If p->iStatement is greater than zero, then this Vdbe opened a |
| 60716 | 60743 | ** statement transaction that should be closed here. The only exception |
| 60717 | - ** is that an IO error may have occured, causing an emergency rollback. | |
| 60744 | + ** is that an IO error may have occurred, causing an emergency rollback. | |
| 60718 | 60745 | ** In this case (db->nStatement==0), and there is nothing to do. |
| 60719 | 60746 | */ |
| 60720 | 60747 | if( db->nStatement && p->iStatement ){ |
| 60721 | 60748 | int i; |
| 60722 | 60749 | const int iSavepoint = p->iStatement-1; |
| @@ -60848,11 +60875,11 @@ | ||
| 60848 | 60875 | ** transaction must be rolled back to restore the database to a |
| 60849 | 60876 | ** consistent state. |
| 60850 | 60877 | ** |
| 60851 | 60878 | ** Even if the statement is read-only, it is important to perform |
| 60852 | 60879 | ** a statement or transaction rollback operation. If the error |
| 60853 | - ** occured while writing to the journal, sub-journal or database | |
| 60880 | + ** occurred while writing to the journal, sub-journal or database | |
| 60854 | 60881 | ** file as part of an effort to free up cache space (see function |
| 60855 | 60882 | ** pagerStress() in pager.c), the rollback is required to restore |
| 60856 | 60883 | ** the pager to a consistent state. |
| 60857 | 60884 | */ |
| 60858 | 60885 | if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){ |
| @@ -61262,11 +61289,11 @@ | ||
| 61262 | 61289 | ** |
| 61263 | 61290 | ** In an SQLite index record, the serial type is stored directly before |
| 61264 | 61291 | ** the blob of data that it corresponds to. In a table record, all serial |
| 61265 | 61292 | ** types are stored at the start of the record, and the blobs of data at |
| 61266 | 61293 | ** the end. Hence these functions allow the caller to handle the |
| 61267 | -** serial-type and data blob seperately. | |
| 61294 | +** serial-type and data blob separately. | |
| 61268 | 61295 | ** |
| 61269 | 61296 | ** The following table describes the various storage classes for data: |
| 61270 | 61297 | ** |
| 61271 | 61298 | ** serial type bytes of data type |
| 61272 | 61299 | ** -------------- --------------- --------------- |
| @@ -62402,11 +62429,11 @@ | ||
| 62402 | 62429 | || rc==SQLITE_BUSY || rc==SQLITE_MISUSE |
| 62403 | 62430 | ); |
| 62404 | 62431 | assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); |
| 62405 | 62432 | if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ |
| 62406 | 62433 | /* If this statement was prepared using sqlite3_prepare_v2(), and an |
| 62407 | - ** error has occured, then return the error code in p->rc to the | |
| 62434 | + ** error has occurred, then return the error code in p->rc to the | |
| 62408 | 62435 | ** caller. Set the error code in the database handle to the same value. |
| 62409 | 62436 | */ |
| 62410 | 62437 | rc = sqlite3VdbeTransferError(p); |
| 62411 | 62438 | } |
| 62412 | 62439 | return (rc&db->errMask); |
| @@ -63692,15 +63719,11 @@ | ||
| 63692 | 63719 | #define Deephemeralize(P) \ |
| 63693 | 63720 | if( ((P)->flags&MEM_Ephem)!=0 \ |
| 63694 | 63721 | && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} |
| 63695 | 63722 | |
| 63696 | 63723 | /* Return true if the cursor was opened using the OP_OpenSorter opcode. */ |
| 63697 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 63698 | -# define isSorter(x) 0 | |
| 63699 | -#else | |
| 63700 | 63724 | # define isSorter(x) ((x)->pSorter!=0) |
| 63701 | -#endif | |
| 63702 | 63725 | |
| 63703 | 63726 | /* |
| 63704 | 63727 | ** Argument pMem points at a register that will be passed to a |
| 63705 | 63728 | ** user-defined function or returned to the user as the result of a query. |
| 63706 | 63729 | ** This routine sets the pMem->type variable used by the sqlite3_value_*() |
| @@ -67433,21 +67456,16 @@ | ||
| 67433 | 67456 | case OP_SorterOpen: { |
| 67434 | 67457 | #if 0 /* local variables moved into u.ba */ |
| 67435 | 67458 | VdbeCursor *pCx; |
| 67436 | 67459 | #endif /* local variables moved into u.ba */ |
| 67437 | 67460 | |
| 67438 | -#ifndef SQLITE_OMIT_MERGE_SORT | |
| 67439 | 67461 | u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 67440 | 67462 | if( u.ba.pCx==0 ) goto no_mem; |
| 67441 | 67463 | u.ba.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 67442 | 67464 | u.ba.pCx->pKeyInfo->enc = ENC(p->db); |
| 67443 | 67465 | u.ba.pCx->isSorter = 1; |
| 67444 | 67466 | rc = sqlite3VdbeSorterInit(db, u.ba.pCx); |
| 67445 | -#else | |
| 67446 | - pOp->opcode = OP_OpenEphemeral; | |
| 67447 | - pc--; | |
| 67448 | -#endif | |
| 67449 | 67467 | break; |
| 67450 | 67468 | } |
| 67451 | 67469 | |
| 67452 | 67470 | /* Opcode: OpenPseudo P1 P2 P3 * P5 |
| 67453 | 67471 | ** |
| @@ -68348,19 +68366,14 @@ | ||
| 68348 | 68366 | case OP_SorterData: { |
| 68349 | 68367 | #if 0 /* local variables moved into u.bl */ |
| 68350 | 68368 | VdbeCursor *pC; |
| 68351 | 68369 | #endif /* local variables moved into u.bl */ |
| 68352 | 68370 | |
| 68353 | -#ifndef SQLITE_OMIT_MERGE_SORT | |
| 68354 | 68371 | pOut = &aMem[pOp->p2]; |
| 68355 | 68372 | u.bl.pC = p->apCsr[pOp->p1]; |
| 68356 | 68373 | assert( u.bl.pC->isSorter ); |
| 68357 | 68374 | rc = sqlite3VdbeSorterRowkey(u.bl.pC, pOut); |
| 68358 | -#else | |
| 68359 | - pOp->opcode = OP_RowKey; | |
| 68360 | - pc--; | |
| 68361 | -#endif | |
| 68362 | 68375 | break; |
| 68363 | 68376 | } |
| 68364 | 68377 | |
| 68365 | 68378 | /* Opcode: RowData P1 P2 * * * |
| 68366 | 68379 | ** |
| @@ -68563,13 +68576,10 @@ | ||
| 68563 | 68576 | ** rewinding so that the global variable will be incremented and |
| 68564 | 68577 | ** regression tests can determine whether or not the optimizer is |
| 68565 | 68578 | ** correctly optimizing out sorts. |
| 68566 | 68579 | */ |
| 68567 | 68580 | case OP_SorterSort: /* jump */ |
| 68568 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 68569 | - pOp->opcode = OP_Sort; | |
| 68570 | -#endif | |
| 68571 | 68581 | case OP_Sort: { /* jump */ |
| 68572 | 68582 | #ifdef SQLITE_TEST |
| 68573 | 68583 | sqlite3_sort_count++; |
| 68574 | 68584 | sqlite3_search_count--; |
| 68575 | 68585 | #endif |
| @@ -68646,13 +68656,10 @@ | ||
| 68646 | 68656 | ** |
| 68647 | 68657 | ** If P5 is positive and the jump is taken, then event counter |
| 68648 | 68658 | ** number P5-1 in the prepared statement is incremented. |
| 68649 | 68659 | */ |
| 68650 | 68660 | case OP_SorterNext: /* jump */ |
| 68651 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 68652 | - pOp->opcode = OP_Next; | |
| 68653 | -#endif | |
| 68654 | 68661 | case OP_Prev: /* jump */ |
| 68655 | 68662 | case OP_Next: { /* jump */ |
| 68656 | 68663 | #if 0 /* local variables moved into u.br */ |
| 68657 | 68664 | VdbeCursor *pC; |
| 68658 | 68665 | int res; |
| @@ -68701,13 +68708,10 @@ | ||
| 68701 | 68708 | ** |
| 68702 | 68709 | ** This instruction only works for indices. The equivalent instruction |
| 68703 | 68710 | ** for tables is OP_Insert. |
| 68704 | 68711 | */ |
| 68705 | 68712 | case OP_SorterInsert: /* in2 */ |
| 68706 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 68707 | - pOp->opcode = OP_IdxInsert; | |
| 68708 | -#endif | |
| 68709 | 68713 | case OP_IdxInsert: { /* in2 */ |
| 68710 | 68714 | #if 0 /* local variables moved into u.bs */ |
| 68711 | 68715 | VdbeCursor *pC; |
| 68712 | 68716 | BtCursor *pCrsr; |
| 68713 | 68717 | int nKey; |
| @@ -69972,11 +69976,11 @@ | ||
| 69972 | 69976 | importVtabErrMsg(p, u.cm.pVtab); |
| 69973 | 69977 | if( SQLITE_OK==rc ){ |
| 69974 | 69978 | /* Initialize sqlite3_vtab_cursor base class */ |
| 69975 | 69979 | u.cm.pVtabCursor->pVtab = u.cm.pVtab; |
| 69976 | 69980 | |
| 69977 | - /* Initialise vdbe cursor object */ | |
| 69981 | + /* Initialize vdbe cursor object */ | |
| 69978 | 69982 | u.cm.pCur = allocateCursor(p, pOp->p1, 0, -1, 0); |
| 69979 | 69983 | if( u.cm.pCur ){ |
| 69980 | 69984 | u.cm.pCur->pVtabCursor = u.cm.pVtabCursor; |
| 69981 | 69985 | u.cm.pCur->pModule = u.cm.pVtabCursor->pVtab->pModule; |
| 69982 | 69986 | }else{ |
| @@ -70954,11 +70958,10 @@ | ||
| 70954 | 70958 | ** example, by CREATE INDEX statements on tables too large to fit in main |
| 70955 | 70959 | ** memory). |
| 70956 | 70960 | */ |
| 70957 | 70961 | |
| 70958 | 70962 | |
| 70959 | -#ifndef SQLITE_OMIT_MERGE_SORT | |
| 70960 | 70963 | |
| 70961 | 70964 | typedef struct VdbeSorterIter VdbeSorterIter; |
| 70962 | 70965 | typedef struct SorterRecord SorterRecord; |
| 70963 | 70966 | typedef struct FileWriter FileWriter; |
| 70964 | 70967 | |
| @@ -71974,12 +71977,10 @@ | ||
| 71974 | 71977 | pKey = vdbeSorterRowkey(pSorter, &nKey); |
| 71975 | 71978 | vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes); |
| 71976 | 71979 | return SQLITE_OK; |
| 71977 | 71980 | } |
| 71978 | 71981 | |
| 71979 | -#endif /* #ifndef SQLITE_OMIT_MERGE_SORT */ | |
| 71980 | - | |
| 71981 | 71982 | /************** End of vdbesort.c ********************************************/ |
| 71982 | 71983 | /************** Begin file journal.c *****************************************/ |
| 71983 | 71984 | /* |
| 71984 | 71985 | ** 2007 August 22 |
| 71985 | 71986 | ** |
| @@ -77513,11 +77514,11 @@ | ||
| 77513 | 77514 | int regFree1 = 0; |
| 77514 | 77515 | int regFree2 = 0; |
| 77515 | 77516 | int r1, r2; |
| 77516 | 77517 | |
| 77517 | 77518 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77518 | - if( NEVER(v==0) ) return; /* Existance of VDBE checked by caller */ | |
| 77519 | + if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */ | |
| 77519 | 77520 | if( NEVER(pExpr==0) ) return; /* No way this can happen */ |
| 77520 | 77521 | op = pExpr->op; |
| 77521 | 77522 | switch( op ){ |
| 77522 | 77523 | case TK_AND: { |
| 77523 | 77524 | int d2 = sqlite3VdbeMakeLabel(v); |
| @@ -77633,11 +77634,11 @@ | ||
| 77633 | 77634 | int regFree1 = 0; |
| 77634 | 77635 | int regFree2 = 0; |
| 77635 | 77636 | int r1, r2; |
| 77636 | 77637 | |
| 77637 | 77638 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77638 | - if( NEVER(v==0) ) return; /* Existance of VDBE checked by caller */ | |
| 77639 | + if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */ | |
| 77639 | 77640 | if( pExpr==0 ) return; |
| 77640 | 77641 | |
| 77641 | 77642 | /* The value of pExpr->op and op are related as follows: |
| 77642 | 77643 | ** |
| 77643 | 77644 | ** pExpr->op op |
| @@ -80230,11 +80231,11 @@ | ||
| 80230 | 80231 | zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); |
| 80231 | 80232 | goto attach_error; |
| 80232 | 80233 | } |
| 80233 | 80234 | } |
| 80234 | 80235 | |
| 80235 | - /* Allocate the new entry in the db->aDb[] array and initialise the schema | |
| 80236 | + /* Allocate the new entry in the db->aDb[] array and initialize the schema | |
| 80236 | 80237 | ** hash tables. |
| 80237 | 80238 | */ |
| 80238 | 80239 | if( db->aDb==db->aDbStatic ){ |
| 80239 | 80240 | aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 ); |
| 80240 | 80241 | if( aNew==0 ) return; |
| @@ -80247,11 +80248,11 @@ | ||
| 80247 | 80248 | aNew = &db->aDb[db->nDb]; |
| 80248 | 80249 | memset(aNew, 0, sizeof(*aNew)); |
| 80249 | 80250 | |
| 80250 | 80251 | /* Open the database file. If the btree is successfully opened, use |
| 80251 | 80252 | ** it to obtain the database schema. At this point the schema may |
| 80252 | - ** or may not be initialised. | |
| 80253 | + ** or may not be initialized. | |
| 80253 | 80254 | */ |
| 80254 | 80255 | flags = db->openFlags; |
| 80255 | 80256 | rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr); |
| 80256 | 80257 | if( rc!=SQLITE_OK ){ |
| 80257 | 80258 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; |
| @@ -83033,11 +83034,11 @@ | ||
| 83033 | 83034 | #endif |
| 83034 | 83035 | |
| 83035 | 83036 | /* Drop all SQLITE_MASTER table and index entries that refer to the |
| 83036 | 83037 | ** table. The program name loops through the master table and deletes |
| 83037 | 83038 | ** every row that refers to a table of the same name as the one being |
| 83038 | - ** dropped. Triggers are handled seperately because a trigger can be | |
| 83039 | + ** dropped. Triggers are handled separately because a trigger can be | |
| 83039 | 83040 | ** created in the temp database that refers to a table in another |
| 83040 | 83041 | ** database. |
| 83041 | 83042 | */ |
| 83042 | 83043 | sqlite3NestedParse(pParse, |
| 83043 | 83044 | "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", |
| @@ -83325,13 +83326,10 @@ | ||
| 83325 | 83326 | int addr1; /* Address of top of loop */ |
| 83326 | 83327 | int addr2; /* Address to jump to for next iteration */ |
| 83327 | 83328 | int tnum; /* Root page of index */ |
| 83328 | 83329 | Vdbe *v; /* Generate code into this virtual machine */ |
| 83329 | 83330 | KeyInfo *pKey; /* KeyInfo for index */ |
| 83330 | -#ifdef SQLITE_OMIT_MERGE_SORT | |
| 83331 | - int regIdxKey; /* Registers containing the index key */ | |
| 83332 | -#endif | |
| 83333 | 83331 | int regRecord; /* Register holding assemblied index record */ |
| 83334 | 83332 | sqlite3 *db = pParse->db; /* The database connection */ |
| 83335 | 83333 | int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); |
| 83336 | 83334 | |
| 83337 | 83335 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -83355,25 +83353,20 @@ | ||
| 83355 | 83353 | pKey = sqlite3IndexKeyinfo(pParse, pIndex); |
| 83356 | 83354 | sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, |
| 83357 | 83355 | (char *)pKey, P4_KEYINFO_HANDOFF); |
| 83358 | 83356 | sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); |
| 83359 | 83357 | |
| 83360 | -#ifndef SQLITE_OMIT_MERGE_SORT | |
| 83361 | 83358 | /* Open the sorter cursor if we are to use one. */ |
| 83362 | 83359 | iSorter = pParse->nTab++; |
| 83363 | 83360 | sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); |
| 83364 | -#else | |
| 83365 | - iSorter = iTab; | |
| 83366 | -#endif | |
| 83367 | 83361 | |
| 83368 | 83362 | /* Open the table. Loop through all rows of the table, inserting index |
| 83369 | 83363 | ** records into the sorter. */ |
| 83370 | 83364 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 83371 | 83365 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 83372 | 83366 | regRecord = sqlite3GetTempReg(pParse); |
| 83373 | 83367 | |
| 83374 | -#ifndef SQLITE_OMIT_MERGE_SORT | |
| 83375 | 83368 | sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 83376 | 83369 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 83377 | 83370 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 83378 | 83371 | sqlite3VdbeJumpHere(v, addr1); |
| 83379 | 83372 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| @@ -83389,34 +83382,10 @@ | ||
| 83389 | 83382 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 83390 | 83383 | } |
| 83391 | 83384 | sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord); |
| 83392 | 83385 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1); |
| 83393 | 83386 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 83394 | -#else | |
| 83395 | - regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); | |
| 83396 | - addr2 = addr1 + 1; | |
| 83397 | - if( pIndex->onError!=OE_None ){ | |
| 83398 | - const int regRowid = regIdxKey + pIndex->nColumn; | |
| 83399 | - const int j2 = sqlite3VdbeCurrentAddr(v) + 2; | |
| 83400 | - void * const pRegKey = SQLITE_INT_TO_PTR(regIdxKey); | |
| 83401 | - | |
| 83402 | - /* The registers accessed by the OP_IsUnique opcode were allocated | |
| 83403 | - ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() | |
| 83404 | - ** call above. Just before that function was freed they were released | |
| 83405 | - ** (made available to the compiler for reuse) using | |
| 83406 | - ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique | |
| 83407 | - ** opcode use the values stored within seems dangerous. However, since | |
| 83408 | - ** we can be sure that no other temp registers have been allocated | |
| 83409 | - ** since sqlite3ReleaseTempRange() was called, it is safe to do so. | |
| 83410 | - */ | |
| 83411 | - sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32); | |
| 83412 | - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE, | |
| 83413 | - "indexed columns are not unique", P4_STATIC); | |
| 83414 | - } | |
| 83415 | - sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0); | |
| 83416 | - sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); | |
| 83417 | -#endif | |
| 83418 | 83387 | sqlite3ReleaseTempReg(pParse, regRecord); |
| 83419 | 83388 | sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); |
| 83420 | 83389 | sqlite3VdbeJumpHere(v, addr1); |
| 83421 | 83390 | |
| 83422 | 83391 | sqlite3VdbeAddOp1(v, OP_Close, iTab); |
| @@ -83772,11 +83741,11 @@ | ||
| 83772 | 83741 | /* This constraint creates the same index as a previous |
| 83773 | 83742 | ** constraint specified somewhere in the CREATE TABLE statement. |
| 83774 | 83743 | ** However the ON CONFLICT clauses are different. If both this |
| 83775 | 83744 | ** constraint and the previous equivalent constraint have explicit |
| 83776 | 83745 | ** ON CONFLICT clauses this is an error. Otherwise, use the |
| 83777 | - ** explicitly specified behaviour for the index. | |
| 83746 | + ** explicitly specified behavior for the index. | |
| 83778 | 83747 | */ |
| 83779 | 83748 | if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){ |
| 83780 | 83749 | sqlite3ErrorMsg(pParse, |
| 83781 | 83750 | "conflicting ON CONFLICT clauses specified", 0); |
| 83782 | 83751 | } |
| @@ -94054,11 +94023,11 @@ | ||
| 94054 | 94023 | assert( sqlite3_mutex_held(db->mutex) ); |
| 94055 | 94024 | assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); |
| 94056 | 94025 | |
| 94057 | 94026 | /* zMasterSchema and zInitScript are set to point at the master schema |
| 94058 | 94027 | ** and initialisation script appropriate for the database being |
| 94059 | - ** initialised. zMasterName is the name of the master table. | |
| 94028 | + ** initialized. zMasterName is the name of the master table. | |
| 94060 | 94029 | */ |
| 94061 | 94030 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 94062 | 94031 | zMasterSchema = temp_master_schema; |
| 94063 | 94032 | }else{ |
| 94064 | 94033 | zMasterSchema = master_schema; |
| @@ -94279,11 +94248,11 @@ | ||
| 94279 | 94248 | if( rc ){ |
| 94280 | 94249 | sqlite3ResetOneSchema(db, i); |
| 94281 | 94250 | } |
| 94282 | 94251 | } |
| 94283 | 94252 | |
| 94284 | - /* Once all the other databases have been initialised, load the schema | |
| 94253 | + /* Once all the other databases have been initialized, load the schema | |
| 94285 | 94254 | ** for the TEMP database. This is loaded last, as the TEMP database |
| 94286 | 94255 | ** schema may contain references to objects in other databases. |
| 94287 | 94256 | */ |
| 94288 | 94257 | #ifndef SQLITE_OMIT_TEMPDB |
| 94289 | 94258 | if( rc==SQLITE_OK && ALWAYS(db->nDb>1) |
| @@ -94302,11 +94271,11 @@ | ||
| 94302 | 94271 | |
| 94303 | 94272 | return rc; |
| 94304 | 94273 | } |
| 94305 | 94274 | |
| 94306 | 94275 | /* |
| 94307 | -** This routine is a no-op if the database schema is already initialised. | |
| 94276 | +** This routine is a no-op if the database schema is already initialized. | |
| 94308 | 94277 | ** Otherwise, the schema is loaded. An error code is returned. |
| 94309 | 94278 | */ |
| 94310 | 94279 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){ |
| 94311 | 94280 | int rc = SQLITE_OK; |
| 94312 | 94281 | sqlite3 *db = pParse->db; |
| @@ -99315,11 +99284,11 @@ | ||
| 99315 | 99284 | ** first iteration (since the first iteration of the loop is |
| 99316 | 99285 | ** guaranteed to operate on the row with the minimum or maximum |
| 99317 | 99286 | ** value of x, the only row required). |
| 99318 | 99287 | ** |
| 99319 | 99288 | ** A special flag must be passed to sqlite3WhereBegin() to slightly |
| 99320 | - ** modify behaviour as follows: | |
| 99289 | + ** modify behavior as follows: | |
| 99321 | 99290 | ** |
| 99322 | 99291 | ** + If the query is a "SELECT min(x)", then the loop coded by |
| 99323 | 99292 | ** where.c should not iterate over any values with a NULL value |
| 99324 | 99293 | ** for x. |
| 99325 | 99294 | ** |
| @@ -101308,11 +101277,11 @@ | ||
| 101308 | 101277 | sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, |
| 101309 | 101278 | TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); |
| 101310 | 101279 | |
| 101311 | 101280 | /* The row-trigger may have deleted the row being updated. In this |
| 101312 | 101281 | ** case, jump to the next row. No updates or AFTER triggers are |
| 101313 | - ** required. This behaviour - what happens when the row being updated | |
| 101282 | + ** required. This behavior - what happens when the row being updated | |
| 101314 | 101283 | ** is deleted or renamed by a BEFORE trigger - is left undefined in the |
| 101315 | 101284 | ** documentation. |
| 101316 | 101285 | */ |
| 101317 | 101286 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); |
| 101318 | 101287 | |
| @@ -103237,10 +103206,12 @@ | ||
| 103237 | 103206 | #define WHERE_IDX_ONLY 0x00400000 /* Use index only - omit table */ |
| 103238 | 103207 | #define WHERE_ORDERED 0x00800000 /* Output will appear in correct order */ |
| 103239 | 103208 | #define WHERE_REVERSE 0x01000000 /* Scan in reverse order */ |
| 103240 | 103209 | #define WHERE_UNIQUE 0x02000000 /* Selects no more than one row */ |
| 103241 | 103210 | #define WHERE_ALL_UNIQUE 0x04000000 /* This and all prior have one row */ |
| 103211 | +#define WHERE_OB_UNIQUE 0x00004000 /* Values in ORDER BY columns are | |
| 103212 | + ** different for every output row */ | |
| 103242 | 103213 | #define WHERE_VIRTUALTABLE 0x08000000 /* Use virtual-table processing */ |
| 103243 | 103214 | #define WHERE_MULTI_OR 0x10000000 /* OR using multiple indices */ |
| 103244 | 103215 | #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */ |
| 103245 | 103216 | #define WHERE_DISTINCT 0x40000000 /* Correct order for DISTINCT */ |
| 103246 | 103217 | #define WHERE_COVER_SCAN 0x80000000 /* Full scan of a covering index */ |
| @@ -103537,11 +103508,11 @@ | ||
| 103537 | 103508 | |
| 103538 | 103509 | /* |
| 103539 | 103510 | ** Commute a comparison operator. Expressions of the form "X op Y" |
| 103540 | 103511 | ** are converted into "Y op X". |
| 103541 | 103512 | ** |
| 103542 | -** If left/right precendence rules come into play when determining the | |
| 103513 | +** If left/right precedence rules come into play when determining the | |
| 103543 | 103514 | ** collating |
| 103544 | 103515 | ** side of the comparison, it remains associated with the same side after |
| 103545 | 103516 | ** the commutation. So "Y collate NOCASE op X" becomes |
| 103546 | 103517 | ** "X op Y". This is because any collation sequence on |
| 103547 | 103518 | ** the left hand side of a comparison overrides any collation sequence |
| @@ -105878,11 +105849,12 @@ | ||
| 105878 | 105849 | */ |
| 105879 | 105850 | static int isSortingIndex( |
| 105880 | 105851 | WhereBestIdx *p, /* Best index search context */ |
| 105881 | 105852 | Index *pIdx, /* The index we are testing */ |
| 105882 | 105853 | int base, /* Cursor number for the table to be sorted */ |
| 105883 | - int *pbRev /* Set to 1 for reverse-order scan of pIdx */ | |
| 105854 | + int *pbRev, /* Set to 1 for reverse-order scan of pIdx */ | |
| 105855 | + int *pbObUnique /* ORDER BY column values will different in every row */ | |
| 105884 | 105856 | ){ |
| 105885 | 105857 | int i; /* Number of pIdx terms used */ |
| 105886 | 105858 | int j; /* Number of ORDER BY terms satisfied */ |
| 105887 | 105859 | int sortOrder = 2; /* 0: forward. 1: backward. 2: unknown */ |
| 105888 | 105860 | int nTerm; /* Number of ORDER BY terms */ |
| @@ -105892,25 +105864,32 @@ | ||
| 105892 | 105864 | Parse *pParse = p->pParse; /* Parser context */ |
| 105893 | 105865 | sqlite3 *db = pParse->db; /* Database connection */ |
| 105894 | 105866 | int nPriorSat; /* ORDER BY terms satisfied by outer loops */ |
| 105895 | 105867 | int seenRowid = 0; /* True if an ORDER BY rowid term is seen */ |
| 105896 | 105868 | int uniqueNotNull; /* pIdx is UNIQUE with all terms are NOT NULL */ |
| 105869 | + int outerObUnique; /* Outer loops generate different values in | |
| 105870 | + ** every row for the ORDER BY columns */ | |
| 105897 | 105871 | |
| 105898 | 105872 | if( p->i==0 ){ |
| 105899 | 105873 | nPriorSat = 0; |
| 105874 | + outerObUnique = 1; | |
| 105900 | 105875 | }else{ |
| 105876 | + u32 wsFlags = p->aLevel[p->i-1].plan.wsFlags; | |
| 105901 | 105877 | nPriorSat = p->aLevel[p->i-1].plan.nOBSat; |
| 105902 | - if( (p->aLevel[p->i-1].plan.wsFlags & WHERE_ORDERED)==0 ){ | |
| 105878 | + if( (wsFlags & WHERE_ORDERED)==0 ){ | |
| 105903 | 105879 | /* This loop cannot be ordered unless the next outer loop is |
| 105904 | 105880 | ** also ordered */ |
| 105905 | 105881 | return nPriorSat; |
| 105906 | 105882 | } |
| 105907 | 105883 | if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){ |
| 105908 | 105884 | /* Only look at the outer-most loop if the OrderByIdxJoin |
| 105909 | 105885 | ** optimization is disabled */ |
| 105910 | 105886 | return nPriorSat; |
| 105911 | 105887 | } |
| 105888 | + testcase( wsFlags & WHERE_OB_UNIQUE ); | |
| 105889 | + testcase( wsFlags & WHERE_ALL_UNIQUE ); | |
| 105890 | + outerObUnique = (wsFlags & (WHERE_OB_UNIQUE|WHERE_ALL_UNIQUE))!=0; | |
| 105912 | 105891 | } |
| 105913 | 105892 | pOrderBy = p->pOrderBy; |
| 105914 | 105893 | assert( pOrderBy!=0 ); |
| 105915 | 105894 | if( pIdx->bUnordered ){ |
| 105916 | 105895 | /* Hash indices (indicated by the "unordered" tag on sqlite_stat1) cannot |
| @@ -106048,23 +106027,38 @@ | ||
| 106048 | 106027 | testcase( isEq==2 ); |
| 106049 | 106028 | testcase( isEq==3 ); |
| 106050 | 106029 | uniqueNotNull = 0; |
| 106051 | 106030 | } |
| 106052 | 106031 | } |
| 106032 | + if( seenRowid ){ | |
| 106033 | + uniqueNotNull = 1; | |
| 106034 | + }else if( uniqueNotNull==0 || i<pIdx->nColumn ){ | |
| 106035 | + uniqueNotNull = 0; | |
| 106036 | + } | |
| 106053 | 106037 | |
| 106054 | 106038 | /* If we have not found at least one ORDER BY term that matches the |
| 106055 | 106039 | ** index, then show no progress. */ |
| 106056 | 106040 | if( pOBItem==&pOrderBy->a[nPriorSat] ) return nPriorSat; |
| 106041 | + | |
| 106042 | + /* Either the outer queries must generate rows where there are no two | |
| 106043 | + ** rows with the same values in all ORDER BY columns, or else this | |
| 106044 | + ** loop must generate just a single row of output. Example: Suppose | |
| 106045 | + ** the outer loops generate A=1 and A=1, and this loop generates B=3 | |
| 106046 | + ** and B=4. Then without the following test, ORDER BY A,B would | |
| 106047 | + ** generate the wrong order output: 1,3 1,4 1,3 1,4 | |
| 106048 | + */ | |
| 106049 | + if( outerObUnique==0 && uniqueNotNull==0 ) return nPriorSat; | |
| 106050 | + *pbObUnique = uniqueNotNull; | |
| 106057 | 106051 | |
| 106058 | 106052 | /* Return the necessary scan order back to the caller */ |
| 106059 | 106053 | *pbRev = sortOrder & 1; |
| 106060 | 106054 | |
| 106061 | 106055 | /* If there was an "ORDER BY rowid" term that matched, or it is only |
| 106062 | 106056 | ** possible for a single row from this table to match, then skip over |
| 106063 | 106057 | ** any additional ORDER BY terms dealing with this table. |
| 106064 | 106058 | */ |
| 106065 | - if( seenRowid || (uniqueNotNull && i>=pIdx->nColumn) ){ | |
| 106059 | + if( uniqueNotNull ){ | |
| 106066 | 106060 | /* Advance j over additional ORDER BY terms associated with base */ |
| 106067 | 106061 | WhereMaskSet *pMS = p->pWC->pMaskSet; |
| 106068 | 106062 | Bitmask m = ~getMask(pMS, base); |
| 106069 | 106063 | while( j<nTerm && (exprTableUsage(pMS, pOrderBy->a[j].pExpr)&m)==0 ){ |
| 106070 | 106064 | j++; |
| @@ -106344,16 +106338,18 @@ | ||
| 106344 | 106338 | ** in pc.plan.wsFlags. Otherwise, if there is an ORDER BY clause but |
| 106345 | 106339 | ** the index will scan rows in a different order, set the bSort |
| 106346 | 106340 | ** variable. */ |
| 106347 | 106341 | if( bSort && (pSrc->jointype & JT_LEFT)==0 ){ |
| 106348 | 106342 | int bRev = 2; |
| 106349 | - WHERETRACE((" --> before isSortingIndex: nPriorSat=%d\n",nPriorSat)); | |
| 106350 | - pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev); | |
| 106351 | - WHERETRACE((" --> after isSortingIndex: bRev=%d nOBSat=%d\n", | |
| 106352 | - bRev, pc.plan.nOBSat)); | |
| 106343 | + int bObUnique = 0; | |
| 106344 | + WHERETRACE((" --> before isSortIndex: nPriorSat=%d\n",nPriorSat)); | |
| 106345 | + pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev, &bObUnique); | |
| 106346 | + WHERETRACE((" --> after isSortIndex: bRev=%d bObU=%d nOBSat=%d\n", | |
| 106347 | + bRev, bObUnique, pc.plan.nOBSat)); | |
| 106353 | 106348 | if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){ |
| 106354 | 106349 | pc.plan.wsFlags |= WHERE_ORDERED; |
| 106350 | + if( bObUnique ) pc.plan.wsFlags |= WHERE_OB_UNIQUE; | |
| 106355 | 106351 | } |
| 106356 | 106352 | if( nOrderBy==pc.plan.nOBSat ){ |
| 106357 | 106353 | bSort = 0; |
| 106358 | 106354 | pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE; |
| 106359 | 106355 | } |
| @@ -106443,11 +106439,12 @@ | ||
| 106443 | 106439 | ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do |
| 106444 | 106440 | ** not give us data on the relative sizes of table and index records. |
| 106445 | 106441 | ** So this computation assumes table records are about twice as big |
| 106446 | 106442 | ** as index records |
| 106447 | 106443 | */ |
| 106448 | - if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED))==WHERE_IDX_ONLY | |
| 106444 | + if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED|WHERE_OB_UNIQUE)) | |
| 106445 | + ==WHERE_IDX_ONLY | |
| 106449 | 106446 | && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 |
| 106450 | 106447 | && sqlite3GlobalConfig.bUseCis |
| 106451 | 106448 | && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan) |
| 106452 | 106449 | ){ |
| 106453 | 106450 | /* This index is not useful for indexing, but it is a covering index. |
| @@ -106603,11 +106600,11 @@ | ||
| 106603 | 106600 | } |
| 106604 | 106601 | |
| 106605 | 106602 | /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag |
| 106606 | 106603 | ** is set, then reverse the order that the index will be scanned |
| 106607 | 106604 | ** in. This is used for application testing, to help find cases |
| 106608 | - ** where application behaviour depends on the (undefined) order that | |
| 106605 | + ** where application behavior depends on the (undefined) order that | |
| 106609 | 106606 | ** SQLite outputs rows in in the absence of an ORDER BY clause. */ |
| 106610 | 106607 | if( !p->pOrderBy && pParse->db->flags & SQLITE_ReverseOrder ){ |
| 106611 | 106608 | p->cost.plan.wsFlags |= WHERE_REVERSE; |
| 106612 | 106609 | } |
| 106613 | 106610 | |
| @@ -114198,11 +114195,11 @@ | ||
| 114198 | 114195 | return; |
| 114199 | 114196 | } |
| 114200 | 114197 | |
| 114201 | 114198 | /* If we reach this point, it means that the database connection has |
| 114202 | 114199 | ** closed all sqlite3_stmt and sqlite3_backup objects and has been |
| 114203 | - ** pased to sqlite3_close (meaning that it is a zombie). Therefore, | |
| 114200 | + ** passed to sqlite3_close (meaning that it is a zombie). Therefore, | |
| 114204 | 114201 | ** go ahead and free all resources. |
| 114205 | 114202 | */ |
| 114206 | 114203 | |
| 114207 | 114204 | /* Free any outstanding Savepoint structures. */ |
| 114208 | 114205 | sqlite3CloseSavepoints(db); |
| @@ -117250,11 +117247,11 @@ | ||
| 117250 | 117247 | ** to the strings "arg1" and "arg2". |
| 117251 | 117248 | ** |
| 117252 | 117249 | ** This method should return either SQLITE_OK (0), or an SQLite error |
| 117253 | 117250 | ** code. If SQLITE_OK is returned, then *ppTokenizer should be set |
| 117254 | 117251 | ** to point at the newly created tokenizer structure. The generic |
| 117255 | - ** sqlite3_tokenizer.pModule variable should not be initialised by | |
| 117252 | + ** sqlite3_tokenizer.pModule variable should not be initialized by | |
| 117256 | 117253 | ** this callback. The caller will do so. |
| 117257 | 117254 | */ |
| 117258 | 117255 | int (*xCreate)( |
| 117259 | 117256 | int argc, /* Size of argv array */ |
| 117260 | 117257 | const char *const*argv, /* Tokenizer argument strings */ |
| @@ -117355,11 +117352,11 @@ | ||
| 117355 | 117352 | ** May you do good and not evil. |
| 117356 | 117353 | ** May you find forgiveness for yourself and forgive others. |
| 117357 | 117354 | ** May you share freely, never taking more than you give. |
| 117358 | 117355 | ** |
| 117359 | 117356 | ************************************************************************* |
| 117360 | -** This is the header file for the generic hash-table implemenation | |
| 117357 | +** This is the header file for the generic hash-table implementation | |
| 117361 | 117358 | ** used in SQLite. We've modified it slightly to serve as a standalone |
| 117362 | 117359 | ** hash table implementation for the full-text indexing module. |
| 117363 | 117360 | ** |
| 117364 | 117361 | */ |
| 117365 | 117362 | #ifndef _FTS3_HASH_H_ |
| @@ -119262,11 +119259,11 @@ | ||
| 119262 | 119259 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 119263 | 119260 | return SQLITE_OK; |
| 119264 | 119261 | }else{ |
| 119265 | 119262 | rc = sqlite3_reset(pCsr->pStmt); |
| 119266 | 119263 | if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ |
| 119267 | - /* If no row was found and no error has occured, then the %_content | |
| 119264 | + /* If no row was found and no error has occurred, then the %_content | |
| 119268 | 119265 | ** table is missing a row that is present in the full-text index. |
| 119269 | 119266 | ** The data structures are corrupt. */ |
| 119270 | 119267 | rc = FTS_CORRUPT_VTAB; |
| 119271 | 119268 | pCsr->isEof = 1; |
| 119272 | 119269 | } |
| @@ -120502,11 +120499,11 @@ | ||
| 120502 | 120499 | sqlite3Fts3SegReaderFinish(pSegcsr); |
| 120503 | 120500 | sqlite3_free(pSegcsr); |
| 120504 | 120501 | } |
| 120505 | 120502 | |
| 120506 | 120503 | /* |
| 120507 | -** This function retreives the doclist for the specified term (or term | |
| 120504 | +** This function retrieves the doclist for the specified term (or term | |
| 120508 | 120505 | ** prefix) from the database. |
| 120509 | 120506 | */ |
| 120510 | 120507 | static int fts3TermSelect( |
| 120511 | 120508 | Fts3Table *p, /* Virtual table handle */ |
| 120512 | 120509 | Fts3PhraseToken *pTok, /* Token to query for */ |
| @@ -121253,11 +121250,11 @@ | ||
| 121253 | 121250 | #ifdef SQLITE_ENABLE_ICU |
| 121254 | 121251 | SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 121255 | 121252 | #endif |
| 121256 | 121253 | |
| 121257 | 121254 | /* |
| 121258 | -** Initialise the fts3 extension. If this extension is built as part | |
| 121255 | +** Initialize the fts3 extension. If this extension is built as part | |
| 121259 | 121256 | ** of the sqlite library, then this function is called directly by |
| 121260 | 121257 | ** SQLite. If fts3 is built as a dynamically loadable extension, this |
| 121261 | 121258 | ** function is called by the sqlite3_extension_init() entry point. |
| 121262 | 121259 | */ |
| 121263 | 121260 | SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ |
| @@ -121287,11 +121284,11 @@ | ||
| 121287 | 121284 | if( rc!=SQLITE_OK ) return rc; |
| 121288 | 121285 | |
| 121289 | 121286 | sqlite3Fts3SimpleTokenizerModule(&pSimple); |
| 121290 | 121287 | sqlite3Fts3PorterTokenizerModule(&pPorter); |
| 121291 | 121288 | |
| 121292 | - /* Allocate and initialise the hash-table used to store tokenizers. */ | |
| 121289 | + /* Allocate and initialize the hash-table used to store tokenizers. */ | |
| 121293 | 121290 | pHash = sqlite3_malloc(sizeof(Fts3Hash)); |
| 121294 | 121291 | if( !pHash ){ |
| 121295 | 121292 | rc = SQLITE_NOMEM; |
| 121296 | 121293 | }else{ |
| 121297 | 121294 | sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| @@ -122886,11 +122883,11 @@ | ||
| 122886 | 122883 | ** The returned value is either NULL or a pointer to a buffer containing |
| 122887 | 122884 | ** a position-list indicating the occurrences of the phrase in column iCol |
| 122888 | 122885 | ** of the current row. |
| 122889 | 122886 | ** |
| 122890 | 122887 | ** More specifically, the returned buffer contains 1 varint for each |
| 122891 | -** occurence of the phrase in the column, stored using the normal (delta+2) | |
| 122888 | +** occurrence of the phrase in the column, stored using the normal (delta+2) | |
| 122892 | 122889 | ** compression and is terminated by either an 0x01 or 0x00 byte. For example, |
| 122893 | 122890 | ** if the requested column contains "a b X c d X X" and the position-list |
| 122894 | 122891 | ** for 'X' is requested, the buffer returned may contain: |
| 122895 | 122892 | ** |
| 122896 | 122893 | ** 0x04 0x05 0x03 0x01 or 0x04 0x05 0x03 0x00 |
| @@ -123625,11 +123622,11 @@ | ||
| 123625 | 123622 | |
| 123626 | 123623 | /* |
| 123627 | 123624 | ** This function is equivalent to the standard isspace() function. |
| 123628 | 123625 | ** |
| 123629 | 123626 | ** The standard isspace() can be awkward to use safely, because although it |
| 123630 | -** is defined to accept an argument of type int, its behaviour when passed | |
| 123627 | +** is defined to accept an argument of type int, its behavior when passed | |
| 123631 | 123628 | ** an integer that falls outside of the range of the unsigned char type |
| 123632 | 123629 | ** is undefined (and sometimes, "undefined" means segfault). This wrapper |
| 123633 | 123630 | ** is defined to accept an argument of type char, and always returns 0 for |
| 123634 | 123631 | ** any values that fall outside of the range of the unsigned char type (i.e. |
| 123635 | 123632 | ** negative values). |
| @@ -125993,11 +125990,11 @@ | ||
| 125993 | 125990 | #endif |
| 125994 | 125991 | |
| 125995 | 125992 | /* |
| 125996 | 125993 | ** Set up SQL objects in database db used to access the contents of |
| 125997 | 125994 | ** the hash table pointed to by argument pHash. The hash table must |
| 125998 | -** been initialised to use string keys, and to take a private copy | |
| 125995 | +** been initialized to use string keys, and to take a private copy | |
| 125999 | 125996 | ** of the key when a value is inserted. i.e. by a call similar to: |
| 126000 | 125997 | ** |
| 126001 | 125998 | ** sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| 126002 | 125999 | ** |
| 126003 | 126000 | ** This function adds a scalar function (see header comment above |
| @@ -127772,10 +127769,11 @@ | ||
| 127772 | 127769 | if( ppOffsetList ){ |
| 127773 | 127770 | *ppOffsetList = pReader->pOffsetList; |
| 127774 | 127771 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 127775 | 127772 | } |
| 127776 | 127773 | |
| 127774 | + /* List may have been edited in place by fts3EvalNearTrim() */ | |
| 127777 | 127775 | while( p<pEnd && *p==0 ) p++; |
| 127778 | 127776 | |
| 127779 | 127777 | /* If there are no more entries in the doclist, set pOffsetList to |
| 127780 | 127778 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 127781 | 127779 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| @@ -128787,13 +128785,17 @@ | ||
| 128787 | 128785 | ** function adjusts the pointer *ppList and the length *pnList so that they |
| 128788 | 128786 | ** identify the subset of the position list that corresponds to column iCol. |
| 128789 | 128787 | ** |
| 128790 | 128788 | ** If there are no entries in the input position list for column iCol, then |
| 128791 | 128789 | ** *pnList is set to zero before returning. |
| 128790 | +** | |
| 128791 | +** If parameter bZero is non-zero, then any part of the input list following | |
| 128792 | +** the end of the output list is zeroed before returning. | |
| 128792 | 128793 | */ |
| 128793 | 128794 | static void fts3ColumnFilter( |
| 128794 | 128795 | int iCol, /* Column to filter on */ |
| 128796 | + int bZero, /* Zero out anything following *ppList */ | |
| 128795 | 128797 | char **ppList, /* IN/OUT: Pointer to position list */ |
| 128796 | 128798 | int *pnList /* IN/OUT: Size of buffer *ppList in bytes */ |
| 128797 | 128799 | ){ |
| 128798 | 128800 | char *pList = *ppList; |
| 128799 | 128801 | int nList = *pnList; |
| @@ -128818,10 +128820,13 @@ | ||
| 128818 | 128820 | } |
| 128819 | 128821 | p = &pList[1]; |
| 128820 | 128822 | p += sqlite3Fts3GetVarint32(p, &iCurrent); |
| 128821 | 128823 | } |
| 128822 | 128824 | |
| 128825 | + if( bZero && &pList[nList]!=pEnd ){ | |
| 128826 | + memset(&pList[nList], 0, pEnd - &pList[nList]); | |
| 128827 | + } | |
| 128823 | 128828 | *ppList = pList; |
| 128824 | 128829 | *pnList = nList; |
| 128825 | 128830 | } |
| 128826 | 128831 | |
| 128827 | 128832 | /* |
| @@ -128890,24 +128895,24 @@ | ||
| 128890 | 128895 | rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 128891 | 128896 | j++; |
| 128892 | 128897 | } |
| 128893 | 128898 | if( rc!=SQLITE_OK ) return rc; |
| 128894 | 128899 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 128900 | + | |
| 128901 | + if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){ | |
| 128902 | + rc = fts3MsrBufferData(pMsr, pList, nList+1); | |
| 128903 | + if( rc!=SQLITE_OK ) return rc; | |
| 128904 | + assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); | |
| 128905 | + pList = pMsr->aBuffer; | |
| 128906 | + } | |
| 128895 | 128907 | |
| 128896 | 128908 | if( pMsr->iColFilter>=0 ){ |
| 128897 | - fts3ColumnFilter(pMsr->iColFilter, &pList, &nList); | |
| 128909 | + fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList); | |
| 128898 | 128910 | } |
| 128899 | 128911 | |
| 128900 | 128912 | if( nList>0 ){ |
| 128901 | - if( fts3SegReaderIsPending(apSegment[0]) ){ | |
| 128902 | - rc = fts3MsrBufferData(pMsr, pList, nList+1); | |
| 128903 | - if( rc!=SQLITE_OK ) return rc; | |
| 128904 | - *paPoslist = pMsr->aBuffer; | |
| 128905 | - assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); | |
| 128906 | - }else{ | |
| 128907 | - *paPoslist = pList; | |
| 128908 | - } | |
| 128913 | + *paPoslist = pList; | |
| 128909 | 128914 | *piDocid = iDocid; |
| 128910 | 128915 | *pnPoslist = nList; |
| 128911 | 128916 | break; |
| 128912 | 128917 | } |
| 128913 | 128918 | } |
| @@ -129146,11 +129151,11 @@ | ||
| 129146 | 129151 | fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 129147 | 129152 | j++; |
| 129148 | 129153 | } |
| 129149 | 129154 | |
| 129150 | 129155 | if( isColFilter ){ |
| 129151 | - fts3ColumnFilter(pFilter->iCol, &pList, &nList); | |
| 129156 | + fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList); | |
| 129152 | 129157 | } |
| 129153 | 129158 | |
| 129154 | 129159 | if( !isIgnoreEmpty || nList>0 ){ |
| 129155 | 129160 | |
| 129156 | 129161 | /* Calculate the 'docid' delta value to write into the merged |
| @@ -132083,13 +132088,13 @@ | ||
| 132083 | 132088 | ** Select the fragment of text consisting of nFragment contiguous tokens |
| 132084 | 132089 | ** from column iCol that represent the "best" snippet. The best snippet |
| 132085 | 132090 | ** is the snippet with the highest score, where scores are calculated |
| 132086 | 132091 | ** by adding: |
| 132087 | 132092 | ** |
| 132088 | -** (a) +1 point for each occurence of a matchable phrase in the snippet. | |
| 132093 | +** (a) +1 point for each occurrence of a matchable phrase in the snippet. | |
| 132089 | 132094 | ** |
| 132090 | -** (b) +1000 points for the first occurence of each matchable phrase in | |
| 132095 | +** (b) +1000 points for the first occurrence of each matchable phrase in | |
| 132091 | 132096 | ** the snippet for which the corresponding mCovered bit is not set. |
| 132092 | 132097 | ** |
| 132093 | 132098 | ** The selected snippet parameters are stored in structure *pFragment before |
| 132094 | 132099 | ** returning. The score of the selected snippet is stored in *piScore |
| 132095 | 132100 | ** before returning. |
| @@ -133340,11 +133345,11 @@ | ||
| 133340 | 133345 | ** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all |
| 133341 | 133346 | ** codepoints in the aiException[] array. |
| 133342 | 133347 | ** |
| 133343 | 133348 | ** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic() |
| 133344 | 133349 | ** identifies as a diacritic) occurs in the zIn/nIn string it is ignored. |
| 133345 | -** It is not possible to change the behaviour of the tokenizer with respect | |
| 133350 | +** It is not possible to change the behavior of the tokenizer with respect | |
| 133346 | 133351 | ** to these codepoints. |
| 133347 | 133352 | */ |
| 133348 | 133353 | static int unicodeAddExceptions( |
| 133349 | 133354 | unicode_tokenizer *p, /* Tokenizer to add exceptions to */ |
| 133350 | 133355 | int bAlnum, /* Replace Isalnum() return value with this */ |
| @@ -136643,11 +136648,11 @@ | ||
| 136643 | 136648 | RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */ |
| 136644 | 136649 | int iCell; /* Index of iDelete cell in pLeaf */ |
| 136645 | 136650 | RtreeNode *pRoot; /* Root node of rtree structure */ |
| 136646 | 136651 | |
| 136647 | 136652 | |
| 136648 | - /* Obtain a reference to the root node to initialise Rtree.iDepth */ | |
| 136653 | + /* Obtain a reference to the root node to initialize Rtree.iDepth */ | |
| 136649 | 136654 | rc = nodeAcquire(pRtree, 1, 0, &pRoot); |
| 136650 | 136655 | |
| 136651 | 136656 | /* Obtain a reference to the leaf node that contains the entry |
| 136652 | 136657 | ** about to be deleted. |
| 136653 | 136658 | */ |
| 136654 | 136659 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.7.16. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -676,13 +676,13 @@ | |
| 676 | ** |
| 677 | ** See also: [sqlite3_libversion()], |
| 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | */ |
| 681 | #define SQLITE_VERSION "3.7.16" |
| 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | #define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" |
| 684 | |
| 685 | /* |
| 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | ** |
| @@ -3249,11 +3249,11 @@ | |
| 3249 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 3250 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 3251 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 3252 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 3253 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 3254 | ** a URI filename, its value overrides any behaviour requested by setting |
| 3255 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 3256 | ** </ul> |
| 3257 | ** |
| 3258 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 3259 | ** error. Future versions of SQLite might understand additional query |
| @@ -4567,11 +4567,12 @@ | |
| 4567 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 4568 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 4569 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 4570 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4571 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4572 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); |
| 4573 | #endif |
| 4574 | |
| 4575 | /* |
| 4576 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4577 | ** |
| @@ -4647,18 +4648,21 @@ | |
| 4647 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4648 | ** implementation is never called and xFinal() is called exactly once. |
| 4649 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4650 | ** first time from within xFinal().)^ |
| 4651 | ** |
| 4652 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is |
| 4653 | ** less than or equal to zero or if a memory allocate error occurs. |
| 4654 | ** |
| 4655 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4656 | ** determined by the N parameter on first successful call. Changing the |
| 4657 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4658 | ** the same aggregate function instance will not resize the memory |
| 4659 | ** allocation.)^ |
| 4660 | ** |
| 4661 | ** ^SQLite automatically frees the memory allocated by |
| 4662 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4663 | ** |
| 4664 | ** The first parameter must be a copy of the |
| @@ -6948,11 +6952,11 @@ | |
| 6948 | ** intact. If the requested page is not already in the cache, then the |
| 6949 | ** cache implementation should use the value of the createFlag |
| 6950 | ** parameter to help it determined what action to take: |
| 6951 | ** |
| 6952 | ** <table border=1 width=85% align=center> |
| 6953 | ** <tr><th> createFlag <th> Behaviour when page is not already in cache |
| 6954 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6955 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6956 | ** Otherwise return NULL. |
| 6957 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6958 | ** NULL if allocating a new page is effectively impossible. |
| @@ -7753,11 +7757,11 @@ | |
| 7753 | ** May you do good and not evil. |
| 7754 | ** May you find forgiveness for yourself and forgive others. |
| 7755 | ** May you share freely, never taking more than you give. |
| 7756 | ** |
| 7757 | ************************************************************************* |
| 7758 | ** This is the header file for the generic hash-table implemenation |
| 7759 | ** used in SQLite. |
| 7760 | */ |
| 7761 | #ifndef _SQLITE_HASH_H_ |
| 7762 | #define _SQLITE_HASH_H_ |
| 7763 | |
| @@ -12943,13 +12947,10 @@ | |
| 12943 | "OMIT_LOOKASIDE", |
| 12944 | #endif |
| 12945 | #ifdef SQLITE_OMIT_MEMORYDB |
| 12946 | "OMIT_MEMORYDB", |
| 12947 | #endif |
| 12948 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 12949 | "OMIT_MERGE_SORT", |
| 12950 | #endif |
| 12951 | #ifdef SQLITE_OMIT_OR_OPTIMIZATION |
| 12952 | "OMIT_OR_OPTIMIZATION", |
| 12953 | #endif |
| 12954 | #ifdef SQLITE_OMIT_PAGER_PRAGMAS |
| 12955 | "OMIT_PAGER_PRAGMAS", |
| @@ -13534,27 +13535,17 @@ | |
| 13534 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); |
| 13535 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); |
| 13536 | SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem); |
| 13537 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 13538 | |
| 13539 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 13540 | # define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK |
| 13541 | # define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK |
| 13542 | # define sqlite3VdbeSorterClose(Y,Z) |
| 13543 | # define sqlite3VdbeSorterRowkey(Y,Z) SQLITE_OK |
| 13544 | # define sqlite3VdbeSorterRewind(X,Y,Z) SQLITE_OK |
| 13545 | # define sqlite3VdbeSorterNext(X,Y,Z) SQLITE_OK |
| 13546 | # define sqlite3VdbeSorterCompare(X,Y,Z) SQLITE_OK |
| 13547 | #else |
| 13548 | SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *); |
| 13549 | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); |
| 13550 | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); |
| 13551 | SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *); |
| 13552 | SQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *); |
| 13553 | SQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *); |
| 13554 | SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *); |
| 13555 | #endif |
| 13556 | |
| 13557 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 |
| 13558 | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*); |
| 13559 | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe*); |
| 13560 | #else |
| @@ -21334,11 +21325,11 @@ | |
| 21334 | ** returns FALSE but it still converts the prefix and writes the result |
| 21335 | ** into *pResult. |
| 21336 | */ |
| 21337 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 21338 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 21339 | int incr = (enc==SQLITE_UTF8?1:2); |
| 21340 | const char *zEnd = z + length; |
| 21341 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 21342 | int sign = 1; /* sign of significand */ |
| 21343 | i64 s = 0; /* significand */ |
| 21344 | int d = 0; /* adjust exponent for shifting decimal point */ |
| @@ -21345,14 +21336,26 @@ | |
| 21345 | int esign = 1; /* sign of exponent */ |
| 21346 | int e = 0; /* exponent */ |
| 21347 | int eValid = 1; /* True exponent is either not used or is well-formed */ |
| 21348 | double result; |
| 21349 | int nDigits = 0; |
| 21350 | |
| 21351 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 21352 | |
| 21353 | if( enc==SQLITE_UTF16BE ) z++; |
| 21354 | |
| 21355 | /* skip leading spaces */ |
| 21356 | while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; |
| 21357 | if( z>=zEnd ) return 0; |
| 21358 | |
| @@ -21481,11 +21484,11 @@ | |
| 21481 | |
| 21482 | /* store the result */ |
| 21483 | *pResult = result; |
| 21484 | |
| 21485 | /* return true if number and no extra non-whitespace chracters after */ |
| 21486 | return z>=zEnd && nDigits>0 && eValid; |
| 21487 | #else |
| 21488 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 21489 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 21490 | } |
| 21491 | |
| @@ -21530,25 +21533,37 @@ | |
| 21530 | ** If zNum is exactly 9223372036854665808, return 2. This special |
| 21531 | ** case is broken out because while 9223372036854665808 cannot be a |
| 21532 | ** signed 64-bit integer, its negative -9223372036854665808 can be. |
| 21533 | ** |
| 21534 | ** If zNum is too big for a 64-bit integer and is not |
| 21535 | ** 9223372036854665808 then return 1. |
| 21536 | ** |
| 21537 | ** length is the number of bytes in the string (bytes, not characters). |
| 21538 | ** The string is not necessarily zero-terminated. The encoding is |
| 21539 | ** given by enc. |
| 21540 | */ |
| 21541 | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ |
| 21542 | int incr = (enc==SQLITE_UTF8?1:2); |
| 21543 | u64 u = 0; |
| 21544 | int neg = 0; /* assume positive */ |
| 21545 | int i; |
| 21546 | int c = 0; |
| 21547 | const char *zStart; |
| 21548 | const char *zEnd = zNum + length; |
| 21549 | if( enc==SQLITE_UTF16BE ) zNum++; |
| 21550 | while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr; |
| 21551 | if( zNum<zEnd ){ |
| 21552 | if( *zNum=='-' ){ |
| 21553 | neg = 1; |
| 21554 | zNum+=incr; |
| @@ -21569,11 +21584,11 @@ | |
| 21569 | *pNum = (i64)u; |
| 21570 | } |
| 21571 | testcase( i==18 ); |
| 21572 | testcase( i==19 ); |
| 21573 | testcase( i==20 ); |
| 21574 | if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ |
| 21575 | /* zNum is empty or contains non-numeric text or is longer |
| 21576 | ** than 19 digits (thus guaranteeing that it is too large) */ |
| 21577 | return 1; |
| 21578 | }else if( i<19*incr ){ |
| 21579 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| @@ -23250,11 +23265,11 @@ | |
| 23250 | ** they may be overridden at runtime to facilitate fault injection during |
| 23251 | ** testing and sandboxing. The following array holds the names and pointers |
| 23252 | ** to all overrideable system calls. |
| 23253 | */ |
| 23254 | static struct unix_syscall { |
| 23255 | const char *zName; /* Name of the sytem call */ |
| 23256 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 23257 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 23258 | } aSyscall[] = { |
| 23259 | { "open", (sqlite3_syscall_ptr)posixOpen, 0 }, |
| 23260 | #define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent) |
| @@ -24822,11 +24837,11 @@ | |
| 24822 | ******************************************************************************/ |
| 24823 | |
| 24824 | /****************************************************************************** |
| 24825 | ************************* Begin dot-file Locking ****************************** |
| 24826 | ** |
| 24827 | ** The dotfile locking implementation uses the existance of separate lock |
| 24828 | ** files (really a directory) to control access to the database. This works |
| 24829 | ** on just about every filesystem imaginable. But there are serious downsides: |
| 24830 | ** |
| 24831 | ** (1) There is zero concurrency. A single reader blocks all other |
| 24832 | ** connections from reading or writing the database. |
| @@ -24837,11 +24852,11 @@ | |
| 24837 | ** Nevertheless, a dotlock is an appropriate locking mode for use if no |
| 24838 | ** other locking strategy is available. |
| 24839 | ** |
| 24840 | ** Dotfile locking works by creating a subdirectory in the same directory as |
| 24841 | ** the database and with the same name but with a ".lock" extension added. |
| 24842 | ** The existance of a lock directory implies an EXCLUSIVE lock. All other |
| 24843 | ** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE. |
| 24844 | */ |
| 24845 | |
| 24846 | /* |
| 24847 | ** The file suffix added to the data base filename in order to create the |
| @@ -26326,11 +26341,11 @@ | |
| 26326 | pFile->lastErrno = errno; |
| 26327 | return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath); |
| 26328 | } |
| 26329 | |
| 26330 | /* Also fsync the directory containing the file if the DIRSYNC flag |
| 26331 | ** is set. This is a one-time occurrance. Many systems (examples: AIX) |
| 26332 | ** are unable to fsync a directory, so ignore errors on the fsync. |
| 26333 | */ |
| 26334 | if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){ |
| 26335 | int dirfd; |
| 26336 | OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath, |
| @@ -27700,11 +27715,11 @@ | |
| 27700 | #endif |
| 27701 | ){ |
| 27702 | unixEnterMutex(); |
| 27703 | rc = findInodeInfo(pNew, &pNew->pInode); |
| 27704 | if( rc!=SQLITE_OK ){ |
| 27705 | /* If an error occured in findInodeInfo(), close the file descriptor |
| 27706 | ** immediately, before releasing the mutex. findInodeInfo() may fail |
| 27707 | ** in two scenarios: |
| 27708 | ** |
| 27709 | ** (a) A call to fstat() failed. |
| 27710 | ** (b) A malloc failed. |
| @@ -28338,11 +28353,11 @@ | |
| 28338 | #endif |
| 28339 | return rc; |
| 28340 | } |
| 28341 | |
| 28342 | /* |
| 28343 | ** Test the existance of or access permissions of file zPath. The |
| 28344 | ** test performed depends on the value of flags: |
| 28345 | ** |
| 28346 | ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists |
| 28347 | ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. |
| 28348 | ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. |
| @@ -30442,11 +30457,11 @@ | |
| 30442 | ** they may be overridden at runtime to facilitate fault injection during |
| 30443 | ** testing and sandboxing. The following array holds the names and pointers |
| 30444 | ** to all overrideable system calls. |
| 30445 | */ |
| 30446 | static struct win_syscall { |
| 30447 | const char *zName; /* Name of the sytem call */ |
| 30448 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 30449 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 30450 | } aSyscall[] = { |
| 30451 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 30452 | { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 }, |
| @@ -32159,11 +32174,11 @@ | |
| 32159 | |
| 32160 | /* API oddity: If successful, SetFilePointer() returns a dword |
| 32161 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 32162 | ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, |
| 32163 | ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine |
| 32164 | ** whether an error has actually occured, it is also necessary to call |
| 32165 | ** GetLastError(). |
| 32166 | */ |
| 32167 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 32168 | |
| 32169 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -32305,11 +32320,11 @@ | |
| 32305 | sqlite3_file *id, /* File to write into */ |
| 32306 | const void *pBuf, /* The bytes to be written */ |
| 32307 | int amt, /* Number of bytes to write */ |
| 32308 | sqlite3_int64 offset /* Offset into the file to begin writing at */ |
| 32309 | ){ |
| 32310 | int rc = 0; /* True if error has occured, else false */ |
| 32311 | winFile *pFile = (winFile*)id; /* File handle */ |
| 32312 | int nRetry = 0; /* Number of retries */ |
| 32313 | |
| 32314 | assert( amt>0 ); |
| 32315 | assert( pFile ); |
| @@ -34127,11 +34142,11 @@ | |
| 34127 | OSTRACE(("DELETE \"%s\" %s\n", zFilename, (rc ? "failed" : "ok" ))); |
| 34128 | return rc; |
| 34129 | } |
| 34130 | |
| 34131 | /* |
| 34132 | ** Check the existance and status of a file. |
| 34133 | */ |
| 34134 | static int winAccess( |
| 34135 | sqlite3_vfs *pVfs, /* Not used on win32 */ |
| 34136 | const char *zFilename, /* Name of file to check */ |
| 34137 | int flags, /* Type of test to make on this file */ |
| @@ -34736,11 +34751,11 @@ | |
| 34736 | |
| 34737 | |
| 34738 | /* |
| 34739 | ** A bitmap is an instance of the following structure. |
| 34740 | ** |
| 34741 | ** This bitmap records the existance of zero or more bits |
| 34742 | ** with values between 1 and iSize, inclusive. |
| 34743 | ** |
| 34744 | ** There are three possible representations of the bitmap. |
| 34745 | ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight |
| 34746 | ** bitmap. The least significant bit is bit 1. |
| @@ -37638,11 +37653,11 @@ | |
| 37638 | ** layer must either commit or rollback the transaction. |
| 37639 | ** |
| 37640 | ** * A write transaction is active. |
| 37641 | ** * An EXCLUSIVE or greater lock is held on the database file. |
| 37642 | ** * All writing and syncing of journal and database data has finished. |
| 37643 | ** If no error occured, all that remains is to finalize the journal to |
| 37644 | ** commit the transaction. If an error did occur, the caller will need |
| 37645 | ** to rollback the transaction. |
| 37646 | ** |
| 37647 | ** ERROR: |
| 37648 | ** |
| @@ -37886,11 +37901,11 @@ | |
| 37886 | ** journal file from being successfully finalized, the setMaster flag |
| 37887 | ** is cleared anyway (and the pager will move to ERROR state). |
| 37888 | ** |
| 37889 | ** doNotSpill, doNotSyncSpill |
| 37890 | ** |
| 37891 | ** These two boolean variables control the behaviour of cache-spills |
| 37892 | ** (calls made by the pcache module to the pagerStress() routine to |
| 37893 | ** write cached data to the file-system in order to free up memory). |
| 37894 | ** |
| 37895 | ** When doNotSpill is non-zero, writing to the database from pagerStress() |
| 37896 | ** is disabled altogether. This is done in a very obscure case that |
| @@ -38764,11 +38779,11 @@ | |
| 38764 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 38765 | }else{ |
| 38766 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 38767 | } |
| 38768 | |
| 38769 | /* The random check-hash initialiser */ |
| 38770 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); |
| 38771 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 38772 | /* The initial database size */ |
| 38773 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 38774 | /* The assumed sector size for this process */ |
| @@ -41096,11 +41111,11 @@ | |
| 41096 | ** |
| 41097 | ** If the condition asserted by this function were not true, and the |
| 41098 | ** dirty page were to be discarded from the cache via the pagerStress() |
| 41099 | ** routine, pagerStress() would not write the current page content to |
| 41100 | ** the database file. If a savepoint transaction were rolled back after |
| 41101 | ** this happened, the correct behaviour would be to restore the current |
| 41102 | ** content of the page. However, since this content is not present in either |
| 41103 | ** the database file or the portion of the rollback journal and |
| 41104 | ** sub-journal rolled back the content could not be restored and the |
| 41105 | ** database image would become corrupt. It is therefore fortunate that |
| 41106 | ** this circumstance cannot arise. |
| @@ -48938,10 +48953,23 @@ | |
| 48938 | */ |
| 48939 | static void btreeClearHasContent(BtShared *pBt){ |
| 48940 | sqlite3BitvecDestroy(pBt->pHasContent); |
| 48941 | pBt->pHasContent = 0; |
| 48942 | } |
| 48943 | |
| 48944 | /* |
| 48945 | ** Save the current cursor position in the variables BtCursor.nKey |
| 48946 | ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. |
| 48947 | ** |
| @@ -48978,16 +49006,11 @@ | |
| 48978 | } |
| 48979 | } |
| 48980 | assert( !pCur->apPage[0]->intKey || !pCur->pKey ); |
| 48981 | |
| 48982 | if( rc==SQLITE_OK ){ |
| 48983 | int i; |
| 48984 | for(i=0; i<=pCur->iPage; i++){ |
| 48985 | releasePage(pCur->apPage[i]); |
| 48986 | pCur->apPage[i] = 0; |
| 48987 | } |
| 48988 | pCur->iPage = -1; |
| 48989 | pCur->eState = CURSOR_REQUIRESEEK; |
| 48990 | } |
| 48991 | |
| 48992 | invalidateOverflowCache(pCur); |
| 48993 | return rc; |
| @@ -49001,15 +49024,19 @@ | |
| 49001 | static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){ |
| 49002 | BtCursor *p; |
| 49003 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 49004 | assert( pExcept==0 || pExcept->pBt==pBt ); |
| 49005 | for(p=pBt->pCursor; p; p=p->pNext){ |
| 49006 | if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) && |
| 49007 | p->eState==CURSOR_VALID ){ |
| 49008 | int rc = saveCursorPosition(p); |
| 49009 | if( SQLITE_OK!=rc ){ |
| 49010 | return rc; |
| 49011 | } |
| 49012 | } |
| 49013 | } |
| 49014 | return SQLITE_OK; |
| 49015 | } |
| @@ -50593,11 +50620,11 @@ | |
| 50593 | ** |
| 50594 | ** This is useful in one special case in the backup API code where it is |
| 50595 | ** known that the shared b-tree mutex is held, but the mutex on the |
| 50596 | ** database handle that owns *p is not. In this case if sqlite3BtreeEnter() |
| 50597 | ** were to be called, it might collide with some other operation on the |
| 50598 | ** database handle that owns *p, causing undefined behaviour. |
| 50599 | */ |
| 50600 | SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){ |
| 50601 | assert( sqlite3_mutex_held(p->pBt->mutex) ); |
| 50602 | return p->pBt->pageSize - p->pBt->usableSize; |
| 50603 | } |
| @@ -53873,11 +53900,11 @@ | |
| 53873 | ** for that page now. |
| 53874 | ** |
| 53875 | ** If this is the first overflow page, then write a partial entry |
| 53876 | ** to the pointer-map. If we write nothing to this pointer-map slot, |
| 53877 | ** then the optimistic overflow chain processing in clearCell() |
| 53878 | ** may misinterpret the uninitialised values and delete the |
| 53879 | ** wrong pages from the database. |
| 53880 | */ |
| 53881 | if( pBt->autoVacuum && rc==SQLITE_OK ){ |
| 53882 | u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1); |
| 53883 | ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc); |
| @@ -55346,11 +55373,11 @@ | |
| 55346 | assert( pPage->leaf ); |
| 55347 | } |
| 55348 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 55349 | assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); |
| 55350 | |
| 55351 | /* If no error has occured and pPage has an overflow cell, call balance() |
| 55352 | ** to redistribute the cells within the tree. Since balance() may move |
| 55353 | ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey |
| 55354 | ** variables. |
| 55355 | ** |
| 55356 | ** Previous versions of SQLite called moveToRoot() to move the cursor |
| @@ -59080,11 +59107,11 @@ | |
| 59080 | break; |
| 59081 | } |
| 59082 | } |
| 59083 | sqlite3DbFree(v->db, sIter.apSub); |
| 59084 | |
| 59085 | /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. |
| 59086 | ** If malloc failed, then the while() loop above may not have iterated |
| 59087 | ** through all opcodes and hasAbort may be set incorrectly. Return |
| 59088 | ** true for this case to prevent the assert() in the callers frame |
| 59089 | ** from failing. */ |
| 59090 | return ( v->db->mallocFailed || hasAbort==mayAbort ); |
| @@ -60712,11 +60739,11 @@ | |
| 60712 | sqlite3 *const db = p->db; |
| 60713 | int rc = SQLITE_OK; |
| 60714 | |
| 60715 | /* If p->iStatement is greater than zero, then this Vdbe opened a |
| 60716 | ** statement transaction that should be closed here. The only exception |
| 60717 | ** is that an IO error may have occured, causing an emergency rollback. |
| 60718 | ** In this case (db->nStatement==0), and there is nothing to do. |
| 60719 | */ |
| 60720 | if( db->nStatement && p->iStatement ){ |
| 60721 | int i; |
| 60722 | const int iSavepoint = p->iStatement-1; |
| @@ -60848,11 +60875,11 @@ | |
| 60848 | ** transaction must be rolled back to restore the database to a |
| 60849 | ** consistent state. |
| 60850 | ** |
| 60851 | ** Even if the statement is read-only, it is important to perform |
| 60852 | ** a statement or transaction rollback operation. If the error |
| 60853 | ** occured while writing to the journal, sub-journal or database |
| 60854 | ** file as part of an effort to free up cache space (see function |
| 60855 | ** pagerStress() in pager.c), the rollback is required to restore |
| 60856 | ** the pager to a consistent state. |
| 60857 | */ |
| 60858 | if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){ |
| @@ -61262,11 +61289,11 @@ | |
| 61262 | ** |
| 61263 | ** In an SQLite index record, the serial type is stored directly before |
| 61264 | ** the blob of data that it corresponds to. In a table record, all serial |
| 61265 | ** types are stored at the start of the record, and the blobs of data at |
| 61266 | ** the end. Hence these functions allow the caller to handle the |
| 61267 | ** serial-type and data blob seperately. |
| 61268 | ** |
| 61269 | ** The following table describes the various storage classes for data: |
| 61270 | ** |
| 61271 | ** serial type bytes of data type |
| 61272 | ** -------------- --------------- --------------- |
| @@ -62402,11 +62429,11 @@ | |
| 62402 | || rc==SQLITE_BUSY || rc==SQLITE_MISUSE |
| 62403 | ); |
| 62404 | assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); |
| 62405 | if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ |
| 62406 | /* If this statement was prepared using sqlite3_prepare_v2(), and an |
| 62407 | ** error has occured, then return the error code in p->rc to the |
| 62408 | ** caller. Set the error code in the database handle to the same value. |
| 62409 | */ |
| 62410 | rc = sqlite3VdbeTransferError(p); |
| 62411 | } |
| 62412 | return (rc&db->errMask); |
| @@ -63692,15 +63719,11 @@ | |
| 63692 | #define Deephemeralize(P) \ |
| 63693 | if( ((P)->flags&MEM_Ephem)!=0 \ |
| 63694 | && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} |
| 63695 | |
| 63696 | /* Return true if the cursor was opened using the OP_OpenSorter opcode. */ |
| 63697 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 63698 | # define isSorter(x) 0 |
| 63699 | #else |
| 63700 | # define isSorter(x) ((x)->pSorter!=0) |
| 63701 | #endif |
| 63702 | |
| 63703 | /* |
| 63704 | ** Argument pMem points at a register that will be passed to a |
| 63705 | ** user-defined function or returned to the user as the result of a query. |
| 63706 | ** This routine sets the pMem->type variable used by the sqlite3_value_*() |
| @@ -67433,21 +67456,16 @@ | |
| 67433 | case OP_SorterOpen: { |
| 67434 | #if 0 /* local variables moved into u.ba */ |
| 67435 | VdbeCursor *pCx; |
| 67436 | #endif /* local variables moved into u.ba */ |
| 67437 | |
| 67438 | #ifndef SQLITE_OMIT_MERGE_SORT |
| 67439 | u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 67440 | if( u.ba.pCx==0 ) goto no_mem; |
| 67441 | u.ba.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 67442 | u.ba.pCx->pKeyInfo->enc = ENC(p->db); |
| 67443 | u.ba.pCx->isSorter = 1; |
| 67444 | rc = sqlite3VdbeSorterInit(db, u.ba.pCx); |
| 67445 | #else |
| 67446 | pOp->opcode = OP_OpenEphemeral; |
| 67447 | pc--; |
| 67448 | #endif |
| 67449 | break; |
| 67450 | } |
| 67451 | |
| 67452 | /* Opcode: OpenPseudo P1 P2 P3 * P5 |
| 67453 | ** |
| @@ -68348,19 +68366,14 @@ | |
| 68348 | case OP_SorterData: { |
| 68349 | #if 0 /* local variables moved into u.bl */ |
| 68350 | VdbeCursor *pC; |
| 68351 | #endif /* local variables moved into u.bl */ |
| 68352 | |
| 68353 | #ifndef SQLITE_OMIT_MERGE_SORT |
| 68354 | pOut = &aMem[pOp->p2]; |
| 68355 | u.bl.pC = p->apCsr[pOp->p1]; |
| 68356 | assert( u.bl.pC->isSorter ); |
| 68357 | rc = sqlite3VdbeSorterRowkey(u.bl.pC, pOut); |
| 68358 | #else |
| 68359 | pOp->opcode = OP_RowKey; |
| 68360 | pc--; |
| 68361 | #endif |
| 68362 | break; |
| 68363 | } |
| 68364 | |
| 68365 | /* Opcode: RowData P1 P2 * * * |
| 68366 | ** |
| @@ -68563,13 +68576,10 @@ | |
| 68563 | ** rewinding so that the global variable will be incremented and |
| 68564 | ** regression tests can determine whether or not the optimizer is |
| 68565 | ** correctly optimizing out sorts. |
| 68566 | */ |
| 68567 | case OP_SorterSort: /* jump */ |
| 68568 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 68569 | pOp->opcode = OP_Sort; |
| 68570 | #endif |
| 68571 | case OP_Sort: { /* jump */ |
| 68572 | #ifdef SQLITE_TEST |
| 68573 | sqlite3_sort_count++; |
| 68574 | sqlite3_search_count--; |
| 68575 | #endif |
| @@ -68646,13 +68656,10 @@ | |
| 68646 | ** |
| 68647 | ** If P5 is positive and the jump is taken, then event counter |
| 68648 | ** number P5-1 in the prepared statement is incremented. |
| 68649 | */ |
| 68650 | case OP_SorterNext: /* jump */ |
| 68651 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 68652 | pOp->opcode = OP_Next; |
| 68653 | #endif |
| 68654 | case OP_Prev: /* jump */ |
| 68655 | case OP_Next: { /* jump */ |
| 68656 | #if 0 /* local variables moved into u.br */ |
| 68657 | VdbeCursor *pC; |
| 68658 | int res; |
| @@ -68701,13 +68708,10 @@ | |
| 68701 | ** |
| 68702 | ** This instruction only works for indices. The equivalent instruction |
| 68703 | ** for tables is OP_Insert. |
| 68704 | */ |
| 68705 | case OP_SorterInsert: /* in2 */ |
| 68706 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 68707 | pOp->opcode = OP_IdxInsert; |
| 68708 | #endif |
| 68709 | case OP_IdxInsert: { /* in2 */ |
| 68710 | #if 0 /* local variables moved into u.bs */ |
| 68711 | VdbeCursor *pC; |
| 68712 | BtCursor *pCrsr; |
| 68713 | int nKey; |
| @@ -69972,11 +69976,11 @@ | |
| 69972 | importVtabErrMsg(p, u.cm.pVtab); |
| 69973 | if( SQLITE_OK==rc ){ |
| 69974 | /* Initialize sqlite3_vtab_cursor base class */ |
| 69975 | u.cm.pVtabCursor->pVtab = u.cm.pVtab; |
| 69976 | |
| 69977 | /* Initialise vdbe cursor object */ |
| 69978 | u.cm.pCur = allocateCursor(p, pOp->p1, 0, -1, 0); |
| 69979 | if( u.cm.pCur ){ |
| 69980 | u.cm.pCur->pVtabCursor = u.cm.pVtabCursor; |
| 69981 | u.cm.pCur->pModule = u.cm.pVtabCursor->pVtab->pModule; |
| 69982 | }else{ |
| @@ -70954,11 +70958,10 @@ | |
| 70954 | ** example, by CREATE INDEX statements on tables too large to fit in main |
| 70955 | ** memory). |
| 70956 | */ |
| 70957 | |
| 70958 | |
| 70959 | #ifndef SQLITE_OMIT_MERGE_SORT |
| 70960 | |
| 70961 | typedef struct VdbeSorterIter VdbeSorterIter; |
| 70962 | typedef struct SorterRecord SorterRecord; |
| 70963 | typedef struct FileWriter FileWriter; |
| 70964 | |
| @@ -71974,12 +71977,10 @@ | |
| 71974 | pKey = vdbeSorterRowkey(pSorter, &nKey); |
| 71975 | vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes); |
| 71976 | return SQLITE_OK; |
| 71977 | } |
| 71978 | |
| 71979 | #endif /* #ifndef SQLITE_OMIT_MERGE_SORT */ |
| 71980 | |
| 71981 | /************** End of vdbesort.c ********************************************/ |
| 71982 | /************** Begin file journal.c *****************************************/ |
| 71983 | /* |
| 71984 | ** 2007 August 22 |
| 71985 | ** |
| @@ -77513,11 +77514,11 @@ | |
| 77513 | int regFree1 = 0; |
| 77514 | int regFree2 = 0; |
| 77515 | int r1, r2; |
| 77516 | |
| 77517 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77518 | if( NEVER(v==0) ) return; /* Existance of VDBE checked by caller */ |
| 77519 | if( NEVER(pExpr==0) ) return; /* No way this can happen */ |
| 77520 | op = pExpr->op; |
| 77521 | switch( op ){ |
| 77522 | case TK_AND: { |
| 77523 | int d2 = sqlite3VdbeMakeLabel(v); |
| @@ -77633,11 +77634,11 @@ | |
| 77633 | int regFree1 = 0; |
| 77634 | int regFree2 = 0; |
| 77635 | int r1, r2; |
| 77636 | |
| 77637 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77638 | if( NEVER(v==0) ) return; /* Existance of VDBE checked by caller */ |
| 77639 | if( pExpr==0 ) return; |
| 77640 | |
| 77641 | /* The value of pExpr->op and op are related as follows: |
| 77642 | ** |
| 77643 | ** pExpr->op op |
| @@ -80230,11 +80231,11 @@ | |
| 80230 | zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); |
| 80231 | goto attach_error; |
| 80232 | } |
| 80233 | } |
| 80234 | |
| 80235 | /* Allocate the new entry in the db->aDb[] array and initialise the schema |
| 80236 | ** hash tables. |
| 80237 | */ |
| 80238 | if( db->aDb==db->aDbStatic ){ |
| 80239 | aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 ); |
| 80240 | if( aNew==0 ) return; |
| @@ -80247,11 +80248,11 @@ | |
| 80247 | aNew = &db->aDb[db->nDb]; |
| 80248 | memset(aNew, 0, sizeof(*aNew)); |
| 80249 | |
| 80250 | /* Open the database file. If the btree is successfully opened, use |
| 80251 | ** it to obtain the database schema. At this point the schema may |
| 80252 | ** or may not be initialised. |
| 80253 | */ |
| 80254 | flags = db->openFlags; |
| 80255 | rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr); |
| 80256 | if( rc!=SQLITE_OK ){ |
| 80257 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; |
| @@ -83033,11 +83034,11 @@ | |
| 83033 | #endif |
| 83034 | |
| 83035 | /* Drop all SQLITE_MASTER table and index entries that refer to the |
| 83036 | ** table. The program name loops through the master table and deletes |
| 83037 | ** every row that refers to a table of the same name as the one being |
| 83038 | ** dropped. Triggers are handled seperately because a trigger can be |
| 83039 | ** created in the temp database that refers to a table in another |
| 83040 | ** database. |
| 83041 | */ |
| 83042 | sqlite3NestedParse(pParse, |
| 83043 | "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", |
| @@ -83325,13 +83326,10 @@ | |
| 83325 | int addr1; /* Address of top of loop */ |
| 83326 | int addr2; /* Address to jump to for next iteration */ |
| 83327 | int tnum; /* Root page of index */ |
| 83328 | Vdbe *v; /* Generate code into this virtual machine */ |
| 83329 | KeyInfo *pKey; /* KeyInfo for index */ |
| 83330 | #ifdef SQLITE_OMIT_MERGE_SORT |
| 83331 | int regIdxKey; /* Registers containing the index key */ |
| 83332 | #endif |
| 83333 | int regRecord; /* Register holding assemblied index record */ |
| 83334 | sqlite3 *db = pParse->db; /* The database connection */ |
| 83335 | int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); |
| 83336 | |
| 83337 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -83355,25 +83353,20 @@ | |
| 83355 | pKey = sqlite3IndexKeyinfo(pParse, pIndex); |
| 83356 | sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, |
| 83357 | (char *)pKey, P4_KEYINFO_HANDOFF); |
| 83358 | sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); |
| 83359 | |
| 83360 | #ifndef SQLITE_OMIT_MERGE_SORT |
| 83361 | /* Open the sorter cursor if we are to use one. */ |
| 83362 | iSorter = pParse->nTab++; |
| 83363 | sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); |
| 83364 | #else |
| 83365 | iSorter = iTab; |
| 83366 | #endif |
| 83367 | |
| 83368 | /* Open the table. Loop through all rows of the table, inserting index |
| 83369 | ** records into the sorter. */ |
| 83370 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 83371 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 83372 | regRecord = sqlite3GetTempReg(pParse); |
| 83373 | |
| 83374 | #ifndef SQLITE_OMIT_MERGE_SORT |
| 83375 | sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 83376 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 83377 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 83378 | sqlite3VdbeJumpHere(v, addr1); |
| 83379 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| @@ -83389,34 +83382,10 @@ | |
| 83389 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 83390 | } |
| 83391 | sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord); |
| 83392 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1); |
| 83393 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 83394 | #else |
| 83395 | regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 83396 | addr2 = addr1 + 1; |
| 83397 | if( pIndex->onError!=OE_None ){ |
| 83398 | const int regRowid = regIdxKey + pIndex->nColumn; |
| 83399 | const int j2 = sqlite3VdbeCurrentAddr(v) + 2; |
| 83400 | void * const pRegKey = SQLITE_INT_TO_PTR(regIdxKey); |
| 83401 | |
| 83402 | /* The registers accessed by the OP_IsUnique opcode were allocated |
| 83403 | ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() |
| 83404 | ** call above. Just before that function was freed they were released |
| 83405 | ** (made available to the compiler for reuse) using |
| 83406 | ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique |
| 83407 | ** opcode use the values stored within seems dangerous. However, since |
| 83408 | ** we can be sure that no other temp registers have been allocated |
| 83409 | ** since sqlite3ReleaseTempRange() was called, it is safe to do so. |
| 83410 | */ |
| 83411 | sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32); |
| 83412 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE, |
| 83413 | "indexed columns are not unique", P4_STATIC); |
| 83414 | } |
| 83415 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0); |
| 83416 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 83417 | #endif |
| 83418 | sqlite3ReleaseTempReg(pParse, regRecord); |
| 83419 | sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); |
| 83420 | sqlite3VdbeJumpHere(v, addr1); |
| 83421 | |
| 83422 | sqlite3VdbeAddOp1(v, OP_Close, iTab); |
| @@ -83772,11 +83741,11 @@ | |
| 83772 | /* This constraint creates the same index as a previous |
| 83773 | ** constraint specified somewhere in the CREATE TABLE statement. |
| 83774 | ** However the ON CONFLICT clauses are different. If both this |
| 83775 | ** constraint and the previous equivalent constraint have explicit |
| 83776 | ** ON CONFLICT clauses this is an error. Otherwise, use the |
| 83777 | ** explicitly specified behaviour for the index. |
| 83778 | */ |
| 83779 | if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){ |
| 83780 | sqlite3ErrorMsg(pParse, |
| 83781 | "conflicting ON CONFLICT clauses specified", 0); |
| 83782 | } |
| @@ -94054,11 +94023,11 @@ | |
| 94054 | assert( sqlite3_mutex_held(db->mutex) ); |
| 94055 | assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); |
| 94056 | |
| 94057 | /* zMasterSchema and zInitScript are set to point at the master schema |
| 94058 | ** and initialisation script appropriate for the database being |
| 94059 | ** initialised. zMasterName is the name of the master table. |
| 94060 | */ |
| 94061 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 94062 | zMasterSchema = temp_master_schema; |
| 94063 | }else{ |
| 94064 | zMasterSchema = master_schema; |
| @@ -94279,11 +94248,11 @@ | |
| 94279 | if( rc ){ |
| 94280 | sqlite3ResetOneSchema(db, i); |
| 94281 | } |
| 94282 | } |
| 94283 | |
| 94284 | /* Once all the other databases have been initialised, load the schema |
| 94285 | ** for the TEMP database. This is loaded last, as the TEMP database |
| 94286 | ** schema may contain references to objects in other databases. |
| 94287 | */ |
| 94288 | #ifndef SQLITE_OMIT_TEMPDB |
| 94289 | if( rc==SQLITE_OK && ALWAYS(db->nDb>1) |
| @@ -94302,11 +94271,11 @@ | |
| 94302 | |
| 94303 | return rc; |
| 94304 | } |
| 94305 | |
| 94306 | /* |
| 94307 | ** This routine is a no-op if the database schema is already initialised. |
| 94308 | ** Otherwise, the schema is loaded. An error code is returned. |
| 94309 | */ |
| 94310 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){ |
| 94311 | int rc = SQLITE_OK; |
| 94312 | sqlite3 *db = pParse->db; |
| @@ -99315,11 +99284,11 @@ | |
| 99315 | ** first iteration (since the first iteration of the loop is |
| 99316 | ** guaranteed to operate on the row with the minimum or maximum |
| 99317 | ** value of x, the only row required). |
| 99318 | ** |
| 99319 | ** A special flag must be passed to sqlite3WhereBegin() to slightly |
| 99320 | ** modify behaviour as follows: |
| 99321 | ** |
| 99322 | ** + If the query is a "SELECT min(x)", then the loop coded by |
| 99323 | ** where.c should not iterate over any values with a NULL value |
| 99324 | ** for x. |
| 99325 | ** |
| @@ -101308,11 +101277,11 @@ | |
| 101308 | sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, |
| 101309 | TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); |
| 101310 | |
| 101311 | /* The row-trigger may have deleted the row being updated. In this |
| 101312 | ** case, jump to the next row. No updates or AFTER triggers are |
| 101313 | ** required. This behaviour - what happens when the row being updated |
| 101314 | ** is deleted or renamed by a BEFORE trigger - is left undefined in the |
| 101315 | ** documentation. |
| 101316 | */ |
| 101317 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); |
| 101318 | |
| @@ -103237,10 +103206,12 @@ | |
| 103237 | #define WHERE_IDX_ONLY 0x00400000 /* Use index only - omit table */ |
| 103238 | #define WHERE_ORDERED 0x00800000 /* Output will appear in correct order */ |
| 103239 | #define WHERE_REVERSE 0x01000000 /* Scan in reverse order */ |
| 103240 | #define WHERE_UNIQUE 0x02000000 /* Selects no more than one row */ |
| 103241 | #define WHERE_ALL_UNIQUE 0x04000000 /* This and all prior have one row */ |
| 103242 | #define WHERE_VIRTUALTABLE 0x08000000 /* Use virtual-table processing */ |
| 103243 | #define WHERE_MULTI_OR 0x10000000 /* OR using multiple indices */ |
| 103244 | #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */ |
| 103245 | #define WHERE_DISTINCT 0x40000000 /* Correct order for DISTINCT */ |
| 103246 | #define WHERE_COVER_SCAN 0x80000000 /* Full scan of a covering index */ |
| @@ -103537,11 +103508,11 @@ | |
| 103537 | |
| 103538 | /* |
| 103539 | ** Commute a comparison operator. Expressions of the form "X op Y" |
| 103540 | ** are converted into "Y op X". |
| 103541 | ** |
| 103542 | ** If left/right precendence rules come into play when determining the |
| 103543 | ** collating |
| 103544 | ** side of the comparison, it remains associated with the same side after |
| 103545 | ** the commutation. So "Y collate NOCASE op X" becomes |
| 103546 | ** "X op Y". This is because any collation sequence on |
| 103547 | ** the left hand side of a comparison overrides any collation sequence |
| @@ -105878,11 +105849,12 @@ | |
| 105878 | */ |
| 105879 | static int isSortingIndex( |
| 105880 | WhereBestIdx *p, /* Best index search context */ |
| 105881 | Index *pIdx, /* The index we are testing */ |
| 105882 | int base, /* Cursor number for the table to be sorted */ |
| 105883 | int *pbRev /* Set to 1 for reverse-order scan of pIdx */ |
| 105884 | ){ |
| 105885 | int i; /* Number of pIdx terms used */ |
| 105886 | int j; /* Number of ORDER BY terms satisfied */ |
| 105887 | int sortOrder = 2; /* 0: forward. 1: backward. 2: unknown */ |
| 105888 | int nTerm; /* Number of ORDER BY terms */ |
| @@ -105892,25 +105864,32 @@ | |
| 105892 | Parse *pParse = p->pParse; /* Parser context */ |
| 105893 | sqlite3 *db = pParse->db; /* Database connection */ |
| 105894 | int nPriorSat; /* ORDER BY terms satisfied by outer loops */ |
| 105895 | int seenRowid = 0; /* True if an ORDER BY rowid term is seen */ |
| 105896 | int uniqueNotNull; /* pIdx is UNIQUE with all terms are NOT NULL */ |
| 105897 | |
| 105898 | if( p->i==0 ){ |
| 105899 | nPriorSat = 0; |
| 105900 | }else{ |
| 105901 | nPriorSat = p->aLevel[p->i-1].plan.nOBSat; |
| 105902 | if( (p->aLevel[p->i-1].plan.wsFlags & WHERE_ORDERED)==0 ){ |
| 105903 | /* This loop cannot be ordered unless the next outer loop is |
| 105904 | ** also ordered */ |
| 105905 | return nPriorSat; |
| 105906 | } |
| 105907 | if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){ |
| 105908 | /* Only look at the outer-most loop if the OrderByIdxJoin |
| 105909 | ** optimization is disabled */ |
| 105910 | return nPriorSat; |
| 105911 | } |
| 105912 | } |
| 105913 | pOrderBy = p->pOrderBy; |
| 105914 | assert( pOrderBy!=0 ); |
| 105915 | if( pIdx->bUnordered ){ |
| 105916 | /* Hash indices (indicated by the "unordered" tag on sqlite_stat1) cannot |
| @@ -106048,23 +106027,38 @@ | |
| 106048 | testcase( isEq==2 ); |
| 106049 | testcase( isEq==3 ); |
| 106050 | uniqueNotNull = 0; |
| 106051 | } |
| 106052 | } |
| 106053 | |
| 106054 | /* If we have not found at least one ORDER BY term that matches the |
| 106055 | ** index, then show no progress. */ |
| 106056 | if( pOBItem==&pOrderBy->a[nPriorSat] ) return nPriorSat; |
| 106057 | |
| 106058 | /* Return the necessary scan order back to the caller */ |
| 106059 | *pbRev = sortOrder & 1; |
| 106060 | |
| 106061 | /* If there was an "ORDER BY rowid" term that matched, or it is only |
| 106062 | ** possible for a single row from this table to match, then skip over |
| 106063 | ** any additional ORDER BY terms dealing with this table. |
| 106064 | */ |
| 106065 | if( seenRowid || (uniqueNotNull && i>=pIdx->nColumn) ){ |
| 106066 | /* Advance j over additional ORDER BY terms associated with base */ |
| 106067 | WhereMaskSet *pMS = p->pWC->pMaskSet; |
| 106068 | Bitmask m = ~getMask(pMS, base); |
| 106069 | while( j<nTerm && (exprTableUsage(pMS, pOrderBy->a[j].pExpr)&m)==0 ){ |
| 106070 | j++; |
| @@ -106344,16 +106338,18 @@ | |
| 106344 | ** in pc.plan.wsFlags. Otherwise, if there is an ORDER BY clause but |
| 106345 | ** the index will scan rows in a different order, set the bSort |
| 106346 | ** variable. */ |
| 106347 | if( bSort && (pSrc->jointype & JT_LEFT)==0 ){ |
| 106348 | int bRev = 2; |
| 106349 | WHERETRACE((" --> before isSortingIndex: nPriorSat=%d\n",nPriorSat)); |
| 106350 | pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev); |
| 106351 | WHERETRACE((" --> after isSortingIndex: bRev=%d nOBSat=%d\n", |
| 106352 | bRev, pc.plan.nOBSat)); |
| 106353 | if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){ |
| 106354 | pc.plan.wsFlags |= WHERE_ORDERED; |
| 106355 | } |
| 106356 | if( nOrderBy==pc.plan.nOBSat ){ |
| 106357 | bSort = 0; |
| 106358 | pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE; |
| 106359 | } |
| @@ -106443,11 +106439,12 @@ | |
| 106443 | ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do |
| 106444 | ** not give us data on the relative sizes of table and index records. |
| 106445 | ** So this computation assumes table records are about twice as big |
| 106446 | ** as index records |
| 106447 | */ |
| 106448 | if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED))==WHERE_IDX_ONLY |
| 106449 | && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 |
| 106450 | && sqlite3GlobalConfig.bUseCis |
| 106451 | && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan) |
| 106452 | ){ |
| 106453 | /* This index is not useful for indexing, but it is a covering index. |
| @@ -106603,11 +106600,11 @@ | |
| 106603 | } |
| 106604 | |
| 106605 | /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag |
| 106606 | ** is set, then reverse the order that the index will be scanned |
| 106607 | ** in. This is used for application testing, to help find cases |
| 106608 | ** where application behaviour depends on the (undefined) order that |
| 106609 | ** SQLite outputs rows in in the absence of an ORDER BY clause. */ |
| 106610 | if( !p->pOrderBy && pParse->db->flags & SQLITE_ReverseOrder ){ |
| 106611 | p->cost.plan.wsFlags |= WHERE_REVERSE; |
| 106612 | } |
| 106613 | |
| @@ -114198,11 +114195,11 @@ | |
| 114198 | return; |
| 114199 | } |
| 114200 | |
| 114201 | /* If we reach this point, it means that the database connection has |
| 114202 | ** closed all sqlite3_stmt and sqlite3_backup objects and has been |
| 114203 | ** pased to sqlite3_close (meaning that it is a zombie). Therefore, |
| 114204 | ** go ahead and free all resources. |
| 114205 | */ |
| 114206 | |
| 114207 | /* Free any outstanding Savepoint structures. */ |
| 114208 | sqlite3CloseSavepoints(db); |
| @@ -117250,11 +117247,11 @@ | |
| 117250 | ** to the strings "arg1" and "arg2". |
| 117251 | ** |
| 117252 | ** This method should return either SQLITE_OK (0), or an SQLite error |
| 117253 | ** code. If SQLITE_OK is returned, then *ppTokenizer should be set |
| 117254 | ** to point at the newly created tokenizer structure. The generic |
| 117255 | ** sqlite3_tokenizer.pModule variable should not be initialised by |
| 117256 | ** this callback. The caller will do so. |
| 117257 | */ |
| 117258 | int (*xCreate)( |
| 117259 | int argc, /* Size of argv array */ |
| 117260 | const char *const*argv, /* Tokenizer argument strings */ |
| @@ -117355,11 +117352,11 @@ | |
| 117355 | ** May you do good and not evil. |
| 117356 | ** May you find forgiveness for yourself and forgive others. |
| 117357 | ** May you share freely, never taking more than you give. |
| 117358 | ** |
| 117359 | ************************************************************************* |
| 117360 | ** This is the header file for the generic hash-table implemenation |
| 117361 | ** used in SQLite. We've modified it slightly to serve as a standalone |
| 117362 | ** hash table implementation for the full-text indexing module. |
| 117363 | ** |
| 117364 | */ |
| 117365 | #ifndef _FTS3_HASH_H_ |
| @@ -119262,11 +119259,11 @@ | |
| 119262 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 119263 | return SQLITE_OK; |
| 119264 | }else{ |
| 119265 | rc = sqlite3_reset(pCsr->pStmt); |
| 119266 | if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ |
| 119267 | /* If no row was found and no error has occured, then the %_content |
| 119268 | ** table is missing a row that is present in the full-text index. |
| 119269 | ** The data structures are corrupt. */ |
| 119270 | rc = FTS_CORRUPT_VTAB; |
| 119271 | pCsr->isEof = 1; |
| 119272 | } |
| @@ -120502,11 +120499,11 @@ | |
| 120502 | sqlite3Fts3SegReaderFinish(pSegcsr); |
| 120503 | sqlite3_free(pSegcsr); |
| 120504 | } |
| 120505 | |
| 120506 | /* |
| 120507 | ** This function retreives the doclist for the specified term (or term |
| 120508 | ** prefix) from the database. |
| 120509 | */ |
| 120510 | static int fts3TermSelect( |
| 120511 | Fts3Table *p, /* Virtual table handle */ |
| 120512 | Fts3PhraseToken *pTok, /* Token to query for */ |
| @@ -121253,11 +121250,11 @@ | |
| 121253 | #ifdef SQLITE_ENABLE_ICU |
| 121254 | SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 121255 | #endif |
| 121256 | |
| 121257 | /* |
| 121258 | ** Initialise the fts3 extension. If this extension is built as part |
| 121259 | ** of the sqlite library, then this function is called directly by |
| 121260 | ** SQLite. If fts3 is built as a dynamically loadable extension, this |
| 121261 | ** function is called by the sqlite3_extension_init() entry point. |
| 121262 | */ |
| 121263 | SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ |
| @@ -121287,11 +121284,11 @@ | |
| 121287 | if( rc!=SQLITE_OK ) return rc; |
| 121288 | |
| 121289 | sqlite3Fts3SimpleTokenizerModule(&pSimple); |
| 121290 | sqlite3Fts3PorterTokenizerModule(&pPorter); |
| 121291 | |
| 121292 | /* Allocate and initialise the hash-table used to store tokenizers. */ |
| 121293 | pHash = sqlite3_malloc(sizeof(Fts3Hash)); |
| 121294 | if( !pHash ){ |
| 121295 | rc = SQLITE_NOMEM; |
| 121296 | }else{ |
| 121297 | sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| @@ -122886,11 +122883,11 @@ | |
| 122886 | ** The returned value is either NULL or a pointer to a buffer containing |
| 122887 | ** a position-list indicating the occurrences of the phrase in column iCol |
| 122888 | ** of the current row. |
| 122889 | ** |
| 122890 | ** More specifically, the returned buffer contains 1 varint for each |
| 122891 | ** occurence of the phrase in the column, stored using the normal (delta+2) |
| 122892 | ** compression and is terminated by either an 0x01 or 0x00 byte. For example, |
| 122893 | ** if the requested column contains "a b X c d X X" and the position-list |
| 122894 | ** for 'X' is requested, the buffer returned may contain: |
| 122895 | ** |
| 122896 | ** 0x04 0x05 0x03 0x01 or 0x04 0x05 0x03 0x00 |
| @@ -123625,11 +123622,11 @@ | |
| 123625 | |
| 123626 | /* |
| 123627 | ** This function is equivalent to the standard isspace() function. |
| 123628 | ** |
| 123629 | ** The standard isspace() can be awkward to use safely, because although it |
| 123630 | ** is defined to accept an argument of type int, its behaviour when passed |
| 123631 | ** an integer that falls outside of the range of the unsigned char type |
| 123632 | ** is undefined (and sometimes, "undefined" means segfault). This wrapper |
| 123633 | ** is defined to accept an argument of type char, and always returns 0 for |
| 123634 | ** any values that fall outside of the range of the unsigned char type (i.e. |
| 123635 | ** negative values). |
| @@ -125993,11 +125990,11 @@ | |
| 125993 | #endif |
| 125994 | |
| 125995 | /* |
| 125996 | ** Set up SQL objects in database db used to access the contents of |
| 125997 | ** the hash table pointed to by argument pHash. The hash table must |
| 125998 | ** been initialised to use string keys, and to take a private copy |
| 125999 | ** of the key when a value is inserted. i.e. by a call similar to: |
| 126000 | ** |
| 126001 | ** sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| 126002 | ** |
| 126003 | ** This function adds a scalar function (see header comment above |
| @@ -127772,10 +127769,11 @@ | |
| 127772 | if( ppOffsetList ){ |
| 127773 | *ppOffsetList = pReader->pOffsetList; |
| 127774 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 127775 | } |
| 127776 | |
| 127777 | while( p<pEnd && *p==0 ) p++; |
| 127778 | |
| 127779 | /* If there are no more entries in the doclist, set pOffsetList to |
| 127780 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 127781 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| @@ -128787,13 +128785,17 @@ | |
| 128787 | ** function adjusts the pointer *ppList and the length *pnList so that they |
| 128788 | ** identify the subset of the position list that corresponds to column iCol. |
| 128789 | ** |
| 128790 | ** If there are no entries in the input position list for column iCol, then |
| 128791 | ** *pnList is set to zero before returning. |
| 128792 | */ |
| 128793 | static void fts3ColumnFilter( |
| 128794 | int iCol, /* Column to filter on */ |
| 128795 | char **ppList, /* IN/OUT: Pointer to position list */ |
| 128796 | int *pnList /* IN/OUT: Size of buffer *ppList in bytes */ |
| 128797 | ){ |
| 128798 | char *pList = *ppList; |
| 128799 | int nList = *pnList; |
| @@ -128818,10 +128820,13 @@ | |
| 128818 | } |
| 128819 | p = &pList[1]; |
| 128820 | p += sqlite3Fts3GetVarint32(p, &iCurrent); |
| 128821 | } |
| 128822 | |
| 128823 | *ppList = pList; |
| 128824 | *pnList = nList; |
| 128825 | } |
| 128826 | |
| 128827 | /* |
| @@ -128890,24 +128895,24 @@ | |
| 128890 | rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 128891 | j++; |
| 128892 | } |
| 128893 | if( rc!=SQLITE_OK ) return rc; |
| 128894 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 128895 | |
| 128896 | if( pMsr->iColFilter>=0 ){ |
| 128897 | fts3ColumnFilter(pMsr->iColFilter, &pList, &nList); |
| 128898 | } |
| 128899 | |
| 128900 | if( nList>0 ){ |
| 128901 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 128902 | rc = fts3MsrBufferData(pMsr, pList, nList+1); |
| 128903 | if( rc!=SQLITE_OK ) return rc; |
| 128904 | *paPoslist = pMsr->aBuffer; |
| 128905 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 128906 | }else{ |
| 128907 | *paPoslist = pList; |
| 128908 | } |
| 128909 | *piDocid = iDocid; |
| 128910 | *pnPoslist = nList; |
| 128911 | break; |
| 128912 | } |
| 128913 | } |
| @@ -129146,11 +129151,11 @@ | |
| 129146 | fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 129147 | j++; |
| 129148 | } |
| 129149 | |
| 129150 | if( isColFilter ){ |
| 129151 | fts3ColumnFilter(pFilter->iCol, &pList, &nList); |
| 129152 | } |
| 129153 | |
| 129154 | if( !isIgnoreEmpty || nList>0 ){ |
| 129155 | |
| 129156 | /* Calculate the 'docid' delta value to write into the merged |
| @@ -132083,13 +132088,13 @@ | |
| 132083 | ** Select the fragment of text consisting of nFragment contiguous tokens |
| 132084 | ** from column iCol that represent the "best" snippet. The best snippet |
| 132085 | ** is the snippet with the highest score, where scores are calculated |
| 132086 | ** by adding: |
| 132087 | ** |
| 132088 | ** (a) +1 point for each occurence of a matchable phrase in the snippet. |
| 132089 | ** |
| 132090 | ** (b) +1000 points for the first occurence of each matchable phrase in |
| 132091 | ** the snippet for which the corresponding mCovered bit is not set. |
| 132092 | ** |
| 132093 | ** The selected snippet parameters are stored in structure *pFragment before |
| 132094 | ** returning. The score of the selected snippet is stored in *piScore |
| 132095 | ** before returning. |
| @@ -133340,11 +133345,11 @@ | |
| 133340 | ** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all |
| 133341 | ** codepoints in the aiException[] array. |
| 133342 | ** |
| 133343 | ** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic() |
| 133344 | ** identifies as a diacritic) occurs in the zIn/nIn string it is ignored. |
| 133345 | ** It is not possible to change the behaviour of the tokenizer with respect |
| 133346 | ** to these codepoints. |
| 133347 | */ |
| 133348 | static int unicodeAddExceptions( |
| 133349 | unicode_tokenizer *p, /* Tokenizer to add exceptions to */ |
| 133350 | int bAlnum, /* Replace Isalnum() return value with this */ |
| @@ -136643,11 +136648,11 @@ | |
| 136643 | RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */ |
| 136644 | int iCell; /* Index of iDelete cell in pLeaf */ |
| 136645 | RtreeNode *pRoot; /* Root node of rtree structure */ |
| 136646 | |
| 136647 | |
| 136648 | /* Obtain a reference to the root node to initialise Rtree.iDepth */ |
| 136649 | rc = nodeAcquire(pRtree, 1, 0, &pRoot); |
| 136650 | |
| 136651 | /* Obtain a reference to the leaf node that contains the entry |
| 136652 | ** about to be deleted. |
| 136653 | */ |
| 136654 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.7.16.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -676,13 +676,13 @@ | |
| 676 | ** |
| 677 | ** See also: [sqlite3_libversion()], |
| 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | */ |
| 681 | #define SQLITE_VERSION "3.7.16.1" |
| 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | #define SQLITE_SOURCE_ID "2013-03-27 20:41:15 274d2a22660c7b34b8bbd85f3c29cbafbcb1b4e7" |
| 684 | |
| 685 | /* |
| 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | ** |
| @@ -3249,11 +3249,11 @@ | |
| 3249 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 3250 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 3251 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 3252 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 3253 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 3254 | ** a URI filename, its value overrides any behavior requested by setting |
| 3255 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 3256 | ** </ul> |
| 3257 | ** |
| 3258 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 3259 | ** error. Future versions of SQLite might understand additional query |
| @@ -4567,11 +4567,12 @@ | |
| 4567 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 4568 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 4569 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 4570 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4571 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4572 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
| 4573 | void*,sqlite3_int64); |
| 4574 | #endif |
| 4575 | |
| 4576 | /* |
| 4577 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4578 | ** |
| @@ -4647,18 +4648,21 @@ | |
| 4648 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4649 | ** implementation is never called and xFinal() is called exactly once. |
| 4650 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4651 | ** first time from within xFinal().)^ |
| 4652 | ** |
| 4653 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer |
| 4654 | ** when first called if N is less than or equal to zero or if a memory |
| 4655 | ** allocate error occurs. |
| 4656 | ** |
| 4657 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4658 | ** determined by the N parameter on first successful call. Changing the |
| 4659 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4660 | ** the same aggregate function instance will not resize the memory |
| 4661 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 4662 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 4663 | ** pointless memory allocations occur. |
| 4664 | ** |
| 4665 | ** ^SQLite automatically frees the memory allocated by |
| 4666 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4667 | ** |
| 4668 | ** The first parameter must be a copy of the |
| @@ -6948,11 +6952,11 @@ | |
| 6952 | ** intact. If the requested page is not already in the cache, then the |
| 6953 | ** cache implementation should use the value of the createFlag |
| 6954 | ** parameter to help it determined what action to take: |
| 6955 | ** |
| 6956 | ** <table border=1 width=85% align=center> |
| 6957 | ** <tr><th> createFlag <th> Behavior when page is not already in cache |
| 6958 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6959 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6960 | ** Otherwise return NULL. |
| 6961 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6962 | ** NULL if allocating a new page is effectively impossible. |
| @@ -7753,11 +7757,11 @@ | |
| 7757 | ** May you do good and not evil. |
| 7758 | ** May you find forgiveness for yourself and forgive others. |
| 7759 | ** May you share freely, never taking more than you give. |
| 7760 | ** |
| 7761 | ************************************************************************* |
| 7762 | ** This is the header file for the generic hash-table implementation |
| 7763 | ** used in SQLite. |
| 7764 | */ |
| 7765 | #ifndef _SQLITE_HASH_H_ |
| 7766 | #define _SQLITE_HASH_H_ |
| 7767 | |
| @@ -12943,13 +12947,10 @@ | |
| 12947 | "OMIT_LOOKASIDE", |
| 12948 | #endif |
| 12949 | #ifdef SQLITE_OMIT_MEMORYDB |
| 12950 | "OMIT_MEMORYDB", |
| 12951 | #endif |
| 12952 | #ifdef SQLITE_OMIT_OR_OPTIMIZATION |
| 12953 | "OMIT_OR_OPTIMIZATION", |
| 12954 | #endif |
| 12955 | #ifdef SQLITE_OMIT_PAGER_PRAGMAS |
| 12956 | "OMIT_PAGER_PRAGMAS", |
| @@ -13534,27 +13535,17 @@ | |
| 13535 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); |
| 13536 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); |
| 13537 | SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem); |
| 13538 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 13539 | |
| 13540 | SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *); |
| 13541 | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); |
| 13542 | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); |
| 13543 | SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *); |
| 13544 | SQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *); |
| 13545 | SQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *); |
| 13546 | SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *); |
| 13547 | |
| 13548 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 |
| 13549 | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*); |
| 13550 | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe*); |
| 13551 | #else |
| @@ -21334,11 +21325,11 @@ | |
| 21325 | ** returns FALSE but it still converts the prefix and writes the result |
| 21326 | ** into *pResult. |
| 21327 | */ |
| 21328 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 21329 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 21330 | int incr; |
| 21331 | const char *zEnd = z + length; |
| 21332 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 21333 | int sign = 1; /* sign of significand */ |
| 21334 | i64 s = 0; /* significand */ |
| 21335 | int d = 0; /* adjust exponent for shifting decimal point */ |
| @@ -21345,14 +21336,26 @@ | |
| 21336 | int esign = 1; /* sign of exponent */ |
| 21337 | int e = 0; /* exponent */ |
| 21338 | int eValid = 1; /* True exponent is either not used or is well-formed */ |
| 21339 | double result; |
| 21340 | int nDigits = 0; |
| 21341 | int nonNum = 0; |
| 21342 | |
| 21343 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 21344 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 21345 | |
| 21346 | if( enc==SQLITE_UTF8 ){ |
| 21347 | incr = 1; |
| 21348 | }else{ |
| 21349 | int i; |
| 21350 | incr = 2; |
| 21351 | assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); |
| 21352 | for(i=3-enc; i<length && z[i]==0; i+=2){} |
| 21353 | nonNum = i<length; |
| 21354 | zEnd = z+i+enc-3; |
| 21355 | z += (enc&1); |
| 21356 | } |
| 21357 | |
| 21358 | /* skip leading spaces */ |
| 21359 | while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; |
| 21360 | if( z>=zEnd ) return 0; |
| 21361 | |
| @@ -21481,11 +21484,11 @@ | |
| 21484 | |
| 21485 | /* store the result */ |
| 21486 | *pResult = result; |
| 21487 | |
| 21488 | /* return true if number and no extra non-whitespace chracters after */ |
| 21489 | return z>=zEnd && nDigits>0 && eValid && nonNum==0; |
| 21490 | #else |
| 21491 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 21492 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 21493 | } |
| 21494 | |
| @@ -21530,25 +21533,37 @@ | |
| 21533 | ** If zNum is exactly 9223372036854665808, return 2. This special |
| 21534 | ** case is broken out because while 9223372036854665808 cannot be a |
| 21535 | ** signed 64-bit integer, its negative -9223372036854665808 can be. |
| 21536 | ** |
| 21537 | ** If zNum is too big for a 64-bit integer and is not |
| 21538 | ** 9223372036854665808 or if zNum contains any non-numeric text, |
| 21539 | ** then return 1. |
| 21540 | ** |
| 21541 | ** length is the number of bytes in the string (bytes, not characters). |
| 21542 | ** The string is not necessarily zero-terminated. The encoding is |
| 21543 | ** given by enc. |
| 21544 | */ |
| 21545 | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ |
| 21546 | int incr; |
| 21547 | u64 u = 0; |
| 21548 | int neg = 0; /* assume positive */ |
| 21549 | int i; |
| 21550 | int c = 0; |
| 21551 | int nonNum = 0; |
| 21552 | const char *zStart; |
| 21553 | const char *zEnd = zNum + length; |
| 21554 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 21555 | if( enc==SQLITE_UTF8 ){ |
| 21556 | incr = 1; |
| 21557 | }else{ |
| 21558 | incr = 2; |
| 21559 | assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); |
| 21560 | for(i=3-enc; i<length && zNum[i]==0; i+=2){} |
| 21561 | nonNum = i<length; |
| 21562 | zEnd = zNum+i+enc-3; |
| 21563 | zNum += (enc&1); |
| 21564 | } |
| 21565 | while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr; |
| 21566 | if( zNum<zEnd ){ |
| 21567 | if( *zNum=='-' ){ |
| 21568 | neg = 1; |
| 21569 | zNum+=incr; |
| @@ -21569,11 +21584,11 @@ | |
| 21584 | *pNum = (i64)u; |
| 21585 | } |
| 21586 | testcase( i==18 ); |
| 21587 | testcase( i==19 ); |
| 21588 | testcase( i==20 ); |
| 21589 | if( (c+nonNum!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ |
| 21590 | /* zNum is empty or contains non-numeric text or is longer |
| 21591 | ** than 19 digits (thus guaranteeing that it is too large) */ |
| 21592 | return 1; |
| 21593 | }else if( i<19*incr ){ |
| 21594 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| @@ -23250,11 +23265,11 @@ | |
| 23265 | ** they may be overridden at runtime to facilitate fault injection during |
| 23266 | ** testing and sandboxing. The following array holds the names and pointers |
| 23267 | ** to all overrideable system calls. |
| 23268 | */ |
| 23269 | static struct unix_syscall { |
| 23270 | const char *zName; /* Name of the system call */ |
| 23271 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 23272 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 23273 | } aSyscall[] = { |
| 23274 | { "open", (sqlite3_syscall_ptr)posixOpen, 0 }, |
| 23275 | #define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent) |
| @@ -24822,11 +24837,11 @@ | |
| 24837 | ******************************************************************************/ |
| 24838 | |
| 24839 | /****************************************************************************** |
| 24840 | ************************* Begin dot-file Locking ****************************** |
| 24841 | ** |
| 24842 | ** The dotfile locking implementation uses the existence of separate lock |
| 24843 | ** files (really a directory) to control access to the database. This works |
| 24844 | ** on just about every filesystem imaginable. But there are serious downsides: |
| 24845 | ** |
| 24846 | ** (1) There is zero concurrency. A single reader blocks all other |
| 24847 | ** connections from reading or writing the database. |
| @@ -24837,11 +24852,11 @@ | |
| 24852 | ** Nevertheless, a dotlock is an appropriate locking mode for use if no |
| 24853 | ** other locking strategy is available. |
| 24854 | ** |
| 24855 | ** Dotfile locking works by creating a subdirectory in the same directory as |
| 24856 | ** the database and with the same name but with a ".lock" extension added. |
| 24857 | ** The existence of a lock directory implies an EXCLUSIVE lock. All other |
| 24858 | ** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE. |
| 24859 | */ |
| 24860 | |
| 24861 | /* |
| 24862 | ** The file suffix added to the data base filename in order to create the |
| @@ -26326,11 +26341,11 @@ | |
| 26341 | pFile->lastErrno = errno; |
| 26342 | return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath); |
| 26343 | } |
| 26344 | |
| 26345 | /* Also fsync the directory containing the file if the DIRSYNC flag |
| 26346 | ** is set. This is a one-time occurrence. Many systems (examples: AIX) |
| 26347 | ** are unable to fsync a directory, so ignore errors on the fsync. |
| 26348 | */ |
| 26349 | if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){ |
| 26350 | int dirfd; |
| 26351 | OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath, |
| @@ -27700,11 +27715,11 @@ | |
| 27715 | #endif |
| 27716 | ){ |
| 27717 | unixEnterMutex(); |
| 27718 | rc = findInodeInfo(pNew, &pNew->pInode); |
| 27719 | if( rc!=SQLITE_OK ){ |
| 27720 | /* If an error occurred in findInodeInfo(), close the file descriptor |
| 27721 | ** immediately, before releasing the mutex. findInodeInfo() may fail |
| 27722 | ** in two scenarios: |
| 27723 | ** |
| 27724 | ** (a) A call to fstat() failed. |
| 27725 | ** (b) A malloc failed. |
| @@ -28338,11 +28353,11 @@ | |
| 28353 | #endif |
| 28354 | return rc; |
| 28355 | } |
| 28356 | |
| 28357 | /* |
| 28358 | ** Test the existence of or access permissions of file zPath. The |
| 28359 | ** test performed depends on the value of flags: |
| 28360 | ** |
| 28361 | ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists |
| 28362 | ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. |
| 28363 | ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. |
| @@ -30442,11 +30457,11 @@ | |
| 30457 | ** they may be overridden at runtime to facilitate fault injection during |
| 30458 | ** testing and sandboxing. The following array holds the names and pointers |
| 30459 | ** to all overrideable system calls. |
| 30460 | */ |
| 30461 | static struct win_syscall { |
| 30462 | const char *zName; /* Name of the system call */ |
| 30463 | sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ |
| 30464 | sqlite3_syscall_ptr pDefault; /* Default value */ |
| 30465 | } aSyscall[] = { |
| 30466 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 30467 | { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 }, |
| @@ -32159,11 +32174,11 @@ | |
| 32174 | |
| 32175 | /* API oddity: If successful, SetFilePointer() returns a dword |
| 32176 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 32177 | ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, |
| 32178 | ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine |
| 32179 | ** whether an error has actually occurred, it is also necessary to call |
| 32180 | ** GetLastError(). |
| 32181 | */ |
| 32182 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 32183 | |
| 32184 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -32305,11 +32320,11 @@ | |
| 32320 | sqlite3_file *id, /* File to write into */ |
| 32321 | const void *pBuf, /* The bytes to be written */ |
| 32322 | int amt, /* Number of bytes to write */ |
| 32323 | sqlite3_int64 offset /* Offset into the file to begin writing at */ |
| 32324 | ){ |
| 32325 | int rc = 0; /* True if error has occurred, else false */ |
| 32326 | winFile *pFile = (winFile*)id; /* File handle */ |
| 32327 | int nRetry = 0; /* Number of retries */ |
| 32328 | |
| 32329 | assert( amt>0 ); |
| 32330 | assert( pFile ); |
| @@ -34127,11 +34142,11 @@ | |
| 34142 | OSTRACE(("DELETE \"%s\" %s\n", zFilename, (rc ? "failed" : "ok" ))); |
| 34143 | return rc; |
| 34144 | } |
| 34145 | |
| 34146 | /* |
| 34147 | ** Check the existence and status of a file. |
| 34148 | */ |
| 34149 | static int winAccess( |
| 34150 | sqlite3_vfs *pVfs, /* Not used on win32 */ |
| 34151 | const char *zFilename, /* Name of file to check */ |
| 34152 | int flags, /* Type of test to make on this file */ |
| @@ -34736,11 +34751,11 @@ | |
| 34751 | |
| 34752 | |
| 34753 | /* |
| 34754 | ** A bitmap is an instance of the following structure. |
| 34755 | ** |
| 34756 | ** This bitmap records the existence of zero or more bits |
| 34757 | ** with values between 1 and iSize, inclusive. |
| 34758 | ** |
| 34759 | ** There are three possible representations of the bitmap. |
| 34760 | ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight |
| 34761 | ** bitmap. The least significant bit is bit 1. |
| @@ -37638,11 +37653,11 @@ | |
| 37653 | ** layer must either commit or rollback the transaction. |
| 37654 | ** |
| 37655 | ** * A write transaction is active. |
| 37656 | ** * An EXCLUSIVE or greater lock is held on the database file. |
| 37657 | ** * All writing and syncing of journal and database data has finished. |
| 37658 | ** If no error occurred, all that remains is to finalize the journal to |
| 37659 | ** commit the transaction. If an error did occur, the caller will need |
| 37660 | ** to rollback the transaction. |
| 37661 | ** |
| 37662 | ** ERROR: |
| 37663 | ** |
| @@ -37886,11 +37901,11 @@ | |
| 37901 | ** journal file from being successfully finalized, the setMaster flag |
| 37902 | ** is cleared anyway (and the pager will move to ERROR state). |
| 37903 | ** |
| 37904 | ** doNotSpill, doNotSyncSpill |
| 37905 | ** |
| 37906 | ** These two boolean variables control the behavior of cache-spills |
| 37907 | ** (calls made by the pcache module to the pagerStress() routine to |
| 37908 | ** write cached data to the file-system in order to free up memory). |
| 37909 | ** |
| 37910 | ** When doNotSpill is non-zero, writing to the database from pagerStress() |
| 37911 | ** is disabled altogether. This is done in a very obscure case that |
| @@ -38764,11 +38779,11 @@ | |
| 38779 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 38780 | }else{ |
| 38781 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 38782 | } |
| 38783 | |
| 38784 | /* The random check-hash initializer */ |
| 38785 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); |
| 38786 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 38787 | /* The initial database size */ |
| 38788 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 38789 | /* The assumed sector size for this process */ |
| @@ -41096,11 +41111,11 @@ | |
| 41111 | ** |
| 41112 | ** If the condition asserted by this function were not true, and the |
| 41113 | ** dirty page were to be discarded from the cache via the pagerStress() |
| 41114 | ** routine, pagerStress() would not write the current page content to |
| 41115 | ** the database file. If a savepoint transaction were rolled back after |
| 41116 | ** this happened, the correct behavior would be to restore the current |
| 41117 | ** content of the page. However, since this content is not present in either |
| 41118 | ** the database file or the portion of the rollback journal and |
| 41119 | ** sub-journal rolled back the content could not be restored and the |
| 41120 | ** database image would become corrupt. It is therefore fortunate that |
| 41121 | ** this circumstance cannot arise. |
| @@ -48938,10 +48953,23 @@ | |
| 48953 | */ |
| 48954 | static void btreeClearHasContent(BtShared *pBt){ |
| 48955 | sqlite3BitvecDestroy(pBt->pHasContent); |
| 48956 | pBt->pHasContent = 0; |
| 48957 | } |
| 48958 | |
| 48959 | /* |
| 48960 | ** Release all of the apPage[] pages for a cursor. |
| 48961 | */ |
| 48962 | static void btreeReleaseAllCursorPages(BtCursor *pCur){ |
| 48963 | int i; |
| 48964 | for(i=0; i<=pCur->iPage; i++){ |
| 48965 | releasePage(pCur->apPage[i]); |
| 48966 | pCur->apPage[i] = 0; |
| 48967 | } |
| 48968 | pCur->iPage = -1; |
| 48969 | } |
| 48970 | |
| 48971 | |
| 48972 | /* |
| 48973 | ** Save the current cursor position in the variables BtCursor.nKey |
| 48974 | ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. |
| 48975 | ** |
| @@ -48978,16 +49006,11 @@ | |
| 49006 | } |
| 49007 | } |
| 49008 | assert( !pCur->apPage[0]->intKey || !pCur->pKey ); |
| 49009 | |
| 49010 | if( rc==SQLITE_OK ){ |
| 49011 | btreeReleaseAllCursorPages(pCur); |
| 49012 | pCur->eState = CURSOR_REQUIRESEEK; |
| 49013 | } |
| 49014 | |
| 49015 | invalidateOverflowCache(pCur); |
| 49016 | return rc; |
| @@ -49001,15 +49024,19 @@ | |
| 49024 | static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){ |
| 49025 | BtCursor *p; |
| 49026 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 49027 | assert( pExcept==0 || pExcept->pBt==pBt ); |
| 49028 | for(p=pBt->pCursor; p; p=p->pNext){ |
| 49029 | if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){ |
| 49030 | if( p->eState==CURSOR_VALID ){ |
| 49031 | int rc = saveCursorPosition(p); |
| 49032 | if( SQLITE_OK!=rc ){ |
| 49033 | return rc; |
| 49034 | } |
| 49035 | }else{ |
| 49036 | testcase( p->iPage>0 ); |
| 49037 | btreeReleaseAllCursorPages(p); |
| 49038 | } |
| 49039 | } |
| 49040 | } |
| 49041 | return SQLITE_OK; |
| 49042 | } |
| @@ -50593,11 +50620,11 @@ | |
| 50620 | ** |
| 50621 | ** This is useful in one special case in the backup API code where it is |
| 50622 | ** known that the shared b-tree mutex is held, but the mutex on the |
| 50623 | ** database handle that owns *p is not. In this case if sqlite3BtreeEnter() |
| 50624 | ** were to be called, it might collide with some other operation on the |
| 50625 | ** database handle that owns *p, causing undefined behavior. |
| 50626 | */ |
| 50627 | SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){ |
| 50628 | assert( sqlite3_mutex_held(p->pBt->mutex) ); |
| 50629 | return p->pBt->pageSize - p->pBt->usableSize; |
| 50630 | } |
| @@ -53873,11 +53900,11 @@ | |
| 53900 | ** for that page now. |
| 53901 | ** |
| 53902 | ** If this is the first overflow page, then write a partial entry |
| 53903 | ** to the pointer-map. If we write nothing to this pointer-map slot, |
| 53904 | ** then the optimistic overflow chain processing in clearCell() |
| 53905 | ** may misinterpret the uninitialized values and delete the |
| 53906 | ** wrong pages from the database. |
| 53907 | */ |
| 53908 | if( pBt->autoVacuum && rc==SQLITE_OK ){ |
| 53909 | u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1); |
| 53910 | ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc); |
| @@ -55346,11 +55373,11 @@ | |
| 55373 | assert( pPage->leaf ); |
| 55374 | } |
| 55375 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 55376 | assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); |
| 55377 | |
| 55378 | /* If no error has occurred and pPage has an overflow cell, call balance() |
| 55379 | ** to redistribute the cells within the tree. Since balance() may move |
| 55380 | ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey |
| 55381 | ** variables. |
| 55382 | ** |
| 55383 | ** Previous versions of SQLite called moveToRoot() to move the cursor |
| @@ -59080,11 +59107,11 @@ | |
| 59107 | break; |
| 59108 | } |
| 59109 | } |
| 59110 | sqlite3DbFree(v->db, sIter.apSub); |
| 59111 | |
| 59112 | /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred. |
| 59113 | ** If malloc failed, then the while() loop above may not have iterated |
| 59114 | ** through all opcodes and hasAbort may be set incorrectly. Return |
| 59115 | ** true for this case to prevent the assert() in the callers frame |
| 59116 | ** from failing. */ |
| 59117 | return ( v->db->mallocFailed || hasAbort==mayAbort ); |
| @@ -60712,11 +60739,11 @@ | |
| 60739 | sqlite3 *const db = p->db; |
| 60740 | int rc = SQLITE_OK; |
| 60741 | |
| 60742 | /* If p->iStatement is greater than zero, then this Vdbe opened a |
| 60743 | ** statement transaction that should be closed here. The only exception |
| 60744 | ** is that an IO error may have occurred, causing an emergency rollback. |
| 60745 | ** In this case (db->nStatement==0), and there is nothing to do. |
| 60746 | */ |
| 60747 | if( db->nStatement && p->iStatement ){ |
| 60748 | int i; |
| 60749 | const int iSavepoint = p->iStatement-1; |
| @@ -60848,11 +60875,11 @@ | |
| 60875 | ** transaction must be rolled back to restore the database to a |
| 60876 | ** consistent state. |
| 60877 | ** |
| 60878 | ** Even if the statement is read-only, it is important to perform |
| 60879 | ** a statement or transaction rollback operation. If the error |
| 60880 | ** occurred while writing to the journal, sub-journal or database |
| 60881 | ** file as part of an effort to free up cache space (see function |
| 60882 | ** pagerStress() in pager.c), the rollback is required to restore |
| 60883 | ** the pager to a consistent state. |
| 60884 | */ |
| 60885 | if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){ |
| @@ -61262,11 +61289,11 @@ | |
| 61289 | ** |
| 61290 | ** In an SQLite index record, the serial type is stored directly before |
| 61291 | ** the blob of data that it corresponds to. In a table record, all serial |
| 61292 | ** types are stored at the start of the record, and the blobs of data at |
| 61293 | ** the end. Hence these functions allow the caller to handle the |
| 61294 | ** serial-type and data blob separately. |
| 61295 | ** |
| 61296 | ** The following table describes the various storage classes for data: |
| 61297 | ** |
| 61298 | ** serial type bytes of data type |
| 61299 | ** -------------- --------------- --------------- |
| @@ -62402,11 +62429,11 @@ | |
| 62429 | || rc==SQLITE_BUSY || rc==SQLITE_MISUSE |
| 62430 | ); |
| 62431 | assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); |
| 62432 | if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ |
| 62433 | /* If this statement was prepared using sqlite3_prepare_v2(), and an |
| 62434 | ** error has occurred, then return the error code in p->rc to the |
| 62435 | ** caller. Set the error code in the database handle to the same value. |
| 62436 | */ |
| 62437 | rc = sqlite3VdbeTransferError(p); |
| 62438 | } |
| 62439 | return (rc&db->errMask); |
| @@ -63692,15 +63719,11 @@ | |
| 63719 | #define Deephemeralize(P) \ |
| 63720 | if( ((P)->flags&MEM_Ephem)!=0 \ |
| 63721 | && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} |
| 63722 | |
| 63723 | /* Return true if the cursor was opened using the OP_OpenSorter opcode. */ |
| 63724 | # define isSorter(x) ((x)->pSorter!=0) |
| 63725 | |
| 63726 | /* |
| 63727 | ** Argument pMem points at a register that will be passed to a |
| 63728 | ** user-defined function or returned to the user as the result of a query. |
| 63729 | ** This routine sets the pMem->type variable used by the sqlite3_value_*() |
| @@ -67433,21 +67456,16 @@ | |
| 67456 | case OP_SorterOpen: { |
| 67457 | #if 0 /* local variables moved into u.ba */ |
| 67458 | VdbeCursor *pCx; |
| 67459 | #endif /* local variables moved into u.ba */ |
| 67460 | |
| 67461 | u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 67462 | if( u.ba.pCx==0 ) goto no_mem; |
| 67463 | u.ba.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 67464 | u.ba.pCx->pKeyInfo->enc = ENC(p->db); |
| 67465 | u.ba.pCx->isSorter = 1; |
| 67466 | rc = sqlite3VdbeSorterInit(db, u.ba.pCx); |
| 67467 | break; |
| 67468 | } |
| 67469 | |
| 67470 | /* Opcode: OpenPseudo P1 P2 P3 * P5 |
| 67471 | ** |
| @@ -68348,19 +68366,14 @@ | |
| 68366 | case OP_SorterData: { |
| 68367 | #if 0 /* local variables moved into u.bl */ |
| 68368 | VdbeCursor *pC; |
| 68369 | #endif /* local variables moved into u.bl */ |
| 68370 | |
| 68371 | pOut = &aMem[pOp->p2]; |
| 68372 | u.bl.pC = p->apCsr[pOp->p1]; |
| 68373 | assert( u.bl.pC->isSorter ); |
| 68374 | rc = sqlite3VdbeSorterRowkey(u.bl.pC, pOut); |
| 68375 | break; |
| 68376 | } |
| 68377 | |
| 68378 | /* Opcode: RowData P1 P2 * * * |
| 68379 | ** |
| @@ -68563,13 +68576,10 @@ | |
| 68576 | ** rewinding so that the global variable will be incremented and |
| 68577 | ** regression tests can determine whether or not the optimizer is |
| 68578 | ** correctly optimizing out sorts. |
| 68579 | */ |
| 68580 | case OP_SorterSort: /* jump */ |
| 68581 | case OP_Sort: { /* jump */ |
| 68582 | #ifdef SQLITE_TEST |
| 68583 | sqlite3_sort_count++; |
| 68584 | sqlite3_search_count--; |
| 68585 | #endif |
| @@ -68646,13 +68656,10 @@ | |
| 68656 | ** |
| 68657 | ** If P5 is positive and the jump is taken, then event counter |
| 68658 | ** number P5-1 in the prepared statement is incremented. |
| 68659 | */ |
| 68660 | case OP_SorterNext: /* jump */ |
| 68661 | case OP_Prev: /* jump */ |
| 68662 | case OP_Next: { /* jump */ |
| 68663 | #if 0 /* local variables moved into u.br */ |
| 68664 | VdbeCursor *pC; |
| 68665 | int res; |
| @@ -68701,13 +68708,10 @@ | |
| 68708 | ** |
| 68709 | ** This instruction only works for indices. The equivalent instruction |
| 68710 | ** for tables is OP_Insert. |
| 68711 | */ |
| 68712 | case OP_SorterInsert: /* in2 */ |
| 68713 | case OP_IdxInsert: { /* in2 */ |
| 68714 | #if 0 /* local variables moved into u.bs */ |
| 68715 | VdbeCursor *pC; |
| 68716 | BtCursor *pCrsr; |
| 68717 | int nKey; |
| @@ -69972,11 +69976,11 @@ | |
| 69976 | importVtabErrMsg(p, u.cm.pVtab); |
| 69977 | if( SQLITE_OK==rc ){ |
| 69978 | /* Initialize sqlite3_vtab_cursor base class */ |
| 69979 | u.cm.pVtabCursor->pVtab = u.cm.pVtab; |
| 69980 | |
| 69981 | /* Initialize vdbe cursor object */ |
| 69982 | u.cm.pCur = allocateCursor(p, pOp->p1, 0, -1, 0); |
| 69983 | if( u.cm.pCur ){ |
| 69984 | u.cm.pCur->pVtabCursor = u.cm.pVtabCursor; |
| 69985 | u.cm.pCur->pModule = u.cm.pVtabCursor->pVtab->pModule; |
| 69986 | }else{ |
| @@ -70954,11 +70958,10 @@ | |
| 70958 | ** example, by CREATE INDEX statements on tables too large to fit in main |
| 70959 | ** memory). |
| 70960 | */ |
| 70961 | |
| 70962 | |
| 70963 | |
| 70964 | typedef struct VdbeSorterIter VdbeSorterIter; |
| 70965 | typedef struct SorterRecord SorterRecord; |
| 70966 | typedef struct FileWriter FileWriter; |
| 70967 | |
| @@ -71974,12 +71977,10 @@ | |
| 71977 | pKey = vdbeSorterRowkey(pSorter, &nKey); |
| 71978 | vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes); |
| 71979 | return SQLITE_OK; |
| 71980 | } |
| 71981 | |
| 71982 | /************** End of vdbesort.c ********************************************/ |
| 71983 | /************** Begin file journal.c *****************************************/ |
| 71984 | /* |
| 71985 | ** 2007 August 22 |
| 71986 | ** |
| @@ -77513,11 +77514,11 @@ | |
| 77514 | int regFree1 = 0; |
| 77515 | int regFree2 = 0; |
| 77516 | int r1, r2; |
| 77517 | |
| 77518 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77519 | if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */ |
| 77520 | if( NEVER(pExpr==0) ) return; /* No way this can happen */ |
| 77521 | op = pExpr->op; |
| 77522 | switch( op ){ |
| 77523 | case TK_AND: { |
| 77524 | int d2 = sqlite3VdbeMakeLabel(v); |
| @@ -77633,11 +77634,11 @@ | |
| 77634 | int regFree1 = 0; |
| 77635 | int regFree2 = 0; |
| 77636 | int r1, r2; |
| 77637 | |
| 77638 | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); |
| 77639 | if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */ |
| 77640 | if( pExpr==0 ) return; |
| 77641 | |
| 77642 | /* The value of pExpr->op and op are related as follows: |
| 77643 | ** |
| 77644 | ** pExpr->op op |
| @@ -80230,11 +80231,11 @@ | |
| 80231 | zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); |
| 80232 | goto attach_error; |
| 80233 | } |
| 80234 | } |
| 80235 | |
| 80236 | /* Allocate the new entry in the db->aDb[] array and initialize the schema |
| 80237 | ** hash tables. |
| 80238 | */ |
| 80239 | if( db->aDb==db->aDbStatic ){ |
| 80240 | aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 ); |
| 80241 | if( aNew==0 ) return; |
| @@ -80247,11 +80248,11 @@ | |
| 80248 | aNew = &db->aDb[db->nDb]; |
| 80249 | memset(aNew, 0, sizeof(*aNew)); |
| 80250 | |
| 80251 | /* Open the database file. If the btree is successfully opened, use |
| 80252 | ** it to obtain the database schema. At this point the schema may |
| 80253 | ** or may not be initialized. |
| 80254 | */ |
| 80255 | flags = db->openFlags; |
| 80256 | rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr); |
| 80257 | if( rc!=SQLITE_OK ){ |
| 80258 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; |
| @@ -83033,11 +83034,11 @@ | |
| 83034 | #endif |
| 83035 | |
| 83036 | /* Drop all SQLITE_MASTER table and index entries that refer to the |
| 83037 | ** table. The program name loops through the master table and deletes |
| 83038 | ** every row that refers to a table of the same name as the one being |
| 83039 | ** dropped. Triggers are handled separately because a trigger can be |
| 83040 | ** created in the temp database that refers to a table in another |
| 83041 | ** database. |
| 83042 | */ |
| 83043 | sqlite3NestedParse(pParse, |
| 83044 | "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", |
| @@ -83325,13 +83326,10 @@ | |
| 83326 | int addr1; /* Address of top of loop */ |
| 83327 | int addr2; /* Address to jump to for next iteration */ |
| 83328 | int tnum; /* Root page of index */ |
| 83329 | Vdbe *v; /* Generate code into this virtual machine */ |
| 83330 | KeyInfo *pKey; /* KeyInfo for index */ |
| 83331 | int regRecord; /* Register holding assemblied index record */ |
| 83332 | sqlite3 *db = pParse->db; /* The database connection */ |
| 83333 | int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); |
| 83334 | |
| 83335 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -83355,25 +83353,20 @@ | |
| 83353 | pKey = sqlite3IndexKeyinfo(pParse, pIndex); |
| 83354 | sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, |
| 83355 | (char *)pKey, P4_KEYINFO_HANDOFF); |
| 83356 | sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); |
| 83357 | |
| 83358 | /* Open the sorter cursor if we are to use one. */ |
| 83359 | iSorter = pParse->nTab++; |
| 83360 | sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); |
| 83361 | |
| 83362 | /* Open the table. Loop through all rows of the table, inserting index |
| 83363 | ** records into the sorter. */ |
| 83364 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 83365 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 83366 | regRecord = sqlite3GetTempReg(pParse); |
| 83367 | |
| 83368 | sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 83369 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 83370 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 83371 | sqlite3VdbeJumpHere(v, addr1); |
| 83372 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| @@ -83389,34 +83382,10 @@ | |
| 83382 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 83383 | } |
| 83384 | sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord); |
| 83385 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1); |
| 83386 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 83387 | sqlite3ReleaseTempReg(pParse, regRecord); |
| 83388 | sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); |
| 83389 | sqlite3VdbeJumpHere(v, addr1); |
| 83390 | |
| 83391 | sqlite3VdbeAddOp1(v, OP_Close, iTab); |
| @@ -83772,11 +83741,11 @@ | |
| 83741 | /* This constraint creates the same index as a previous |
| 83742 | ** constraint specified somewhere in the CREATE TABLE statement. |
| 83743 | ** However the ON CONFLICT clauses are different. If both this |
| 83744 | ** constraint and the previous equivalent constraint have explicit |
| 83745 | ** ON CONFLICT clauses this is an error. Otherwise, use the |
| 83746 | ** explicitly specified behavior for the index. |
| 83747 | */ |
| 83748 | if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){ |
| 83749 | sqlite3ErrorMsg(pParse, |
| 83750 | "conflicting ON CONFLICT clauses specified", 0); |
| 83751 | } |
| @@ -94054,11 +94023,11 @@ | |
| 94023 | assert( sqlite3_mutex_held(db->mutex) ); |
| 94024 | assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); |
| 94025 | |
| 94026 | /* zMasterSchema and zInitScript are set to point at the master schema |
| 94027 | ** and initialisation script appropriate for the database being |
| 94028 | ** initialized. zMasterName is the name of the master table. |
| 94029 | */ |
| 94030 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 94031 | zMasterSchema = temp_master_schema; |
| 94032 | }else{ |
| 94033 | zMasterSchema = master_schema; |
| @@ -94279,11 +94248,11 @@ | |
| 94248 | if( rc ){ |
| 94249 | sqlite3ResetOneSchema(db, i); |
| 94250 | } |
| 94251 | } |
| 94252 | |
| 94253 | /* Once all the other databases have been initialized, load the schema |
| 94254 | ** for the TEMP database. This is loaded last, as the TEMP database |
| 94255 | ** schema may contain references to objects in other databases. |
| 94256 | */ |
| 94257 | #ifndef SQLITE_OMIT_TEMPDB |
| 94258 | if( rc==SQLITE_OK && ALWAYS(db->nDb>1) |
| @@ -94302,11 +94271,11 @@ | |
| 94271 | |
| 94272 | return rc; |
| 94273 | } |
| 94274 | |
| 94275 | /* |
| 94276 | ** This routine is a no-op if the database schema is already initialized. |
| 94277 | ** Otherwise, the schema is loaded. An error code is returned. |
| 94278 | */ |
| 94279 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){ |
| 94280 | int rc = SQLITE_OK; |
| 94281 | sqlite3 *db = pParse->db; |
| @@ -99315,11 +99284,11 @@ | |
| 99284 | ** first iteration (since the first iteration of the loop is |
| 99285 | ** guaranteed to operate on the row with the minimum or maximum |
| 99286 | ** value of x, the only row required). |
| 99287 | ** |
| 99288 | ** A special flag must be passed to sqlite3WhereBegin() to slightly |
| 99289 | ** modify behavior as follows: |
| 99290 | ** |
| 99291 | ** + If the query is a "SELECT min(x)", then the loop coded by |
| 99292 | ** where.c should not iterate over any values with a NULL value |
| 99293 | ** for x. |
| 99294 | ** |
| @@ -101308,11 +101277,11 @@ | |
| 101277 | sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, |
| 101278 | TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); |
| 101279 | |
| 101280 | /* The row-trigger may have deleted the row being updated. In this |
| 101281 | ** case, jump to the next row. No updates or AFTER triggers are |
| 101282 | ** required. This behavior - what happens when the row being updated |
| 101283 | ** is deleted or renamed by a BEFORE trigger - is left undefined in the |
| 101284 | ** documentation. |
| 101285 | */ |
| 101286 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); |
| 101287 | |
| @@ -103237,10 +103206,12 @@ | |
| 103206 | #define WHERE_IDX_ONLY 0x00400000 /* Use index only - omit table */ |
| 103207 | #define WHERE_ORDERED 0x00800000 /* Output will appear in correct order */ |
| 103208 | #define WHERE_REVERSE 0x01000000 /* Scan in reverse order */ |
| 103209 | #define WHERE_UNIQUE 0x02000000 /* Selects no more than one row */ |
| 103210 | #define WHERE_ALL_UNIQUE 0x04000000 /* This and all prior have one row */ |
| 103211 | #define WHERE_OB_UNIQUE 0x00004000 /* Values in ORDER BY columns are |
| 103212 | ** different for every output row */ |
| 103213 | #define WHERE_VIRTUALTABLE 0x08000000 /* Use virtual-table processing */ |
| 103214 | #define WHERE_MULTI_OR 0x10000000 /* OR using multiple indices */ |
| 103215 | #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */ |
| 103216 | #define WHERE_DISTINCT 0x40000000 /* Correct order for DISTINCT */ |
| 103217 | #define WHERE_COVER_SCAN 0x80000000 /* Full scan of a covering index */ |
| @@ -103537,11 +103508,11 @@ | |
| 103508 | |
| 103509 | /* |
| 103510 | ** Commute a comparison operator. Expressions of the form "X op Y" |
| 103511 | ** are converted into "Y op X". |
| 103512 | ** |
| 103513 | ** If left/right precedence rules come into play when determining the |
| 103514 | ** collating |
| 103515 | ** side of the comparison, it remains associated with the same side after |
| 103516 | ** the commutation. So "Y collate NOCASE op X" becomes |
| 103517 | ** "X op Y". This is because any collation sequence on |
| 103518 | ** the left hand side of a comparison overrides any collation sequence |
| @@ -105878,11 +105849,12 @@ | |
| 105849 | */ |
| 105850 | static int isSortingIndex( |
| 105851 | WhereBestIdx *p, /* Best index search context */ |
| 105852 | Index *pIdx, /* The index we are testing */ |
| 105853 | int base, /* Cursor number for the table to be sorted */ |
| 105854 | int *pbRev, /* Set to 1 for reverse-order scan of pIdx */ |
| 105855 | int *pbObUnique /* ORDER BY column values will different in every row */ |
| 105856 | ){ |
| 105857 | int i; /* Number of pIdx terms used */ |
| 105858 | int j; /* Number of ORDER BY terms satisfied */ |
| 105859 | int sortOrder = 2; /* 0: forward. 1: backward. 2: unknown */ |
| 105860 | int nTerm; /* Number of ORDER BY terms */ |
| @@ -105892,25 +105864,32 @@ | |
| 105864 | Parse *pParse = p->pParse; /* Parser context */ |
| 105865 | sqlite3 *db = pParse->db; /* Database connection */ |
| 105866 | int nPriorSat; /* ORDER BY terms satisfied by outer loops */ |
| 105867 | int seenRowid = 0; /* True if an ORDER BY rowid term is seen */ |
| 105868 | int uniqueNotNull; /* pIdx is UNIQUE with all terms are NOT NULL */ |
| 105869 | int outerObUnique; /* Outer loops generate different values in |
| 105870 | ** every row for the ORDER BY columns */ |
| 105871 | |
| 105872 | if( p->i==0 ){ |
| 105873 | nPriorSat = 0; |
| 105874 | outerObUnique = 1; |
| 105875 | }else{ |
| 105876 | u32 wsFlags = p->aLevel[p->i-1].plan.wsFlags; |
| 105877 | nPriorSat = p->aLevel[p->i-1].plan.nOBSat; |
| 105878 | if( (wsFlags & WHERE_ORDERED)==0 ){ |
| 105879 | /* This loop cannot be ordered unless the next outer loop is |
| 105880 | ** also ordered */ |
| 105881 | return nPriorSat; |
| 105882 | } |
| 105883 | if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){ |
| 105884 | /* Only look at the outer-most loop if the OrderByIdxJoin |
| 105885 | ** optimization is disabled */ |
| 105886 | return nPriorSat; |
| 105887 | } |
| 105888 | testcase( wsFlags & WHERE_OB_UNIQUE ); |
| 105889 | testcase( wsFlags & WHERE_ALL_UNIQUE ); |
| 105890 | outerObUnique = (wsFlags & (WHERE_OB_UNIQUE|WHERE_ALL_UNIQUE))!=0; |
| 105891 | } |
| 105892 | pOrderBy = p->pOrderBy; |
| 105893 | assert( pOrderBy!=0 ); |
| 105894 | if( pIdx->bUnordered ){ |
| 105895 | /* Hash indices (indicated by the "unordered" tag on sqlite_stat1) cannot |
| @@ -106048,23 +106027,38 @@ | |
| 106027 | testcase( isEq==2 ); |
| 106028 | testcase( isEq==3 ); |
| 106029 | uniqueNotNull = 0; |
| 106030 | } |
| 106031 | } |
| 106032 | if( seenRowid ){ |
| 106033 | uniqueNotNull = 1; |
| 106034 | }else if( uniqueNotNull==0 || i<pIdx->nColumn ){ |
| 106035 | uniqueNotNull = 0; |
| 106036 | } |
| 106037 | |
| 106038 | /* If we have not found at least one ORDER BY term that matches the |
| 106039 | ** index, then show no progress. */ |
| 106040 | if( pOBItem==&pOrderBy->a[nPriorSat] ) return nPriorSat; |
| 106041 | |
| 106042 | /* Either the outer queries must generate rows where there are no two |
| 106043 | ** rows with the same values in all ORDER BY columns, or else this |
| 106044 | ** loop must generate just a single row of output. Example: Suppose |
| 106045 | ** the outer loops generate A=1 and A=1, and this loop generates B=3 |
| 106046 | ** and B=4. Then without the following test, ORDER BY A,B would |
| 106047 | ** generate the wrong order output: 1,3 1,4 1,3 1,4 |
| 106048 | */ |
| 106049 | if( outerObUnique==0 && uniqueNotNull==0 ) return nPriorSat; |
| 106050 | *pbObUnique = uniqueNotNull; |
| 106051 | |
| 106052 | /* Return the necessary scan order back to the caller */ |
| 106053 | *pbRev = sortOrder & 1; |
| 106054 | |
| 106055 | /* If there was an "ORDER BY rowid" term that matched, or it is only |
| 106056 | ** possible for a single row from this table to match, then skip over |
| 106057 | ** any additional ORDER BY terms dealing with this table. |
| 106058 | */ |
| 106059 | if( uniqueNotNull ){ |
| 106060 | /* Advance j over additional ORDER BY terms associated with base */ |
| 106061 | WhereMaskSet *pMS = p->pWC->pMaskSet; |
| 106062 | Bitmask m = ~getMask(pMS, base); |
| 106063 | while( j<nTerm && (exprTableUsage(pMS, pOrderBy->a[j].pExpr)&m)==0 ){ |
| 106064 | j++; |
| @@ -106344,16 +106338,18 @@ | |
| 106338 | ** in pc.plan.wsFlags. Otherwise, if there is an ORDER BY clause but |
| 106339 | ** the index will scan rows in a different order, set the bSort |
| 106340 | ** variable. */ |
| 106341 | if( bSort && (pSrc->jointype & JT_LEFT)==0 ){ |
| 106342 | int bRev = 2; |
| 106343 | int bObUnique = 0; |
| 106344 | WHERETRACE((" --> before isSortIndex: nPriorSat=%d\n",nPriorSat)); |
| 106345 | pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev, &bObUnique); |
| 106346 | WHERETRACE((" --> after isSortIndex: bRev=%d bObU=%d nOBSat=%d\n", |
| 106347 | bRev, bObUnique, pc.plan.nOBSat)); |
| 106348 | if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){ |
| 106349 | pc.plan.wsFlags |= WHERE_ORDERED; |
| 106350 | if( bObUnique ) pc.plan.wsFlags |= WHERE_OB_UNIQUE; |
| 106351 | } |
| 106352 | if( nOrderBy==pc.plan.nOBSat ){ |
| 106353 | bSort = 0; |
| 106354 | pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE; |
| 106355 | } |
| @@ -106443,11 +106439,12 @@ | |
| 106439 | ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do |
| 106440 | ** not give us data on the relative sizes of table and index records. |
| 106441 | ** So this computation assumes table records are about twice as big |
| 106442 | ** as index records |
| 106443 | */ |
| 106444 | if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED|WHERE_OB_UNIQUE)) |
| 106445 | ==WHERE_IDX_ONLY |
| 106446 | && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 |
| 106447 | && sqlite3GlobalConfig.bUseCis |
| 106448 | && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan) |
| 106449 | ){ |
| 106450 | /* This index is not useful for indexing, but it is a covering index. |
| @@ -106603,11 +106600,11 @@ | |
| 106600 | } |
| 106601 | |
| 106602 | /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag |
| 106603 | ** is set, then reverse the order that the index will be scanned |
| 106604 | ** in. This is used for application testing, to help find cases |
| 106605 | ** where application behavior depends on the (undefined) order that |
| 106606 | ** SQLite outputs rows in in the absence of an ORDER BY clause. */ |
| 106607 | if( !p->pOrderBy && pParse->db->flags & SQLITE_ReverseOrder ){ |
| 106608 | p->cost.plan.wsFlags |= WHERE_REVERSE; |
| 106609 | } |
| 106610 | |
| @@ -114198,11 +114195,11 @@ | |
| 114195 | return; |
| 114196 | } |
| 114197 | |
| 114198 | /* If we reach this point, it means that the database connection has |
| 114199 | ** closed all sqlite3_stmt and sqlite3_backup objects and has been |
| 114200 | ** passed to sqlite3_close (meaning that it is a zombie). Therefore, |
| 114201 | ** go ahead and free all resources. |
| 114202 | */ |
| 114203 | |
| 114204 | /* Free any outstanding Savepoint structures. */ |
| 114205 | sqlite3CloseSavepoints(db); |
| @@ -117250,11 +117247,11 @@ | |
| 117247 | ** to the strings "arg1" and "arg2". |
| 117248 | ** |
| 117249 | ** This method should return either SQLITE_OK (0), or an SQLite error |
| 117250 | ** code. If SQLITE_OK is returned, then *ppTokenizer should be set |
| 117251 | ** to point at the newly created tokenizer structure. The generic |
| 117252 | ** sqlite3_tokenizer.pModule variable should not be initialized by |
| 117253 | ** this callback. The caller will do so. |
| 117254 | */ |
| 117255 | int (*xCreate)( |
| 117256 | int argc, /* Size of argv array */ |
| 117257 | const char *const*argv, /* Tokenizer argument strings */ |
| @@ -117355,11 +117352,11 @@ | |
| 117352 | ** May you do good and not evil. |
| 117353 | ** May you find forgiveness for yourself and forgive others. |
| 117354 | ** May you share freely, never taking more than you give. |
| 117355 | ** |
| 117356 | ************************************************************************* |
| 117357 | ** This is the header file for the generic hash-table implementation |
| 117358 | ** used in SQLite. We've modified it slightly to serve as a standalone |
| 117359 | ** hash table implementation for the full-text indexing module. |
| 117360 | ** |
| 117361 | */ |
| 117362 | #ifndef _FTS3_HASH_H_ |
| @@ -119262,11 +119259,11 @@ | |
| 119259 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 119260 | return SQLITE_OK; |
| 119261 | }else{ |
| 119262 | rc = sqlite3_reset(pCsr->pStmt); |
| 119263 | if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ |
| 119264 | /* If no row was found and no error has occurred, then the %_content |
| 119265 | ** table is missing a row that is present in the full-text index. |
| 119266 | ** The data structures are corrupt. */ |
| 119267 | rc = FTS_CORRUPT_VTAB; |
| 119268 | pCsr->isEof = 1; |
| 119269 | } |
| @@ -120502,11 +120499,11 @@ | |
| 120499 | sqlite3Fts3SegReaderFinish(pSegcsr); |
| 120500 | sqlite3_free(pSegcsr); |
| 120501 | } |
| 120502 | |
| 120503 | /* |
| 120504 | ** This function retrieves the doclist for the specified term (or term |
| 120505 | ** prefix) from the database. |
| 120506 | */ |
| 120507 | static int fts3TermSelect( |
| 120508 | Fts3Table *p, /* Virtual table handle */ |
| 120509 | Fts3PhraseToken *pTok, /* Token to query for */ |
| @@ -121253,11 +121250,11 @@ | |
| 121250 | #ifdef SQLITE_ENABLE_ICU |
| 121251 | SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 121252 | #endif |
| 121253 | |
| 121254 | /* |
| 121255 | ** Initialize the fts3 extension. If this extension is built as part |
| 121256 | ** of the sqlite library, then this function is called directly by |
| 121257 | ** SQLite. If fts3 is built as a dynamically loadable extension, this |
| 121258 | ** function is called by the sqlite3_extension_init() entry point. |
| 121259 | */ |
| 121260 | SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ |
| @@ -121287,11 +121284,11 @@ | |
| 121284 | if( rc!=SQLITE_OK ) return rc; |
| 121285 | |
| 121286 | sqlite3Fts3SimpleTokenizerModule(&pSimple); |
| 121287 | sqlite3Fts3PorterTokenizerModule(&pPorter); |
| 121288 | |
| 121289 | /* Allocate and initialize the hash-table used to store tokenizers. */ |
| 121290 | pHash = sqlite3_malloc(sizeof(Fts3Hash)); |
| 121291 | if( !pHash ){ |
| 121292 | rc = SQLITE_NOMEM; |
| 121293 | }else{ |
| 121294 | sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| @@ -122886,11 +122883,11 @@ | |
| 122883 | ** The returned value is either NULL or a pointer to a buffer containing |
| 122884 | ** a position-list indicating the occurrences of the phrase in column iCol |
| 122885 | ** of the current row. |
| 122886 | ** |
| 122887 | ** More specifically, the returned buffer contains 1 varint for each |
| 122888 | ** occurrence of the phrase in the column, stored using the normal (delta+2) |
| 122889 | ** compression and is terminated by either an 0x01 or 0x00 byte. For example, |
| 122890 | ** if the requested column contains "a b X c d X X" and the position-list |
| 122891 | ** for 'X' is requested, the buffer returned may contain: |
| 122892 | ** |
| 122893 | ** 0x04 0x05 0x03 0x01 or 0x04 0x05 0x03 0x00 |
| @@ -123625,11 +123622,11 @@ | |
| 123622 | |
| 123623 | /* |
| 123624 | ** This function is equivalent to the standard isspace() function. |
| 123625 | ** |
| 123626 | ** The standard isspace() can be awkward to use safely, because although it |
| 123627 | ** is defined to accept an argument of type int, its behavior when passed |
| 123628 | ** an integer that falls outside of the range of the unsigned char type |
| 123629 | ** is undefined (and sometimes, "undefined" means segfault). This wrapper |
| 123630 | ** is defined to accept an argument of type char, and always returns 0 for |
| 123631 | ** any values that fall outside of the range of the unsigned char type (i.e. |
| 123632 | ** negative values). |
| @@ -125993,11 +125990,11 @@ | |
| 125990 | #endif |
| 125991 | |
| 125992 | /* |
| 125993 | ** Set up SQL objects in database db used to access the contents of |
| 125994 | ** the hash table pointed to by argument pHash. The hash table must |
| 125995 | ** been initialized to use string keys, and to take a private copy |
| 125996 | ** of the key when a value is inserted. i.e. by a call similar to: |
| 125997 | ** |
| 125998 | ** sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1); |
| 125999 | ** |
| 126000 | ** This function adds a scalar function (see header comment above |
| @@ -127772,10 +127769,11 @@ | |
| 127769 | if( ppOffsetList ){ |
| 127770 | *ppOffsetList = pReader->pOffsetList; |
| 127771 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 127772 | } |
| 127773 | |
| 127774 | /* List may have been edited in place by fts3EvalNearTrim() */ |
| 127775 | while( p<pEnd && *p==0 ) p++; |
| 127776 | |
| 127777 | /* If there are no more entries in the doclist, set pOffsetList to |
| 127778 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 127779 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| @@ -128787,13 +128785,17 @@ | |
| 128785 | ** function adjusts the pointer *ppList and the length *pnList so that they |
| 128786 | ** identify the subset of the position list that corresponds to column iCol. |
| 128787 | ** |
| 128788 | ** If there are no entries in the input position list for column iCol, then |
| 128789 | ** *pnList is set to zero before returning. |
| 128790 | ** |
| 128791 | ** If parameter bZero is non-zero, then any part of the input list following |
| 128792 | ** the end of the output list is zeroed before returning. |
| 128793 | */ |
| 128794 | static void fts3ColumnFilter( |
| 128795 | int iCol, /* Column to filter on */ |
| 128796 | int bZero, /* Zero out anything following *ppList */ |
| 128797 | char **ppList, /* IN/OUT: Pointer to position list */ |
| 128798 | int *pnList /* IN/OUT: Size of buffer *ppList in bytes */ |
| 128799 | ){ |
| 128800 | char *pList = *ppList; |
| 128801 | int nList = *pnList; |
| @@ -128818,10 +128820,13 @@ | |
| 128820 | } |
| 128821 | p = &pList[1]; |
| 128822 | p += sqlite3Fts3GetVarint32(p, &iCurrent); |
| 128823 | } |
| 128824 | |
| 128825 | if( bZero && &pList[nList]!=pEnd ){ |
| 128826 | memset(&pList[nList], 0, pEnd - &pList[nList]); |
| 128827 | } |
| 128828 | *ppList = pList; |
| 128829 | *pnList = nList; |
| 128830 | } |
| 128831 | |
| 128832 | /* |
| @@ -128890,24 +128895,24 @@ | |
| 128895 | rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 128896 | j++; |
| 128897 | } |
| 128898 | if( rc!=SQLITE_OK ) return rc; |
| 128899 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 128900 | |
| 128901 | if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){ |
| 128902 | rc = fts3MsrBufferData(pMsr, pList, nList+1); |
| 128903 | if( rc!=SQLITE_OK ) return rc; |
| 128904 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 128905 | pList = pMsr->aBuffer; |
| 128906 | } |
| 128907 | |
| 128908 | if( pMsr->iColFilter>=0 ){ |
| 128909 | fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList); |
| 128910 | } |
| 128911 | |
| 128912 | if( nList>0 ){ |
| 128913 | *paPoslist = pList; |
| 128914 | *piDocid = iDocid; |
| 128915 | *pnPoslist = nList; |
| 128916 | break; |
| 128917 | } |
| 128918 | } |
| @@ -129146,11 +129151,11 @@ | |
| 129151 | fts3SegReaderNextDocid(p, apSegment[j], 0, 0); |
| 129152 | j++; |
| 129153 | } |
| 129154 | |
| 129155 | if( isColFilter ){ |
| 129156 | fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList); |
| 129157 | } |
| 129158 | |
| 129159 | if( !isIgnoreEmpty || nList>0 ){ |
| 129160 | |
| 129161 | /* Calculate the 'docid' delta value to write into the merged |
| @@ -132083,13 +132088,13 @@ | |
| 132088 | ** Select the fragment of text consisting of nFragment contiguous tokens |
| 132089 | ** from column iCol that represent the "best" snippet. The best snippet |
| 132090 | ** is the snippet with the highest score, where scores are calculated |
| 132091 | ** by adding: |
| 132092 | ** |
| 132093 | ** (a) +1 point for each occurrence of a matchable phrase in the snippet. |
| 132094 | ** |
| 132095 | ** (b) +1000 points for the first occurrence of each matchable phrase in |
| 132096 | ** the snippet for which the corresponding mCovered bit is not set. |
| 132097 | ** |
| 132098 | ** The selected snippet parameters are stored in structure *pFragment before |
| 132099 | ** returning. The score of the selected snippet is stored in *piScore |
| 132100 | ** before returning. |
| @@ -133340,11 +133345,11 @@ | |
| 133345 | ** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all |
| 133346 | ** codepoints in the aiException[] array. |
| 133347 | ** |
| 133348 | ** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic() |
| 133349 | ** identifies as a diacritic) occurs in the zIn/nIn string it is ignored. |
| 133350 | ** It is not possible to change the behavior of the tokenizer with respect |
| 133351 | ** to these codepoints. |
| 133352 | */ |
| 133353 | static int unicodeAddExceptions( |
| 133354 | unicode_tokenizer *p, /* Tokenizer to add exceptions to */ |
| 133355 | int bAlnum, /* Replace Isalnum() return value with this */ |
| @@ -136643,11 +136648,11 @@ | |
| 136648 | RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */ |
| 136649 | int iCell; /* Index of iDelete cell in pLeaf */ |
| 136650 | RtreeNode *pRoot; /* Root node of rtree structure */ |
| 136651 | |
| 136652 | |
| 136653 | /* Obtain a reference to the root node to initialize Rtree.iDepth */ |
| 136654 | rc = nodeAcquire(pRtree, 1, 0, &pRoot); |
| 136655 | |
| 136656 | /* Obtain a reference to the leaf node that contains the entry |
| 136657 | ** about to be deleted. |
| 136658 | */ |
| 136659 |
+12
-8
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -105,13 +105,13 @@ | ||
| 105 | 105 | ** |
| 106 | 106 | ** See also: [sqlite3_libversion()], |
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | -#define SQLITE_VERSION "3.7.16" | |
| 110 | +#define SQLITE_VERSION "3.7.16.1" | |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | -#define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-03-27 20:41:15 274d2a22660c7b34b8bbd85f3c29cbafbcb1b4e7" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -2678,11 +2678,11 @@ | ||
| 2678 | 2678 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 2679 | 2679 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 2680 | 2680 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 2681 | 2681 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 2682 | 2682 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 2683 | -** a URI filename, its value overrides any behaviour requested by setting | |
| 2683 | +** a URI filename, its value overrides any behavior requested by setting | |
| 2684 | 2684 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 2685 | 2685 | ** </ul> |
| 2686 | 2686 | ** |
| 2687 | 2687 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 2688 | 2688 | ** error. Future versions of SQLite might understand additional query |
| @@ -3996,11 +3996,12 @@ | ||
| 3996 | 3996 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 3997 | 3997 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 3998 | 3998 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 3999 | 3999 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4000 | 4000 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4001 | -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); | |
| 4001 | +SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), | |
| 4002 | + void*,sqlite3_int64); | |
| 4002 | 4003 | #endif |
| 4003 | 4004 | |
| 4004 | 4005 | /* |
| 4005 | 4006 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4006 | 4007 | ** |
| @@ -4076,18 +4077,21 @@ | ||
| 4076 | 4077 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4077 | 4078 | ** implementation is never called and xFinal() is called exactly once. |
| 4078 | 4079 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4079 | 4080 | ** first time from within xFinal().)^ |
| 4080 | 4081 | ** |
| 4081 | -** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is | |
| 4082 | -** less than or equal to zero or if a memory allocate error occurs. | |
| 4082 | +** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer | |
| 4083 | +** when first called if N is less than or equal to zero or if a memory | |
| 4084 | +** allocate error occurs. | |
| 4083 | 4085 | ** |
| 4084 | 4086 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4085 | 4087 | ** determined by the N parameter on first successful call. Changing the |
| 4086 | 4088 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4087 | 4089 | ** the same aggregate function instance will not resize the memory |
| 4088 | -** allocation.)^ | |
| 4090 | +** allocation.)^ Within the xFinal callback, it is customary to set | |
| 4091 | +** N=0 in calls to sqlite3_aggregate_context(C,N) so that no | |
| 4092 | +** pointless memory allocations occur. | |
| 4089 | 4093 | ** |
| 4090 | 4094 | ** ^SQLite automatically frees the memory allocated by |
| 4091 | 4095 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4092 | 4096 | ** |
| 4093 | 4097 | ** The first parameter must be a copy of the |
| @@ -6377,11 +6381,11 @@ | ||
| 6377 | 6381 | ** intact. If the requested page is not already in the cache, then the |
| 6378 | 6382 | ** cache implementation should use the value of the createFlag |
| 6379 | 6383 | ** parameter to help it determined what action to take: |
| 6380 | 6384 | ** |
| 6381 | 6385 | ** <table border=1 width=85% align=center> |
| 6382 | -** <tr><th> createFlag <th> Behaviour when page is not already in cache | |
| 6386 | +** <tr><th> createFlag <th> Behavior when page is not already in cache | |
| 6383 | 6387 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6384 | 6388 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6385 | 6389 | ** Otherwise return NULL. |
| 6386 | 6390 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6387 | 6391 | ** NULL if allocating a new page is effectively impossible. |
| 6388 | 6392 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -2678,11 +2678,11 @@ | |
| 2678 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 2679 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 2680 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 2681 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 2682 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 2683 | ** a URI filename, its value overrides any behaviour requested by setting |
| 2684 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 2685 | ** </ul> |
| 2686 | ** |
| 2687 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 2688 | ** error. Future versions of SQLite might understand additional query |
| @@ -3996,11 +3996,12 @@ | |
| 3996 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 3997 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 3998 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 3999 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4000 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4001 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); |
| 4002 | #endif |
| 4003 | |
| 4004 | /* |
| 4005 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4006 | ** |
| @@ -4076,18 +4077,21 @@ | |
| 4076 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4077 | ** implementation is never called and xFinal() is called exactly once. |
| 4078 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4079 | ** first time from within xFinal().)^ |
| 4080 | ** |
| 4081 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is |
| 4082 | ** less than or equal to zero or if a memory allocate error occurs. |
| 4083 | ** |
| 4084 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4085 | ** determined by the N parameter on first successful call. Changing the |
| 4086 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4087 | ** the same aggregate function instance will not resize the memory |
| 4088 | ** allocation.)^ |
| 4089 | ** |
| 4090 | ** ^SQLite automatically frees the memory allocated by |
| 4091 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4092 | ** |
| 4093 | ** The first parameter must be a copy of the |
| @@ -6377,11 +6381,11 @@ | |
| 6377 | ** intact. If the requested page is not already in the cache, then the |
| 6378 | ** cache implementation should use the value of the createFlag |
| 6379 | ** parameter to help it determined what action to take: |
| 6380 | ** |
| 6381 | ** <table border=1 width=85% align=center> |
| 6382 | ** <tr><th> createFlag <th> Behaviour when page is not already in cache |
| 6383 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6384 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6385 | ** Otherwise return NULL. |
| 6386 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6387 | ** NULL if allocating a new page is effectively impossible. |
| 6388 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16.1" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-27 20:41:15 274d2a22660c7b34b8bbd85f3c29cbafbcb1b4e7" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -2678,11 +2678,11 @@ | |
| 2678 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 2679 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
| 2680 | ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
| 2681 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 2682 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 2683 | ** a URI filename, its value overrides any behavior requested by setting |
| 2684 | ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
| 2685 | ** </ul> |
| 2686 | ** |
| 2687 | ** ^Specifying an unknown parameter in the query component of a URI is not an |
| 2688 | ** error. Future versions of SQLite might understand additional query |
| @@ -3996,11 +3996,12 @@ | |
| 3996 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 3997 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 3998 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 3999 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4000 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4001 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
| 4002 | void*,sqlite3_int64); |
| 4003 | #endif |
| 4004 | |
| 4005 | /* |
| 4006 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| 4007 | ** |
| @@ -4076,18 +4077,21 @@ | |
| 4077 | ** an aggregate query, the xStep() callback of the aggregate function |
| 4078 | ** implementation is never called and xFinal() is called exactly once. |
| 4079 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4080 | ** first time from within xFinal().)^ |
| 4081 | ** |
| 4082 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer |
| 4083 | ** when first called if N is less than or equal to zero or if a memory |
| 4084 | ** allocate error occurs. |
| 4085 | ** |
| 4086 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 4087 | ** determined by the N parameter on first successful call. Changing the |
| 4088 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4089 | ** the same aggregate function instance will not resize the memory |
| 4090 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 4091 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 4092 | ** pointless memory allocations occur. |
| 4093 | ** |
| 4094 | ** ^SQLite automatically frees the memory allocated by |
| 4095 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4096 | ** |
| 4097 | ** The first parameter must be a copy of the |
| @@ -6377,11 +6381,11 @@ | |
| 6381 | ** intact. If the requested page is not already in the cache, then the |
| 6382 | ** cache implementation should use the value of the createFlag |
| 6383 | ** parameter to help it determined what action to take: |
| 6384 | ** |
| 6385 | ** <table border=1 width=85% align=center> |
| 6386 | ** <tr><th> createFlag <th> Behavior when page is not already in cache |
| 6387 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 6388 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 6389 | ** Otherwise return NULL. |
| 6390 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 6391 | ** NULL if allocating a new page is effectively impossible. |
| 6392 |