Fossil SCM
Update the built-in SQLite to the latest 3.7.7 release candidate.
Commit
74cbfc69adb528de5990c300ffbf12786d320973
Parent
a8f271e81e77f56…
2 files changed
+308
-197
+10
-10
+308
-197
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | -#define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389" | |
| 655 | +#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -851,11 +851,11 @@ | ||
| 851 | 851 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 852 | 852 | ** in the context of the [database connection] passed in as its 1st |
| 853 | 853 | ** argument. ^If the callback function of the 3rd argument to |
| 854 | 854 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 855 | 855 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 856 | -** to sqlite3_exec() is relayed through to the 1st argument of each | |
| 856 | +** sqlite3_exec() is relayed through to the 1st argument of each | |
| 857 | 857 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 858 | 858 | ** is NULL, then no callback is ever invoked and result rows are |
| 859 | 859 | ** ignored. |
| 860 | 860 | ** |
| 861 | 861 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -1443,11 +1443,11 @@ | ||
| 1443 | 1443 | ** The xSleep() method causes the calling thread to sleep for at |
| 1444 | 1444 | ** least the number of microseconds given. ^The xCurrentTime() |
| 1445 | 1445 | ** method returns a Julian Day Number for the current date and time as |
| 1446 | 1446 | ** a floating point value. |
| 1447 | 1447 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 1448 | -** Day Number multipled by 86400000 (the number of milliseconds in | |
| 1448 | +** Day Number multiplied by 86400000 (the number of milliseconds in | |
| 1449 | 1449 | ** a 24-hour day). |
| 1450 | 1450 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 1451 | 1451 | ** date and time if that method is available (if iVersion is 2 or |
| 1452 | 1452 | ** greater and the function pointer is not NULL) and will fall back |
| 1453 | 1453 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1881,11 +1881,11 @@ | ||
| 1881 | 1881 | ** scratch memory beyond what is provided by this configuration option, then |
| 1882 | 1882 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1883 | 1883 | ** |
| 1884 | 1884 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1885 | 1885 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1886 | -** the database page cache with the default page cache implemenation. | |
| 1886 | +** the database page cache with the default page cache implementation. | |
| 1887 | 1887 | ** This configuration should not be used if an application-define page |
| 1888 | 1888 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1889 | 1889 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1890 | 1890 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1891 | 1891 | ** The sz argument should be the size of the largest database page |
| @@ -2979,16 +2979,16 @@ | ||
| 2979 | 2979 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2980 | 2980 | ** |
| 2981 | 2981 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2982 | 2982 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2983 | 2983 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2984 | -** is set in the fourth argument to sqlite3_open_v2(), or if it has | |
| 2984 | +** set in the fourth argument to sqlite3_open_v2(), or if it has | |
| 2985 | 2985 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2986 | 2986 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2987 | 2987 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2988 | 2988 | ** by default, but future releases of SQLite might enable URI filename |
| 2989 | -** intepretation by default. See "[URI filenames]" for additional | |
| 2989 | +** interpretation by default. See "[URI filenames]" for additional | |
| 2990 | 2990 | ** information. |
| 2991 | 2991 | ** |
| 2992 | 2992 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2993 | 2993 | ** authority, then it must be either an empty string or the string |
| 2994 | 2994 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3803,11 +3803,11 @@ | ||
| 3803 | 3803 | ** [extended result codes] might be returned as well. |
| 3804 | 3804 | ** |
| 3805 | 3805 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3806 | 3806 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3807 | 3807 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3808 | -** statement. If the statement is not a [COMMIT] and occurs within a | |
| 3808 | +** statement. If the statement is not a [COMMIT] and occurs within an | |
| 3809 | 3809 | ** explicit transaction then you should rollback the transaction before |
| 3810 | 3810 | ** continuing. |
| 3811 | 3811 | ** |
| 3812 | 3812 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3813 | 3813 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -4082,11 +4082,11 @@ | ||
| 4082 | 4082 | |
| 4083 | 4083 | /* |
| 4084 | 4084 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 4085 | 4085 | ** |
| 4086 | 4086 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 4087 | -** ^If the most recent evaluation of the statement encountered no errors or | |
| 4087 | +** ^If the most recent evaluation of the statement encountered no errors | |
| 4088 | 4088 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 4089 | 4089 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 4090 | 4090 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 4091 | 4091 | ** [extended error code]. |
| 4092 | 4092 | ** |
| @@ -5996,11 +5996,11 @@ | ||
| 5996 | 5996 | ** versions of these routines, it should at least provide stubs that always |
| 5997 | 5997 | ** return true so that one does not get spurious assertion failures. |
| 5998 | 5998 | ** |
| 5999 | 5999 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 6000 | 6000 | ** the routine should return 1. This seems counter-intuitive since |
| 6001 | -** clearly the mutex cannot be held if it does not exist. But the | |
| 6001 | +** clearly the mutex cannot be held if it does not exist. But | |
| 6002 | 6002 | ** the reason the mutex does not exist is because the build is not |
| 6003 | 6003 | ** using mutexes. And we do not want the assert() containing the |
| 6004 | 6004 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 6005 | 6005 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 6006 | 6006 | ** interface should also return 1 when given a NULL pointer. |
| @@ -6505,11 +6505,11 @@ | ||
| 6505 | 6505 | ** [[the xFetch() page cache methods]] |
| 6506 | 6506 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 6507 | 6507 | ** the page, or a NULL pointer. |
| 6508 | 6508 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 6509 | 6509 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 6510 | -** mimimum key value is 1. After it has been retrieved using xFetch, the page | |
| 6510 | +** minimum key value is 1. After it has been retrieved using xFetch, the page | |
| 6511 | 6511 | ** is considered to be "pinned". |
| 6512 | 6512 | ** |
| 6513 | 6513 | ** If the requested page is already in the page cache, then the page cache |
| 6514 | 6514 | ** implementation must return a pointer to the page buffer with its content |
| 6515 | 6515 | ** intact. If the requested page is not already in the cache, then the |
| @@ -24364,10 +24364,14 @@ | ||
| 24364 | 24364 | |
| 24365 | 24365 | #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 24366 | 24366 | # include <sys/mount.h> |
| 24367 | 24367 | #endif |
| 24368 | 24368 | |
| 24369 | +#ifdef HAVE_UTIME | |
| 24370 | +# include <utime.h> | |
| 24371 | +#endif | |
| 24372 | + | |
| 24369 | 24373 | /* |
| 24370 | 24374 | ** Allowed values of unixFile.fsFlags |
| 24371 | 24375 | */ |
| 24372 | 24376 | #define SQLITE_FSFLAGS_IS_MSDOS 0x1 |
| 24373 | 24377 | |
| @@ -26369,12 +26373,14 @@ | ||
| 26369 | 26373 | /* If we have any lock, then the lock file already exists. All we have |
| 26370 | 26374 | ** to do is adjust our internal record of the lock level. |
| 26371 | 26375 | */ |
| 26372 | 26376 | if( pFile->eFileLock > NO_LOCK ){ |
| 26373 | 26377 | pFile->eFileLock = eFileLock; |
| 26374 | -#if !OS_VXWORKS | |
| 26375 | 26378 | /* Always update the timestamp on the old file */ |
| 26379 | +#ifdef HAVE_UTIME | |
| 26380 | + utime(zLockFile, NULL); | |
| 26381 | +#else | |
| 26376 | 26382 | utimes(zLockFile, NULL); |
| 26377 | 26383 | #endif |
| 26378 | 26384 | return SQLITE_OK; |
| 26379 | 26385 | } |
| 26380 | 26386 | |
| @@ -32254,11 +32260,12 @@ | ||
| 32254 | 32260 | rc = 1; |
| 32255 | 32261 | } |
| 32256 | 32262 | } |
| 32257 | 32263 | |
| 32258 | 32264 | if( rc ){ |
| 32259 | - if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){ | |
| 32265 | + if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ) | |
| 32266 | + || ( pFile->lastErrno==ERROR_DISK_FULL )){ | |
| 32260 | 32267 | return SQLITE_FULL; |
| 32261 | 32268 | } |
| 32262 | 32269 | return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath); |
| 32263 | 32270 | } |
| 32264 | 32271 | return SQLITE_OK; |
| @@ -63496,11 +63503,11 @@ | ||
| 63496 | 63503 | break; |
| 63497 | 63504 | } |
| 63498 | 63505 | |
| 63499 | 63506 | /* Opcode: HaltIfNull P1 P2 P3 P4 * |
| 63500 | 63507 | ** |
| 63501 | -** Check the value in register P3. If is is NULL then Halt using | |
| 63508 | +** Check the value in register P3. If it is NULL then Halt using | |
| 63502 | 63509 | ** parameter P1, P2, and P4 as if this were a Halt instruction. If the |
| 63503 | 63510 | ** value in register P3 is not NULL, then this routine is a no-op. |
| 63504 | 63511 | */ |
| 63505 | 63512 | case OP_HaltIfNull: { /* in3 */ |
| 63506 | 63513 | pIn3 = &aMem[pOp->p3]; |
| @@ -64433,11 +64440,11 @@ | ||
| 64433 | 64440 | ** additional information. |
| 64434 | 64441 | ** |
| 64435 | 64442 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64436 | 64443 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64437 | 64444 | ** of comparison is false. If either operand is NULL then the result is true. |
| 64438 | -** If neither operand is NULL the the result is the same as it would be if | |
| 64445 | +** If neither operand is NULL the result is the same as it would be if | |
| 64439 | 64446 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64440 | 64447 | */ |
| 64441 | 64448 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| 64442 | 64449 | ** |
| 64443 | 64450 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64445,11 +64452,11 @@ | ||
| 64445 | 64452 | ** See the Lt opcode for additional information. |
| 64446 | 64453 | ** |
| 64447 | 64454 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64448 | 64455 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64449 | 64456 | ** of comparison is true. If either operand is NULL then the result is false. |
| 64450 | -** If neither operand is NULL the the result is the same as it would be if | |
| 64457 | +** If neither operand is NULL the result is the same as it would be if | |
| 64451 | 64458 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64452 | 64459 | */ |
| 64453 | 64460 | /* Opcode: Le P1 P2 P3 P4 P5 |
| 64454 | 64461 | ** |
| 64455 | 64462 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64730,17 +64737,17 @@ | ||
| 64730 | 64737 | break; |
| 64731 | 64738 | } |
| 64732 | 64739 | |
| 64733 | 64740 | /* Opcode: If P1 P2 P3 * * |
| 64734 | 64741 | ** |
| 64735 | -** Jump to P2 if the value in register P1 is true. The value is | |
| 64742 | +** Jump to P2 if the value in register P1 is true. The value | |
| 64736 | 64743 | ** is considered true if it is numeric and non-zero. If the value |
| 64737 | 64744 | ** in P1 is NULL then take the jump if P3 is true. |
| 64738 | 64745 | */ |
| 64739 | 64746 | /* Opcode: IfNot P1 P2 P3 * * |
| 64740 | 64747 | ** |
| 64741 | -** Jump to P2 if the value in register P1 is False. The value is | |
| 64748 | +** Jump to P2 if the value in register P1 is False. The value | |
| 64742 | 64749 | ** is considered true if it has a numeric value of zero. If the value |
| 64743 | 64750 | ** in P1 is NULL then take the jump if P3 is true. |
| 64744 | 64751 | */ |
| 64745 | 64752 | case OP_If: /* jump, in1 */ |
| 64746 | 64753 | case OP_IfNot: { /* jump, in1 */ |
| @@ -66390,11 +66397,11 @@ | ||
| 66390 | 66397 | break; |
| 66391 | 66398 | } |
| 66392 | 66399 | |
| 66393 | 66400 | /* Opcode: NotExists P1 P2 P3 * * |
| 66394 | 66401 | ** |
| 66395 | -** Use the content of register P3 as a integer key. If a record | |
| 66402 | +** Use the content of register P3 as an integer key. If a record | |
| 66396 | 66403 | ** with that key does not exist in table of P1, then jump to P2. |
| 66397 | 66404 | ** If the record does exist, then fall through. The cursor is left |
| 66398 | 66405 | ** pointing to the record if it exists. |
| 66399 | 66406 | ** |
| 66400 | 66407 | ** The difference between this operation and NotFound is that this |
| @@ -66468,11 +66475,11 @@ | ||
| 66468 | 66475 | ** written to register P2. |
| 66469 | 66476 | ** |
| 66470 | 66477 | ** If P3>0 then P3 is a register in the root frame of this VDBE that holds |
| 66471 | 66478 | ** the largest previously generated record number. No new record numbers are |
| 66472 | 66479 | ** allowed to be less than this value. When this value reaches its maximum, |
| 66473 | -** a SQLITE_FULL error is generated. The P3 register is updated with the ' | |
| 66480 | +** an SQLITE_FULL error is generated. The P3 register is updated with the ' | |
| 66474 | 66481 | ** generated record number. This P3 mechanism is used to help implement the |
| 66475 | 66482 | ** AUTOINCREMENT feature. |
| 66476 | 66483 | */ |
| 66477 | 66484 | case OP_NewRowid: { /* out2-prerelease */ |
| 66478 | 66485 | #if 0 /* local variables moved into u.be */ |
| @@ -67110,11 +67117,11 @@ | ||
| 67110 | 67117 | break; |
| 67111 | 67118 | } |
| 67112 | 67119 | |
| 67113 | 67120 | /* Opcode: IdxInsert P1 P2 P3 * P5 |
| 67114 | 67121 | ** |
| 67115 | -** Register P2 holds a SQL index key made using the | |
| 67122 | +** Register P2 holds an SQL index key made using the | |
| 67116 | 67123 | ** MakeRecord instructions. This opcode writes that key |
| 67117 | 67124 | ** into the index P1. Data for the entry is nil. |
| 67118 | 67125 | ** |
| 67119 | 67126 | ** P3 is a flag that provides a hint to the b-tree layer that this |
| 67120 | 67127 | ** insert is likely to be an append. |
| @@ -111420,16 +111427,10 @@ | ||
| 111420 | 111427 | ** TODO(shess) Provide a VACUUM type operation to clear out all |
| 111421 | 111428 | ** deletions and duplications. This would basically be a forced merge |
| 111422 | 111429 | ** into a single segment. |
| 111423 | 111430 | */ |
| 111424 | 111431 | |
| 111425 | -#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) | |
| 111426 | - | |
| 111427 | -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) | |
| 111428 | -# define SQLITE_CORE 1 | |
| 111429 | -#endif | |
| 111430 | - | |
| 111431 | 111432 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 111432 | 111433 | /************** Begin file fts3Int.h *****************************************/ |
| 111433 | 111434 | /* |
| 111434 | 111435 | ** 2009 Nov 12 |
| 111435 | 111436 | ** |
| @@ -111441,18 +111442,27 @@ | ||
| 111441 | 111442 | ** May you share freely, never taking more than you give. |
| 111442 | 111443 | ** |
| 111443 | 111444 | ****************************************************************************** |
| 111444 | 111445 | ** |
| 111445 | 111446 | */ |
| 111446 | - | |
| 111447 | 111447 | #ifndef _FTSINT_H |
| 111448 | 111448 | #define _FTSINT_H |
| 111449 | 111449 | |
| 111450 | 111450 | #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| 111451 | 111451 | # define NDEBUG 1 |
| 111452 | 111452 | #endif |
| 111453 | 111453 | |
| 111454 | +/* | |
| 111455 | +** FTS4 is really an extension for FTS3. It is enabled using the | |
| 111456 | +** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all | |
| 111457 | +** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. | |
| 111458 | +*/ | |
| 111459 | +#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) | |
| 111460 | +# define SQLITE_ENABLE_FTS3 | |
| 111461 | +#endif | |
| 111462 | + | |
| 111463 | +#ifdef SQLITE_ENABLE_FTS3 | |
| 111454 | 111464 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 111455 | 111465 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 111456 | 111466 | /* |
| 111457 | 111467 | ** 2006 July 10 |
| 111458 | 111468 | ** |
| @@ -111940,11 +111950,11 @@ | ||
| 111940 | 111950 | char *aDoclist; /* List of docids for full-text queries */ |
| 111941 | 111951 | int nDoclist; /* Size of buffer at aDoclist */ |
| 111942 | 111952 | u8 bDesc; /* True to sort in descending order */ |
| 111943 | 111953 | int eEvalmode; /* An FTS3_EVAL_XX constant */ |
| 111944 | 111954 | int nRowAvg; /* Average size of database rows, in pages */ |
| 111945 | - int nDoc; /* Documents in table */ | |
| 111955 | + sqlite3_int64 nDoc; /* Documents in table */ | |
| 111946 | 111956 | |
| 111947 | 111957 | int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */ |
| 111948 | 111958 | u32 *aMatchinfo; /* Information about most recent match */ |
| 111949 | 111959 | int nMatchinfo; /* Number of elements in aMatchinfo[] */ |
| 111950 | 111960 | char *zMatchinfo; /* Matchinfo specification */ |
| @@ -111997,19 +112007,19 @@ | ||
| 111997 | 112007 | int isPrefix; /* True if token ends with a "*" character */ |
| 111998 | 112008 | |
| 111999 | 112009 | /* Variables above this point are populated when the expression is |
| 112000 | 112010 | ** parsed (by code in fts3_expr.c). Below this point the variables are |
| 112001 | 112011 | ** used when evaluating the expression. */ |
| 112002 | - int bFulltext; /* True if full-text index was used */ | |
| 112003 | 112012 | Fts3DeferredToken *pDeferred; /* Deferred token object for this token */ |
| 112004 | 112013 | Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */ |
| 112005 | 112014 | }; |
| 112006 | 112015 | |
| 112007 | 112016 | struct Fts3Phrase { |
| 112008 | 112017 | /* Cache of doclist for this phrase. */ |
| 112009 | 112018 | Fts3Doclist doclist; |
| 112010 | 112019 | int bIncr; /* True if doclist is loaded incrementally */ |
| 112020 | + int iDoclistToken; | |
| 112011 | 112021 | |
| 112012 | 112022 | /* Variables below this point are populated by fts3_expr.c when parsing |
| 112013 | 112023 | ** a MATCH expression. Everything above is part of the evaluation phase. |
| 112014 | 112024 | */ |
| 112015 | 112025 | int nToken; /* Number of tokens in the phrase */ |
| @@ -112130,10 +112140,11 @@ | ||
| 112130 | 112140 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 112131 | 112141 | char *aBuffer; /* Buffer to merge doclists in */ |
| 112132 | 112142 | int nBuffer; /* Allocated size of aBuffer[] in bytes */ |
| 112133 | 112143 | |
| 112134 | 112144 | int iColFilter; /* If >=0, filter for this column */ |
| 112145 | + int bRestart; | |
| 112135 | 112146 | |
| 112136 | 112147 | /* Used by fts3.c only. */ |
| 112137 | 112148 | int nCost; /* Cost of running iterator */ |
| 112138 | 112149 | int bLookup; /* True if a lookup of a single entry. */ |
| 112139 | 112150 | |
| @@ -112199,18 +112210,24 @@ | ||
| 112199 | 112210 | Fts3Table*, Fts3MultiSegReader*, int, const char*, int); |
| 112200 | 112211 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 112201 | 112212 | Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *); |
| 112202 | 112213 | SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol); |
| 112203 | 112214 | SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *); |
| 112215 | +SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr); | |
| 112204 | 112216 | |
| 112205 | 112217 | SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *); |
| 112206 | 112218 | |
| 112207 | - | |
| 112219 | +#endif /* SQLITE_ENABLE_FTS3 */ | |
| 112208 | 112220 | #endif /* _FTSINT_H */ |
| 112209 | 112221 | |
| 112210 | 112222 | /************** End of fts3Int.h *********************************************/ |
| 112211 | 112223 | /************** Continuing where we left off in fts3.c ***********************/ |
| 112224 | +#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) | |
| 112225 | + | |
| 112226 | +#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) | |
| 112227 | +# define SQLITE_CORE 1 | |
| 112228 | +#endif | |
| 112212 | 112229 | |
| 112213 | 112230 | |
| 112214 | 112231 | #ifndef SQLITE_CORE |
| 112215 | 112232 | SQLITE_EXTENSION_INIT1 |
| 112216 | 112233 | #endif |
| @@ -112995,11 +113012,11 @@ | ||
| 112995 | 113012 | zCsr += nDb; |
| 112996 | 113013 | |
| 112997 | 113014 | /* Fill in the azColumn array */ |
| 112998 | 113015 | for(iCol=0; iCol<nCol; iCol++){ |
| 112999 | 113016 | char *z; |
| 113000 | - int n; | |
| 113017 | + int n = 0; | |
| 113001 | 113018 | z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n); |
| 113002 | 113019 | memcpy(zCsr, z, n); |
| 113003 | 113020 | zCsr[n] = '\0'; |
| 113004 | 113021 | sqlite3Fts3Dequote(zCsr); |
| 113005 | 113022 | p->azColumn[iCol] = zCsr; |
| @@ -114581,12 +114598,12 @@ | ||
| 114581 | 114598 | |
| 114582 | 114599 | /* |
| 114583 | 114600 | ** Implementation of xBegin() method. This is a no-op. |
| 114584 | 114601 | */ |
| 114585 | 114602 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ |
| 114586 | - UNUSED_PARAMETER(pVtab); | |
| 114587 | 114603 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114604 | + UNUSED_PARAMETER(pVtab); | |
| 114588 | 114605 | assert( p->pSegments==0 ); |
| 114589 | 114606 | assert( p->nPendingData==0 ); |
| 114590 | 114607 | assert( p->inTransaction!=1 ); |
| 114591 | 114608 | TESTONLY( p->inTransaction = 1 ); |
| 114592 | 114609 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -114597,12 +114614,12 @@ | ||
| 114597 | 114614 | ** Implementation of xCommit() method. This is a no-op. The contents of |
| 114598 | 114615 | ** the pending-terms hash-table have already been flushed into the database |
| 114599 | 114616 | ** by fts3SyncMethod(). |
| 114600 | 114617 | */ |
| 114601 | 114618 | static int fts3CommitMethod(sqlite3_vtab *pVtab){ |
| 114602 | - UNUSED_PARAMETER(pVtab); | |
| 114603 | 114619 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114620 | + UNUSED_PARAMETER(pVtab); | |
| 114604 | 114621 | assert( p->nPendingData==0 ); |
| 114605 | 114622 | assert( p->inTransaction!=0 ); |
| 114606 | 114623 | assert( p->pSegments==0 ); |
| 114607 | 114624 | TESTONLY( p->inTransaction = 0 ); |
| 114608 | 114625 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -115083,75 +115100,105 @@ | ||
| 115083 | 115100 | if( rc!=SQLITE_OK ){ |
| 115084 | 115101 | *pRc = rc; |
| 115085 | 115102 | return; |
| 115086 | 115103 | } |
| 115087 | 115104 | } |
| 115105 | + assert( pExpr->pPhrase->iDoclistToken==0 ); | |
| 115106 | + pExpr->pPhrase->iDoclistToken = -1; | |
| 115088 | 115107 | }else{ |
| 115089 | 115108 | *pnOr += (pExpr->eType==FTSQUERY_OR); |
| 115090 | 115109 | fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc); |
| 115091 | 115110 | fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc); |
| 115092 | 115111 | } |
| 115093 | 115112 | } |
| 115094 | 115113 | } |
| 115114 | + | |
| 115115 | +static void fts3EvalPhraseMergeToken( | |
| 115116 | + Fts3Table *pTab, | |
| 115117 | + Fts3Phrase *p, | |
| 115118 | + int iToken, | |
| 115119 | + char *pList, | |
| 115120 | + int nList | |
| 115121 | +){ | |
| 115122 | + assert( iToken!=p->iDoclistToken ); | |
| 115123 | + | |
| 115124 | + if( pList==0 ){ | |
| 115125 | + sqlite3_free(p->doclist.aAll); | |
| 115126 | + p->doclist.aAll = 0; | |
| 115127 | + p->doclist.nAll = 0; | |
| 115128 | + } | |
| 115129 | + | |
| 115130 | + else if( p->iDoclistToken<0 ){ | |
| 115131 | + p->doclist.aAll = pList; | |
| 115132 | + p->doclist.nAll = nList; | |
| 115133 | + } | |
| 115134 | + | |
| 115135 | + else if( p->doclist.aAll==0 ){ | |
| 115136 | + sqlite3_free(pList); | |
| 115137 | + } | |
| 115138 | + | |
| 115139 | + else { | |
| 115140 | + char *pLeft; | |
| 115141 | + char *pRight; | |
| 115142 | + int nLeft; | |
| 115143 | + int nRight; | |
| 115144 | + int nDiff; | |
| 115145 | + | |
| 115146 | + if( p->iDoclistToken<iToken ){ | |
| 115147 | + pLeft = p->doclist.aAll; | |
| 115148 | + nLeft = p->doclist.nAll; | |
| 115149 | + pRight = pList; | |
| 115150 | + nRight = nList; | |
| 115151 | + nDiff = iToken - p->iDoclistToken; | |
| 115152 | + }else{ | |
| 115153 | + pRight = p->doclist.aAll; | |
| 115154 | + nRight = p->doclist.nAll; | |
| 115155 | + pLeft = pList; | |
| 115156 | + nLeft = nList; | |
| 115157 | + nDiff = p->iDoclistToken - iToken; | |
| 115158 | + } | |
| 115159 | + | |
| 115160 | + fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight); | |
| 115161 | + sqlite3_free(pLeft); | |
| 115162 | + p->doclist.aAll = pRight; | |
| 115163 | + p->doclist.nAll = nRight; | |
| 115164 | + } | |
| 115165 | + | |
| 115166 | + if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken; | |
| 115167 | +} | |
| 115095 | 115168 | |
| 115096 | 115169 | static int fts3EvalPhraseLoad( |
| 115097 | 115170 | Fts3Cursor *pCsr, |
| 115098 | 115171 | Fts3Phrase *p |
| 115099 | 115172 | ){ |
| 115100 | 115173 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115101 | 115174 | int iToken; |
| 115102 | 115175 | int rc = SQLITE_OK; |
| 115103 | 115176 | |
| 115104 | - char *aDoclist = 0; | |
| 115105 | - int nDoclist = 0; | |
| 115106 | - int iPrev = -1; | |
| 115107 | - | |
| 115108 | 115177 | for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){ |
| 115109 | 115178 | Fts3PhraseToken *pToken = &p->aToken[iToken]; |
| 115110 | - assert( pToken->pSegcsr || pToken->pDeferred ); | |
| 115179 | + assert( pToken->pDeferred==0 || pToken->pSegcsr==0 ); | |
| 115111 | 115180 | |
| 115112 | - if( pToken->pDeferred==0 ){ | |
| 115181 | + if( pToken->pSegcsr ){ | |
| 115113 | 115182 | int nThis = 0; |
| 115114 | 115183 | char *pThis = 0; |
| 115115 | 115184 | rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis); |
| 115116 | 115185 | if( rc==SQLITE_OK ){ |
| 115117 | - if( pThis==0 ){ | |
| 115118 | - sqlite3_free(aDoclist); | |
| 115119 | - aDoclist = 0; | |
| 115120 | - nDoclist = 0; | |
| 115121 | - break; | |
| 115122 | - }else if( aDoclist==0 ){ | |
| 115123 | - aDoclist = pThis; | |
| 115124 | - nDoclist = nThis; | |
| 115125 | - }else{ | |
| 115126 | - assert( iPrev>=0 ); | |
| 115127 | - fts3DoclistPhraseMerge(pTab->bDescIdx, | |
| 115128 | - iToken-iPrev, aDoclist, nDoclist, pThis, &nThis | |
| 115129 | - ); | |
| 115130 | - sqlite3_free(aDoclist); | |
| 115131 | - aDoclist = pThis; | |
| 115132 | - nDoclist = nThis; | |
| 115133 | - } | |
| 115134 | - iPrev = iToken; | |
| 115135 | - } | |
| 115136 | - } | |
| 115137 | - } | |
| 115138 | - | |
| 115139 | - if( rc==SQLITE_OK ){ | |
| 115140 | - p->doclist.aAll = aDoclist; | |
| 115141 | - p->doclist.nAll = nDoclist; | |
| 115142 | - }else{ | |
| 115143 | - sqlite3_free(aDoclist); | |
| 115144 | - } | |
| 115186 | + fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis); | |
| 115187 | + } | |
| 115188 | + } | |
| 115189 | + assert( pToken->pSegcsr==0 ); | |
| 115190 | + } | |
| 115191 | + | |
| 115145 | 115192 | return rc; |
| 115146 | 115193 | } |
| 115147 | 115194 | |
| 115148 | 115195 | static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){ |
| 115149 | 115196 | int iToken; |
| 115150 | 115197 | int rc = SQLITE_OK; |
| 115151 | 115198 | |
| 115152 | - int nMaxUndeferred = -1; | |
| 115199 | + int nMaxUndeferred = pPhrase->iDoclistToken; | |
| 115153 | 115200 | char *aPoslist = 0; |
| 115154 | 115201 | int nPoslist = 0; |
| 115155 | 115202 | int iPrev = -1; |
| 115156 | 115203 | |
| 115157 | 115204 | assert( pPhrase->doclist.bFreeList==0 ); |
| @@ -115192,12 +115239,10 @@ | ||
| 115192 | 115239 | pPhrase->doclist.nList = 0; |
| 115193 | 115240 | return SQLITE_OK; |
| 115194 | 115241 | } |
| 115195 | 115242 | } |
| 115196 | 115243 | iPrev = iToken; |
| 115197 | - }else{ | |
| 115198 | - nMaxUndeferred = iToken; | |
| 115199 | 115244 | } |
| 115200 | 115245 | } |
| 115201 | 115246 | |
| 115202 | 115247 | if( iPrev>=0 ){ |
| 115203 | 115248 | if( nMaxUndeferred<0 ){ |
| @@ -115252,13 +115297,15 @@ | ||
| 115252 | 115297 | static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ |
| 115253 | 115298 | int rc; |
| 115254 | 115299 | Fts3PhraseToken *pFirst = &p->aToken[0]; |
| 115255 | 115300 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115256 | 115301 | |
| 115257 | - assert( p->doclist.aAll==0 ); | |
| 115258 | - if( pCsr->bDesc==pTab->bDescIdx && bOptOk==1 && p->nToken==1 | |
| 115259 | - && pFirst->pSegcsr && pFirst->pSegcsr->bLookup | |
| 115302 | + if( pCsr->bDesc==pTab->bDescIdx | |
| 115303 | + && bOptOk==1 | |
| 115304 | + && p->nToken==1 | |
| 115305 | + && pFirst->pSegcsr | |
| 115306 | + && pFirst->pSegcsr->bLookup | |
| 115260 | 115307 | ){ |
| 115261 | 115308 | /* Use the incremental approach. */ |
| 115262 | 115309 | int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn); |
| 115263 | 115310 | rc = sqlite3Fts3MsrIncrStart( |
| 115264 | 115311 | pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n); |
| @@ -115394,11 +115441,11 @@ | ||
| 115394 | 115441 | ** with this case by advancing pIter past the zero-padding added by |
| 115395 | 115442 | ** fts3EvalNearTrim2(). */ |
| 115396 | 115443 | while( pIter<pEnd && *pIter==0 ) pIter++; |
| 115397 | 115444 | |
| 115398 | 115445 | pDL->pNextDocid = pIter; |
| 115399 | - assert( *pIter || pIter>=&pDL->aAll[pDL->nAll] ); | |
| 115446 | + assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter ); | |
| 115400 | 115447 | *pbEof = 0; |
| 115401 | 115448 | } |
| 115402 | 115449 | } |
| 115403 | 115450 | |
| 115404 | 115451 | return rc; |
| @@ -115425,17 +115472,18 @@ | ||
| 115425 | 115472 | pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred); |
| 115426 | 115473 | } |
| 115427 | 115474 | } |
| 115428 | 115475 | } |
| 115429 | 115476 | |
| 115430 | - | |
| 115431 | 115477 | typedef struct Fts3TokenAndCost Fts3TokenAndCost; |
| 115432 | 115478 | struct Fts3TokenAndCost { |
| 115433 | - Fts3PhraseToken *pToken; | |
| 115434 | - Fts3Expr *pRoot; | |
| 115479 | + Fts3Phrase *pPhrase; /* The phrase the token belongs to */ | |
| 115480 | + int iToken; /* Position of token in phrase */ | |
| 115481 | + Fts3PhraseToken *pToken; /* The token itself */ | |
| 115482 | + Fts3Expr *pRoot; | |
| 115435 | 115483 | int nOvfl; |
| 115436 | - int iCol; | |
| 115484 | + int iCol; /* The column the token must match */ | |
| 115437 | 115485 | }; |
| 115438 | 115486 | |
| 115439 | 115487 | static void fts3EvalTokenCosts( |
| 115440 | 115488 | Fts3Cursor *pCsr, |
| 115441 | 115489 | Fts3Expr *pRoot, |
| @@ -115448,10 +115496,12 @@ | ||
| 115448 | 115496 | if( pExpr->eType==FTSQUERY_PHRASE ){ |
| 115449 | 115497 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 115450 | 115498 | int i; |
| 115451 | 115499 | for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){ |
| 115452 | 115500 | Fts3TokenAndCost *pTC = (*ppTC)++; |
| 115501 | + pTC->pPhrase = pPhrase; | |
| 115502 | + pTC->iToken = i; | |
| 115453 | 115503 | pTC->pRoot = pRoot; |
| 115454 | 115504 | pTC->pToken = &pPhrase->aToken[i]; |
| 115455 | 115505 | pTC->iCol = pPhrase->iColumn; |
| 115456 | 115506 | *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl); |
| 115457 | 115507 | } |
| @@ -115560,23 +115610,19 @@ | ||
| 115560 | 115610 | /* At this point pTC points to the cheapest remaining token. */ |
| 115561 | 115611 | if( ii==0 ){ |
| 115562 | 115612 | if( pTC->nOvfl ){ |
| 115563 | 115613 | nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10; |
| 115564 | 115614 | }else{ |
| 115565 | - /* TODO: Fix this so that the doclist need not be read twice. */ | |
| 115566 | 115615 | Fts3PhraseToken *pToken = pTC->pToken; |
| 115567 | 115616 | int nList = 0; |
| 115568 | 115617 | char *pList = 0; |
| 115569 | 115618 | rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList); |
| 115619 | + assert( rc==SQLITE_OK || pList==0 ); | |
| 115620 | + | |
| 115570 | 115621 | if( rc==SQLITE_OK ){ |
| 115571 | 115622 | nDocEst = fts3DoclistCountDocids(1, pList, nList); |
| 115572 | - } | |
| 115573 | - sqlite3_free(pList); | |
| 115574 | - if( rc==SQLITE_OK ){ | |
| 115575 | - rc = sqlite3Fts3TermSegReaderCursor(pCsr, | |
| 115576 | - pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr | |
| 115577 | - ); | |
| 115623 | + fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList); | |
| 115578 | 115624 | } |
| 115579 | 115625 | } |
| 115580 | 115626 | }else{ |
| 115581 | 115627 | if( pTC->nOvfl>=(nDocEst*nDocSize) ){ |
| 115582 | 115628 | Fts3PhraseToken *pToken = pTC->pToken; |
| @@ -116032,17 +116078,18 @@ | ||
| 116032 | 116078 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 116033 | 116079 | |
| 116034 | 116080 | if( pPhrase ){ |
| 116035 | 116081 | fts3EvalZeroPoslist(pPhrase); |
| 116036 | 116082 | if( pPhrase->bIncr ){ |
| 116037 | - sqlite3Fts3EvalPhraseCleanup(pPhrase); | |
| 116038 | - memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist)); | |
| 116039 | - *pRc = sqlite3Fts3EvalStart(pCsr, pExpr, 0); | |
| 116040 | - }else{ | |
| 116041 | - pPhrase->doclist.pNextDocid = 0; | |
| 116042 | - pPhrase->doclist.iDocid = 0; | |
| 116083 | + assert( pPhrase->nToken==1 ); | |
| 116084 | + assert( pPhrase->aToken[0].pSegcsr ); | |
| 116085 | + sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr); | |
| 116086 | + *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase); | |
| 116043 | 116087 | } |
| 116088 | + | |
| 116089 | + pPhrase->doclist.pNextDocid = 0; | |
| 116090 | + pPhrase->doclist.iDocid = 0; | |
| 116044 | 116091 | } |
| 116045 | 116092 | |
| 116046 | 116093 | pExpr->iDocid = 0; |
| 116047 | 116094 | pExpr->bEof = 0; |
| 116048 | 116095 | pExpr->bStart = 0; |
| @@ -116225,12 +116272,12 @@ | ||
| 116225 | 116272 | int iCol; |
| 116226 | 116273 | |
| 116227 | 116274 | if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){ |
| 116228 | 116275 | assert( pCsr->nDoc>0 ); |
| 116229 | 116276 | for(iCol=0; iCol<pTab->nColumn; iCol++){ |
| 116230 | - aiOut[iCol*3 + 1] = pCsr->nDoc; | |
| 116231 | - aiOut[iCol*3 + 2] = pCsr->nDoc; | |
| 116277 | + aiOut[iCol*3 + 1] = (u32)pCsr->nDoc; | |
| 116278 | + aiOut[iCol*3 + 2] = (u32)pCsr->nDoc; | |
| 116232 | 116279 | } |
| 116233 | 116280 | }else{ |
| 116234 | 116281 | rc = fts3EvalGatherStats(pCsr, pExpr); |
| 116235 | 116282 | if( rc==SQLITE_OK ){ |
| 116236 | 116283 | assert( pExpr->aMI ); |
| @@ -116334,11 +116381,10 @@ | ||
| 116334 | 116381 | ** May you share freely, never taking more than you give. |
| 116335 | 116382 | ** |
| 116336 | 116383 | ****************************************************************************** |
| 116337 | 116384 | ** |
| 116338 | 116385 | */ |
| 116339 | - | |
| 116340 | 116386 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 116341 | 116387 | |
| 116342 | 116388 | |
| 116343 | 116389 | typedef struct Fts3auxTable Fts3auxTable; |
| 116344 | 116390 | typedef struct Fts3auxCursor Fts3auxCursor; |
| @@ -118168,11 +118214,10 @@ | ||
| 118168 | 118214 | */ |
| 118169 | 118215 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 118170 | 118216 | |
| 118171 | 118217 | |
| 118172 | 118218 | |
| 118173 | - | |
| 118174 | 118219 | /* |
| 118175 | 118220 | ** Class derived from sqlite3_tokenizer |
| 118176 | 118221 | */ |
| 118177 | 118222 | typedef struct porter_tokenizer { |
| 118178 | 118223 | sqlite3_tokenizer base; /* Base class */ |
| @@ -118808,15 +118853,15 @@ | ||
| 118808 | 118853 | ** (in which case SQLITE_CORE is not defined), or |
| 118809 | 118854 | ** |
| 118810 | 118855 | ** * The FTS3 module is being built into the core of |
| 118811 | 118856 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 118812 | 118857 | */ |
| 118813 | -#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) | |
| 118814 | - | |
| 118815 | 118858 | #ifndef SQLITE_CORE |
| 118816 | 118859 | SQLITE_EXTENSION_INIT1 |
| 118817 | 118860 | #endif |
| 118861 | + | |
| 118862 | +#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) | |
| 118818 | 118863 | |
| 118819 | 118864 | |
| 118820 | 118865 | /* |
| 118821 | 118866 | ** Implementation of the SQL scalar function for accessing the underlying |
| 118822 | 118867 | ** hash table. This function may be called as follows: |
| @@ -118937,11 +118982,11 @@ | ||
| 118937 | 118982 | sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */ |
| 118938 | 118983 | char **pzErr /* OUT: Set to malloced error message */ |
| 118939 | 118984 | ){ |
| 118940 | 118985 | int rc; |
| 118941 | 118986 | char *z = (char *)zArg; |
| 118942 | - int n; | |
| 118987 | + int n = 0; | |
| 118943 | 118988 | char *zCopy; |
| 118944 | 118989 | char *zEnd; /* Pointer to nul-term of zCopy */ |
| 118945 | 118990 | sqlite3_tokenizer_module *m; |
| 118946 | 118991 | |
| 118947 | 118992 | zCopy = sqlite3_mprintf("%s", zArg); |
| @@ -119299,11 +119344,10 @@ | ||
| 119299 | 119344 | ** |
| 119300 | 119345 | ** * The FTS3 module is being built into the core of |
| 119301 | 119346 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 119302 | 119347 | */ |
| 119303 | 119348 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 119304 | - | |
| 119305 | 119349 | |
| 119306 | 119350 | |
| 119307 | 119351 | |
| 119308 | 119352 | typedef struct simple_tokenizer { |
| 119309 | 119353 | sqlite3_tokenizer base; |
| @@ -120750,10 +120794,11 @@ | ||
| 120750 | 120794 | pReader->pOffsetList = 0; |
| 120751 | 120795 | }else{ |
| 120752 | 120796 | pReader->pOffsetList = p; |
| 120753 | 120797 | } |
| 120754 | 120798 | }else{ |
| 120799 | + char *pEnd = &pReader->aDoclist[pReader->nDoclist]; | |
| 120755 | 120800 | |
| 120756 | 120801 | /* Pointer p currently points at the first byte of an offset list. The |
| 120757 | 120802 | ** following block advances it to point one byte past the end of |
| 120758 | 120803 | ** the same offset list. */ |
| 120759 | 120804 | while( 1 ){ |
| @@ -120778,17 +120823,19 @@ | ||
| 120778 | 120823 | */ |
| 120779 | 120824 | if( ppOffsetList ){ |
| 120780 | 120825 | *ppOffsetList = pReader->pOffsetList; |
| 120781 | 120826 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 120782 | 120827 | } |
| 120828 | + | |
| 120829 | + while( p<pEnd && *p==0 ) p++; | |
| 120783 | 120830 | |
| 120784 | 120831 | /* If there are no more entries in the doclist, set pOffsetList to |
| 120785 | 120832 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 120786 | 120833 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| 120787 | 120834 | ** returning. |
| 120788 | 120835 | */ |
| 120789 | - if( p>=&pReader->aDoclist[pReader->nDoclist] ){ | |
| 120836 | + if( p>=pEnd ){ | |
| 120790 | 120837 | pReader->pOffsetList = 0; |
| 120791 | 120838 | }else{ |
| 120792 | 120839 | rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); |
| 120793 | 120840 | if( rc==SQLITE_OK ){ |
| 120794 | 120841 | sqlite3_int64 iDelta; |
| @@ -120823,11 +120870,11 @@ | ||
| 120823 | 120870 | for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){ |
| 120824 | 120871 | Fts3SegReader *pReader = pMsr->apSegment[ii]; |
| 120825 | 120872 | if( !fts3SegReaderIsPending(pReader) |
| 120826 | 120873 | && !fts3SegReaderIsRootOnly(pReader) |
| 120827 | 120874 | ){ |
| 120828 | - int jj; | |
| 120875 | + sqlite3_int64 jj; | |
| 120829 | 120876 | for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){ |
| 120830 | 120877 | int nBlob; |
| 120831 | 120878 | rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0); |
| 120832 | 120879 | if( rc!=SQLITE_OK ) break; |
| 120833 | 120880 | if( (nBlob+35)>pgsz ){ |
| @@ -121768,55 +121815,31 @@ | ||
| 121768 | 121815 | |
| 121769 | 121816 | *ppList = pList; |
| 121770 | 121817 | *pnList = nList; |
| 121771 | 121818 | } |
| 121772 | 121819 | |
| 121773 | -SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart( | |
| 121774 | - Fts3Table *p, /* Virtual table handle */ | |
| 121775 | - Fts3MultiSegReader *pCsr, /* Cursor object */ | |
| 121776 | - int iCol, /* Column to match on. */ | |
| 121777 | - const char *zTerm, /* Term to iterate through a doclist for */ | |
| 121778 | - int nTerm /* Number of bytes in zTerm */ | |
| 121820 | +/* | |
| 121821 | +** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any | |
| 121822 | +** existing data). Grow the buffer if required. | |
| 121823 | +** | |
| 121824 | +** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered | |
| 121825 | +** trying to resize the buffer, return SQLITE_NOMEM. | |
| 121826 | +*/ | |
| 121827 | +static int fts3MsrBufferData( | |
| 121828 | + Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ | |
| 121829 | + char *pList, | |
| 121830 | + int nList | |
| 121779 | 121831 | ){ |
| 121780 | - int i; | |
| 121781 | - int nSegment = pCsr->nSegment; | |
| 121782 | - int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = ( | |
| 121783 | - p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp | |
| 121784 | - ); | |
| 121785 | - | |
| 121786 | - assert( pCsr->pFilter==0 ); | |
| 121787 | - assert( zTerm && nTerm>0 ); | |
| 121788 | - | |
| 121789 | - /* Advance each segment iterator until it points to the term zTerm/nTerm. */ | |
| 121790 | - for(i=0; i<nSegment; i++){ | |
| 121791 | - Fts3SegReader *pSeg = pCsr->apSegment[i]; | |
| 121792 | - do { | |
| 121793 | - int rc = fts3SegReaderNext(p, pSeg, 1); | |
| 121794 | - if( rc!=SQLITE_OK ) return rc; | |
| 121795 | - }while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); | |
| 121796 | - } | |
| 121797 | - fts3SegReaderSort(pCsr->apSegment, nSegment, nSegment, fts3SegReaderCmp); | |
| 121798 | - | |
| 121799 | - /* Determine how many of the segments actually point to zTerm/nTerm. */ | |
| 121800 | - for(i=0; i<nSegment; i++){ | |
| 121801 | - Fts3SegReader *pSeg = pCsr->apSegment[i]; | |
| 121802 | - if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){ | |
| 121803 | - break; | |
| 121804 | - } | |
| 121805 | - } | |
| 121806 | - pCsr->nAdvance = i; | |
| 121807 | - | |
| 121808 | - /* Advance each of the segments to point to the first docid. */ | |
| 121809 | - for(i=0; i<pCsr->nAdvance; i++){ | |
| 121810 | - int rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]); | |
| 121811 | - if( rc!=SQLITE_OK ) return rc; | |
| 121812 | - } | |
| 121813 | - fts3SegReaderSort(pCsr->apSegment, i, i, xCmp); | |
| 121814 | - | |
| 121815 | - assert( iCol<0 || iCol<p->nColumn ); | |
| 121816 | - pCsr->iColFilter = iCol; | |
| 121817 | - | |
| 121832 | + if( nList>pMsr->nBuffer ){ | |
| 121833 | + char *pNew; | |
| 121834 | + pMsr->nBuffer = nList*2; | |
| 121835 | + pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer); | |
| 121836 | + if( !pNew ) return SQLITE_NOMEM; | |
| 121837 | + pMsr->aBuffer = pNew; | |
| 121838 | + } | |
| 121839 | + | |
| 121840 | + memcpy(pMsr->aBuffer, pList, nList); | |
| 121818 | 121841 | return SQLITE_OK; |
| 121819 | 121842 | } |
| 121820 | 121843 | |
| 121821 | 121844 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 121822 | 121845 | Fts3Table *p, /* Virtual table handle */ |
| @@ -121866,52 +121889,138 @@ | ||
| 121866 | 121889 | if( pMsr->iColFilter>=0 ){ |
| 121867 | 121890 | fts3ColumnFilter(pMsr->iColFilter, &pList, &nList); |
| 121868 | 121891 | } |
| 121869 | 121892 | |
| 121870 | 121893 | if( nList>0 ){ |
| 121894 | + if( fts3SegReaderIsPending(apSegment[0]) ){ | |
| 121895 | + rc = fts3MsrBufferData(pMsr, pList, nList+1); | |
| 121896 | + if( rc!=SQLITE_OK ) return rc; | |
| 121897 | + *paPoslist = pMsr->aBuffer; | |
| 121898 | + assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); | |
| 121899 | + }else{ | |
| 121900 | + *paPoslist = pList; | |
| 121901 | + } | |
| 121871 | 121902 | *piDocid = iDocid; |
| 121872 | - *paPoslist = pList; | |
| 121873 | 121903 | *pnPoslist = nList; |
| 121874 | 121904 | break; |
| 121875 | 121905 | } |
| 121876 | 121906 | } |
| 121877 | - | |
| 121878 | 121907 | } |
| 121879 | 121908 | |
| 121909 | + return SQLITE_OK; | |
| 121910 | +} | |
| 121911 | + | |
| 121912 | +static int fts3SegReaderStart( | |
| 121913 | + Fts3Table *p, /* Virtual table handle */ | |
| 121914 | + Fts3MultiSegReader *pCsr, /* Cursor object */ | |
| 121915 | + const char *zTerm, /* Term searched for (or NULL) */ | |
| 121916 | + int nTerm /* Length of zTerm in bytes */ | |
| 121917 | +){ | |
| 121918 | + int i; | |
| 121919 | + int nSeg = pCsr->nSegment; | |
| 121920 | + | |
| 121921 | + /* If the Fts3SegFilter defines a specific term (or term prefix) to search | |
| 121922 | + ** for, then advance each segment iterator until it points to a term of | |
| 121923 | + ** equal or greater value than the specified term. This prevents many | |
| 121924 | + ** unnecessary merge/sort operations for the case where single segment | |
| 121925 | + ** b-tree leaf nodes contain more than one term. | |
| 121926 | + */ | |
| 121927 | + for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){ | |
| 121928 | + Fts3SegReader *pSeg = pCsr->apSegment[i]; | |
| 121929 | + do { | |
| 121930 | + int rc = fts3SegReaderNext(p, pSeg, 0); | |
| 121931 | + if( rc!=SQLITE_OK ) return rc; | |
| 121932 | + }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); | |
| 121933 | + } | |
| 121934 | + fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp); | |
| 121935 | + | |
| 121880 | 121936 | return SQLITE_OK; |
| 121881 | 121937 | } |
| 121882 | 121938 | |
| 121883 | 121939 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStart( |
| 121884 | 121940 | Fts3Table *p, /* Virtual table handle */ |
| 121885 | 121941 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121886 | 121942 | Fts3SegFilter *pFilter /* Restrictions on range of iteration */ |
| 121887 | 121943 | ){ |
| 121888 | - int i; | |
| 121889 | - | |
| 121890 | - /* Initialize the cursor object */ | |
| 121891 | 121944 | pCsr->pFilter = pFilter; |
| 121892 | - | |
| 121893 | - /* If the Fts3SegFilter defines a specific term (or term prefix) to search | |
| 121894 | - ** for, then advance each segment iterator until it points to a term of | |
| 121895 | - ** equal or greater value than the specified term. This prevents many | |
| 121896 | - ** unnecessary merge/sort operations for the case where single segment | |
| 121897 | - ** b-tree leaf nodes contain more than one term. | |
| 121898 | - */ | |
| 121899 | - for(i=0; i<pCsr->nSegment; i++){ | |
| 121900 | - int nTerm = pFilter->nTerm; | |
| 121901 | - const char *zTerm = pFilter->zTerm; | |
| 121945 | + return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm); | |
| 121946 | +} | |
| 121947 | + | |
| 121948 | +SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart( | |
| 121949 | + Fts3Table *p, /* Virtual table handle */ | |
| 121950 | + Fts3MultiSegReader *pCsr, /* Cursor object */ | |
| 121951 | + int iCol, /* Column to match on. */ | |
| 121952 | + const char *zTerm, /* Term to iterate through a doclist for */ | |
| 121953 | + int nTerm /* Number of bytes in zTerm */ | |
| 121954 | +){ | |
| 121955 | + int i; | |
| 121956 | + int rc; | |
| 121957 | + int nSegment = pCsr->nSegment; | |
| 121958 | + int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = ( | |
| 121959 | + p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp | |
| 121960 | + ); | |
| 121961 | + | |
| 121962 | + assert( pCsr->pFilter==0 ); | |
| 121963 | + assert( zTerm && nTerm>0 ); | |
| 121964 | + | |
| 121965 | + /* Advance each segment iterator until it points to the term zTerm/nTerm. */ | |
| 121966 | + rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm); | |
| 121967 | + if( rc!=SQLITE_OK ) return rc; | |
| 121968 | + | |
| 121969 | + /* Determine how many of the segments actually point to zTerm/nTerm. */ | |
| 121970 | + for(i=0; i<nSegment; i++){ | |
| 121902 | 121971 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121903 | - do { | |
| 121904 | - int rc = fts3SegReaderNext(p, pSeg, 0); | |
| 121905 | - if( rc!=SQLITE_OK ) return rc; | |
| 121906 | - }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); | |
| 121972 | + if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){ | |
| 121973 | + break; | |
| 121974 | + } | |
| 121907 | 121975 | } |
| 121908 | - fts3SegReaderSort( | |
| 121909 | - pCsr->apSegment, pCsr->nSegment, pCsr->nSegment, fts3SegReaderCmp); | |
| 121976 | + pCsr->nAdvance = i; | |
| 121977 | + | |
| 121978 | + /* Advance each of the segments to point to the first docid. */ | |
| 121979 | + for(i=0; i<pCsr->nAdvance; i++){ | |
| 121980 | + rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]); | |
| 121981 | + if( rc!=SQLITE_OK ) return rc; | |
| 121982 | + } | |
| 121983 | + fts3SegReaderSort(pCsr->apSegment, i, i, xCmp); | |
| 121984 | + | |
| 121985 | + assert( iCol<0 || iCol<p->nColumn ); | |
| 121986 | + pCsr->iColFilter = iCol; | |
| 121987 | + | |
| 121988 | + return SQLITE_OK; | |
| 121989 | +} | |
| 121990 | + | |
| 121991 | +/* | |
| 121992 | +** This function is called on a MultiSegReader that has been started using | |
| 121993 | +** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also | |
| 121994 | +** have been made. Calling this function puts the MultiSegReader in such | |
| 121995 | +** a state that if the next two calls are: | |
| 121996 | +** | |
| 121997 | +** sqlite3Fts3SegReaderStart() | |
| 121998 | +** sqlite3Fts3SegReaderStep() | |
| 121999 | +** | |
| 122000 | +** then the entire doclist for the term is available in | |
| 122001 | +** MultiSegReader.aDoclist/nDoclist. | |
| 122002 | +*/ | |
| 122003 | +SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){ | |
| 122004 | + int i; /* Used to iterate through segment-readers */ | |
| 122005 | + | |
| 122006 | + assert( pCsr->zTerm==0 ); | |
| 122007 | + assert( pCsr->nTerm==0 ); | |
| 122008 | + assert( pCsr->aDoclist==0 ); | |
| 122009 | + assert( pCsr->nDoclist==0 ); | |
| 122010 | + | |
| 122011 | + pCsr->nAdvance = 0; | |
| 122012 | + pCsr->bRestart = 1; | |
| 122013 | + for(i=0; i<pCsr->nSegment; i++){ | |
| 122014 | + pCsr->apSegment[i]->pOffsetList = 0; | |
| 122015 | + pCsr->apSegment[i]->nOffsetList = 0; | |
| 122016 | + pCsr->apSegment[i]->iDocid = 0; | |
| 122017 | + } | |
| 121910 | 122018 | |
| 121911 | 122019 | return SQLITE_OK; |
| 121912 | 122020 | } |
| 122021 | + | |
| 121913 | 122022 | |
| 121914 | 122023 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStep( |
| 121915 | 122024 | Fts3Table *p, /* Virtual table handle */ |
| 121916 | 122025 | Fts3MultiSegReader *pCsr /* Cursor object */ |
| 121917 | 122026 | ){ |
| @@ -121981,13 +122090,18 @@ | ||
| 121981 | 122090 | assert( isIgnoreEmpty || (isRequirePos && !isColFilter) ); |
| 121982 | 122091 | if( nMerge==1 |
| 121983 | 122092 | && !isIgnoreEmpty |
| 121984 | 122093 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 121985 | 122094 | ){ |
| 121986 | - pCsr->aDoclist = apSegment[0]->aDoclist; | |
| 121987 | 122095 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 121988 | - rc = SQLITE_ROW; | |
| 122096 | + if( fts3SegReaderIsPending(apSegment[0]) ){ | |
| 122097 | + rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist); | |
| 122098 | + pCsr->aDoclist = pCsr->aBuffer; | |
| 122099 | + }else{ | |
| 122100 | + pCsr->aDoclist = apSegment[0]->aDoclist; | |
| 122101 | + } | |
| 122102 | + if( rc==SQLITE_OK ) rc = SQLITE_ROW; | |
| 121989 | 122103 | }else{ |
| 121990 | 122104 | int nDoclist = 0; /* Size of doclist */ |
| 121991 | 122105 | sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */ |
| 121992 | 122106 | |
| 121993 | 122107 | /* The current term of the first nMerge entries in the array |
| @@ -123725,11 +123839,11 @@ | ||
| 123725 | 123839 | if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol; |
| 123726 | 123840 | break; |
| 123727 | 123841 | |
| 123728 | 123842 | case FTS3_MATCHINFO_NDOC: |
| 123729 | 123843 | if( bGlobal ){ |
| 123730 | - sqlite3_int64 nDoc; | |
| 123844 | + sqlite3_int64 nDoc = 0; | |
| 123731 | 123845 | rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0); |
| 123732 | 123846 | pInfo->aMatchinfo[0] = (u32)nDoc; |
| 123733 | 123847 | } |
| 123734 | 123848 | break; |
| 123735 | 123849 | |
| @@ -125620,11 +125734,11 @@ | ||
| 125620 | 125734 | */ |
| 125621 | 125735 | static float cellArea(Rtree *pRtree, RtreeCell *p){ |
| 125622 | 125736 | float area = 1.0; |
| 125623 | 125737 | int ii; |
| 125624 | 125738 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125625 | - area = area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); | |
| 125739 | + area = (float)(area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]))); | |
| 125626 | 125740 | } |
| 125627 | 125741 | return area; |
| 125628 | 125742 | } |
| 125629 | 125743 | |
| 125630 | 125744 | /* |
| @@ -125633,11 +125747,11 @@ | ||
| 125633 | 125747 | */ |
| 125634 | 125748 | static float cellMargin(Rtree *pRtree, RtreeCell *p){ |
| 125635 | 125749 | float margin = 0.0; |
| 125636 | 125750 | int ii; |
| 125637 | 125751 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125638 | - margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); | |
| 125752 | + margin += (float)(DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); | |
| 125639 | 125753 | } |
| 125640 | 125754 | return margin; |
| 125641 | 125755 | } |
| 125642 | 125756 | |
| 125643 | 125757 | /* |
| @@ -125718,11 +125832,11 @@ | ||
| 125718 | 125832 | |
| 125719 | 125833 | if( x2<x1 ){ |
| 125720 | 125834 | o = 0.0; |
| 125721 | 125835 | break; |
| 125722 | 125836 | }else{ |
| 125723 | - o = o * (x2-x1); | |
| 125837 | + o = o * (float)(x2-x1); | |
| 125724 | 125838 | } |
| 125725 | 125839 | } |
| 125726 | 125840 | overlap += o; |
| 125727 | 125841 | } |
| 125728 | 125842 | } |
| @@ -125737,16 +125851,16 @@ | ||
| 125737 | 125851 | RtreeCell *pInsert, |
| 125738 | 125852 | RtreeCell *aCell, |
| 125739 | 125853 | int nCell, |
| 125740 | 125854 | int iExclude |
| 125741 | 125855 | ){ |
| 125742 | - float before; | |
| 125743 | - float after; | |
| 125856 | + double before; | |
| 125857 | + double after; | |
| 125744 | 125858 | before = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125745 | 125859 | cellUnion(pRtree, p, pInsert); |
| 125746 | 125860 | after = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125747 | - return after-before; | |
| 125861 | + return (float)(after-before); | |
| 125748 | 125862 | } |
| 125749 | 125863 | #endif |
| 125750 | 125864 | |
| 125751 | 125865 | |
| 125752 | 125866 | /* |
| @@ -125764,15 +125878,15 @@ | ||
| 125764 | 125878 | RtreeNode *pNode; |
| 125765 | 125879 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 125766 | 125880 | |
| 125767 | 125881 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 125768 | 125882 | int iCell; |
| 125769 | - sqlite3_int64 iBest; | |
| 125883 | + sqlite3_int64 iBest = 0; | |
| 125770 | 125884 | |
| 125771 | - float fMinGrowth; | |
| 125772 | - float fMinArea; | |
| 125773 | - float fMinOverlap; | |
| 125885 | + float fMinGrowth = 0.0; | |
| 125886 | + float fMinArea = 0.0; | |
| 125887 | + float fMinOverlap = 0.0; | |
| 125774 | 125888 | |
| 125775 | 125889 | int nCell = NCELL(pNode); |
| 125776 | 125890 | RtreeCell cell; |
| 125777 | 125891 | RtreeNode *pChild; |
| 125778 | 125892 | |
| @@ -126198,13 +126312,13 @@ | ||
| 126198 | 126312 | ){ |
| 126199 | 126313 | int **aaSorted; |
| 126200 | 126314 | int *aSpare; |
| 126201 | 126315 | int ii; |
| 126202 | 126316 | |
| 126203 | - int iBestDim; | |
| 126204 | - int iBestSplit; | |
| 126205 | - float fBestMargin; | |
| 126317 | + int iBestDim = 0; | |
| 126318 | + int iBestSplit = 0; | |
| 126319 | + float fBestMargin = 0.0; | |
| 126206 | 126320 | |
| 126207 | 126321 | int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); |
| 126208 | 126322 | |
| 126209 | 126323 | aaSorted = (int **)sqlite3_malloc(nByte); |
| 126210 | 126324 | if( !aaSorted ){ |
| @@ -126222,13 +126336,13 @@ | ||
| 126222 | 126336 | SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare); |
| 126223 | 126337 | } |
| 126224 | 126338 | |
| 126225 | 126339 | for(ii=0; ii<pRtree->nDim; ii++){ |
| 126226 | 126340 | float margin = 0.0; |
| 126227 | - float fBestOverlap; | |
| 126228 | - float fBestArea; | |
| 126229 | - int iBestLeft; | |
| 126341 | + float fBestOverlap = 0.0; | |
| 126342 | + float fBestArea = 0.0; | |
| 126343 | + int iBestLeft = 0; | |
| 126230 | 126344 | int nLeft; |
| 126231 | 126345 | |
| 126232 | 126346 | for( |
| 126233 | 126347 | nLeft=RTREE_MINCELLS(pRtree); |
| 126234 | 126348 | nLeft<=(nCell-RTREE_MINCELLS(pRtree)); |
| @@ -126539,11 +126653,11 @@ | ||
| 126539 | 126653 | static int deleteCell(Rtree *, RtreeNode *, int, int); |
| 126540 | 126654 | |
| 126541 | 126655 | static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){ |
| 126542 | 126656 | int rc; |
| 126543 | 126657 | int rc2; |
| 126544 | - RtreeNode *pParent; | |
| 126658 | + RtreeNode *pParent = 0; | |
| 126545 | 126659 | int iCell; |
| 126546 | 126660 | |
| 126547 | 126661 | assert( pNode->nRef==1 ); |
| 126548 | 126662 | |
| 126549 | 126663 | /* Remove the entry in the parent cell. */ |
| @@ -126687,23 +126801,23 @@ | ||
| 126687 | 126801 | }else{ |
| 126688 | 126802 | nodeGetCell(pRtree, pNode, ii, &aCell[ii]); |
| 126689 | 126803 | } |
| 126690 | 126804 | aOrder[ii] = ii; |
| 126691 | 126805 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126692 | - aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]); | |
| 126693 | - aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]); | |
| 126806 | + aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2]); | |
| 126807 | + aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2+1]); | |
| 126694 | 126808 | } |
| 126695 | 126809 | } |
| 126696 | 126810 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126697 | - aCenterCoord[iDim] = aCenterCoord[iDim]/((float)nCell*2.0); | |
| 126811 | + aCenterCoord[iDim] = (float)(aCenterCoord[iDim]/((float)nCell*2.0)); | |
| 126698 | 126812 | } |
| 126699 | 126813 | |
| 126700 | 126814 | for(ii=0; ii<nCell; ii++){ |
| 126701 | 126815 | aDistance[ii] = 0.0; |
| 126702 | 126816 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126703 | - float coord = DCOORD(aCell[ii].aCoord[iDim*2+1]) - | |
| 126704 | - DCOORD(aCell[ii].aCoord[iDim*2]); | |
| 126817 | + float coord = (float)(DCOORD(aCell[ii].aCoord[iDim*2+1]) - | |
| 126818 | + DCOORD(aCell[ii].aCoord[iDim*2])); | |
| 126705 | 126819 | aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); |
| 126706 | 126820 | } |
| 126707 | 126821 | } |
| 126708 | 126822 | |
| 126709 | 126823 | SortByDistance(aOrder, nCell, aDistance, aSpare); |
| @@ -126798,14 +126912,14 @@ | ||
| 126798 | 126912 | nodeGetCell(pRtree, pNode, ii, &cell); |
| 126799 | 126913 | |
| 126800 | 126914 | /* Find a node to store this cell in. pNode->iNode currently contains |
| 126801 | 126915 | ** the height of the sub-tree headed by the cell. |
| 126802 | 126916 | */ |
| 126803 | - rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert); | |
| 126917 | + rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert); | |
| 126804 | 126918 | if( rc==SQLITE_OK ){ |
| 126805 | 126919 | int rc2; |
| 126806 | - rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode); | |
| 126920 | + rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode); | |
| 126807 | 126921 | rc2 = nodeRelease(pRtree, pInsert); |
| 126808 | 126922 | if( rc==SQLITE_OK ){ |
| 126809 | 126923 | rc = rc2; |
| 126810 | 126924 | } |
| 126811 | 126925 | } |
| @@ -127190,11 +127304,11 @@ | ||
| 127190 | 127304 | int isCreate /* True for xCreate, false for xConnect */ |
| 127191 | 127305 | ){ |
| 127192 | 127306 | int rc; |
| 127193 | 127307 | char *zSql; |
| 127194 | 127308 | if( isCreate ){ |
| 127195 | - int iPageSize; | |
| 127309 | + int iPageSize = 0; | |
| 127196 | 127310 | zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); |
| 127197 | 127311 | rc = getIntFromStmt(db, zSql, &iPageSize); |
| 127198 | 127312 | if( rc==SQLITE_OK ){ |
| 127199 | 127313 | pRtree->iNodeSize = iPageSize-64; |
| 127200 | 127314 | if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ |
| @@ -127993,14 +128107,11 @@ | ||
| 127993 | 128107 | ** May you find forgiveness for yourself and forgive others. |
| 127994 | 128108 | ** May you share freely, never taking more than you give. |
| 127995 | 128109 | ** |
| 127996 | 128110 | ************************************************************************* |
| 127997 | 128111 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 127998 | -** | |
| 127999 | -** $Id: fts3_icu.c,v 1.3 2008/09/01 18:34:20 danielk1977 Exp $ | |
| 128000 | 128112 | */ |
| 128001 | - | |
| 128002 | 128113 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 128003 | 128114 | #ifdef SQLITE_ENABLE_ICU |
| 128004 | 128115 | |
| 128005 | 128116 | |
| 128006 | 128117 | #include <unicode/ubrk.h> |
| 128007 | 128118 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | #define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -851,11 +851,11 @@ | |
| 851 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 852 | ** in the context of the [database connection] passed in as its 1st |
| 853 | ** argument. ^If the callback function of the 3rd argument to |
| 854 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 855 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 856 | ** to sqlite3_exec() is relayed through to the 1st argument of each |
| 857 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 858 | ** is NULL, then no callback is ever invoked and result rows are |
| 859 | ** ignored. |
| 860 | ** |
| 861 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -1443,11 +1443,11 @@ | |
| 1443 | ** The xSleep() method causes the calling thread to sleep for at |
| 1444 | ** least the number of microseconds given. ^The xCurrentTime() |
| 1445 | ** method returns a Julian Day Number for the current date and time as |
| 1446 | ** a floating point value. |
| 1447 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 1448 | ** Day Number multipled by 86400000 (the number of milliseconds in |
| 1449 | ** a 24-hour day). |
| 1450 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 1451 | ** date and time if that method is available (if iVersion is 2 or |
| 1452 | ** greater and the function pointer is not NULL) and will fall back |
| 1453 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1881,11 +1881,11 @@ | |
| 1881 | ** scratch memory beyond what is provided by this configuration option, then |
| 1882 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1883 | ** |
| 1884 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1885 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1886 | ** the database page cache with the default page cache implemenation. |
| 1887 | ** This configuration should not be used if an application-define page |
| 1888 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1889 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1890 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1891 | ** The sz argument should be the size of the largest database page |
| @@ -2979,16 +2979,16 @@ | |
| 2979 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2980 | ** |
| 2981 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2982 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2983 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2984 | ** is set in the fourth argument to sqlite3_open_v2(), or if it has |
| 2985 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2986 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2987 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2988 | ** by default, but future releases of SQLite might enable URI filename |
| 2989 | ** intepretation by default. See "[URI filenames]" for additional |
| 2990 | ** information. |
| 2991 | ** |
| 2992 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2993 | ** authority, then it must be either an empty string or the string |
| 2994 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3803,11 +3803,11 @@ | |
| 3803 | ** [extended result codes] might be returned as well. |
| 3804 | ** |
| 3805 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3806 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3807 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3808 | ** statement. If the statement is not a [COMMIT] and occurs within a |
| 3809 | ** explicit transaction then you should rollback the transaction before |
| 3810 | ** continuing. |
| 3811 | ** |
| 3812 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3813 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -4082,11 +4082,11 @@ | |
| 4082 | |
| 4083 | /* |
| 4084 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 4085 | ** |
| 4086 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 4087 | ** ^If the most recent evaluation of the statement encountered no errors or |
| 4088 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 4089 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 4090 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 4091 | ** [extended error code]. |
| 4092 | ** |
| @@ -5996,11 +5996,11 @@ | |
| 5996 | ** versions of these routines, it should at least provide stubs that always |
| 5997 | ** return true so that one does not get spurious assertion failures. |
| 5998 | ** |
| 5999 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 6000 | ** the routine should return 1. This seems counter-intuitive since |
| 6001 | ** clearly the mutex cannot be held if it does not exist. But the |
| 6002 | ** the reason the mutex does not exist is because the build is not |
| 6003 | ** using mutexes. And we do not want the assert() containing the |
| 6004 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 6005 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 6006 | ** interface should also return 1 when given a NULL pointer. |
| @@ -6505,11 +6505,11 @@ | |
| 6505 | ** [[the xFetch() page cache methods]] |
| 6506 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 6507 | ** the page, or a NULL pointer. |
| 6508 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 6509 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 6510 | ** mimimum key value is 1. After it has been retrieved using xFetch, the page |
| 6511 | ** is considered to be "pinned". |
| 6512 | ** |
| 6513 | ** If the requested page is already in the page cache, then the page cache |
| 6514 | ** implementation must return a pointer to the page buffer with its content |
| 6515 | ** intact. If the requested page is not already in the cache, then the |
| @@ -24364,10 +24364,14 @@ | |
| 24364 | |
| 24365 | #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 24366 | # include <sys/mount.h> |
| 24367 | #endif |
| 24368 | |
| 24369 | /* |
| 24370 | ** Allowed values of unixFile.fsFlags |
| 24371 | */ |
| 24372 | #define SQLITE_FSFLAGS_IS_MSDOS 0x1 |
| 24373 | |
| @@ -26369,12 +26373,14 @@ | |
| 26369 | /* If we have any lock, then the lock file already exists. All we have |
| 26370 | ** to do is adjust our internal record of the lock level. |
| 26371 | */ |
| 26372 | if( pFile->eFileLock > NO_LOCK ){ |
| 26373 | pFile->eFileLock = eFileLock; |
| 26374 | #if !OS_VXWORKS |
| 26375 | /* Always update the timestamp on the old file */ |
| 26376 | utimes(zLockFile, NULL); |
| 26377 | #endif |
| 26378 | return SQLITE_OK; |
| 26379 | } |
| 26380 | |
| @@ -32254,11 +32260,12 @@ | |
| 32254 | rc = 1; |
| 32255 | } |
| 32256 | } |
| 32257 | |
| 32258 | if( rc ){ |
| 32259 | if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){ |
| 32260 | return SQLITE_FULL; |
| 32261 | } |
| 32262 | return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath); |
| 32263 | } |
| 32264 | return SQLITE_OK; |
| @@ -63496,11 +63503,11 @@ | |
| 63496 | break; |
| 63497 | } |
| 63498 | |
| 63499 | /* Opcode: HaltIfNull P1 P2 P3 P4 * |
| 63500 | ** |
| 63501 | ** Check the value in register P3. If is is NULL then Halt using |
| 63502 | ** parameter P1, P2, and P4 as if this were a Halt instruction. If the |
| 63503 | ** value in register P3 is not NULL, then this routine is a no-op. |
| 63504 | */ |
| 63505 | case OP_HaltIfNull: { /* in3 */ |
| 63506 | pIn3 = &aMem[pOp->p3]; |
| @@ -64433,11 +64440,11 @@ | |
| 64433 | ** additional information. |
| 64434 | ** |
| 64435 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64436 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64437 | ** of comparison is false. If either operand is NULL then the result is true. |
| 64438 | ** If neither operand is NULL the the result is the same as it would be if |
| 64439 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64440 | */ |
| 64441 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| 64442 | ** |
| 64443 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64445,11 +64452,11 @@ | |
| 64445 | ** See the Lt opcode for additional information. |
| 64446 | ** |
| 64447 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64448 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64449 | ** of comparison is true. If either operand is NULL then the result is false. |
| 64450 | ** If neither operand is NULL the the result is the same as it would be if |
| 64451 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64452 | */ |
| 64453 | /* Opcode: Le P1 P2 P3 P4 P5 |
| 64454 | ** |
| 64455 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64730,17 +64737,17 @@ | |
| 64730 | break; |
| 64731 | } |
| 64732 | |
| 64733 | /* Opcode: If P1 P2 P3 * * |
| 64734 | ** |
| 64735 | ** Jump to P2 if the value in register P1 is true. The value is |
| 64736 | ** is considered true if it is numeric and non-zero. If the value |
| 64737 | ** in P1 is NULL then take the jump if P3 is true. |
| 64738 | */ |
| 64739 | /* Opcode: IfNot P1 P2 P3 * * |
| 64740 | ** |
| 64741 | ** Jump to P2 if the value in register P1 is False. The value is |
| 64742 | ** is considered true if it has a numeric value of zero. If the value |
| 64743 | ** in P1 is NULL then take the jump if P3 is true. |
| 64744 | */ |
| 64745 | case OP_If: /* jump, in1 */ |
| 64746 | case OP_IfNot: { /* jump, in1 */ |
| @@ -66390,11 +66397,11 @@ | |
| 66390 | break; |
| 66391 | } |
| 66392 | |
| 66393 | /* Opcode: NotExists P1 P2 P3 * * |
| 66394 | ** |
| 66395 | ** Use the content of register P3 as a integer key. If a record |
| 66396 | ** with that key does not exist in table of P1, then jump to P2. |
| 66397 | ** If the record does exist, then fall through. The cursor is left |
| 66398 | ** pointing to the record if it exists. |
| 66399 | ** |
| 66400 | ** The difference between this operation and NotFound is that this |
| @@ -66468,11 +66475,11 @@ | |
| 66468 | ** written to register P2. |
| 66469 | ** |
| 66470 | ** If P3>0 then P3 is a register in the root frame of this VDBE that holds |
| 66471 | ** the largest previously generated record number. No new record numbers are |
| 66472 | ** allowed to be less than this value. When this value reaches its maximum, |
| 66473 | ** a SQLITE_FULL error is generated. The P3 register is updated with the ' |
| 66474 | ** generated record number. This P3 mechanism is used to help implement the |
| 66475 | ** AUTOINCREMENT feature. |
| 66476 | */ |
| 66477 | case OP_NewRowid: { /* out2-prerelease */ |
| 66478 | #if 0 /* local variables moved into u.be */ |
| @@ -67110,11 +67117,11 @@ | |
| 67110 | break; |
| 67111 | } |
| 67112 | |
| 67113 | /* Opcode: IdxInsert P1 P2 P3 * P5 |
| 67114 | ** |
| 67115 | ** Register P2 holds a SQL index key made using the |
| 67116 | ** MakeRecord instructions. This opcode writes that key |
| 67117 | ** into the index P1. Data for the entry is nil. |
| 67118 | ** |
| 67119 | ** P3 is a flag that provides a hint to the b-tree layer that this |
| 67120 | ** insert is likely to be an append. |
| @@ -111420,16 +111427,10 @@ | |
| 111420 | ** TODO(shess) Provide a VACUUM type operation to clear out all |
| 111421 | ** deletions and duplications. This would basically be a forced merge |
| 111422 | ** into a single segment. |
| 111423 | */ |
| 111424 | |
| 111425 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 111426 | |
| 111427 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 111428 | # define SQLITE_CORE 1 |
| 111429 | #endif |
| 111430 | |
| 111431 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 111432 | /************** Begin file fts3Int.h *****************************************/ |
| 111433 | /* |
| 111434 | ** 2009 Nov 12 |
| 111435 | ** |
| @@ -111441,18 +111442,27 @@ | |
| 111441 | ** May you share freely, never taking more than you give. |
| 111442 | ** |
| 111443 | ****************************************************************************** |
| 111444 | ** |
| 111445 | */ |
| 111446 | |
| 111447 | #ifndef _FTSINT_H |
| 111448 | #define _FTSINT_H |
| 111449 | |
| 111450 | #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| 111451 | # define NDEBUG 1 |
| 111452 | #endif |
| 111453 | |
| 111454 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 111455 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 111456 | /* |
| 111457 | ** 2006 July 10 |
| 111458 | ** |
| @@ -111940,11 +111950,11 @@ | |
| 111940 | char *aDoclist; /* List of docids for full-text queries */ |
| 111941 | int nDoclist; /* Size of buffer at aDoclist */ |
| 111942 | u8 bDesc; /* True to sort in descending order */ |
| 111943 | int eEvalmode; /* An FTS3_EVAL_XX constant */ |
| 111944 | int nRowAvg; /* Average size of database rows, in pages */ |
| 111945 | int nDoc; /* Documents in table */ |
| 111946 | |
| 111947 | int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */ |
| 111948 | u32 *aMatchinfo; /* Information about most recent match */ |
| 111949 | int nMatchinfo; /* Number of elements in aMatchinfo[] */ |
| 111950 | char *zMatchinfo; /* Matchinfo specification */ |
| @@ -111997,19 +112007,19 @@ | |
| 111997 | int isPrefix; /* True if token ends with a "*" character */ |
| 111998 | |
| 111999 | /* Variables above this point are populated when the expression is |
| 112000 | ** parsed (by code in fts3_expr.c). Below this point the variables are |
| 112001 | ** used when evaluating the expression. */ |
| 112002 | int bFulltext; /* True if full-text index was used */ |
| 112003 | Fts3DeferredToken *pDeferred; /* Deferred token object for this token */ |
| 112004 | Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */ |
| 112005 | }; |
| 112006 | |
| 112007 | struct Fts3Phrase { |
| 112008 | /* Cache of doclist for this phrase. */ |
| 112009 | Fts3Doclist doclist; |
| 112010 | int bIncr; /* True if doclist is loaded incrementally */ |
| 112011 | |
| 112012 | /* Variables below this point are populated by fts3_expr.c when parsing |
| 112013 | ** a MATCH expression. Everything above is part of the evaluation phase. |
| 112014 | */ |
| 112015 | int nToken; /* Number of tokens in the phrase */ |
| @@ -112130,10 +112140,11 @@ | |
| 112130 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 112131 | char *aBuffer; /* Buffer to merge doclists in */ |
| 112132 | int nBuffer; /* Allocated size of aBuffer[] in bytes */ |
| 112133 | |
| 112134 | int iColFilter; /* If >=0, filter for this column */ |
| 112135 | |
| 112136 | /* Used by fts3.c only. */ |
| 112137 | int nCost; /* Cost of running iterator */ |
| 112138 | int bLookup; /* True if a lookup of a single entry. */ |
| 112139 | |
| @@ -112199,18 +112210,24 @@ | |
| 112199 | Fts3Table*, Fts3MultiSegReader*, int, const char*, int); |
| 112200 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 112201 | Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *); |
| 112202 | SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol); |
| 112203 | SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *); |
| 112204 | |
| 112205 | SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *); |
| 112206 | |
| 112207 | |
| 112208 | #endif /* _FTSINT_H */ |
| 112209 | |
| 112210 | /************** End of fts3Int.h *********************************************/ |
| 112211 | /************** Continuing where we left off in fts3.c ***********************/ |
| 112212 | |
| 112213 | |
| 112214 | #ifndef SQLITE_CORE |
| 112215 | SQLITE_EXTENSION_INIT1 |
| 112216 | #endif |
| @@ -112995,11 +113012,11 @@ | |
| 112995 | zCsr += nDb; |
| 112996 | |
| 112997 | /* Fill in the azColumn array */ |
| 112998 | for(iCol=0; iCol<nCol; iCol++){ |
| 112999 | char *z; |
| 113000 | int n; |
| 113001 | z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n); |
| 113002 | memcpy(zCsr, z, n); |
| 113003 | zCsr[n] = '\0'; |
| 113004 | sqlite3Fts3Dequote(zCsr); |
| 113005 | p->azColumn[iCol] = zCsr; |
| @@ -114581,12 +114598,12 @@ | |
| 114581 | |
| 114582 | /* |
| 114583 | ** Implementation of xBegin() method. This is a no-op. |
| 114584 | */ |
| 114585 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ |
| 114586 | UNUSED_PARAMETER(pVtab); |
| 114587 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114588 | assert( p->pSegments==0 ); |
| 114589 | assert( p->nPendingData==0 ); |
| 114590 | assert( p->inTransaction!=1 ); |
| 114591 | TESTONLY( p->inTransaction = 1 ); |
| 114592 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -114597,12 +114614,12 @@ | |
| 114597 | ** Implementation of xCommit() method. This is a no-op. The contents of |
| 114598 | ** the pending-terms hash-table have already been flushed into the database |
| 114599 | ** by fts3SyncMethod(). |
| 114600 | */ |
| 114601 | static int fts3CommitMethod(sqlite3_vtab *pVtab){ |
| 114602 | UNUSED_PARAMETER(pVtab); |
| 114603 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114604 | assert( p->nPendingData==0 ); |
| 114605 | assert( p->inTransaction!=0 ); |
| 114606 | assert( p->pSegments==0 ); |
| 114607 | TESTONLY( p->inTransaction = 0 ); |
| 114608 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -115083,75 +115100,105 @@ | |
| 115083 | if( rc!=SQLITE_OK ){ |
| 115084 | *pRc = rc; |
| 115085 | return; |
| 115086 | } |
| 115087 | } |
| 115088 | }else{ |
| 115089 | *pnOr += (pExpr->eType==FTSQUERY_OR); |
| 115090 | fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc); |
| 115091 | fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc); |
| 115092 | } |
| 115093 | } |
| 115094 | } |
| 115095 | |
| 115096 | static int fts3EvalPhraseLoad( |
| 115097 | Fts3Cursor *pCsr, |
| 115098 | Fts3Phrase *p |
| 115099 | ){ |
| 115100 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115101 | int iToken; |
| 115102 | int rc = SQLITE_OK; |
| 115103 | |
| 115104 | char *aDoclist = 0; |
| 115105 | int nDoclist = 0; |
| 115106 | int iPrev = -1; |
| 115107 | |
| 115108 | for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){ |
| 115109 | Fts3PhraseToken *pToken = &p->aToken[iToken]; |
| 115110 | assert( pToken->pSegcsr || pToken->pDeferred ); |
| 115111 | |
| 115112 | if( pToken->pDeferred==0 ){ |
| 115113 | int nThis = 0; |
| 115114 | char *pThis = 0; |
| 115115 | rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis); |
| 115116 | if( rc==SQLITE_OK ){ |
| 115117 | if( pThis==0 ){ |
| 115118 | sqlite3_free(aDoclist); |
| 115119 | aDoclist = 0; |
| 115120 | nDoclist = 0; |
| 115121 | break; |
| 115122 | }else if( aDoclist==0 ){ |
| 115123 | aDoclist = pThis; |
| 115124 | nDoclist = nThis; |
| 115125 | }else{ |
| 115126 | assert( iPrev>=0 ); |
| 115127 | fts3DoclistPhraseMerge(pTab->bDescIdx, |
| 115128 | iToken-iPrev, aDoclist, nDoclist, pThis, &nThis |
| 115129 | ); |
| 115130 | sqlite3_free(aDoclist); |
| 115131 | aDoclist = pThis; |
| 115132 | nDoclist = nThis; |
| 115133 | } |
| 115134 | iPrev = iToken; |
| 115135 | } |
| 115136 | } |
| 115137 | } |
| 115138 | |
| 115139 | if( rc==SQLITE_OK ){ |
| 115140 | p->doclist.aAll = aDoclist; |
| 115141 | p->doclist.nAll = nDoclist; |
| 115142 | }else{ |
| 115143 | sqlite3_free(aDoclist); |
| 115144 | } |
| 115145 | return rc; |
| 115146 | } |
| 115147 | |
| 115148 | static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){ |
| 115149 | int iToken; |
| 115150 | int rc = SQLITE_OK; |
| 115151 | |
| 115152 | int nMaxUndeferred = -1; |
| 115153 | char *aPoslist = 0; |
| 115154 | int nPoslist = 0; |
| 115155 | int iPrev = -1; |
| 115156 | |
| 115157 | assert( pPhrase->doclist.bFreeList==0 ); |
| @@ -115192,12 +115239,10 @@ | |
| 115192 | pPhrase->doclist.nList = 0; |
| 115193 | return SQLITE_OK; |
| 115194 | } |
| 115195 | } |
| 115196 | iPrev = iToken; |
| 115197 | }else{ |
| 115198 | nMaxUndeferred = iToken; |
| 115199 | } |
| 115200 | } |
| 115201 | |
| 115202 | if( iPrev>=0 ){ |
| 115203 | if( nMaxUndeferred<0 ){ |
| @@ -115252,13 +115297,15 @@ | |
| 115252 | static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ |
| 115253 | int rc; |
| 115254 | Fts3PhraseToken *pFirst = &p->aToken[0]; |
| 115255 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115256 | |
| 115257 | assert( p->doclist.aAll==0 ); |
| 115258 | if( pCsr->bDesc==pTab->bDescIdx && bOptOk==1 && p->nToken==1 |
| 115259 | && pFirst->pSegcsr && pFirst->pSegcsr->bLookup |
| 115260 | ){ |
| 115261 | /* Use the incremental approach. */ |
| 115262 | int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn); |
| 115263 | rc = sqlite3Fts3MsrIncrStart( |
| 115264 | pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n); |
| @@ -115394,11 +115441,11 @@ | |
| 115394 | ** with this case by advancing pIter past the zero-padding added by |
| 115395 | ** fts3EvalNearTrim2(). */ |
| 115396 | while( pIter<pEnd && *pIter==0 ) pIter++; |
| 115397 | |
| 115398 | pDL->pNextDocid = pIter; |
| 115399 | assert( *pIter || pIter>=&pDL->aAll[pDL->nAll] ); |
| 115400 | *pbEof = 0; |
| 115401 | } |
| 115402 | } |
| 115403 | |
| 115404 | return rc; |
| @@ -115425,17 +115472,18 @@ | |
| 115425 | pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred); |
| 115426 | } |
| 115427 | } |
| 115428 | } |
| 115429 | |
| 115430 | |
| 115431 | typedef struct Fts3TokenAndCost Fts3TokenAndCost; |
| 115432 | struct Fts3TokenAndCost { |
| 115433 | Fts3PhraseToken *pToken; |
| 115434 | Fts3Expr *pRoot; |
| 115435 | int nOvfl; |
| 115436 | int iCol; |
| 115437 | }; |
| 115438 | |
| 115439 | static void fts3EvalTokenCosts( |
| 115440 | Fts3Cursor *pCsr, |
| 115441 | Fts3Expr *pRoot, |
| @@ -115448,10 +115496,12 @@ | |
| 115448 | if( pExpr->eType==FTSQUERY_PHRASE ){ |
| 115449 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 115450 | int i; |
| 115451 | for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){ |
| 115452 | Fts3TokenAndCost *pTC = (*ppTC)++; |
| 115453 | pTC->pRoot = pRoot; |
| 115454 | pTC->pToken = &pPhrase->aToken[i]; |
| 115455 | pTC->iCol = pPhrase->iColumn; |
| 115456 | *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl); |
| 115457 | } |
| @@ -115560,23 +115610,19 @@ | |
| 115560 | /* At this point pTC points to the cheapest remaining token. */ |
| 115561 | if( ii==0 ){ |
| 115562 | if( pTC->nOvfl ){ |
| 115563 | nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10; |
| 115564 | }else{ |
| 115565 | /* TODO: Fix this so that the doclist need not be read twice. */ |
| 115566 | Fts3PhraseToken *pToken = pTC->pToken; |
| 115567 | int nList = 0; |
| 115568 | char *pList = 0; |
| 115569 | rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList); |
| 115570 | if( rc==SQLITE_OK ){ |
| 115571 | nDocEst = fts3DoclistCountDocids(1, pList, nList); |
| 115572 | } |
| 115573 | sqlite3_free(pList); |
| 115574 | if( rc==SQLITE_OK ){ |
| 115575 | rc = sqlite3Fts3TermSegReaderCursor(pCsr, |
| 115576 | pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr |
| 115577 | ); |
| 115578 | } |
| 115579 | } |
| 115580 | }else{ |
| 115581 | if( pTC->nOvfl>=(nDocEst*nDocSize) ){ |
| 115582 | Fts3PhraseToken *pToken = pTC->pToken; |
| @@ -116032,17 +116078,18 @@ | |
| 116032 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 116033 | |
| 116034 | if( pPhrase ){ |
| 116035 | fts3EvalZeroPoslist(pPhrase); |
| 116036 | if( pPhrase->bIncr ){ |
| 116037 | sqlite3Fts3EvalPhraseCleanup(pPhrase); |
| 116038 | memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist)); |
| 116039 | *pRc = sqlite3Fts3EvalStart(pCsr, pExpr, 0); |
| 116040 | }else{ |
| 116041 | pPhrase->doclist.pNextDocid = 0; |
| 116042 | pPhrase->doclist.iDocid = 0; |
| 116043 | } |
| 116044 | } |
| 116045 | |
| 116046 | pExpr->iDocid = 0; |
| 116047 | pExpr->bEof = 0; |
| 116048 | pExpr->bStart = 0; |
| @@ -116225,12 +116272,12 @@ | |
| 116225 | int iCol; |
| 116226 | |
| 116227 | if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){ |
| 116228 | assert( pCsr->nDoc>0 ); |
| 116229 | for(iCol=0; iCol<pTab->nColumn; iCol++){ |
| 116230 | aiOut[iCol*3 + 1] = pCsr->nDoc; |
| 116231 | aiOut[iCol*3 + 2] = pCsr->nDoc; |
| 116232 | } |
| 116233 | }else{ |
| 116234 | rc = fts3EvalGatherStats(pCsr, pExpr); |
| 116235 | if( rc==SQLITE_OK ){ |
| 116236 | assert( pExpr->aMI ); |
| @@ -116334,11 +116381,10 @@ | |
| 116334 | ** May you share freely, never taking more than you give. |
| 116335 | ** |
| 116336 | ****************************************************************************** |
| 116337 | ** |
| 116338 | */ |
| 116339 | |
| 116340 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 116341 | |
| 116342 | |
| 116343 | typedef struct Fts3auxTable Fts3auxTable; |
| 116344 | typedef struct Fts3auxCursor Fts3auxCursor; |
| @@ -118168,11 +118214,10 @@ | |
| 118168 | */ |
| 118169 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 118170 | |
| 118171 | |
| 118172 | |
| 118173 | |
| 118174 | /* |
| 118175 | ** Class derived from sqlite3_tokenizer |
| 118176 | */ |
| 118177 | typedef struct porter_tokenizer { |
| 118178 | sqlite3_tokenizer base; /* Base class */ |
| @@ -118808,15 +118853,15 @@ | |
| 118808 | ** (in which case SQLITE_CORE is not defined), or |
| 118809 | ** |
| 118810 | ** * The FTS3 module is being built into the core of |
| 118811 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 118812 | */ |
| 118813 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 118814 | |
| 118815 | #ifndef SQLITE_CORE |
| 118816 | SQLITE_EXTENSION_INIT1 |
| 118817 | #endif |
| 118818 | |
| 118819 | |
| 118820 | /* |
| 118821 | ** Implementation of the SQL scalar function for accessing the underlying |
| 118822 | ** hash table. This function may be called as follows: |
| @@ -118937,11 +118982,11 @@ | |
| 118937 | sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */ |
| 118938 | char **pzErr /* OUT: Set to malloced error message */ |
| 118939 | ){ |
| 118940 | int rc; |
| 118941 | char *z = (char *)zArg; |
| 118942 | int n; |
| 118943 | char *zCopy; |
| 118944 | char *zEnd; /* Pointer to nul-term of zCopy */ |
| 118945 | sqlite3_tokenizer_module *m; |
| 118946 | |
| 118947 | zCopy = sqlite3_mprintf("%s", zArg); |
| @@ -119299,11 +119344,10 @@ | |
| 119299 | ** |
| 119300 | ** * The FTS3 module is being built into the core of |
| 119301 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 119302 | */ |
| 119303 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 119304 | |
| 119305 | |
| 119306 | |
| 119307 | |
| 119308 | typedef struct simple_tokenizer { |
| 119309 | sqlite3_tokenizer base; |
| @@ -120750,10 +120794,11 @@ | |
| 120750 | pReader->pOffsetList = 0; |
| 120751 | }else{ |
| 120752 | pReader->pOffsetList = p; |
| 120753 | } |
| 120754 | }else{ |
| 120755 | |
| 120756 | /* Pointer p currently points at the first byte of an offset list. The |
| 120757 | ** following block advances it to point one byte past the end of |
| 120758 | ** the same offset list. */ |
| 120759 | while( 1 ){ |
| @@ -120778,17 +120823,19 @@ | |
| 120778 | */ |
| 120779 | if( ppOffsetList ){ |
| 120780 | *ppOffsetList = pReader->pOffsetList; |
| 120781 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 120782 | } |
| 120783 | |
| 120784 | /* If there are no more entries in the doclist, set pOffsetList to |
| 120785 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 120786 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| 120787 | ** returning. |
| 120788 | */ |
| 120789 | if( p>=&pReader->aDoclist[pReader->nDoclist] ){ |
| 120790 | pReader->pOffsetList = 0; |
| 120791 | }else{ |
| 120792 | rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); |
| 120793 | if( rc==SQLITE_OK ){ |
| 120794 | sqlite3_int64 iDelta; |
| @@ -120823,11 +120870,11 @@ | |
| 120823 | for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){ |
| 120824 | Fts3SegReader *pReader = pMsr->apSegment[ii]; |
| 120825 | if( !fts3SegReaderIsPending(pReader) |
| 120826 | && !fts3SegReaderIsRootOnly(pReader) |
| 120827 | ){ |
| 120828 | int jj; |
| 120829 | for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){ |
| 120830 | int nBlob; |
| 120831 | rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0); |
| 120832 | if( rc!=SQLITE_OK ) break; |
| 120833 | if( (nBlob+35)>pgsz ){ |
| @@ -121768,55 +121815,31 @@ | |
| 121768 | |
| 121769 | *ppList = pList; |
| 121770 | *pnList = nList; |
| 121771 | } |
| 121772 | |
| 121773 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart( |
| 121774 | Fts3Table *p, /* Virtual table handle */ |
| 121775 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121776 | int iCol, /* Column to match on. */ |
| 121777 | const char *zTerm, /* Term to iterate through a doclist for */ |
| 121778 | int nTerm /* Number of bytes in zTerm */ |
| 121779 | ){ |
| 121780 | int i; |
| 121781 | int nSegment = pCsr->nSegment; |
| 121782 | int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = ( |
| 121783 | p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp |
| 121784 | ); |
| 121785 | |
| 121786 | assert( pCsr->pFilter==0 ); |
| 121787 | assert( zTerm && nTerm>0 ); |
| 121788 | |
| 121789 | /* Advance each segment iterator until it points to the term zTerm/nTerm. */ |
| 121790 | for(i=0; i<nSegment; i++){ |
| 121791 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121792 | do { |
| 121793 | int rc = fts3SegReaderNext(p, pSeg, 1); |
| 121794 | if( rc!=SQLITE_OK ) return rc; |
| 121795 | }while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); |
| 121796 | } |
| 121797 | fts3SegReaderSort(pCsr->apSegment, nSegment, nSegment, fts3SegReaderCmp); |
| 121798 | |
| 121799 | /* Determine how many of the segments actually point to zTerm/nTerm. */ |
| 121800 | for(i=0; i<nSegment; i++){ |
| 121801 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121802 | if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){ |
| 121803 | break; |
| 121804 | } |
| 121805 | } |
| 121806 | pCsr->nAdvance = i; |
| 121807 | |
| 121808 | /* Advance each of the segments to point to the first docid. */ |
| 121809 | for(i=0; i<pCsr->nAdvance; i++){ |
| 121810 | int rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]); |
| 121811 | if( rc!=SQLITE_OK ) return rc; |
| 121812 | } |
| 121813 | fts3SegReaderSort(pCsr->apSegment, i, i, xCmp); |
| 121814 | |
| 121815 | assert( iCol<0 || iCol<p->nColumn ); |
| 121816 | pCsr->iColFilter = iCol; |
| 121817 | |
| 121818 | return SQLITE_OK; |
| 121819 | } |
| 121820 | |
| 121821 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 121822 | Fts3Table *p, /* Virtual table handle */ |
| @@ -121866,52 +121889,138 @@ | |
| 121866 | if( pMsr->iColFilter>=0 ){ |
| 121867 | fts3ColumnFilter(pMsr->iColFilter, &pList, &nList); |
| 121868 | } |
| 121869 | |
| 121870 | if( nList>0 ){ |
| 121871 | *piDocid = iDocid; |
| 121872 | *paPoslist = pList; |
| 121873 | *pnPoslist = nList; |
| 121874 | break; |
| 121875 | } |
| 121876 | } |
| 121877 | |
| 121878 | } |
| 121879 | |
| 121880 | return SQLITE_OK; |
| 121881 | } |
| 121882 | |
| 121883 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStart( |
| 121884 | Fts3Table *p, /* Virtual table handle */ |
| 121885 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121886 | Fts3SegFilter *pFilter /* Restrictions on range of iteration */ |
| 121887 | ){ |
| 121888 | int i; |
| 121889 | |
| 121890 | /* Initialize the cursor object */ |
| 121891 | pCsr->pFilter = pFilter; |
| 121892 | |
| 121893 | /* If the Fts3SegFilter defines a specific term (or term prefix) to search |
| 121894 | ** for, then advance each segment iterator until it points to a term of |
| 121895 | ** equal or greater value than the specified term. This prevents many |
| 121896 | ** unnecessary merge/sort operations for the case where single segment |
| 121897 | ** b-tree leaf nodes contain more than one term. |
| 121898 | */ |
| 121899 | for(i=0; i<pCsr->nSegment; i++){ |
| 121900 | int nTerm = pFilter->nTerm; |
| 121901 | const char *zTerm = pFilter->zTerm; |
| 121902 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121903 | do { |
| 121904 | int rc = fts3SegReaderNext(p, pSeg, 0); |
| 121905 | if( rc!=SQLITE_OK ) return rc; |
| 121906 | }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); |
| 121907 | } |
| 121908 | fts3SegReaderSort( |
| 121909 | pCsr->apSegment, pCsr->nSegment, pCsr->nSegment, fts3SegReaderCmp); |
| 121910 | |
| 121911 | return SQLITE_OK; |
| 121912 | } |
| 121913 | |
| 121914 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStep( |
| 121915 | Fts3Table *p, /* Virtual table handle */ |
| 121916 | Fts3MultiSegReader *pCsr /* Cursor object */ |
| 121917 | ){ |
| @@ -121981,13 +122090,18 @@ | |
| 121981 | assert( isIgnoreEmpty || (isRequirePos && !isColFilter) ); |
| 121982 | if( nMerge==1 |
| 121983 | && !isIgnoreEmpty |
| 121984 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 121985 | ){ |
| 121986 | pCsr->aDoclist = apSegment[0]->aDoclist; |
| 121987 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 121988 | rc = SQLITE_ROW; |
| 121989 | }else{ |
| 121990 | int nDoclist = 0; /* Size of doclist */ |
| 121991 | sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */ |
| 121992 | |
| 121993 | /* The current term of the first nMerge entries in the array |
| @@ -123725,11 +123839,11 @@ | |
| 123725 | if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol; |
| 123726 | break; |
| 123727 | |
| 123728 | case FTS3_MATCHINFO_NDOC: |
| 123729 | if( bGlobal ){ |
| 123730 | sqlite3_int64 nDoc; |
| 123731 | rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0); |
| 123732 | pInfo->aMatchinfo[0] = (u32)nDoc; |
| 123733 | } |
| 123734 | break; |
| 123735 | |
| @@ -125620,11 +125734,11 @@ | |
| 125620 | */ |
| 125621 | static float cellArea(Rtree *pRtree, RtreeCell *p){ |
| 125622 | float area = 1.0; |
| 125623 | int ii; |
| 125624 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125625 | area = area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); |
| 125626 | } |
| 125627 | return area; |
| 125628 | } |
| 125629 | |
| 125630 | /* |
| @@ -125633,11 +125747,11 @@ | |
| 125633 | */ |
| 125634 | static float cellMargin(Rtree *pRtree, RtreeCell *p){ |
| 125635 | float margin = 0.0; |
| 125636 | int ii; |
| 125637 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125638 | margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); |
| 125639 | } |
| 125640 | return margin; |
| 125641 | } |
| 125642 | |
| 125643 | /* |
| @@ -125718,11 +125832,11 @@ | |
| 125718 | |
| 125719 | if( x2<x1 ){ |
| 125720 | o = 0.0; |
| 125721 | break; |
| 125722 | }else{ |
| 125723 | o = o * (x2-x1); |
| 125724 | } |
| 125725 | } |
| 125726 | overlap += o; |
| 125727 | } |
| 125728 | } |
| @@ -125737,16 +125851,16 @@ | |
| 125737 | RtreeCell *pInsert, |
| 125738 | RtreeCell *aCell, |
| 125739 | int nCell, |
| 125740 | int iExclude |
| 125741 | ){ |
| 125742 | float before; |
| 125743 | float after; |
| 125744 | before = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125745 | cellUnion(pRtree, p, pInsert); |
| 125746 | after = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125747 | return after-before; |
| 125748 | } |
| 125749 | #endif |
| 125750 | |
| 125751 | |
| 125752 | /* |
| @@ -125764,15 +125878,15 @@ | |
| 125764 | RtreeNode *pNode; |
| 125765 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 125766 | |
| 125767 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 125768 | int iCell; |
| 125769 | sqlite3_int64 iBest; |
| 125770 | |
| 125771 | float fMinGrowth; |
| 125772 | float fMinArea; |
| 125773 | float fMinOverlap; |
| 125774 | |
| 125775 | int nCell = NCELL(pNode); |
| 125776 | RtreeCell cell; |
| 125777 | RtreeNode *pChild; |
| 125778 | |
| @@ -126198,13 +126312,13 @@ | |
| 126198 | ){ |
| 126199 | int **aaSorted; |
| 126200 | int *aSpare; |
| 126201 | int ii; |
| 126202 | |
| 126203 | int iBestDim; |
| 126204 | int iBestSplit; |
| 126205 | float fBestMargin; |
| 126206 | |
| 126207 | int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); |
| 126208 | |
| 126209 | aaSorted = (int **)sqlite3_malloc(nByte); |
| 126210 | if( !aaSorted ){ |
| @@ -126222,13 +126336,13 @@ | |
| 126222 | SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare); |
| 126223 | } |
| 126224 | |
| 126225 | for(ii=0; ii<pRtree->nDim; ii++){ |
| 126226 | float margin = 0.0; |
| 126227 | float fBestOverlap; |
| 126228 | float fBestArea; |
| 126229 | int iBestLeft; |
| 126230 | int nLeft; |
| 126231 | |
| 126232 | for( |
| 126233 | nLeft=RTREE_MINCELLS(pRtree); |
| 126234 | nLeft<=(nCell-RTREE_MINCELLS(pRtree)); |
| @@ -126539,11 +126653,11 @@ | |
| 126539 | static int deleteCell(Rtree *, RtreeNode *, int, int); |
| 126540 | |
| 126541 | static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){ |
| 126542 | int rc; |
| 126543 | int rc2; |
| 126544 | RtreeNode *pParent; |
| 126545 | int iCell; |
| 126546 | |
| 126547 | assert( pNode->nRef==1 ); |
| 126548 | |
| 126549 | /* Remove the entry in the parent cell. */ |
| @@ -126687,23 +126801,23 @@ | |
| 126687 | }else{ |
| 126688 | nodeGetCell(pRtree, pNode, ii, &aCell[ii]); |
| 126689 | } |
| 126690 | aOrder[ii] = ii; |
| 126691 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126692 | aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]); |
| 126693 | aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]); |
| 126694 | } |
| 126695 | } |
| 126696 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126697 | aCenterCoord[iDim] = aCenterCoord[iDim]/((float)nCell*2.0); |
| 126698 | } |
| 126699 | |
| 126700 | for(ii=0; ii<nCell; ii++){ |
| 126701 | aDistance[ii] = 0.0; |
| 126702 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126703 | float coord = DCOORD(aCell[ii].aCoord[iDim*2+1]) - |
| 126704 | DCOORD(aCell[ii].aCoord[iDim*2]); |
| 126705 | aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); |
| 126706 | } |
| 126707 | } |
| 126708 | |
| 126709 | SortByDistance(aOrder, nCell, aDistance, aSpare); |
| @@ -126798,14 +126912,14 @@ | |
| 126798 | nodeGetCell(pRtree, pNode, ii, &cell); |
| 126799 | |
| 126800 | /* Find a node to store this cell in. pNode->iNode currently contains |
| 126801 | ** the height of the sub-tree headed by the cell. |
| 126802 | */ |
| 126803 | rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert); |
| 126804 | if( rc==SQLITE_OK ){ |
| 126805 | int rc2; |
| 126806 | rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode); |
| 126807 | rc2 = nodeRelease(pRtree, pInsert); |
| 126808 | if( rc==SQLITE_OK ){ |
| 126809 | rc = rc2; |
| 126810 | } |
| 126811 | } |
| @@ -127190,11 +127304,11 @@ | |
| 127190 | int isCreate /* True for xCreate, false for xConnect */ |
| 127191 | ){ |
| 127192 | int rc; |
| 127193 | char *zSql; |
| 127194 | if( isCreate ){ |
| 127195 | int iPageSize; |
| 127196 | zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); |
| 127197 | rc = getIntFromStmt(db, zSql, &iPageSize); |
| 127198 | if( rc==SQLITE_OK ){ |
| 127199 | pRtree->iNodeSize = iPageSize-64; |
| 127200 | if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ |
| @@ -127993,14 +128107,11 @@ | |
| 127993 | ** May you find forgiveness for yourself and forgive others. |
| 127994 | ** May you share freely, never taking more than you give. |
| 127995 | ** |
| 127996 | ************************************************************************* |
| 127997 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 127998 | ** |
| 127999 | ** $Id: fts3_icu.c,v 1.3 2008/09/01 18:34:20 danielk1977 Exp $ |
| 128000 | */ |
| 128001 | |
| 128002 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 128003 | #ifdef SQLITE_ENABLE_ICU |
| 128004 | |
| 128005 | |
| 128006 | #include <unicode/ubrk.h> |
| 128007 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -851,11 +851,11 @@ | |
| 851 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 852 | ** in the context of the [database connection] passed in as its 1st |
| 853 | ** argument. ^If the callback function of the 3rd argument to |
| 854 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 855 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 856 | ** sqlite3_exec() is relayed through to the 1st argument of each |
| 857 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 858 | ** is NULL, then no callback is ever invoked and result rows are |
| 859 | ** ignored. |
| 860 | ** |
| 861 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -1443,11 +1443,11 @@ | |
| 1443 | ** The xSleep() method causes the calling thread to sleep for at |
| 1444 | ** least the number of microseconds given. ^The xCurrentTime() |
| 1445 | ** method returns a Julian Day Number for the current date and time as |
| 1446 | ** a floating point value. |
| 1447 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 1448 | ** Day Number multiplied by 86400000 (the number of milliseconds in |
| 1449 | ** a 24-hour day). |
| 1450 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 1451 | ** date and time if that method is available (if iVersion is 2 or |
| 1452 | ** greater and the function pointer is not NULL) and will fall back |
| 1453 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1881,11 +1881,11 @@ | |
| 1881 | ** scratch memory beyond what is provided by this configuration option, then |
| 1882 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1883 | ** |
| 1884 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1885 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1886 | ** the database page cache with the default page cache implementation. |
| 1887 | ** This configuration should not be used if an application-define page |
| 1888 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1889 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1890 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1891 | ** The sz argument should be the size of the largest database page |
| @@ -2979,16 +2979,16 @@ | |
| 2979 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2980 | ** |
| 2981 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2982 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2983 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2984 | ** set in the fourth argument to sqlite3_open_v2(), or if it has |
| 2985 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2986 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2987 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2988 | ** by default, but future releases of SQLite might enable URI filename |
| 2989 | ** interpretation by default. See "[URI filenames]" for additional |
| 2990 | ** information. |
| 2991 | ** |
| 2992 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2993 | ** authority, then it must be either an empty string or the string |
| 2994 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3803,11 +3803,11 @@ | |
| 3803 | ** [extended result codes] might be returned as well. |
| 3804 | ** |
| 3805 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3806 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3807 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3808 | ** statement. If the statement is not a [COMMIT] and occurs within an |
| 3809 | ** explicit transaction then you should rollback the transaction before |
| 3810 | ** continuing. |
| 3811 | ** |
| 3812 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3813 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -4082,11 +4082,11 @@ | |
| 4082 | |
| 4083 | /* |
| 4084 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 4085 | ** |
| 4086 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 4087 | ** ^If the most recent evaluation of the statement encountered no errors |
| 4088 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 4089 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 4090 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 4091 | ** [extended error code]. |
| 4092 | ** |
| @@ -5996,11 +5996,11 @@ | |
| 5996 | ** versions of these routines, it should at least provide stubs that always |
| 5997 | ** return true so that one does not get spurious assertion failures. |
| 5998 | ** |
| 5999 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 6000 | ** the routine should return 1. This seems counter-intuitive since |
| 6001 | ** clearly the mutex cannot be held if it does not exist. But |
| 6002 | ** the reason the mutex does not exist is because the build is not |
| 6003 | ** using mutexes. And we do not want the assert() containing the |
| 6004 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 6005 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 6006 | ** interface should also return 1 when given a NULL pointer. |
| @@ -6505,11 +6505,11 @@ | |
| 6505 | ** [[the xFetch() page cache methods]] |
| 6506 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 6507 | ** the page, or a NULL pointer. |
| 6508 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 6509 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 6510 | ** minimum key value is 1. After it has been retrieved using xFetch, the page |
| 6511 | ** is considered to be "pinned". |
| 6512 | ** |
| 6513 | ** If the requested page is already in the page cache, then the page cache |
| 6514 | ** implementation must return a pointer to the page buffer with its content |
| 6515 | ** intact. If the requested page is not already in the cache, then the |
| @@ -24364,10 +24364,14 @@ | |
| 24364 | |
| 24365 | #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 24366 | # include <sys/mount.h> |
| 24367 | #endif |
| 24368 | |
| 24369 | #ifdef HAVE_UTIME |
| 24370 | # include <utime.h> |
| 24371 | #endif |
| 24372 | |
| 24373 | /* |
| 24374 | ** Allowed values of unixFile.fsFlags |
| 24375 | */ |
| 24376 | #define SQLITE_FSFLAGS_IS_MSDOS 0x1 |
| 24377 | |
| @@ -26369,12 +26373,14 @@ | |
| 26373 | /* If we have any lock, then the lock file already exists. All we have |
| 26374 | ** to do is adjust our internal record of the lock level. |
| 26375 | */ |
| 26376 | if( pFile->eFileLock > NO_LOCK ){ |
| 26377 | pFile->eFileLock = eFileLock; |
| 26378 | /* Always update the timestamp on the old file */ |
| 26379 | #ifdef HAVE_UTIME |
| 26380 | utime(zLockFile, NULL); |
| 26381 | #else |
| 26382 | utimes(zLockFile, NULL); |
| 26383 | #endif |
| 26384 | return SQLITE_OK; |
| 26385 | } |
| 26386 | |
| @@ -32254,11 +32260,12 @@ | |
| 32260 | rc = 1; |
| 32261 | } |
| 32262 | } |
| 32263 | |
| 32264 | if( rc ){ |
| 32265 | if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ) |
| 32266 | || ( pFile->lastErrno==ERROR_DISK_FULL )){ |
| 32267 | return SQLITE_FULL; |
| 32268 | } |
| 32269 | return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath); |
| 32270 | } |
| 32271 | return SQLITE_OK; |
| @@ -63496,11 +63503,11 @@ | |
| 63503 | break; |
| 63504 | } |
| 63505 | |
| 63506 | /* Opcode: HaltIfNull P1 P2 P3 P4 * |
| 63507 | ** |
| 63508 | ** Check the value in register P3. If it is NULL then Halt using |
| 63509 | ** parameter P1, P2, and P4 as if this were a Halt instruction. If the |
| 63510 | ** value in register P3 is not NULL, then this routine is a no-op. |
| 63511 | */ |
| 63512 | case OP_HaltIfNull: { /* in3 */ |
| 63513 | pIn3 = &aMem[pOp->p3]; |
| @@ -64433,11 +64440,11 @@ | |
| 64440 | ** additional information. |
| 64441 | ** |
| 64442 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64443 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64444 | ** of comparison is false. If either operand is NULL then the result is true. |
| 64445 | ** If neither operand is NULL the result is the same as it would be if |
| 64446 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64447 | */ |
| 64448 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| 64449 | ** |
| 64450 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64445,11 +64452,11 @@ | |
| 64452 | ** See the Lt opcode for additional information. |
| 64453 | ** |
| 64454 | ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either |
| 64455 | ** true or false and is never NULL. If both operands are NULL then the result |
| 64456 | ** of comparison is true. If either operand is NULL then the result is false. |
| 64457 | ** If neither operand is NULL the result is the same as it would be if |
| 64458 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 64459 | */ |
| 64460 | /* Opcode: Le P1 P2 P3 P4 P5 |
| 64461 | ** |
| 64462 | ** This works just like the Lt opcode except that the jump is taken if |
| @@ -64730,17 +64737,17 @@ | |
| 64737 | break; |
| 64738 | } |
| 64739 | |
| 64740 | /* Opcode: If P1 P2 P3 * * |
| 64741 | ** |
| 64742 | ** Jump to P2 if the value in register P1 is true. The value |
| 64743 | ** is considered true if it is numeric and non-zero. If the value |
| 64744 | ** in P1 is NULL then take the jump if P3 is true. |
| 64745 | */ |
| 64746 | /* Opcode: IfNot P1 P2 P3 * * |
| 64747 | ** |
| 64748 | ** Jump to P2 if the value in register P1 is False. The value |
| 64749 | ** is considered true if it has a numeric value of zero. If the value |
| 64750 | ** in P1 is NULL then take the jump if P3 is true. |
| 64751 | */ |
| 64752 | case OP_If: /* jump, in1 */ |
| 64753 | case OP_IfNot: { /* jump, in1 */ |
| @@ -66390,11 +66397,11 @@ | |
| 66397 | break; |
| 66398 | } |
| 66399 | |
| 66400 | /* Opcode: NotExists P1 P2 P3 * * |
| 66401 | ** |
| 66402 | ** Use the content of register P3 as an integer key. If a record |
| 66403 | ** with that key does not exist in table of P1, then jump to P2. |
| 66404 | ** If the record does exist, then fall through. The cursor is left |
| 66405 | ** pointing to the record if it exists. |
| 66406 | ** |
| 66407 | ** The difference between this operation and NotFound is that this |
| @@ -66468,11 +66475,11 @@ | |
| 66475 | ** written to register P2. |
| 66476 | ** |
| 66477 | ** If P3>0 then P3 is a register in the root frame of this VDBE that holds |
| 66478 | ** the largest previously generated record number. No new record numbers are |
| 66479 | ** allowed to be less than this value. When this value reaches its maximum, |
| 66480 | ** an SQLITE_FULL error is generated. The P3 register is updated with the ' |
| 66481 | ** generated record number. This P3 mechanism is used to help implement the |
| 66482 | ** AUTOINCREMENT feature. |
| 66483 | */ |
| 66484 | case OP_NewRowid: { /* out2-prerelease */ |
| 66485 | #if 0 /* local variables moved into u.be */ |
| @@ -67110,11 +67117,11 @@ | |
| 67117 | break; |
| 67118 | } |
| 67119 | |
| 67120 | /* Opcode: IdxInsert P1 P2 P3 * P5 |
| 67121 | ** |
| 67122 | ** Register P2 holds an SQL index key made using the |
| 67123 | ** MakeRecord instructions. This opcode writes that key |
| 67124 | ** into the index P1. Data for the entry is nil. |
| 67125 | ** |
| 67126 | ** P3 is a flag that provides a hint to the b-tree layer that this |
| 67127 | ** insert is likely to be an append. |
| @@ -111420,16 +111427,10 @@ | |
| 111427 | ** TODO(shess) Provide a VACUUM type operation to clear out all |
| 111428 | ** deletions and duplications. This would basically be a forced merge |
| 111429 | ** into a single segment. |
| 111430 | */ |
| 111431 | |
| 111432 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 111433 | /************** Begin file fts3Int.h *****************************************/ |
| 111434 | /* |
| 111435 | ** 2009 Nov 12 |
| 111436 | ** |
| @@ -111441,18 +111442,27 @@ | |
| 111442 | ** May you share freely, never taking more than you give. |
| 111443 | ** |
| 111444 | ****************************************************************************** |
| 111445 | ** |
| 111446 | */ |
| 111447 | #ifndef _FTSINT_H |
| 111448 | #define _FTSINT_H |
| 111449 | |
| 111450 | #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| 111451 | # define NDEBUG 1 |
| 111452 | #endif |
| 111453 | |
| 111454 | /* |
| 111455 | ** FTS4 is really an extension for FTS3. It is enabled using the |
| 111456 | ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all |
| 111457 | ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. |
| 111458 | */ |
| 111459 | #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) |
| 111460 | # define SQLITE_ENABLE_FTS3 |
| 111461 | #endif |
| 111462 | |
| 111463 | #ifdef SQLITE_ENABLE_FTS3 |
| 111464 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 111465 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 111466 | /* |
| 111467 | ** 2006 July 10 |
| 111468 | ** |
| @@ -111940,11 +111950,11 @@ | |
| 111950 | char *aDoclist; /* List of docids for full-text queries */ |
| 111951 | int nDoclist; /* Size of buffer at aDoclist */ |
| 111952 | u8 bDesc; /* True to sort in descending order */ |
| 111953 | int eEvalmode; /* An FTS3_EVAL_XX constant */ |
| 111954 | int nRowAvg; /* Average size of database rows, in pages */ |
| 111955 | sqlite3_int64 nDoc; /* Documents in table */ |
| 111956 | |
| 111957 | int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */ |
| 111958 | u32 *aMatchinfo; /* Information about most recent match */ |
| 111959 | int nMatchinfo; /* Number of elements in aMatchinfo[] */ |
| 111960 | char *zMatchinfo; /* Matchinfo specification */ |
| @@ -111997,19 +112007,19 @@ | |
| 112007 | int isPrefix; /* True if token ends with a "*" character */ |
| 112008 | |
| 112009 | /* Variables above this point are populated when the expression is |
| 112010 | ** parsed (by code in fts3_expr.c). Below this point the variables are |
| 112011 | ** used when evaluating the expression. */ |
| 112012 | Fts3DeferredToken *pDeferred; /* Deferred token object for this token */ |
| 112013 | Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */ |
| 112014 | }; |
| 112015 | |
| 112016 | struct Fts3Phrase { |
| 112017 | /* Cache of doclist for this phrase. */ |
| 112018 | Fts3Doclist doclist; |
| 112019 | int bIncr; /* True if doclist is loaded incrementally */ |
| 112020 | int iDoclistToken; |
| 112021 | |
| 112022 | /* Variables below this point are populated by fts3_expr.c when parsing |
| 112023 | ** a MATCH expression. Everything above is part of the evaluation phase. |
| 112024 | */ |
| 112025 | int nToken; /* Number of tokens in the phrase */ |
| @@ -112130,10 +112140,11 @@ | |
| 112140 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 112141 | char *aBuffer; /* Buffer to merge doclists in */ |
| 112142 | int nBuffer; /* Allocated size of aBuffer[] in bytes */ |
| 112143 | |
| 112144 | int iColFilter; /* If >=0, filter for this column */ |
| 112145 | int bRestart; |
| 112146 | |
| 112147 | /* Used by fts3.c only. */ |
| 112148 | int nCost; /* Cost of running iterator */ |
| 112149 | int bLookup; /* True if a lookup of a single entry. */ |
| 112150 | |
| @@ -112199,18 +112210,24 @@ | |
| 112210 | Fts3Table*, Fts3MultiSegReader*, int, const char*, int); |
| 112211 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 112212 | Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *); |
| 112213 | SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol); |
| 112214 | SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *); |
| 112215 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr); |
| 112216 | |
| 112217 | SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *); |
| 112218 | |
| 112219 | #endif /* SQLITE_ENABLE_FTS3 */ |
| 112220 | #endif /* _FTSINT_H */ |
| 112221 | |
| 112222 | /************** End of fts3Int.h *********************************************/ |
| 112223 | /************** Continuing where we left off in fts3.c ***********************/ |
| 112224 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 112225 | |
| 112226 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 112227 | # define SQLITE_CORE 1 |
| 112228 | #endif |
| 112229 | |
| 112230 | |
| 112231 | #ifndef SQLITE_CORE |
| 112232 | SQLITE_EXTENSION_INIT1 |
| 112233 | #endif |
| @@ -112995,11 +113012,11 @@ | |
| 113012 | zCsr += nDb; |
| 113013 | |
| 113014 | /* Fill in the azColumn array */ |
| 113015 | for(iCol=0; iCol<nCol; iCol++){ |
| 113016 | char *z; |
| 113017 | int n = 0; |
| 113018 | z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n); |
| 113019 | memcpy(zCsr, z, n); |
| 113020 | zCsr[n] = '\0'; |
| 113021 | sqlite3Fts3Dequote(zCsr); |
| 113022 | p->azColumn[iCol] = zCsr; |
| @@ -114581,12 +114598,12 @@ | |
| 114598 | |
| 114599 | /* |
| 114600 | ** Implementation of xBegin() method. This is a no-op. |
| 114601 | */ |
| 114602 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ |
| 114603 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114604 | UNUSED_PARAMETER(pVtab); |
| 114605 | assert( p->pSegments==0 ); |
| 114606 | assert( p->nPendingData==0 ); |
| 114607 | assert( p->inTransaction!=1 ); |
| 114608 | TESTONLY( p->inTransaction = 1 ); |
| 114609 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -114597,12 +114614,12 @@ | |
| 114614 | ** Implementation of xCommit() method. This is a no-op. The contents of |
| 114615 | ** the pending-terms hash-table have already been flushed into the database |
| 114616 | ** by fts3SyncMethod(). |
| 114617 | */ |
| 114618 | static int fts3CommitMethod(sqlite3_vtab *pVtab){ |
| 114619 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 114620 | UNUSED_PARAMETER(pVtab); |
| 114621 | assert( p->nPendingData==0 ); |
| 114622 | assert( p->inTransaction!=0 ); |
| 114623 | assert( p->pSegments==0 ); |
| 114624 | TESTONLY( p->inTransaction = 0 ); |
| 114625 | TESTONLY( p->mxSavepoint = -1; ); |
| @@ -115083,75 +115100,105 @@ | |
| 115100 | if( rc!=SQLITE_OK ){ |
| 115101 | *pRc = rc; |
| 115102 | return; |
| 115103 | } |
| 115104 | } |
| 115105 | assert( pExpr->pPhrase->iDoclistToken==0 ); |
| 115106 | pExpr->pPhrase->iDoclistToken = -1; |
| 115107 | }else{ |
| 115108 | *pnOr += (pExpr->eType==FTSQUERY_OR); |
| 115109 | fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc); |
| 115110 | fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc); |
| 115111 | } |
| 115112 | } |
| 115113 | } |
| 115114 | |
| 115115 | static void fts3EvalPhraseMergeToken( |
| 115116 | Fts3Table *pTab, |
| 115117 | Fts3Phrase *p, |
| 115118 | int iToken, |
| 115119 | char *pList, |
| 115120 | int nList |
| 115121 | ){ |
| 115122 | assert( iToken!=p->iDoclistToken ); |
| 115123 | |
| 115124 | if( pList==0 ){ |
| 115125 | sqlite3_free(p->doclist.aAll); |
| 115126 | p->doclist.aAll = 0; |
| 115127 | p->doclist.nAll = 0; |
| 115128 | } |
| 115129 | |
| 115130 | else if( p->iDoclistToken<0 ){ |
| 115131 | p->doclist.aAll = pList; |
| 115132 | p->doclist.nAll = nList; |
| 115133 | } |
| 115134 | |
| 115135 | else if( p->doclist.aAll==0 ){ |
| 115136 | sqlite3_free(pList); |
| 115137 | } |
| 115138 | |
| 115139 | else { |
| 115140 | char *pLeft; |
| 115141 | char *pRight; |
| 115142 | int nLeft; |
| 115143 | int nRight; |
| 115144 | int nDiff; |
| 115145 | |
| 115146 | if( p->iDoclistToken<iToken ){ |
| 115147 | pLeft = p->doclist.aAll; |
| 115148 | nLeft = p->doclist.nAll; |
| 115149 | pRight = pList; |
| 115150 | nRight = nList; |
| 115151 | nDiff = iToken - p->iDoclistToken; |
| 115152 | }else{ |
| 115153 | pRight = p->doclist.aAll; |
| 115154 | nRight = p->doclist.nAll; |
| 115155 | pLeft = pList; |
| 115156 | nLeft = nList; |
| 115157 | nDiff = p->iDoclistToken - iToken; |
| 115158 | } |
| 115159 | |
| 115160 | fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight); |
| 115161 | sqlite3_free(pLeft); |
| 115162 | p->doclist.aAll = pRight; |
| 115163 | p->doclist.nAll = nRight; |
| 115164 | } |
| 115165 | |
| 115166 | if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken; |
| 115167 | } |
| 115168 | |
| 115169 | static int fts3EvalPhraseLoad( |
| 115170 | Fts3Cursor *pCsr, |
| 115171 | Fts3Phrase *p |
| 115172 | ){ |
| 115173 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115174 | int iToken; |
| 115175 | int rc = SQLITE_OK; |
| 115176 | |
| 115177 | for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){ |
| 115178 | Fts3PhraseToken *pToken = &p->aToken[iToken]; |
| 115179 | assert( pToken->pDeferred==0 || pToken->pSegcsr==0 ); |
| 115180 | |
| 115181 | if( pToken->pSegcsr ){ |
| 115182 | int nThis = 0; |
| 115183 | char *pThis = 0; |
| 115184 | rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis); |
| 115185 | if( rc==SQLITE_OK ){ |
| 115186 | fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis); |
| 115187 | } |
| 115188 | } |
| 115189 | assert( pToken->pSegcsr==0 ); |
| 115190 | } |
| 115191 | |
| 115192 | return rc; |
| 115193 | } |
| 115194 | |
| 115195 | static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){ |
| 115196 | int iToken; |
| 115197 | int rc = SQLITE_OK; |
| 115198 | |
| 115199 | int nMaxUndeferred = pPhrase->iDoclistToken; |
| 115200 | char *aPoslist = 0; |
| 115201 | int nPoslist = 0; |
| 115202 | int iPrev = -1; |
| 115203 | |
| 115204 | assert( pPhrase->doclist.bFreeList==0 ); |
| @@ -115192,12 +115239,10 @@ | |
| 115239 | pPhrase->doclist.nList = 0; |
| 115240 | return SQLITE_OK; |
| 115241 | } |
| 115242 | } |
| 115243 | iPrev = iToken; |
| 115244 | } |
| 115245 | } |
| 115246 | |
| 115247 | if( iPrev>=0 ){ |
| 115248 | if( nMaxUndeferred<0 ){ |
| @@ -115252,13 +115297,15 @@ | |
| 115297 | static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ |
| 115298 | int rc; |
| 115299 | Fts3PhraseToken *pFirst = &p->aToken[0]; |
| 115300 | Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; |
| 115301 | |
| 115302 | if( pCsr->bDesc==pTab->bDescIdx |
| 115303 | && bOptOk==1 |
| 115304 | && p->nToken==1 |
| 115305 | && pFirst->pSegcsr |
| 115306 | && pFirst->pSegcsr->bLookup |
| 115307 | ){ |
| 115308 | /* Use the incremental approach. */ |
| 115309 | int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn); |
| 115310 | rc = sqlite3Fts3MsrIncrStart( |
| 115311 | pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n); |
| @@ -115394,11 +115441,11 @@ | |
| 115441 | ** with this case by advancing pIter past the zero-padding added by |
| 115442 | ** fts3EvalNearTrim2(). */ |
| 115443 | while( pIter<pEnd && *pIter==0 ) pIter++; |
| 115444 | |
| 115445 | pDL->pNextDocid = pIter; |
| 115446 | assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter ); |
| 115447 | *pbEof = 0; |
| 115448 | } |
| 115449 | } |
| 115450 | |
| 115451 | return rc; |
| @@ -115425,17 +115472,18 @@ | |
| 115472 | pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred); |
| 115473 | } |
| 115474 | } |
| 115475 | } |
| 115476 | |
| 115477 | typedef struct Fts3TokenAndCost Fts3TokenAndCost; |
| 115478 | struct Fts3TokenAndCost { |
| 115479 | Fts3Phrase *pPhrase; /* The phrase the token belongs to */ |
| 115480 | int iToken; /* Position of token in phrase */ |
| 115481 | Fts3PhraseToken *pToken; /* The token itself */ |
| 115482 | Fts3Expr *pRoot; |
| 115483 | int nOvfl; |
| 115484 | int iCol; /* The column the token must match */ |
| 115485 | }; |
| 115486 | |
| 115487 | static void fts3EvalTokenCosts( |
| 115488 | Fts3Cursor *pCsr, |
| 115489 | Fts3Expr *pRoot, |
| @@ -115448,10 +115496,12 @@ | |
| 115496 | if( pExpr->eType==FTSQUERY_PHRASE ){ |
| 115497 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 115498 | int i; |
| 115499 | for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){ |
| 115500 | Fts3TokenAndCost *pTC = (*ppTC)++; |
| 115501 | pTC->pPhrase = pPhrase; |
| 115502 | pTC->iToken = i; |
| 115503 | pTC->pRoot = pRoot; |
| 115504 | pTC->pToken = &pPhrase->aToken[i]; |
| 115505 | pTC->iCol = pPhrase->iColumn; |
| 115506 | *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl); |
| 115507 | } |
| @@ -115560,23 +115610,19 @@ | |
| 115610 | /* At this point pTC points to the cheapest remaining token. */ |
| 115611 | if( ii==0 ){ |
| 115612 | if( pTC->nOvfl ){ |
| 115613 | nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10; |
| 115614 | }else{ |
| 115615 | Fts3PhraseToken *pToken = pTC->pToken; |
| 115616 | int nList = 0; |
| 115617 | char *pList = 0; |
| 115618 | rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList); |
| 115619 | assert( rc==SQLITE_OK || pList==0 ); |
| 115620 | |
| 115621 | if( rc==SQLITE_OK ){ |
| 115622 | nDocEst = fts3DoclistCountDocids(1, pList, nList); |
| 115623 | fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList); |
| 115624 | } |
| 115625 | } |
| 115626 | }else{ |
| 115627 | if( pTC->nOvfl>=(nDocEst*nDocSize) ){ |
| 115628 | Fts3PhraseToken *pToken = pTC->pToken; |
| @@ -116032,17 +116078,18 @@ | |
| 116078 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 116079 | |
| 116080 | if( pPhrase ){ |
| 116081 | fts3EvalZeroPoslist(pPhrase); |
| 116082 | if( pPhrase->bIncr ){ |
| 116083 | assert( pPhrase->nToken==1 ); |
| 116084 | assert( pPhrase->aToken[0].pSegcsr ); |
| 116085 | sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr); |
| 116086 | *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase); |
| 116087 | } |
| 116088 | |
| 116089 | pPhrase->doclist.pNextDocid = 0; |
| 116090 | pPhrase->doclist.iDocid = 0; |
| 116091 | } |
| 116092 | |
| 116093 | pExpr->iDocid = 0; |
| 116094 | pExpr->bEof = 0; |
| 116095 | pExpr->bStart = 0; |
| @@ -116225,12 +116272,12 @@ | |
| 116272 | int iCol; |
| 116273 | |
| 116274 | if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){ |
| 116275 | assert( pCsr->nDoc>0 ); |
| 116276 | for(iCol=0; iCol<pTab->nColumn; iCol++){ |
| 116277 | aiOut[iCol*3 + 1] = (u32)pCsr->nDoc; |
| 116278 | aiOut[iCol*3 + 2] = (u32)pCsr->nDoc; |
| 116279 | } |
| 116280 | }else{ |
| 116281 | rc = fts3EvalGatherStats(pCsr, pExpr); |
| 116282 | if( rc==SQLITE_OK ){ |
| 116283 | assert( pExpr->aMI ); |
| @@ -116334,11 +116381,10 @@ | |
| 116381 | ** May you share freely, never taking more than you give. |
| 116382 | ** |
| 116383 | ****************************************************************************** |
| 116384 | ** |
| 116385 | */ |
| 116386 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 116387 | |
| 116388 | |
| 116389 | typedef struct Fts3auxTable Fts3auxTable; |
| 116390 | typedef struct Fts3auxCursor Fts3auxCursor; |
| @@ -118168,11 +118214,10 @@ | |
| 118214 | */ |
| 118215 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 118216 | |
| 118217 | |
| 118218 | |
| 118219 | /* |
| 118220 | ** Class derived from sqlite3_tokenizer |
| 118221 | */ |
| 118222 | typedef struct porter_tokenizer { |
| 118223 | sqlite3_tokenizer base; /* Base class */ |
| @@ -118808,15 +118853,15 @@ | |
| 118853 | ** (in which case SQLITE_CORE is not defined), or |
| 118854 | ** |
| 118855 | ** * The FTS3 module is being built into the core of |
| 118856 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 118857 | */ |
| 118858 | #ifndef SQLITE_CORE |
| 118859 | SQLITE_EXTENSION_INIT1 |
| 118860 | #endif |
| 118861 | |
| 118862 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 118863 | |
| 118864 | |
| 118865 | /* |
| 118866 | ** Implementation of the SQL scalar function for accessing the underlying |
| 118867 | ** hash table. This function may be called as follows: |
| @@ -118937,11 +118982,11 @@ | |
| 118982 | sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */ |
| 118983 | char **pzErr /* OUT: Set to malloced error message */ |
| 118984 | ){ |
| 118985 | int rc; |
| 118986 | char *z = (char *)zArg; |
| 118987 | int n = 0; |
| 118988 | char *zCopy; |
| 118989 | char *zEnd; /* Pointer to nul-term of zCopy */ |
| 118990 | sqlite3_tokenizer_module *m; |
| 118991 | |
| 118992 | zCopy = sqlite3_mprintf("%s", zArg); |
| @@ -119299,11 +119344,10 @@ | |
| 119344 | ** |
| 119345 | ** * The FTS3 module is being built into the core of |
| 119346 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 119347 | */ |
| 119348 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 119349 | |
| 119350 | |
| 119351 | |
| 119352 | typedef struct simple_tokenizer { |
| 119353 | sqlite3_tokenizer base; |
| @@ -120750,10 +120794,11 @@ | |
| 120794 | pReader->pOffsetList = 0; |
| 120795 | }else{ |
| 120796 | pReader->pOffsetList = p; |
| 120797 | } |
| 120798 | }else{ |
| 120799 | char *pEnd = &pReader->aDoclist[pReader->nDoclist]; |
| 120800 | |
| 120801 | /* Pointer p currently points at the first byte of an offset list. The |
| 120802 | ** following block advances it to point one byte past the end of |
| 120803 | ** the same offset list. */ |
| 120804 | while( 1 ){ |
| @@ -120778,17 +120823,19 @@ | |
| 120823 | */ |
| 120824 | if( ppOffsetList ){ |
| 120825 | *ppOffsetList = pReader->pOffsetList; |
| 120826 | *pnOffsetList = (int)(p - pReader->pOffsetList - 1); |
| 120827 | } |
| 120828 | |
| 120829 | while( p<pEnd && *p==0 ) p++; |
| 120830 | |
| 120831 | /* If there are no more entries in the doclist, set pOffsetList to |
| 120832 | ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and |
| 120833 | ** Fts3SegReader.pOffsetList to point to the next offset list before |
| 120834 | ** returning. |
| 120835 | */ |
| 120836 | if( p>=pEnd ){ |
| 120837 | pReader->pOffsetList = 0; |
| 120838 | }else{ |
| 120839 | rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); |
| 120840 | if( rc==SQLITE_OK ){ |
| 120841 | sqlite3_int64 iDelta; |
| @@ -120823,11 +120870,11 @@ | |
| 120870 | for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){ |
| 120871 | Fts3SegReader *pReader = pMsr->apSegment[ii]; |
| 120872 | if( !fts3SegReaderIsPending(pReader) |
| 120873 | && !fts3SegReaderIsRootOnly(pReader) |
| 120874 | ){ |
| 120875 | sqlite3_int64 jj; |
| 120876 | for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){ |
| 120877 | int nBlob; |
| 120878 | rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0); |
| 120879 | if( rc!=SQLITE_OK ) break; |
| 120880 | if( (nBlob+35)>pgsz ){ |
| @@ -121768,55 +121815,31 @@ | |
| 121815 | |
| 121816 | *ppList = pList; |
| 121817 | *pnList = nList; |
| 121818 | } |
| 121819 | |
| 121820 | /* |
| 121821 | ** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any |
| 121822 | ** existing data). Grow the buffer if required. |
| 121823 | ** |
| 121824 | ** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered |
| 121825 | ** trying to resize the buffer, return SQLITE_NOMEM. |
| 121826 | */ |
| 121827 | static int fts3MsrBufferData( |
| 121828 | Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ |
| 121829 | char *pList, |
| 121830 | int nList |
| 121831 | ){ |
| 121832 | if( nList>pMsr->nBuffer ){ |
| 121833 | char *pNew; |
| 121834 | pMsr->nBuffer = nList*2; |
| 121835 | pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer); |
| 121836 | if( !pNew ) return SQLITE_NOMEM; |
| 121837 | pMsr->aBuffer = pNew; |
| 121838 | } |
| 121839 | |
| 121840 | memcpy(pMsr->aBuffer, pList, nList); |
| 121841 | return SQLITE_OK; |
| 121842 | } |
| 121843 | |
| 121844 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext( |
| 121845 | Fts3Table *p, /* Virtual table handle */ |
| @@ -121866,52 +121889,138 @@ | |
| 121889 | if( pMsr->iColFilter>=0 ){ |
| 121890 | fts3ColumnFilter(pMsr->iColFilter, &pList, &nList); |
| 121891 | } |
| 121892 | |
| 121893 | if( nList>0 ){ |
| 121894 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 121895 | rc = fts3MsrBufferData(pMsr, pList, nList+1); |
| 121896 | if( rc!=SQLITE_OK ) return rc; |
| 121897 | *paPoslist = pMsr->aBuffer; |
| 121898 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 121899 | }else{ |
| 121900 | *paPoslist = pList; |
| 121901 | } |
| 121902 | *piDocid = iDocid; |
| 121903 | *pnPoslist = nList; |
| 121904 | break; |
| 121905 | } |
| 121906 | } |
| 121907 | } |
| 121908 | |
| 121909 | return SQLITE_OK; |
| 121910 | } |
| 121911 | |
| 121912 | static int fts3SegReaderStart( |
| 121913 | Fts3Table *p, /* Virtual table handle */ |
| 121914 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121915 | const char *zTerm, /* Term searched for (or NULL) */ |
| 121916 | int nTerm /* Length of zTerm in bytes */ |
| 121917 | ){ |
| 121918 | int i; |
| 121919 | int nSeg = pCsr->nSegment; |
| 121920 | |
| 121921 | /* If the Fts3SegFilter defines a specific term (or term prefix) to search |
| 121922 | ** for, then advance each segment iterator until it points to a term of |
| 121923 | ** equal or greater value than the specified term. This prevents many |
| 121924 | ** unnecessary merge/sort operations for the case where single segment |
| 121925 | ** b-tree leaf nodes contain more than one term. |
| 121926 | */ |
| 121927 | for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){ |
| 121928 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121929 | do { |
| 121930 | int rc = fts3SegReaderNext(p, pSeg, 0); |
| 121931 | if( rc!=SQLITE_OK ) return rc; |
| 121932 | }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ); |
| 121933 | } |
| 121934 | fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp); |
| 121935 | |
| 121936 | return SQLITE_OK; |
| 121937 | } |
| 121938 | |
| 121939 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStart( |
| 121940 | Fts3Table *p, /* Virtual table handle */ |
| 121941 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121942 | Fts3SegFilter *pFilter /* Restrictions on range of iteration */ |
| 121943 | ){ |
| 121944 | pCsr->pFilter = pFilter; |
| 121945 | return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm); |
| 121946 | } |
| 121947 | |
| 121948 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart( |
| 121949 | Fts3Table *p, /* Virtual table handle */ |
| 121950 | Fts3MultiSegReader *pCsr, /* Cursor object */ |
| 121951 | int iCol, /* Column to match on. */ |
| 121952 | const char *zTerm, /* Term to iterate through a doclist for */ |
| 121953 | int nTerm /* Number of bytes in zTerm */ |
| 121954 | ){ |
| 121955 | int i; |
| 121956 | int rc; |
| 121957 | int nSegment = pCsr->nSegment; |
| 121958 | int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = ( |
| 121959 | p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp |
| 121960 | ); |
| 121961 | |
| 121962 | assert( pCsr->pFilter==0 ); |
| 121963 | assert( zTerm && nTerm>0 ); |
| 121964 | |
| 121965 | /* Advance each segment iterator until it points to the term zTerm/nTerm. */ |
| 121966 | rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm); |
| 121967 | if( rc!=SQLITE_OK ) return rc; |
| 121968 | |
| 121969 | /* Determine how many of the segments actually point to zTerm/nTerm. */ |
| 121970 | for(i=0; i<nSegment; i++){ |
| 121971 | Fts3SegReader *pSeg = pCsr->apSegment[i]; |
| 121972 | if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){ |
| 121973 | break; |
| 121974 | } |
| 121975 | } |
| 121976 | pCsr->nAdvance = i; |
| 121977 | |
| 121978 | /* Advance each of the segments to point to the first docid. */ |
| 121979 | for(i=0; i<pCsr->nAdvance; i++){ |
| 121980 | rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]); |
| 121981 | if( rc!=SQLITE_OK ) return rc; |
| 121982 | } |
| 121983 | fts3SegReaderSort(pCsr->apSegment, i, i, xCmp); |
| 121984 | |
| 121985 | assert( iCol<0 || iCol<p->nColumn ); |
| 121986 | pCsr->iColFilter = iCol; |
| 121987 | |
| 121988 | return SQLITE_OK; |
| 121989 | } |
| 121990 | |
| 121991 | /* |
| 121992 | ** This function is called on a MultiSegReader that has been started using |
| 121993 | ** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also |
| 121994 | ** have been made. Calling this function puts the MultiSegReader in such |
| 121995 | ** a state that if the next two calls are: |
| 121996 | ** |
| 121997 | ** sqlite3Fts3SegReaderStart() |
| 121998 | ** sqlite3Fts3SegReaderStep() |
| 121999 | ** |
| 122000 | ** then the entire doclist for the term is available in |
| 122001 | ** MultiSegReader.aDoclist/nDoclist. |
| 122002 | */ |
| 122003 | SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){ |
| 122004 | int i; /* Used to iterate through segment-readers */ |
| 122005 | |
| 122006 | assert( pCsr->zTerm==0 ); |
| 122007 | assert( pCsr->nTerm==0 ); |
| 122008 | assert( pCsr->aDoclist==0 ); |
| 122009 | assert( pCsr->nDoclist==0 ); |
| 122010 | |
| 122011 | pCsr->nAdvance = 0; |
| 122012 | pCsr->bRestart = 1; |
| 122013 | for(i=0; i<pCsr->nSegment; i++){ |
| 122014 | pCsr->apSegment[i]->pOffsetList = 0; |
| 122015 | pCsr->apSegment[i]->nOffsetList = 0; |
| 122016 | pCsr->apSegment[i]->iDocid = 0; |
| 122017 | } |
| 122018 | |
| 122019 | return SQLITE_OK; |
| 122020 | } |
| 122021 | |
| 122022 | |
| 122023 | SQLITE_PRIVATE int sqlite3Fts3SegReaderStep( |
| 122024 | Fts3Table *p, /* Virtual table handle */ |
| 122025 | Fts3MultiSegReader *pCsr /* Cursor object */ |
| 122026 | ){ |
| @@ -121981,13 +122090,18 @@ | |
| 122090 | assert( isIgnoreEmpty || (isRequirePos && !isColFilter) ); |
| 122091 | if( nMerge==1 |
| 122092 | && !isIgnoreEmpty |
| 122093 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 122094 | ){ |
| 122095 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 122096 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 122097 | rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist); |
| 122098 | pCsr->aDoclist = pCsr->aBuffer; |
| 122099 | }else{ |
| 122100 | pCsr->aDoclist = apSegment[0]->aDoclist; |
| 122101 | } |
| 122102 | if( rc==SQLITE_OK ) rc = SQLITE_ROW; |
| 122103 | }else{ |
| 122104 | int nDoclist = 0; /* Size of doclist */ |
| 122105 | sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */ |
| 122106 | |
| 122107 | /* The current term of the first nMerge entries in the array |
| @@ -123725,11 +123839,11 @@ | |
| 123839 | if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol; |
| 123840 | break; |
| 123841 | |
| 123842 | case FTS3_MATCHINFO_NDOC: |
| 123843 | if( bGlobal ){ |
| 123844 | sqlite3_int64 nDoc = 0; |
| 123845 | rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0); |
| 123846 | pInfo->aMatchinfo[0] = (u32)nDoc; |
| 123847 | } |
| 123848 | break; |
| 123849 | |
| @@ -125620,11 +125734,11 @@ | |
| 125734 | */ |
| 125735 | static float cellArea(Rtree *pRtree, RtreeCell *p){ |
| 125736 | float area = 1.0; |
| 125737 | int ii; |
| 125738 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125739 | area = (float)(area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]))); |
| 125740 | } |
| 125741 | return area; |
| 125742 | } |
| 125743 | |
| 125744 | /* |
| @@ -125633,11 +125747,11 @@ | |
| 125747 | */ |
| 125748 | static float cellMargin(Rtree *pRtree, RtreeCell *p){ |
| 125749 | float margin = 0.0; |
| 125750 | int ii; |
| 125751 | for(ii=0; ii<(pRtree->nDim*2); ii+=2){ |
| 125752 | margin += (float)(DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); |
| 125753 | } |
| 125754 | return margin; |
| 125755 | } |
| 125756 | |
| 125757 | /* |
| @@ -125718,11 +125832,11 @@ | |
| 125832 | |
| 125833 | if( x2<x1 ){ |
| 125834 | o = 0.0; |
| 125835 | break; |
| 125836 | }else{ |
| 125837 | o = o * (float)(x2-x1); |
| 125838 | } |
| 125839 | } |
| 125840 | overlap += o; |
| 125841 | } |
| 125842 | } |
| @@ -125737,16 +125851,16 @@ | |
| 125851 | RtreeCell *pInsert, |
| 125852 | RtreeCell *aCell, |
| 125853 | int nCell, |
| 125854 | int iExclude |
| 125855 | ){ |
| 125856 | double before; |
| 125857 | double after; |
| 125858 | before = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125859 | cellUnion(pRtree, p, pInsert); |
| 125860 | after = cellOverlap(pRtree, p, aCell, nCell, iExclude); |
| 125861 | return (float)(after-before); |
| 125862 | } |
| 125863 | #endif |
| 125864 | |
| 125865 | |
| 125866 | /* |
| @@ -125764,15 +125878,15 @@ | |
| 125878 | RtreeNode *pNode; |
| 125879 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 125880 | |
| 125881 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 125882 | int iCell; |
| 125883 | sqlite3_int64 iBest = 0; |
| 125884 | |
| 125885 | float fMinGrowth = 0.0; |
| 125886 | float fMinArea = 0.0; |
| 125887 | float fMinOverlap = 0.0; |
| 125888 | |
| 125889 | int nCell = NCELL(pNode); |
| 125890 | RtreeCell cell; |
| 125891 | RtreeNode *pChild; |
| 125892 | |
| @@ -126198,13 +126312,13 @@ | |
| 126312 | ){ |
| 126313 | int **aaSorted; |
| 126314 | int *aSpare; |
| 126315 | int ii; |
| 126316 | |
| 126317 | int iBestDim = 0; |
| 126318 | int iBestSplit = 0; |
| 126319 | float fBestMargin = 0.0; |
| 126320 | |
| 126321 | int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); |
| 126322 | |
| 126323 | aaSorted = (int **)sqlite3_malloc(nByte); |
| 126324 | if( !aaSorted ){ |
| @@ -126222,13 +126336,13 @@ | |
| 126336 | SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare); |
| 126337 | } |
| 126338 | |
| 126339 | for(ii=0; ii<pRtree->nDim; ii++){ |
| 126340 | float margin = 0.0; |
| 126341 | float fBestOverlap = 0.0; |
| 126342 | float fBestArea = 0.0; |
| 126343 | int iBestLeft = 0; |
| 126344 | int nLeft; |
| 126345 | |
| 126346 | for( |
| 126347 | nLeft=RTREE_MINCELLS(pRtree); |
| 126348 | nLeft<=(nCell-RTREE_MINCELLS(pRtree)); |
| @@ -126539,11 +126653,11 @@ | |
| 126653 | static int deleteCell(Rtree *, RtreeNode *, int, int); |
| 126654 | |
| 126655 | static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){ |
| 126656 | int rc; |
| 126657 | int rc2; |
| 126658 | RtreeNode *pParent = 0; |
| 126659 | int iCell; |
| 126660 | |
| 126661 | assert( pNode->nRef==1 ); |
| 126662 | |
| 126663 | /* Remove the entry in the parent cell. */ |
| @@ -126687,23 +126801,23 @@ | |
| 126801 | }else{ |
| 126802 | nodeGetCell(pRtree, pNode, ii, &aCell[ii]); |
| 126803 | } |
| 126804 | aOrder[ii] = ii; |
| 126805 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126806 | aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2]); |
| 126807 | aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2+1]); |
| 126808 | } |
| 126809 | } |
| 126810 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126811 | aCenterCoord[iDim] = (float)(aCenterCoord[iDim]/((float)nCell*2.0)); |
| 126812 | } |
| 126813 | |
| 126814 | for(ii=0; ii<nCell; ii++){ |
| 126815 | aDistance[ii] = 0.0; |
| 126816 | for(iDim=0; iDim<pRtree->nDim; iDim++){ |
| 126817 | float coord = (float)(DCOORD(aCell[ii].aCoord[iDim*2+1]) - |
| 126818 | DCOORD(aCell[ii].aCoord[iDim*2])); |
| 126819 | aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); |
| 126820 | } |
| 126821 | } |
| 126822 | |
| 126823 | SortByDistance(aOrder, nCell, aDistance, aSpare); |
| @@ -126798,14 +126912,14 @@ | |
| 126912 | nodeGetCell(pRtree, pNode, ii, &cell); |
| 126913 | |
| 126914 | /* Find a node to store this cell in. pNode->iNode currently contains |
| 126915 | ** the height of the sub-tree headed by the cell. |
| 126916 | */ |
| 126917 | rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert); |
| 126918 | if( rc==SQLITE_OK ){ |
| 126919 | int rc2; |
| 126920 | rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode); |
| 126921 | rc2 = nodeRelease(pRtree, pInsert); |
| 126922 | if( rc==SQLITE_OK ){ |
| 126923 | rc = rc2; |
| 126924 | } |
| 126925 | } |
| @@ -127190,11 +127304,11 @@ | |
| 127304 | int isCreate /* True for xCreate, false for xConnect */ |
| 127305 | ){ |
| 127306 | int rc; |
| 127307 | char *zSql; |
| 127308 | if( isCreate ){ |
| 127309 | int iPageSize = 0; |
| 127310 | zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); |
| 127311 | rc = getIntFromStmt(db, zSql, &iPageSize); |
| 127312 | if( rc==SQLITE_OK ){ |
| 127313 | pRtree->iNodeSize = iPageSize-64; |
| 127314 | if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ |
| @@ -127993,14 +128107,11 @@ | |
| 128107 | ** May you find forgiveness for yourself and forgive others. |
| 128108 | ** May you share freely, never taking more than you give. |
| 128109 | ** |
| 128110 | ************************************************************************* |
| 128111 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 128112 | */ |
| 128113 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 128114 | #ifdef SQLITE_ENABLE_ICU |
| 128115 | |
| 128116 | |
| 128117 | #include <unicode/ubrk.h> |
| 128118 |
+10
-10
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | -#define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389" | |
| 112 | +#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -308,11 +308,11 @@ | ||
| 308 | 308 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 309 | 309 | ** in the context of the [database connection] passed in as its 1st |
| 310 | 310 | ** argument. ^If the callback function of the 3rd argument to |
| 311 | 311 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 312 | 312 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 313 | -** to sqlite3_exec() is relayed through to the 1st argument of each | |
| 313 | +** sqlite3_exec() is relayed through to the 1st argument of each | |
| 314 | 314 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 315 | 315 | ** is NULL, then no callback is ever invoked and result rows are |
| 316 | 316 | ** ignored. |
| 317 | 317 | ** |
| 318 | 318 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -900,11 +900,11 @@ | ||
| 900 | 900 | ** The xSleep() method causes the calling thread to sleep for at |
| 901 | 901 | ** least the number of microseconds given. ^The xCurrentTime() |
| 902 | 902 | ** method returns a Julian Day Number for the current date and time as |
| 903 | 903 | ** a floating point value. |
| 904 | 904 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 905 | -** Day Number multipled by 86400000 (the number of milliseconds in | |
| 905 | +** Day Number multiplied by 86400000 (the number of milliseconds in | |
| 906 | 906 | ** a 24-hour day). |
| 907 | 907 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 908 | 908 | ** date and time if that method is available (if iVersion is 2 or |
| 909 | 909 | ** greater and the function pointer is not NULL) and will fall back |
| 910 | 910 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1338,11 +1338,11 @@ | ||
| 1338 | 1338 | ** scratch memory beyond what is provided by this configuration option, then |
| 1339 | 1339 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1340 | 1340 | ** |
| 1341 | 1341 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1342 | 1342 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1343 | -** the database page cache with the default page cache implemenation. | |
| 1343 | +** the database page cache with the default page cache implementation. | |
| 1344 | 1344 | ** This configuration should not be used if an application-define page |
| 1345 | 1345 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1346 | 1346 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1347 | 1347 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1348 | 1348 | ** The sz argument should be the size of the largest database page |
| @@ -2436,16 +2436,16 @@ | ||
| 2436 | 2436 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2437 | 2437 | ** |
| 2438 | 2438 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2439 | 2439 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2440 | 2440 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2441 | -** is set in the fourth argument to sqlite3_open_v2(), or if it has | |
| 2441 | +** set in the fourth argument to sqlite3_open_v2(), or if it has | |
| 2442 | 2442 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2443 | 2443 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2444 | 2444 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2445 | 2445 | ** by default, but future releases of SQLite might enable URI filename |
| 2446 | -** intepretation by default. See "[URI filenames]" for additional | |
| 2446 | +** interpretation by default. See "[URI filenames]" for additional | |
| 2447 | 2447 | ** information. |
| 2448 | 2448 | ** |
| 2449 | 2449 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2450 | 2450 | ** authority, then it must be either an empty string or the string |
| 2451 | 2451 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3260,11 +3260,11 @@ | ||
| 3260 | 3260 | ** [extended result codes] might be returned as well. |
| 3261 | 3261 | ** |
| 3262 | 3262 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3263 | 3263 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3264 | 3264 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3265 | -** statement. If the statement is not a [COMMIT] and occurs within a | |
| 3265 | +** statement. If the statement is not a [COMMIT] and occurs within an | |
| 3266 | 3266 | ** explicit transaction then you should rollback the transaction before |
| 3267 | 3267 | ** continuing. |
| 3268 | 3268 | ** |
| 3269 | 3269 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3270 | 3270 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -3539,11 +3539,11 @@ | ||
| 3539 | 3539 | |
| 3540 | 3540 | /* |
| 3541 | 3541 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 3542 | 3542 | ** |
| 3543 | 3543 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 3544 | -** ^If the most recent evaluation of the statement encountered no errors or | |
| 3544 | +** ^If the most recent evaluation of the statement encountered no errors | |
| 3545 | 3545 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 3546 | 3546 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 3547 | 3547 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 3548 | 3548 | ** [extended error code]. |
| 3549 | 3549 | ** |
| @@ -5453,11 +5453,11 @@ | ||
| 5453 | 5453 | ** versions of these routines, it should at least provide stubs that always |
| 5454 | 5454 | ** return true so that one does not get spurious assertion failures. |
| 5455 | 5455 | ** |
| 5456 | 5456 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 5457 | 5457 | ** the routine should return 1. This seems counter-intuitive since |
| 5458 | -** clearly the mutex cannot be held if it does not exist. But the | |
| 5458 | +** clearly the mutex cannot be held if it does not exist. But | |
| 5459 | 5459 | ** the reason the mutex does not exist is because the build is not |
| 5460 | 5460 | ** using mutexes. And we do not want the assert() containing the |
| 5461 | 5461 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 5462 | 5462 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 5463 | 5463 | ** interface should also return 1 when given a NULL pointer. |
| @@ -5962,11 +5962,11 @@ | ||
| 5962 | 5962 | ** [[the xFetch() page cache methods]] |
| 5963 | 5963 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 5964 | 5964 | ** the page, or a NULL pointer. |
| 5965 | 5965 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 5966 | 5966 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 5967 | -** mimimum key value is 1. After it has been retrieved using xFetch, the page | |
| 5967 | +** minimum key value is 1. After it has been retrieved using xFetch, the page | |
| 5968 | 5968 | ** is considered to be "pinned". |
| 5969 | 5969 | ** |
| 5970 | 5970 | ** If the requested page is already in the page cache, then the page cache |
| 5971 | 5971 | ** implementation must return a pointer to the page buffer with its content |
| 5972 | 5972 | ** intact. If the requested page is not already in the cache, then the |
| 5973 | 5973 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | #define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -308,11 +308,11 @@ | |
| 308 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 309 | ** in the context of the [database connection] passed in as its 1st |
| 310 | ** argument. ^If the callback function of the 3rd argument to |
| 311 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 312 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 313 | ** to sqlite3_exec() is relayed through to the 1st argument of each |
| 314 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 315 | ** is NULL, then no callback is ever invoked and result rows are |
| 316 | ** ignored. |
| 317 | ** |
| 318 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -900,11 +900,11 @@ | |
| 900 | ** The xSleep() method causes the calling thread to sleep for at |
| 901 | ** least the number of microseconds given. ^The xCurrentTime() |
| 902 | ** method returns a Julian Day Number for the current date and time as |
| 903 | ** a floating point value. |
| 904 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 905 | ** Day Number multipled by 86400000 (the number of milliseconds in |
| 906 | ** a 24-hour day). |
| 907 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 908 | ** date and time if that method is available (if iVersion is 2 or |
| 909 | ** greater and the function pointer is not NULL) and will fall back |
| 910 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1338,11 +1338,11 @@ | |
| 1338 | ** scratch memory beyond what is provided by this configuration option, then |
| 1339 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1340 | ** |
| 1341 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1342 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1343 | ** the database page cache with the default page cache implemenation. |
| 1344 | ** This configuration should not be used if an application-define page |
| 1345 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1346 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1347 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1348 | ** The sz argument should be the size of the largest database page |
| @@ -2436,16 +2436,16 @@ | |
| 2436 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2437 | ** |
| 2438 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2439 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2440 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2441 | ** is set in the fourth argument to sqlite3_open_v2(), or if it has |
| 2442 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2443 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2444 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2445 | ** by default, but future releases of SQLite might enable URI filename |
| 2446 | ** intepretation by default. See "[URI filenames]" for additional |
| 2447 | ** information. |
| 2448 | ** |
| 2449 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2450 | ** authority, then it must be either an empty string or the string |
| 2451 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3260,11 +3260,11 @@ | |
| 3260 | ** [extended result codes] might be returned as well. |
| 3261 | ** |
| 3262 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3263 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3264 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3265 | ** statement. If the statement is not a [COMMIT] and occurs within a |
| 3266 | ** explicit transaction then you should rollback the transaction before |
| 3267 | ** continuing. |
| 3268 | ** |
| 3269 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3270 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -3539,11 +3539,11 @@ | |
| 3539 | |
| 3540 | /* |
| 3541 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 3542 | ** |
| 3543 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 3544 | ** ^If the most recent evaluation of the statement encountered no errors or |
| 3545 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 3546 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 3547 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 3548 | ** [extended error code]. |
| 3549 | ** |
| @@ -5453,11 +5453,11 @@ | |
| 5453 | ** versions of these routines, it should at least provide stubs that always |
| 5454 | ** return true so that one does not get spurious assertion failures. |
| 5455 | ** |
| 5456 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 5457 | ** the routine should return 1. This seems counter-intuitive since |
| 5458 | ** clearly the mutex cannot be held if it does not exist. But the |
| 5459 | ** the reason the mutex does not exist is because the build is not |
| 5460 | ** using mutexes. And we do not want the assert() containing the |
| 5461 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 5462 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 5463 | ** interface should also return 1 when given a NULL pointer. |
| @@ -5962,11 +5962,11 @@ | |
| 5962 | ** [[the xFetch() page cache methods]] |
| 5963 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 5964 | ** the page, or a NULL pointer. |
| 5965 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 5966 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 5967 | ** mimimum key value is 1. After it has been retrieved using xFetch, the page |
| 5968 | ** is considered to be "pinned". |
| 5969 | ** |
| 5970 | ** If the requested page is already in the page cache, then the page cache |
| 5971 | ** implementation must return a pointer to the page buffer with its content |
| 5972 | ** intact. If the requested page is not already in the cache, then the |
| 5973 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -308,11 +308,11 @@ | |
| 308 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| 309 | ** in the context of the [database connection] passed in as its 1st |
| 310 | ** argument. ^If the callback function of the 3rd argument to |
| 311 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 312 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 313 | ** sqlite3_exec() is relayed through to the 1st argument of each |
| 314 | ** callback invocation. ^If the callback pointer to sqlite3_exec() |
| 315 | ** is NULL, then no callback is ever invoked and result rows are |
| 316 | ** ignored. |
| 317 | ** |
| 318 | ** ^If an error occurs while evaluating the SQL statements passed into |
| @@ -900,11 +900,11 @@ | |
| 900 | ** The xSleep() method causes the calling thread to sleep for at |
| 901 | ** least the number of microseconds given. ^The xCurrentTime() |
| 902 | ** method returns a Julian Day Number for the current date and time as |
| 903 | ** a floating point value. |
| 904 | ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
| 905 | ** Day Number multiplied by 86400000 (the number of milliseconds in |
| 906 | ** a 24-hour day). |
| 907 | ** ^SQLite will use the xCurrentTimeInt64() method to get the current |
| 908 | ** date and time if that method is available (if iVersion is 2 or |
| 909 | ** greater and the function pointer is not NULL) and will fall back |
| 910 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| @@ -1338,11 +1338,11 @@ | |
| 1338 | ** scratch memory beyond what is provided by this configuration option, then |
| 1339 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1340 | ** |
| 1341 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1342 | ** <dd> ^This option specifies a static memory buffer that SQLite can use for |
| 1343 | ** the database page cache with the default page cache implementation. |
| 1344 | ** This configuration should not be used if an application-define page |
| 1345 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1346 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1347 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1348 | ** The sz argument should be the size of the largest database page |
| @@ -2436,16 +2436,16 @@ | |
| 2436 | ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
| 2437 | ** |
| 2438 | ** ^If [URI filename] interpretation is enabled, and the filename argument |
| 2439 | ** begins with "file:", then the filename is interpreted as a URI. ^URI |
| 2440 | ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
| 2441 | ** set in the fourth argument to sqlite3_open_v2(), or if it has |
| 2442 | ** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
| 2443 | ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
| 2444 | ** As of SQLite version 3.7.7, URI filename interpretation is turned off |
| 2445 | ** by default, but future releases of SQLite might enable URI filename |
| 2446 | ** interpretation by default. See "[URI filenames]" for additional |
| 2447 | ** information. |
| 2448 | ** |
| 2449 | ** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
| 2450 | ** authority, then it must be either an empty string or the string |
| 2451 | ** "localhost". ^If the authority is not an empty string or "localhost", an |
| @@ -3260,11 +3260,11 @@ | |
| 3260 | ** [extended result codes] might be returned as well. |
| 3261 | ** |
| 3262 | ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
| 3263 | ** database locks it needs to do its job. ^If the statement is a [COMMIT] |
| 3264 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3265 | ** statement. If the statement is not a [COMMIT] and occurs within an |
| 3266 | ** explicit transaction then you should rollback the transaction before |
| 3267 | ** continuing. |
| 3268 | ** |
| 3269 | ** ^[SQLITE_DONE] means that the statement has finished executing |
| 3270 | ** successfully. sqlite3_step() should not be called again on this virtual |
| @@ -3539,11 +3539,11 @@ | |
| 3539 | |
| 3540 | /* |
| 3541 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 3542 | ** |
| 3543 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 3544 | ** ^If the most recent evaluation of the statement encountered no errors |
| 3545 | ** or if the statement is never been evaluated, then sqlite3_finalize() returns |
| 3546 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 3547 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 3548 | ** [extended error code]. |
| 3549 | ** |
| @@ -5453,11 +5453,11 @@ | |
| 5453 | ** versions of these routines, it should at least provide stubs that always |
| 5454 | ** return true so that one does not get spurious assertion failures. |
| 5455 | ** |
| 5456 | ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
| 5457 | ** the routine should return 1. This seems counter-intuitive since |
| 5458 | ** clearly the mutex cannot be held if it does not exist. But |
| 5459 | ** the reason the mutex does not exist is because the build is not |
| 5460 | ** using mutexes. And we do not want the assert() containing the |
| 5461 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 5462 | ** the appropriate thing to do. ^The sqlite3_mutex_notheld() |
| 5463 | ** interface should also return 1 when given a NULL pointer. |
| @@ -5962,11 +5962,11 @@ | |
| 5962 | ** [[the xFetch() page cache methods]] |
| 5963 | ** The xFetch() method locates a page in the cache and returns a pointer to |
| 5964 | ** the page, or a NULL pointer. |
| 5965 | ** A "page", in this context, means a buffer of szPage bytes aligned at an |
| 5966 | ** 8-byte boundary. The page to be fetched is determined by the key. ^The |
| 5967 | ** minimum key value is 1. After it has been retrieved using xFetch, the page |
| 5968 | ** is considered to be "pinned". |
| 5969 | ** |
| 5970 | ** If the requested page is already in the page cache, then the page cache |
| 5971 | ** implementation must return a pointer to the page buffer with its content |
| 5972 | ** intact. If the requested page is not already in the cache, then the |
| 5973 |