| | @@ -328,11 +328,11 @@ |
| 328 | 328 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 329 | 329 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 330 | 330 | */ |
| 331 | 331 | #define SQLITE_VERSION "3.11.0" |
| 332 | 332 | #define SQLITE_VERSION_NUMBER 3011000 |
| 333 | | -#define SQLITE_SOURCE_ID "2016-02-09 20:11:14 751915cb7e4981661a40dc5e4d029ab27434c2d9" |
| 333 | +#define SQLITE_SOURCE_ID "2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc" |
| 334 | 334 | |
| 335 | 335 | /* |
| 336 | 336 | ** CAPI3REF: Run-Time Library Version Numbers |
| 337 | 337 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 338 | 338 | ** |
| | @@ -13987,10 +13987,11 @@ |
| 13987 | 13987 | int n; /* A counter */ |
| 13988 | 13988 | int iCur; /* A cursor number */ |
| 13989 | 13989 | SrcList *pSrcList; /* FROM clause */ |
| 13990 | 13990 | struct SrcCount *pSrcCount; /* Counting column references */ |
| 13991 | 13991 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 13992 | + int *aiCol; /* array of column indexes */ |
| 13992 | 13993 | } u; |
| 13993 | 13994 | }; |
| 13994 | 13995 | |
| 13995 | 13996 | /* Forward declarations */ |
| 13996 | 13997 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| | @@ -14056,10 +14057,17 @@ |
| 14056 | 14057 | SQLITE_PRIVATE int sqlite3CantopenError(int); |
| 14057 | 14058 | #define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) |
| 14058 | 14059 | #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) |
| 14059 | 14060 | #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) |
| 14060 | 14061 | |
| 14062 | +/* |
| 14063 | +** FTS3 and FTS4 both require virtual table support |
| 14064 | +*/ |
| 14065 | +#if defined(SQLITE_OMIT_VIRTUALTABLE) |
| 14066 | +# undef SQLITE_ENABLE_FTS3 |
| 14067 | +# undef SQLITE_ENABLE_FTS4 |
| 14068 | +#endif |
| 14061 | 14069 | |
| 14062 | 14070 | /* |
| 14063 | 14071 | ** FTS4 is really an extension for FTS3. It is enabled using the |
| 14064 | 14072 | ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call |
| 14065 | 14073 | ** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3. |
| | @@ -14432,11 +14440,11 @@ |
| 14432 | 14440 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 14433 | 14441 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
| 14434 | 14442 | SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); |
| 14435 | 14443 | SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); |
| 14436 | 14444 | SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, |
| 14437 | | - u8,u8,int,int*); |
| 14445 | + u8,u8,int,int*,int*); |
| 14438 | 14446 | SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int); |
| 14439 | 14447 | SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*); |
| 14440 | 14448 | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int); |
| 14441 | 14449 | SQLITE_PRIVATE void sqlite3MultiWrite(Parse*); |
| 14442 | 14450 | SQLITE_PRIVATE void sqlite3MayAbort(Parse*); |
| | @@ -17745,18 +17753,40 @@ |
| 17745 | 17753 | */ |
| 17746 | 17754 | #define _SQLITE_OS_C_ 1 |
| 17747 | 17755 | /* #include "sqliteInt.h" */ |
| 17748 | 17756 | #undef _SQLITE_OS_C_ |
| 17749 | 17757 | |
| 17758 | +/* |
| 17759 | +** If we compile with the SQLITE_TEST macro set, then the following block |
| 17760 | +** of code will give us the ability to simulate a disk I/O error. This |
| 17761 | +** is used for testing the I/O recovery logic. |
| 17762 | +*/ |
| 17763 | +#if defined(SQLITE_TEST) |
| 17764 | +SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */ |
| 17765 | +SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */ |
| 17766 | +SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */ |
| 17767 | +SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */ |
| 17768 | +SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */ |
| 17769 | +SQLITE_API int sqlite3_diskfull_pending = 0; |
| 17770 | +SQLITE_API int sqlite3_diskfull = 0; |
| 17771 | +#endif /* defined(SQLITE_TEST) */ |
| 17772 | + |
| 17773 | +/* |
| 17774 | +** When testing, also keep a count of the number of open files. |
| 17775 | +*/ |
| 17776 | +#if defined(SQLITE_TEST) |
| 17777 | +SQLITE_API int sqlite3_open_file_count = 0; |
| 17778 | +#endif /* defined(SQLITE_TEST) */ |
| 17779 | + |
| 17750 | 17780 | /* |
| 17751 | 17781 | ** The default SQLite sqlite3_vfs implementations do not allocate |
| 17752 | 17782 | ** memory (actually, os_unix.c allocates a small amount of memory |
| 17753 | 17783 | ** from within OsOpen()), but some third-party implementations may. |
| 17754 | 17784 | ** So we test the effects of a malloc() failing and the sqlite3OsXXX() |
| 17755 | 17785 | ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. |
| 17756 | 17786 | ** |
| 17757 | | -** The following functions are instrumented for malloc() failure |
| 17787 | +** The following functions are instrumented for malloc() failure |
| 17758 | 17788 | ** testing: |
| 17759 | 17789 | ** |
| 17760 | 17790 | ** sqlite3OsRead() |
| 17761 | 17791 | ** sqlite3OsWrite() |
| 17762 | 17792 | ** sqlite3OsSync() |
| | @@ -17838,12 +17868,12 @@ |
| 17838 | 17868 | */ |
| 17839 | 17869 | SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ |
| 17840 | 17870 | #ifdef SQLITE_TEST |
| 17841 | 17871 | if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){ |
| 17842 | 17872 | /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite |
| 17843 | | - ** is using a regular VFS, it is called after the corresponding |
| 17844 | | - ** transaction has been committed. Injecting a fault at this point |
| 17873 | + ** is using a regular VFS, it is called after the corresponding |
| 17874 | + ** transaction has been committed. Injecting a fault at this point |
| 17845 | 17875 | ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM |
| 17846 | 17876 | ** but the transaction is committed anyway. |
| 17847 | 17877 | ** |
| 17848 | 17878 | ** The core must call OsFileControl() though, not OsFileControlHint(), |
| 17849 | 17879 | ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably |
| | @@ -17908,14 +17938,14 @@ |
| 17908 | 17938 | /* |
| 17909 | 17939 | ** The next group of routines are convenience wrappers around the |
| 17910 | 17940 | ** VFS methods. |
| 17911 | 17941 | */ |
| 17912 | 17942 | SQLITE_PRIVATE int sqlite3OsOpen( |
| 17913 | | - sqlite3_vfs *pVfs, |
| 17914 | | - const char *zPath, |
| 17915 | | - sqlite3_file *pFile, |
| 17916 | | - int flags, |
| 17943 | + sqlite3_vfs *pVfs, |
| 17944 | + const char *zPath, |
| 17945 | + sqlite3_file *pFile, |
| 17946 | + int flags, |
| 17917 | 17947 | int *pFlagsOut |
| 17918 | 17948 | ){ |
| 17919 | 17949 | int rc; |
| 17920 | 17950 | DO_OS_MALLOC_TEST(0); |
| 17921 | 17951 | /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| | @@ -17930,22 +17960,22 @@ |
| 17930 | 17960 | DO_OS_MALLOC_TEST(0); |
| 17931 | 17961 | assert( dirSync==0 || dirSync==1 ); |
| 17932 | 17962 | return pVfs->xDelete(pVfs, zPath, dirSync); |
| 17933 | 17963 | } |
| 17934 | 17964 | SQLITE_PRIVATE int sqlite3OsAccess( |
| 17935 | | - sqlite3_vfs *pVfs, |
| 17936 | | - const char *zPath, |
| 17937 | | - int flags, |
| 17965 | + sqlite3_vfs *pVfs, |
| 17966 | + const char *zPath, |
| 17967 | + int flags, |
| 17938 | 17968 | int *pResOut |
| 17939 | 17969 | ){ |
| 17940 | 17970 | DO_OS_MALLOC_TEST(0); |
| 17941 | 17971 | return pVfs->xAccess(pVfs, zPath, flags, pResOut); |
| 17942 | 17972 | } |
| 17943 | 17973 | SQLITE_PRIVATE int sqlite3OsFullPathname( |
| 17944 | | - sqlite3_vfs *pVfs, |
| 17945 | | - const char *zPath, |
| 17946 | | - int nPathOut, |
| 17974 | + sqlite3_vfs *pVfs, |
| 17975 | + const char *zPath, |
| 17976 | + int nPathOut, |
| 17947 | 17977 | char *zPathOut |
| 17948 | 17978 | ){ |
| 17949 | 17979 | DO_OS_MALLOC_TEST(0); |
| 17950 | 17980 | zPathOut[0] = 0; |
| 17951 | 17981 | return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut); |
| | @@ -17987,13 +18017,13 @@ |
| 17987 | 18017 | } |
| 17988 | 18018 | return rc; |
| 17989 | 18019 | } |
| 17990 | 18020 | |
| 17991 | 18021 | SQLITE_PRIVATE int sqlite3OsOpenMalloc( |
| 17992 | | - sqlite3_vfs *pVfs, |
| 17993 | | - const char *zFile, |
| 17994 | | - sqlite3_file **ppFile, |
| 18022 | + sqlite3_vfs *pVfs, |
| 18023 | + const char *zFile, |
| 18024 | + sqlite3_file **ppFile, |
| 17995 | 18025 | int flags, |
| 17996 | 18026 | int *pOutFlags |
| 17997 | 18027 | ){ |
| 17998 | 18028 | int rc = SQLITE_NOMEM; |
| 17999 | 18029 | sqlite3_file *pFile; |
| | @@ -21212,12 +21242,12 @@ |
| 21212 | 21242 | ** Macros for performance tracing. Normally turned off. Only works |
| 21213 | 21243 | ** on i486 hardware. |
| 21214 | 21244 | */ |
| 21215 | 21245 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 21216 | 21246 | |
| 21217 | | -/* |
| 21218 | | -** hwtime.h contains inline assembler code for implementing |
| 21247 | +/* |
| 21248 | +** hwtime.h contains inline assembler code for implementing |
| 21219 | 21249 | ** high-performance timing routines. |
| 21220 | 21250 | */ |
| 21221 | 21251 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 21222 | 21252 | /************** Begin file hwtime.h ******************************************/ |
| 21223 | 21253 | /* |
| | @@ -21323,18 +21353,18 @@ |
| 21323 | 21353 | /* |
| 21324 | 21354 | ** If we compile with the SQLITE_TEST macro set, then the following block |
| 21325 | 21355 | ** of code will give us the ability to simulate a disk I/O error. This |
| 21326 | 21356 | ** is used for testing the I/O recovery logic. |
| 21327 | 21357 | */ |
| 21328 | | -#ifdef SQLITE_TEST |
| 21329 | | -SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */ |
| 21330 | | -SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */ |
| 21331 | | -SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */ |
| 21332 | | -SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */ |
| 21333 | | -SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */ |
| 21334 | | -SQLITE_API int sqlite3_diskfull_pending = 0; |
| 21335 | | -SQLITE_API int sqlite3_diskfull = 0; |
| 21358 | +#if defined(SQLITE_TEST) |
| 21359 | +SQLITE_API extern int sqlite3_io_error_hit; |
| 21360 | +SQLITE_API extern int sqlite3_io_error_hardhit; |
| 21361 | +SQLITE_API extern int sqlite3_io_error_pending; |
| 21362 | +SQLITE_API extern int sqlite3_io_error_persist; |
| 21363 | +SQLITE_API extern int sqlite3_io_error_benign; |
| 21364 | +SQLITE_API extern int sqlite3_diskfull_pending; |
| 21365 | +SQLITE_API extern int sqlite3_diskfull; |
| 21336 | 21366 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) |
| 21337 | 21367 | #define SimulateIOError(CODE) \ |
| 21338 | 21368 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ |
| 21339 | 21369 | || sqlite3_io_error_pending-- == 1 ) \ |
| 21340 | 21370 | { local_ioerr(); CODE; } |
| | @@ -21356,21 +21386,21 @@ |
| 21356 | 21386 | } |
| 21357 | 21387 | #else |
| 21358 | 21388 | #define SimulateIOErrorBenign(X) |
| 21359 | 21389 | #define SimulateIOError(A) |
| 21360 | 21390 | #define SimulateDiskfullError(A) |
| 21361 | | -#endif |
| 21391 | +#endif /* defined(SQLITE_TEST) */ |
| 21362 | 21392 | |
| 21363 | 21393 | /* |
| 21364 | 21394 | ** When testing, keep a count of the number of open files. |
| 21365 | 21395 | */ |
| 21366 | | -#ifdef SQLITE_TEST |
| 21367 | | -SQLITE_API int sqlite3_open_file_count = 0; |
| 21396 | +#if defined(SQLITE_TEST) |
| 21397 | +SQLITE_API extern int sqlite3_open_file_count; |
| 21368 | 21398 | #define OpenCounter(X) sqlite3_open_file_count+=(X) |
| 21369 | 21399 | #else |
| 21370 | 21400 | #define OpenCounter(X) |
| 21371 | | -#endif |
| 21401 | +#endif /* defined(SQLITE_TEST) */ |
| 21372 | 21402 | |
| 21373 | 21403 | #endif /* !defined(_OS_COMMON_H_) */ |
| 21374 | 21404 | |
| 21375 | 21405 | /************** End of os_common.h *******************************************/ |
| 21376 | 21406 | /************** Continuing where we left off in mutex_w32.c ******************/ |
| | @@ -27373,12 +27403,12 @@ |
| 27373 | 27403 | ** Macros for performance tracing. Normally turned off. Only works |
| 27374 | 27404 | ** on i486 hardware. |
| 27375 | 27405 | */ |
| 27376 | 27406 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 27377 | 27407 | |
| 27378 | | -/* |
| 27379 | | -** hwtime.h contains inline assembler code for implementing |
| 27408 | +/* |
| 27409 | +** hwtime.h contains inline assembler code for implementing |
| 27380 | 27410 | ** high-performance timing routines. |
| 27381 | 27411 | */ |
| 27382 | 27412 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 27383 | 27413 | /************** Begin file hwtime.h ******************************************/ |
| 27384 | 27414 | /* |
| | @@ -27484,18 +27514,18 @@ |
| 27484 | 27514 | /* |
| 27485 | 27515 | ** If we compile with the SQLITE_TEST macro set, then the following block |
| 27486 | 27516 | ** of code will give us the ability to simulate a disk I/O error. This |
| 27487 | 27517 | ** is used for testing the I/O recovery logic. |
| 27488 | 27518 | */ |
| 27489 | | -#ifdef SQLITE_TEST |
| 27490 | | -SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */ |
| 27491 | | -SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */ |
| 27492 | | -SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */ |
| 27493 | | -SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */ |
| 27494 | | -SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */ |
| 27495 | | -SQLITE_API int sqlite3_diskfull_pending = 0; |
| 27496 | | -SQLITE_API int sqlite3_diskfull = 0; |
| 27519 | +#if defined(SQLITE_TEST) |
| 27520 | +SQLITE_API extern int sqlite3_io_error_hit; |
| 27521 | +SQLITE_API extern int sqlite3_io_error_hardhit; |
| 27522 | +SQLITE_API extern int sqlite3_io_error_pending; |
| 27523 | +SQLITE_API extern int sqlite3_io_error_persist; |
| 27524 | +SQLITE_API extern int sqlite3_io_error_benign; |
| 27525 | +SQLITE_API extern int sqlite3_diskfull_pending; |
| 27526 | +SQLITE_API extern int sqlite3_diskfull; |
| 27497 | 27527 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) |
| 27498 | 27528 | #define SimulateIOError(CODE) \ |
| 27499 | 27529 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ |
| 27500 | 27530 | || sqlite3_io_error_pending-- == 1 ) \ |
| 27501 | 27531 | { local_ioerr(); CODE; } |
| | @@ -27517,21 +27547,21 @@ |
| 27517 | 27547 | } |
| 27518 | 27548 | #else |
| 27519 | 27549 | #define SimulateIOErrorBenign(X) |
| 27520 | 27550 | #define SimulateIOError(A) |
| 27521 | 27551 | #define SimulateDiskfullError(A) |
| 27522 | | -#endif |
| 27552 | +#endif /* defined(SQLITE_TEST) */ |
| 27523 | 27553 | |
| 27524 | 27554 | /* |
| 27525 | 27555 | ** When testing, keep a count of the number of open files. |
| 27526 | 27556 | */ |
| 27527 | | -#ifdef SQLITE_TEST |
| 27528 | | -SQLITE_API int sqlite3_open_file_count = 0; |
| 27557 | +#if defined(SQLITE_TEST) |
| 27558 | +SQLITE_API extern int sqlite3_open_file_count; |
| 27529 | 27559 | #define OpenCounter(X) sqlite3_open_file_count+=(X) |
| 27530 | 27560 | #else |
| 27531 | 27561 | #define OpenCounter(X) |
| 27532 | | -#endif |
| 27562 | +#endif /* defined(SQLITE_TEST) */ |
| 27533 | 27563 | |
| 27534 | 27564 | #endif /* !defined(_OS_COMMON_H_) */ |
| 27535 | 27565 | |
| 27536 | 27566 | /************** End of os_common.h *******************************************/ |
| 27537 | 27567 | /************** Continuing where we left off in os_unix.c ********************/ |
| | @@ -34896,12 +34926,12 @@ |
| 34896 | 34926 | ** Macros for performance tracing. Normally turned off. Only works |
| 34897 | 34927 | ** on i486 hardware. |
| 34898 | 34928 | */ |
| 34899 | 34929 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 34900 | 34930 | |
| 34901 | | -/* |
| 34902 | | -** hwtime.h contains inline assembler code for implementing |
| 34931 | +/* |
| 34932 | +** hwtime.h contains inline assembler code for implementing |
| 34903 | 34933 | ** high-performance timing routines. |
| 34904 | 34934 | */ |
| 34905 | 34935 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 34906 | 34936 | /************** Begin file hwtime.h ******************************************/ |
| 34907 | 34937 | /* |
| | @@ -35007,18 +35037,18 @@ |
| 35007 | 35037 | /* |
| 35008 | 35038 | ** If we compile with the SQLITE_TEST macro set, then the following block |
| 35009 | 35039 | ** of code will give us the ability to simulate a disk I/O error. This |
| 35010 | 35040 | ** is used for testing the I/O recovery logic. |
| 35011 | 35041 | */ |
| 35012 | | -#ifdef SQLITE_TEST |
| 35013 | | -SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */ |
| 35014 | | -SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */ |
| 35015 | | -SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */ |
| 35016 | | -SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */ |
| 35017 | | -SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */ |
| 35018 | | -SQLITE_API int sqlite3_diskfull_pending = 0; |
| 35019 | | -SQLITE_API int sqlite3_diskfull = 0; |
| 35042 | +#if defined(SQLITE_TEST) |
| 35043 | +SQLITE_API extern int sqlite3_io_error_hit; |
| 35044 | +SQLITE_API extern int sqlite3_io_error_hardhit; |
| 35045 | +SQLITE_API extern int sqlite3_io_error_pending; |
| 35046 | +SQLITE_API extern int sqlite3_io_error_persist; |
| 35047 | +SQLITE_API extern int sqlite3_io_error_benign; |
| 35048 | +SQLITE_API extern int sqlite3_diskfull_pending; |
| 35049 | +SQLITE_API extern int sqlite3_diskfull; |
| 35020 | 35050 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) |
| 35021 | 35051 | #define SimulateIOError(CODE) \ |
| 35022 | 35052 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ |
| 35023 | 35053 | || sqlite3_io_error_pending-- == 1 ) \ |
| 35024 | 35054 | { local_ioerr(); CODE; } |
| | @@ -35040,21 +35070,21 @@ |
| 35040 | 35070 | } |
| 35041 | 35071 | #else |
| 35042 | 35072 | #define SimulateIOErrorBenign(X) |
| 35043 | 35073 | #define SimulateIOError(A) |
| 35044 | 35074 | #define SimulateDiskfullError(A) |
| 35045 | | -#endif |
| 35075 | +#endif /* defined(SQLITE_TEST) */ |
| 35046 | 35076 | |
| 35047 | 35077 | /* |
| 35048 | 35078 | ** When testing, keep a count of the number of open files. |
| 35049 | 35079 | */ |
| 35050 | | -#ifdef SQLITE_TEST |
| 35051 | | -SQLITE_API int sqlite3_open_file_count = 0; |
| 35080 | +#if defined(SQLITE_TEST) |
| 35081 | +SQLITE_API extern int sqlite3_open_file_count; |
| 35052 | 35082 | #define OpenCounter(X) sqlite3_open_file_count+=(X) |
| 35053 | 35083 | #else |
| 35054 | 35084 | #define OpenCounter(X) |
| 35055 | | -#endif |
| 35085 | +#endif /* defined(SQLITE_TEST) */ |
| 35056 | 35086 | |
| 35057 | 35087 | #endif /* !defined(_OS_COMMON_H_) */ |
| 35058 | 35088 | |
| 35059 | 35089 | /************** End of os_common.h *******************************************/ |
| 35060 | 35090 | /************** Continuing where we left off in os_win.c *********************/ |
| | @@ -104247,11 +104277,11 @@ |
| 104247 | 104277 | }else |
| 104248 | 104278 | #endif |
| 104249 | 104279 | { |
| 104250 | 104280 | int isReplace; /* Set to true if constraints may cause a replace */ |
| 104251 | 104281 | sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, |
| 104252 | | - regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace |
| 104282 | + regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0 |
| 104253 | 104283 | ); |
| 104254 | 104284 | sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0); |
| 104255 | 104285 | sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur, |
| 104256 | 104286 | regIns, aRegIdx, 0, appendFlag, isReplace==0); |
| 104257 | 104287 | } |
| | @@ -104328,10 +104358,63 @@ |
| 104328 | 104358 | #undef pTrigger |
| 104329 | 104359 | #endif |
| 104330 | 104360 | #ifdef tmask |
| 104331 | 104361 | #undef tmask |
| 104332 | 104362 | #endif |
| 104363 | + |
| 104364 | +/* |
| 104365 | +** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged() |
| 104366 | +*/ |
| 104367 | +#define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */ |
| 104368 | +#define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */ |
| 104369 | + |
| 104370 | +/* This is the Walker callback from checkConstraintUnchanged(). Set |
| 104371 | +** bit 0x01 of pWalker->eCode if |
| 104372 | +** pWalker->eCode to 0 if this expression node references any of the |
| 104373 | +** columns that are being modifed by an UPDATE statement. |
| 104374 | +*/ |
| 104375 | +static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){ |
| 104376 | + if( pExpr->op==TK_COLUMN ){ |
| 104377 | + assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 ); |
| 104378 | + if( pExpr->iColumn>=0 ){ |
| 104379 | + if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){ |
| 104380 | + pWalker->eCode |= CKCNSTRNT_COLUMN; |
| 104381 | + } |
| 104382 | + }else{ |
| 104383 | + pWalker->eCode |= CKCNSTRNT_ROWID; |
| 104384 | + } |
| 104385 | + } |
| 104386 | + return WRC_Continue; |
| 104387 | +} |
| 104388 | + |
| 104389 | +/* |
| 104390 | +** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The |
| 104391 | +** only columns that are modified by the UPDATE are those for which |
| 104392 | +** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true. |
| 104393 | +** |
| 104394 | +** Return true if CHECK constraint pExpr does not use any of the |
| 104395 | +** changing columns (or the rowid if it is changing). In other words, |
| 104396 | +** return true if this CHECK constraint can be skipped when validating |
| 104397 | +** the new row in the UPDATE statement. |
| 104398 | +*/ |
| 104399 | +static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){ |
| 104400 | + Walker w; |
| 104401 | + memset(&w, 0, sizeof(w)); |
| 104402 | + w.eCode = 0; |
| 104403 | + w.xExprCallback = checkConstraintExprNode; |
| 104404 | + w.u.aiCol = aiChng; |
| 104405 | + sqlite3WalkExpr(&w, pExpr); |
| 104406 | + if( !chngRowid ){ |
| 104407 | + testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 ); |
| 104408 | + w.eCode &= ~CKCNSTRNT_ROWID; |
| 104409 | + } |
| 104410 | + testcase( w.eCode==0 ); |
| 104411 | + testcase( w.eCode==CKCNSTRNT_COLUMN ); |
| 104412 | + testcase( w.eCode==CKCNSTRNT_ROWID ); |
| 104413 | + testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) ); |
| 104414 | + return !w.eCode; |
| 104415 | +} |
| 104333 | 104416 | |
| 104334 | 104417 | /* |
| 104335 | 104418 | ** Generate code to do constraint checks prior to an INSERT or an UPDATE |
| 104336 | 104419 | ** on table pTab. |
| 104337 | 104420 | ** |
| | @@ -104423,11 +104506,12 @@ |
| 104423 | 104506 | int regNewData, /* First register in a range holding values to insert */ |
| 104424 | 104507 | int regOldData, /* Previous content. 0 for INSERTs */ |
| 104425 | 104508 | u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */ |
| 104426 | 104509 | u8 overrideError, /* Override onError to this if not OE_Default */ |
| 104427 | 104510 | int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ |
| 104428 | | - int *pbMayReplace /* OUT: Set to true if constraint may cause a replace */ |
| 104511 | + int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */ |
| 104512 | + int *aiChng /* column i is unchanged if aiChng[i]<0 */ |
| 104429 | 104513 | ){ |
| 104430 | 104514 | Vdbe *v; /* VDBE under constrution */ |
| 104431 | 104515 | Index *pIdx; /* Pointer to one of the indices */ |
| 104432 | 104516 | Index *pPk = 0; /* The PRIMARY KEY index */ |
| 104433 | 104517 | sqlite3 *db; /* Database connection */ |
| | @@ -104469,14 +104553,18 @@ |
| 104469 | 104553 | |
| 104470 | 104554 | /* Test all NOT NULL constraints. |
| 104471 | 104555 | */ |
| 104472 | 104556 | for(i=0; i<nCol; i++){ |
| 104473 | 104557 | if( i==pTab->iPKey ){ |
| 104558 | + continue; /* ROWID is never NULL */ |
| 104559 | + } |
| 104560 | + if( aiChng && aiChng[i]<0 ){ |
| 104561 | + /* Don't bother checking for NOT NULL on columns that do not change */ |
| 104474 | 104562 | continue; |
| 104475 | 104563 | } |
| 104476 | 104564 | onError = pTab->aCol[i].notNull; |
| 104477 | | - if( onError==OE_None ) continue; |
| 104565 | + if( onError==OE_None ) continue; /* This column is allowed to be NULL */ |
| 104478 | 104566 | if( overrideError!=OE_Default ){ |
| 104479 | 104567 | onError = overrideError; |
| 104480 | 104568 | }else if( onError==OE_Default ){ |
| 104481 | 104569 | onError = OE_Abort; |
| 104482 | 104570 | } |
| | @@ -104521,12 +104609,15 @@ |
| 104521 | 104609 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 104522 | 104610 | ExprList *pCheck = pTab->pCheck; |
| 104523 | 104611 | pParse->ckBase = regNewData+1; |
| 104524 | 104612 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 104525 | 104613 | for(i=0; i<pCheck->nExpr; i++){ |
| 104526 | | - int allOk = sqlite3VdbeMakeLabel(v); |
| 104527 | | - sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL); |
| 104614 | + int allOk; |
| 104615 | + Expr *pExpr = pCheck->a[i].pExpr; |
| 104616 | + if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue; |
| 104617 | + allOk = sqlite3VdbeMakeLabel(v); |
| 104618 | + sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL); |
| 104528 | 104619 | if( onError==OE_Ignore ){ |
| 104529 | 104620 | sqlite3VdbeGoto(v, ignoreDest); |
| 104530 | 104621 | }else{ |
| 104531 | 104622 | char *zName = pCheck->a[i].zName; |
| 104532 | 104623 | if( zName==0 ) zName = pTab->zName; |
| | @@ -117677,11 +117768,12 @@ |
| 117677 | 117768 | int bReplace = 0; /* True if REPLACE conflict resolution might happen */ |
| 117678 | 117769 | |
| 117679 | 117770 | /* Do constraint checks. */ |
| 117680 | 117771 | assert( regOldRowid>0 ); |
| 117681 | 117772 | sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, |
| 117682 | | - regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace); |
| 117773 | + regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace, |
| 117774 | + aXRef); |
| 117683 | 117775 | |
| 117684 | 117776 | /* Do FK constraint checks. */ |
| 117685 | 117777 | if( hasFK ){ |
| 117686 | 117778 | sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey); |
| 117687 | 117779 | } |
| | @@ -126572,11 +126664,10 @@ |
| 126572 | 126664 | ** Return the cost of sorting nRow rows, assuming that the keys have |
| 126573 | 126665 | ** nOrderby columns and that the first nSorted columns are already in |
| 126574 | 126666 | ** order. |
| 126575 | 126667 | */ |
| 126576 | 126668 | static LogEst whereSortingCost( |
| 126577 | | - WhereInfo *pWInfo, |
| 126578 | 126669 | LogEst nRow, |
| 126579 | 126670 | int nOrderBy, |
| 126580 | 126671 | int nSorted |
| 126581 | 126672 | ){ |
| 126582 | 126673 | /* TUNING: Estimated cost of a full external sort, where N is |
| | @@ -126594,18 +126685,10 @@ |
| 126594 | 126685 | ** below. */ |
| 126595 | 126686 | LogEst rScale, rSortCost; |
| 126596 | 126687 | assert( nOrderBy>0 && 66==sqlite3LogEst(100) ); |
| 126597 | 126688 | rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66; |
| 126598 | 126689 | rSortCost = nRow + estLog(nRow) + rScale + 16; |
| 126599 | | - |
| 126600 | | - /* TUNING: The cost of implementing DISTINCT using a B-TREE is |
| 126601 | | - ** similar but with a larger constant of proportionality. |
| 126602 | | - ** Multiply by an additional factor of 3.0. */ |
| 126603 | | - if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ |
| 126604 | | - rSortCost += 16; |
| 126605 | | - } |
| 126606 | | - |
| 126607 | 126690 | return rSortCost; |
| 126608 | 126691 | } |
| 126609 | 126692 | |
| 126610 | 126693 | /* |
| 126611 | 126694 | ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine |
| | @@ -126735,11 +126818,11 @@ |
| 126735 | 126818 | revMask = pFrom->revLoop; |
| 126736 | 126819 | } |
| 126737 | 126820 | if( isOrdered>=0 && isOrdered<nOrderBy ){ |
| 126738 | 126821 | if( aSortCost[isOrdered]==0 ){ |
| 126739 | 126822 | aSortCost[isOrdered] = whereSortingCost( |
| 126740 | | - pWInfo, nRowEst, nOrderBy, isOrdered |
| 126823 | + nRowEst, nOrderBy, isOrdered |
| 126741 | 126824 | ); |
| 126742 | 126825 | } |
| 126743 | 126826 | rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]); |
| 126744 | 126827 | |
| 126745 | 126828 | WHERETRACE(0x002, |
| | @@ -137300,10 +137383,16 @@ |
| 137300 | 137383 | #define _FTSINT_H |
| 137301 | 137384 | |
| 137302 | 137385 | #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| 137303 | 137386 | # define NDEBUG 1 |
| 137304 | 137387 | #endif |
| 137388 | + |
| 137389 | +/* FTS3/FTS4 require virtual tables */ |
| 137390 | +#ifdef SQLITE_OMIT_VIRTUALTABLE |
| 137391 | +# undef SQLITE_ENABLE_FTS3 |
| 137392 | +# undef SQLITE_ENABLE_FTS4 |
| 137393 | +#endif |
| 137305 | 137394 | |
| 137306 | 137395 | /* |
| 137307 | 137396 | ** FTS4 is really an extension for FTS3. It is enabled using the |
| 137308 | 137397 | ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all |
| 137309 | 137398 | ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. |
| | @@ -165637,11 +165726,15 @@ |
| 165637 | 165726 | /* #include <assert.h> */ |
| 165638 | 165727 | /* #include <string.h> */ |
| 165639 | 165728 | /* #include <stdlib.h> */ |
| 165640 | 165729 | /* #include <stdarg.h> */ |
| 165641 | 165730 | |
| 165642 | | -#define UNUSED_PARAM(X) (void)(X) |
| 165731 | +/* Mark a function parameter as unused, to suppress nuisance compiler |
| 165732 | +** warnings. */ |
| 165733 | +#ifndef UNUSED_PARAM |
| 165734 | +# define UNUSED_PARAM(X) (void)(X) |
| 165735 | +#endif |
| 165643 | 165736 | |
| 165644 | 165737 | #ifndef LARGEST_INT64 |
| 165645 | 165738 | # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) |
| 165646 | 165739 | # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) |
| 165647 | 165740 | #endif |
| | @@ -167158,10 +167251,11 @@ |
| 167158 | 167251 | sqlite3_context *ctx, |
| 167159 | 167252 | int argc, |
| 167160 | 167253 | sqlite3_value **argv |
| 167161 | 167254 | ){ |
| 167162 | 167255 | JsonString *pStr; |
| 167256 | + UNUSED_PARAM(argc); |
| 167163 | 167257 | pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); |
| 167164 | 167258 | if( pStr ){ |
| 167165 | 167259 | if( pStr->zBuf==0 ){ |
| 167166 | 167260 | jsonInit(pStr, ctx); |
| 167167 | 167261 | jsonAppendChar(pStr, '['); |
| | @@ -167203,10 +167297,11 @@ |
| 167203 | 167297 | sqlite3_value **argv |
| 167204 | 167298 | ){ |
| 167205 | 167299 | JsonString *pStr; |
| 167206 | 167300 | const char *z; |
| 167207 | 167301 | u32 n; |
| 167302 | + UNUSED_PARAM(argc); |
| 167208 | 167303 | pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); |
| 167209 | 167304 | if( pStr ){ |
| 167210 | 167305 | if( pStr->zBuf==0 ){ |
| 167211 | 167306 | jsonInit(pStr, ctx); |
| 167212 | 167307 | jsonAppendChar(pStr, '{'); |
| | @@ -168464,10 +168559,20 @@ |
| 168464 | 168559 | SQLITE_API extern int sqlite3_fts5_may_be_corrupt; |
| 168465 | 168560 | # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x)) |
| 168466 | 168561 | #else |
| 168467 | 168562 | # define assert_nc(x) assert(x) |
| 168468 | 168563 | #endif |
| 168564 | + |
| 168565 | +/* Mark a function parameter as unused, to suppress nuisance compiler |
| 168566 | +** warnings. */ |
| 168567 | +#ifndef UNUSED_PARAM |
| 168568 | +# define UNUSED_PARAM(X) (void)(X) |
| 168569 | +#endif |
| 168570 | + |
| 168571 | +#ifndef UNUSED_PARAM2 |
| 168572 | +# define UNUSED_PARAM2(X, Y) (void)(X), (void)(Y) |
| 168573 | +#endif |
| 168469 | 168574 | |
| 168470 | 168575 | typedef struct Fts5Global Fts5Global; |
| 168471 | 168576 | typedef struct Fts5Colset Fts5Colset; |
| 168472 | 168577 | |
| 168473 | 168578 | /* If a NEAR() clump or phrase may only match a specific set of columns, |
| | @@ -168730,20 +168835,10 @@ |
| 168730 | 168835 | ** Create/destroy an Fts5Index object. |
| 168731 | 168836 | */ |
| 168732 | 168837 | static int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**); |
| 168733 | 168838 | static int sqlite3Fts5IndexClose(Fts5Index *p); |
| 168734 | 168839 | |
| 168735 | | -/* |
| 168736 | | -** for( |
| 168737 | | -** sqlite3Fts5IndexQuery(p, "token", 5, 0, 0, &pIter); |
| 168738 | | -** 0==sqlite3Fts5IterEof(pIter); |
| 168739 | | -** sqlite3Fts5IterNext(pIter) |
| 168740 | | -** ){ |
| 168741 | | -** i64 iRowid = sqlite3Fts5IterRowid(pIter); |
| 168742 | | -** } |
| 168743 | | -*/ |
| 168744 | | - |
| 168745 | 168840 | /* |
| 168746 | 168841 | ** Return a simple checksum value based on the arguments. |
| 168747 | 168842 | */ |
| 168748 | 168843 | static u64 sqlite3Fts5IndexEntryCksum( |
| 168749 | 168844 | i64 iRowid, |
| | @@ -168781,11 +168876,10 @@ |
| 168781 | 168876 | ** The various operations on open token or token prefix iterators opened |
| 168782 | 168877 | ** using sqlite3Fts5IndexQuery(). |
| 168783 | 168878 | */ |
| 168784 | 168879 | static int sqlite3Fts5IterNext(Fts5IndexIter*); |
| 168785 | 168880 | static int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch); |
| 168786 | | -static i64 sqlite3Fts5IterRowid(Fts5IndexIter*); |
| 168787 | 168881 | |
| 168788 | 168882 | /* |
| 168789 | 168883 | ** Close an iterator opened by sqlite3Fts5IndexQuery(). |
| 168790 | 168884 | */ |
| 168791 | 168885 | static void sqlite3Fts5IterClose(Fts5IndexIter*); |
| | @@ -169066,11 +169160,11 @@ |
| 169066 | 169160 | Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int |
| 169067 | 169161 | ); |
| 169068 | 169162 | static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); |
| 169069 | 169163 | static void sqlite3Fts5ExprClearEof(Fts5Expr*); |
| 169070 | 169164 | |
| 169071 | | -static int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); |
| 169165 | +static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**); |
| 169072 | 169166 | |
| 169073 | 169167 | static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *); |
| 169074 | 169168 | |
| 169075 | 169169 | /******************************************* |
| 169076 | 169170 | ** The fts5_expr.c API above this point is used by the other hand-written |
| | @@ -169857,11 +169951,12 @@ |
| 169857 | 169951 | while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser); |
| 169858 | 169952 | /* Here code is inserted which will execute if the parser |
| 169859 | 169953 | ** stack every overflows */ |
| 169860 | 169954 | /******** Begin %stack_overflow code ******************************************/ |
| 169861 | 169955 | |
| 169862 | | - assert( 0 ); |
| 169956 | + UNUSED_PARAM(fts5yypMinor); /* Silence a compiler warning */ |
| 169957 | + sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow"); |
| 169863 | 169958 | /******** End %stack_overflow code ********************************************/ |
| 169864 | 169959 | sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 169865 | 169960 | } |
| 169866 | 169961 | |
| 169867 | 169962 | /* |
| | @@ -170154,10 +170249,11 @@ |
| 170154 | 170249 | ){ |
| 170155 | 170250 | sqlite3Fts5ParserARG_FETCH; |
| 170156 | 170251 | #define FTS5TOKEN (fts5yyminor.fts5yy0) |
| 170157 | 170252 | /************ Begin %syntax_error code ****************************************/ |
| 170158 | 170253 | |
| 170254 | + UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */ |
| 170159 | 170255 | sqlite3Fts5ParseError( |
| 170160 | 170256 | pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p |
| 170161 | 170257 | ); |
| 170162 | 170258 | /************ End %syntax_error code ******************************************/ |
| 170163 | 170259 | sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| | @@ -170530,10 +170626,12 @@ |
| 170530 | 170626 | int iEndOff /* End offset of token */ |
| 170531 | 170627 | ){ |
| 170532 | 170628 | HighlightContext *p = (HighlightContext*)pContext; |
| 170533 | 170629 | int rc = SQLITE_OK; |
| 170534 | 170630 | int iPos; |
| 170631 | + |
| 170632 | + UNUSED_PARAM2(pToken, nToken); |
| 170535 | 170633 | |
| 170536 | 170634 | if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK; |
| 170537 | 170635 | iPos = p->iPos++; |
| 170538 | 170636 | |
| 170539 | 170637 | if( p->iRangeEnd>0 ){ |
| | @@ -170764,10 +170862,11 @@ |
| 170764 | 170862 | const Fts5ExtensionApi *pApi, |
| 170765 | 170863 | Fts5Context *pFts, |
| 170766 | 170864 | void *pUserData /* Pointer to sqlite3_int64 variable */ |
| 170767 | 170865 | ){ |
| 170768 | 170866 | sqlite3_int64 *pn = (sqlite3_int64*)pUserData; |
| 170867 | + UNUSED_PARAM2(pApi, pFts); |
| 170769 | 170868 | (*pn)++; |
| 170770 | 170869 | return SQLITE_OK; |
| 170771 | 170870 | } |
| 170772 | 170871 | |
| 170773 | 170872 | /* |
| | @@ -171169,11 +171268,11 @@ |
| 171169 | 171268 | static int sqlite3Fts5PoslistWriterAppend( |
| 171170 | 171269 | Fts5Buffer *pBuf, |
| 171171 | 171270 | Fts5PoslistWriter *pWriter, |
| 171172 | 171271 | i64 iPos |
| 171173 | 171272 | ){ |
| 171174 | | - int rc; |
| 171273 | + int rc = 0; /* Initialized only to suppress erroneous warning from Clang */ |
| 171175 | 171274 | if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc; |
| 171176 | 171275 | sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos); |
| 171177 | 171276 | return SQLITE_OK; |
| 171178 | 171277 | } |
| 171179 | 171278 | |
| | @@ -171323,13 +171422,10 @@ |
| 171323 | 171422 | } |
| 171324 | 171423 | } |
| 171325 | 171424 | sqlite3_free(p); |
| 171326 | 171425 | } |
| 171327 | 171426 | } |
| 171328 | | - |
| 171329 | | - |
| 171330 | | - |
| 171331 | 171427 | |
| 171332 | 171428 | /* |
| 171333 | 171429 | ** 2014 Jun 09 |
| 171334 | 171430 | ** |
| 171335 | 171431 | ** The author disclaims copyright to this source code. In place of |
| | @@ -171535,11 +171631,11 @@ |
| 171535 | 171631 | static int fts5ConfigSetEnum( |
| 171536 | 171632 | const Fts5Enum *aEnum, |
| 171537 | 171633 | const char *zEnum, |
| 171538 | 171634 | int *peVal |
| 171539 | 171635 | ){ |
| 171540 | | - int nEnum = strlen(zEnum); |
| 171636 | + int nEnum = (int)strlen(zEnum); |
| 171541 | 171637 | int i; |
| 171542 | 171638 | int iVal = -1; |
| 171543 | 171639 | |
| 171544 | 171640 | for(i=0; aEnum[i].zName; i++){ |
| 171545 | 171641 | if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){ |
| | @@ -172273,11 +172369,10 @@ |
| 172273 | 172369 | pConfig->iCookie = iCookie; |
| 172274 | 172370 | } |
| 172275 | 172371 | return rc; |
| 172276 | 172372 | } |
| 172277 | 172373 | |
| 172278 | | - |
| 172279 | 172374 | /* |
| 172280 | 172375 | ** 2014 May 31 |
| 172281 | 172376 | ** |
| 172282 | 172377 | ** The author disclaims copyright to this source code. In place of |
| 172283 | 172378 | ** a legal notice, here is a blessing: |
| | @@ -172596,12 +172691,10 @@ |
| 172596 | 172691 | /* |
| 172597 | 172692 | ** Argument pTerm must be a synonym iterator. |
| 172598 | 172693 | */ |
| 172599 | 172694 | static int fts5ExprSynonymList( |
| 172600 | 172695 | Fts5ExprTerm *pTerm, |
| 172601 | | - int bCollist, |
| 172602 | | - Fts5Colset *pColset, |
| 172603 | 172696 | i64 iRowid, |
| 172604 | 172697 | Fts5Buffer *pBuf, /* Use this buffer for space if required */ |
| 172605 | 172698 | u8 **pa, int *pn |
| 172606 | 172699 | ){ |
| 172607 | 172700 | Fts5PoslistReader aStatic[4]; |
| | @@ -172681,11 +172774,10 @@ |
| 172681 | 172774 | ** otherwise. It is not considered an error code if the current rowid is |
| 172682 | 172775 | ** not a match. |
| 172683 | 172776 | */ |
| 172684 | 172777 | static int fts5ExprPhraseIsMatch( |
| 172685 | 172778 | Fts5ExprNode *pNode, /* Node pPhrase belongs to */ |
| 172686 | | - Fts5Colset *pColset, /* Restrict matches to these columns */ |
| 172687 | 172779 | Fts5ExprPhrase *pPhrase, /* Phrase object to initialize */ |
| 172688 | 172780 | int *pbMatch /* OUT: Set to true if really a match */ |
| 172689 | 172781 | ){ |
| 172690 | 172782 | Fts5PoslistWriter writer = {0}; |
| 172691 | 172783 | Fts5PoslistReader aStatic[4]; |
| | @@ -172710,13 +172802,11 @@ |
| 172710 | 172802 | int n = 0; |
| 172711 | 172803 | int bFlag = 0; |
| 172712 | 172804 | u8 *a = 0; |
| 172713 | 172805 | if( pTerm->pSynonym ){ |
| 172714 | 172806 | Fts5Buffer buf = {0, 0, 0}; |
| 172715 | | - rc = fts5ExprSynonymList( |
| 172716 | | - pTerm, 0, pColset, pNode->iRowid, &buf, &a, &n |
| 172717 | | - ); |
| 172807 | + rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n); |
| 172718 | 172808 | if( rc ){ |
| 172719 | 172809 | sqlite3_free(a); |
| 172720 | 172810 | goto ismatch_out; |
| 172721 | 172811 | } |
| 172722 | 172812 | if( a==buf.p ) bFlag = 1; |
| | @@ -173003,11 +173093,11 @@ |
| 173003 | 173093 | ** phrase is not a match, break out of the loop early. */ |
| 173004 | 173094 | for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){ |
| 173005 | 173095 | Fts5ExprPhrase *pPhrase = pNear->apPhrase[i]; |
| 173006 | 173096 | if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){ |
| 173007 | 173097 | int bMatch = 0; |
| 173008 | | - rc = fts5ExprPhraseIsMatch(pNode, pNear->pColset, pPhrase, &bMatch); |
| 173098 | + rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch); |
| 173009 | 173099 | if( bMatch==0 ) break; |
| 173010 | 173100 | }else{ |
| 173011 | 173101 | Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter; |
| 173012 | 173102 | fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData); |
| 173013 | 173103 | } |
| | @@ -173751,10 +173841,12 @@ |
| 173751 | 173841 | ){ |
| 173752 | 173842 | int rc = SQLITE_OK; |
| 173753 | 173843 | const int SZALLOC = 8; |
| 173754 | 173844 | TokenCtx *pCtx = (TokenCtx*)pContext; |
| 173755 | 173845 | Fts5ExprPhrase *pPhrase = pCtx->pPhrase; |
| 173846 | + |
| 173847 | + UNUSED_PARAM2(iUnused1, iUnused2); |
| 173756 | 173848 | |
| 173757 | 173849 | /* If an error has already occurred, this is a no-op */ |
| 173758 | 173850 | if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; |
| 173759 | 173851 | |
| 173760 | 173852 | assert( pPhrase==0 || pPhrase->nTerm>0 ); |
| | @@ -173887,26 +173979,21 @@ |
| 173887 | 173979 | /* |
| 173888 | 173980 | ** Create a new FTS5 expression by cloning phrase iPhrase of the |
| 173889 | 173981 | ** expression passed as the second argument. |
| 173890 | 173982 | */ |
| 173891 | 173983 | static int sqlite3Fts5ExprClonePhrase( |
| 173892 | | - Fts5Config *pConfig, |
| 173893 | 173984 | Fts5Expr *pExpr, |
| 173894 | 173985 | int iPhrase, |
| 173895 | 173986 | Fts5Expr **ppNew |
| 173896 | 173987 | ){ |
| 173897 | 173988 | int rc = SQLITE_OK; /* Return code */ |
| 173898 | 173989 | Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */ |
| 173899 | 173990 | int i; /* Used to iterate through phrase terms */ |
| 173900 | | - |
| 173901 | 173991 | Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ |
| 173902 | | - |
| 173903 | 173992 | TokenCtx sCtx = {0,0}; /* Context object for fts5ParseTokenize */ |
| 173904 | 173993 | |
| 173905 | | - |
| 173906 | 173994 | pOrig = pExpr->apExprPhrase[iPhrase]; |
| 173907 | | - |
| 173908 | 173995 | pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr)); |
| 173909 | 173996 | if( rc==SQLITE_OK ){ |
| 173910 | 173997 | pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, |
| 173911 | 173998 | sizeof(Fts5ExprPhrase*)); |
| 173912 | 173999 | } |
| | @@ -174675,16 +174762,18 @@ |
| 174675 | 174762 | static int fts5ExprPopulatePoslistsCb( |
| 174676 | 174763 | void *pCtx, /* Copy of 2nd argument to xTokenize() */ |
| 174677 | 174764 | int tflags, /* Mask of FTS5_TOKEN_* flags */ |
| 174678 | 174765 | const char *pToken, /* Pointer to buffer containing token */ |
| 174679 | 174766 | int nToken, /* Size of token in bytes */ |
| 174680 | | - int iStart, /* Byte offset of token within input text */ |
| 174681 | | - int iEnd /* Byte offset of end of token within input text */ |
| 174767 | + int iUnused1, /* Byte offset of token within input text */ |
| 174768 | + int iUnused2 /* Byte offset of end of token within input text */ |
| 174682 | 174769 | ){ |
| 174683 | 174770 | Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx; |
| 174684 | 174771 | Fts5Expr *pExpr = p->pExpr; |
| 174685 | 174772 | int i; |
| 174773 | + |
| 174774 | + UNUSED_PARAM2(iUnused1, iUnused2); |
| 174686 | 174775 | |
| 174687 | 174776 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; |
| 174688 | 174777 | for(i=0; i<pExpr->nPhrase; i++){ |
| 174689 | 174778 | Fts5ExprTerm *pTerm; |
| 174690 | 174779 | if( p->aPopulator[i].bOk==0 ) continue; |
| | @@ -174826,11 +174915,11 @@ |
| 174826 | 174915 | ){ |
| 174827 | 174916 | Fts5ExprTerm *pTerm = &pPhrase->aTerm[0]; |
| 174828 | 174917 | if( pTerm->pSynonym ){ |
| 174829 | 174918 | Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1]; |
| 174830 | 174919 | rc = fts5ExprSynonymList( |
| 174831 | | - pTerm, 1, 0, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist |
| 174920 | + pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist |
| 174832 | 174921 | ); |
| 174833 | 174922 | }else{ |
| 174834 | 174923 | *ppCollist = pPhrase->aTerm[0].pIter->pData; |
| 174835 | 174924 | *pnCollist = pPhrase->aTerm[0].pIter->nData; |
| 174836 | 174925 | } |
| | @@ -175977,21 +176066,10 @@ |
| 175977 | 176066 | int nCmp = MIN(pLeft->n, pRight->n); |
| 175978 | 176067 | int res = memcmp(pLeft->p, pRight->p, nCmp); |
| 175979 | 176068 | return (res==0 ? (pLeft->n - pRight->n) : res); |
| 175980 | 176069 | } |
| 175981 | 176070 | |
| 175982 | | -#ifdef SQLITE_DEBUG |
| 175983 | | -static int fts5BlobCompare( |
| 175984 | | - const u8 *pLeft, int nLeft, |
| 175985 | | - const u8 *pRight, int nRight |
| 175986 | | -){ |
| 175987 | | - int nCmp = MIN(nLeft, nRight); |
| 175988 | | - int res = memcmp(pLeft, pRight, nCmp); |
| 175989 | | - return (res==0 ? (nLeft - nRight) : res); |
| 175990 | | -} |
| 175991 | | -#endif |
| 175992 | | - |
| 175993 | 176071 | static int fts5LeafFirstTermOff(Fts5Data *pLeaf){ |
| 175994 | 176072 | int ret; |
| 175995 | 176073 | fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret); |
| 175996 | 176074 | return ret; |
| 175997 | 176075 | } |
| | @@ -176249,28 +176327,37 @@ |
| 176249 | 176327 | for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){ |
| 176250 | 176328 | Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl]; |
| 176251 | 176329 | int nTotal; |
| 176252 | 176330 | int iSeg; |
| 176253 | 176331 | |
| 176254 | | - i += fts5GetVarint32(&pData[i], pLvl->nMerge); |
| 176255 | | - i += fts5GetVarint32(&pData[i], nTotal); |
| 176256 | | - assert( nTotal>=pLvl->nMerge ); |
| 176257 | | - pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, |
| 176258 | | - nTotal * sizeof(Fts5StructureSegment) |
| 176259 | | - ); |
| 176332 | + if( i>=nData ){ |
| 176333 | + rc = FTS5_CORRUPT; |
| 176334 | + }else{ |
| 176335 | + i += fts5GetVarint32(&pData[i], pLvl->nMerge); |
| 176336 | + i += fts5GetVarint32(&pData[i], nTotal); |
| 176337 | + assert( nTotal>=pLvl->nMerge ); |
| 176338 | + pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, |
| 176339 | + nTotal * sizeof(Fts5StructureSegment) |
| 176340 | + ); |
| 176341 | + } |
| 176260 | 176342 | |
| 176261 | 176343 | if( rc==SQLITE_OK ){ |
| 176262 | 176344 | pLvl->nSeg = nTotal; |
| 176263 | 176345 | for(iSeg=0; iSeg<nTotal; iSeg++){ |
| 176346 | + if( i>=nData ){ |
| 176347 | + rc = FTS5_CORRUPT; |
| 176348 | + break; |
| 176349 | + } |
| 176264 | 176350 | i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid); |
| 176265 | 176351 | i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst); |
| 176266 | 176352 | i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast); |
| 176267 | 176353 | } |
| 176268 | | - }else{ |
| 176269 | | - fts5StructureRelease(pRet); |
| 176270 | | - pRet = 0; |
| 176271 | 176354 | } |
| 176355 | + } |
| 176356 | + if( rc!=SQLITE_OK ){ |
| 176357 | + fts5StructureRelease(pRet); |
| 176358 | + pRet = 0; |
| 176272 | 176359 | } |
| 176273 | 176360 | } |
| 176274 | 176361 | |
| 176275 | 176362 | *ppOut = pRet; |
| 176276 | 176363 | return rc; |
| | @@ -176934,10 +177021,14 @@ |
| 176934 | 177021 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 176935 | 177022 | int iOff = pIter->iLeafOffset; /* Offset to read at */ |
| 176936 | 177023 | int nNew; /* Bytes of new data */ |
| 176937 | 177024 | |
| 176938 | 177025 | iOff += fts5GetVarint32(&a[iOff], nNew); |
| 177026 | + if( iOff+nNew>pIter->pLeaf->nn ){ |
| 177027 | + p->rc = FTS5_CORRUPT; |
| 177028 | + return; |
| 177029 | + } |
| 176939 | 177030 | pIter->term.n = nKeep; |
| 176940 | 177031 | fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]); |
| 176941 | 177032 | iOff += nNew; |
| 176942 | 177033 | pIter->iTermLeafOffset = iOff; |
| 176943 | 177034 | pIter->iTermLeafPgno = pIter->iLeafPgno; |
| | @@ -177140,14 +177231,16 @@ |
| 177140 | 177231 | ** This version of fts5SegIterNext() is only used by reverse iterators. |
| 177141 | 177232 | */ |
| 177142 | 177233 | static void fts5SegIterNext_Reverse( |
| 177143 | 177234 | Fts5Index *p, /* FTS5 backend object */ |
| 177144 | 177235 | Fts5SegIter *pIter, /* Iterator to advance */ |
| 177145 | | - int *pbNewTerm /* OUT: Set for new term */ |
| 177236 | + int *pbUnused /* Unused */ |
| 177146 | 177237 | ){ |
| 177147 | 177238 | assert( pIter->flags & FTS5_SEGITER_REVERSE ); |
| 177148 | 177239 | assert( pIter->pNextLeaf==0 ); |
| 177240 | + UNUSED_PARAM(pbUnused); |
| 177241 | + |
| 177149 | 177242 | if( pIter->iRowidOffset>0 ){ |
| 177150 | 177243 | u8 *a = pIter->pLeaf->p; |
| 177151 | 177244 | int iOff; |
| 177152 | 177245 | i64 iDelta; |
| 177153 | 177246 | |
| | @@ -177620,11 +177713,10 @@ |
| 177620 | 177713 | ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If |
| 177621 | 177714 | ** an error has already occurred when this function is called, it is a no-op. |
| 177622 | 177715 | */ |
| 177623 | 177716 | static void fts5SegIterSeekInit( |
| 177624 | 177717 | Fts5Index *p, /* FTS5 backend */ |
| 177625 | | - Fts5Buffer *pBuf, /* Buffer to use for loading pages */ |
| 177626 | 177718 | const u8 *pTerm, int nTerm, /* Term to seek to */ |
| 177627 | 177719 | int flags, /* Mask of FTS5INDEX_XXX flags */ |
| 177628 | 177720 | Fts5StructureSegment *pSeg, /* Description of segment */ |
| 177629 | 177721 | Fts5SegIter *pIter /* Object to populate */ |
| 177630 | 177722 | ){ |
| | @@ -178007,11 +178099,11 @@ |
| 178007 | 178099 | |
| 178008 | 178100 | |
| 178009 | 178101 | /* |
| 178010 | 178102 | ** Free the iterator object passed as the second argument. |
| 178011 | 178103 | */ |
| 178012 | | -static void fts5MultiIterFree(Fts5Index *p, Fts5Iter *pIter){ |
| 178104 | +static void fts5MultiIterFree(Fts5Iter *pIter){ |
| 178013 | 178105 | if( pIter ){ |
| 178014 | 178106 | int i; |
| 178015 | 178107 | for(i=0; i<pIter->nSeg; i++){ |
| 178016 | 178108 | fts5SegIterClear(&pIter->aSeg[i]); |
| 178017 | 178109 | } |
| | @@ -178048,11 +178140,10 @@ |
| 178048 | 178140 | ** If non-zero is returned, the caller should call fts5MultiIterAdvanced() |
| 178049 | 178141 | ** on the iterator instead. That function does the same as this one, except |
| 178050 | 178142 | ** that it deals with more complicated cases as well. |
| 178051 | 178143 | */ |
| 178052 | 178144 | static int fts5MultiIterAdvanceRowid( |
| 178053 | | - Fts5Index *p, /* FTS5 backend to iterate within */ |
| 178054 | 178145 | Fts5Iter *pIter, /* Iterator to update aFirst[] array for */ |
| 178055 | 178146 | int iChanged, /* Index of sub-iterator just advanced */ |
| 178056 | 178147 | Fts5SegIter **ppFirst |
| 178057 | 178148 | ){ |
| 178058 | 178149 | Fts5SegIter *pNew = &pIter->aSeg[iChanged]; |
| | @@ -178123,11 +178214,11 @@ |
| 178123 | 178214 | }else{ |
| 178124 | 178215 | pSeg->xNext(p, pSeg, &bNewTerm); |
| 178125 | 178216 | } |
| 178126 | 178217 | |
| 178127 | 178218 | if( pSeg->pLeaf==0 || bNewTerm |
| 178128 | | - || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg) |
| 178219 | + || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg) |
| 178129 | 178220 | ){ |
| 178130 | 178221 | fts5MultiIterAdvanced(p, pIter, iFirst, 1); |
| 178131 | 178222 | fts5MultiIterSetEof(pIter); |
| 178132 | 178223 | pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst]; |
| 178133 | 178224 | if( pSeg->pLeaf==0 ) return; |
| | @@ -178156,11 +178247,11 @@ |
| 178156 | 178247 | int bNewTerm = 0; |
| 178157 | 178248 | |
| 178158 | 178249 | assert( p->rc==SQLITE_OK ); |
| 178159 | 178250 | pSeg->xNext(p, pSeg, &bNewTerm); |
| 178160 | 178251 | if( pSeg->pLeaf==0 || bNewTerm |
| 178161 | | - || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg) |
| 178252 | + || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg) |
| 178162 | 178253 | ){ |
| 178163 | 178254 | fts5MultiIterAdvanced(p, pIter, iFirst, 1); |
| 178164 | 178255 | fts5MultiIterSetEof(pIter); |
| 178165 | 178256 | *pbNewTerm = 1; |
| 178166 | 178257 | }else{ |
| | @@ -178170,11 +178261,12 @@ |
| 178170 | 178261 | |
| 178171 | 178262 | }while( fts5MultiIterIsEmpty(p, pIter) ); |
| 178172 | 178263 | } |
| 178173 | 178264 | } |
| 178174 | 178265 | |
| 178175 | | -static void fts5IterSetOutputs_Noop(Fts5Iter *pIter, Fts5SegIter *pSeg){ |
| 178266 | +static void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){ |
| 178267 | + UNUSED_PARAM2(pUnused1, pUnused2); |
| 178176 | 178268 | } |
| 178177 | 178269 | |
| 178178 | 178270 | static Fts5Iter *fts5MultiIterAlloc( |
| 178179 | 178271 | Fts5Index *p, /* FTS5 backend to iterate within */ |
| 178180 | 178272 | int nSeg |
| | @@ -178196,14 +178288,15 @@ |
| 178196 | 178288 | } |
| 178197 | 178289 | return pNew; |
| 178198 | 178290 | } |
| 178199 | 178291 | |
| 178200 | 178292 | static void fts5PoslistCallback( |
| 178201 | | - Fts5Index *p, |
| 178293 | + Fts5Index *pUnused, |
| 178202 | 178294 | void *pContext, |
| 178203 | 178295 | const u8 *pChunk, int nChunk |
| 178204 | 178296 | ){ |
| 178297 | + UNUSED_PARAM(pUnused); |
| 178205 | 178298 | assert_nc( nChunk>=0 ); |
| 178206 | 178299 | if( nChunk>0 ){ |
| 178207 | 178300 | fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk); |
| 178208 | 178301 | } |
| 178209 | 178302 | } |
| | @@ -178233,15 +178326,16 @@ |
| 178233 | 178326 | } |
| 178234 | 178327 | return 0; |
| 178235 | 178328 | } |
| 178236 | 178329 | |
| 178237 | 178330 | static void fts5PoslistOffsetsCallback( |
| 178238 | | - Fts5Index *p, |
| 178331 | + Fts5Index *pUnused, |
| 178239 | 178332 | void *pContext, |
| 178240 | 178333 | const u8 *pChunk, int nChunk |
| 178241 | 178334 | ){ |
| 178242 | 178335 | PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext; |
| 178336 | + UNUSED_PARAM(pUnused); |
| 178243 | 178337 | assert_nc( nChunk>=0 ); |
| 178244 | 178338 | if( nChunk>0 ){ |
| 178245 | 178339 | int i = 0; |
| 178246 | 178340 | while( i<nChunk ){ |
| 178247 | 178341 | int iVal; |
| | @@ -178255,15 +178349,16 @@ |
| 178255 | 178349 | } |
| 178256 | 178350 | } |
| 178257 | 178351 | } |
| 178258 | 178352 | |
| 178259 | 178353 | static void fts5PoslistFilterCallback( |
| 178260 | | - Fts5Index *p, |
| 178354 | + Fts5Index *pUnused, |
| 178261 | 178355 | void *pContext, |
| 178262 | 178356 | const u8 *pChunk, int nChunk |
| 178263 | 178357 | ){ |
| 178264 | 178358 | PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext; |
| 178359 | + UNUSED_PARAM(pUnused); |
| 178265 | 178360 | assert_nc( nChunk>=0 ); |
| 178266 | 178361 | if( nChunk>0 ){ |
| 178267 | 178362 | /* Search through to find the first varint with value 1. This is the |
| 178268 | 178363 | ** start of the next columns hits. */ |
| 178269 | 178364 | int i = 0; |
| | @@ -178623,11 +178718,10 @@ |
| 178623 | 178718 | Fts5Iter **ppOut /* New object */ |
| 178624 | 178719 | ){ |
| 178625 | 178720 | int nSeg = 0; /* Number of segment-iters in use */ |
| 178626 | 178721 | int iIter = 0; /* */ |
| 178627 | 178722 | int iSeg; /* Used to iterate through segments */ |
| 178628 | | - Fts5Buffer buf = {0,0,0}; /* Buffer used by fts5SegIterSeekInit() */ |
| 178629 | 178723 | Fts5StructureLevel *pLvl; |
| 178630 | 178724 | Fts5Iter *pNew; |
| 178631 | 178725 | |
| 178632 | 178726 | assert( (pTerm==0 && nTerm==0) || iLevel<0 ); |
| 178633 | 178727 | |
| | @@ -178666,11 +178760,11 @@ |
| 178666 | 178760 | Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg]; |
| 178667 | 178761 | Fts5SegIter *pIter = &pNew->aSeg[iIter++]; |
| 178668 | 178762 | if( pTerm==0 ){ |
| 178669 | 178763 | fts5SegIterInit(p, pSeg, pIter); |
| 178670 | 178764 | }else{ |
| 178671 | | - fts5SegIterSeekInit(p, &buf, pTerm, nTerm, flags, pSeg, pIter); |
| 178765 | + fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter); |
| 178672 | 178766 | } |
| 178673 | 178767 | } |
| 178674 | 178768 | } |
| 178675 | 178769 | }else{ |
| 178676 | 178770 | pLvl = &pStruct->aLevel[iLevel]; |
| | @@ -178703,15 +178797,13 @@ |
| 178703 | 178797 | Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst]; |
| 178704 | 178798 | pNew->xSetOutputs(pNew, pSeg); |
| 178705 | 178799 | } |
| 178706 | 178800 | |
| 178707 | 178801 | }else{ |
| 178708 | | - fts5MultiIterFree(p, pNew); |
| 178802 | + fts5MultiIterFree(pNew); |
| 178709 | 178803 | *ppOut = 0; |
| 178710 | 178804 | } |
| 178711 | | - fts5BufferFree(&buf); |
| 178712 | | - |
| 178713 | 178805 | } |
| 178714 | 178806 | |
| 178715 | 178807 | /* |
| 178716 | 178808 | ** Create an Fts5Iter that iterates through the doclist provided |
| 178717 | 178809 | ** as the second argument. |
| | @@ -178845,19 +178937,18 @@ |
| 178845 | 178937 | p->nPendingData = 0; |
| 178846 | 178938 | } |
| 178847 | 178939 | } |
| 178848 | 178940 | |
| 178849 | 178941 | /* |
| 178850 | | -** Return the size of the prefix, in bytes, that buffer (nNew/pNew) shares |
| 178851 | | -** with buffer (nOld/pOld). |
| 178942 | +** Return the size of the prefix, in bytes, that buffer |
| 178943 | +** (pNew/<length-unknown>) shares with buffer (pOld/nOld). |
| 178944 | +** |
| 178945 | +** Buffer (pNew/<length-unknown>) is guaranteed to be greater |
| 178946 | +** than buffer (pOld/nOld). |
| 178852 | 178947 | */ |
| 178853 | | -static int fts5PrefixCompress( |
| 178854 | | - int nOld, const u8 *pOld, |
| 178855 | | - int nNew, const u8 *pNew |
| 178856 | | -){ |
| 178948 | +static int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){ |
| 178857 | 178949 | int i; |
| 178858 | | - assert( fts5BlobCompare(pOld, nOld, pNew, nNew)<0 ); |
| 178859 | 178950 | for(i=0; i<nOld; i++){ |
| 178860 | 178951 | if( pOld[i]!=pNew[i] ) break; |
| 178861 | 178952 | } |
| 178862 | 178953 | return i; |
| 178863 | 178954 | } |
| | @@ -179163,17 +179254,17 @@ |
| 179163 | 179254 | ** In this case the previous term is not available, so just write a |
| 179164 | 179255 | ** copy of (pTerm/nTerm) into the parent node. This is slightly |
| 179165 | 179256 | ** inefficient, but still correct. */ |
| 179166 | 179257 | int n = nTerm; |
| 179167 | 179258 | if( pPage->term.n ){ |
| 179168 | | - n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm); |
| 179259 | + n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm); |
| 179169 | 179260 | } |
| 179170 | 179261 | fts5WriteBtreeTerm(p, pWriter, n, pTerm); |
| 179171 | 179262 | pPage = &pWriter->writer; |
| 179172 | 179263 | } |
| 179173 | 179264 | }else{ |
| 179174 | | - nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm); |
| 179265 | + nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm); |
| 179175 | 179266 | fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix); |
| 179176 | 179267 | } |
| 179177 | 179268 | |
| 179178 | 179269 | /* Append the number of bytes of new data, then the term data itself |
| 179179 | 179270 | ** to the page. */ |
| | @@ -179535,11 +179626,11 @@ |
| 179535 | 179626 | assert( pSeg->pgnoLast>0 ); |
| 179536 | 179627 | fts5TrimSegments(p, pIter); |
| 179537 | 179628 | pLvl->nMerge = nInput; |
| 179538 | 179629 | } |
| 179539 | 179630 | |
| 179540 | | - fts5MultiIterFree(p, pIter); |
| 179631 | + fts5MultiIterFree(pIter); |
| 179541 | 179632 | fts5BufferFree(&term); |
| 179542 | 179633 | if( pnRem ) *pnRem -= writer.nLeafWritten; |
| 179543 | 179634 | } |
| 179544 | 179635 | |
| 179545 | 179636 | /* |
| | @@ -179911,13 +180002,14 @@ |
| 179911 | 180002 | } |
| 179912 | 180003 | |
| 179913 | 180004 | static void fts5AppendRowid( |
| 179914 | 180005 | Fts5Index *p, |
| 179915 | 180006 | i64 iDelta, |
| 179916 | | - Fts5Iter *pMulti, |
| 180007 | + Fts5Iter *pUnused, |
| 179917 | 180008 | Fts5Buffer *pBuf |
| 179918 | 180009 | ){ |
| 180010 | + UNUSED_PARAM(pUnused); |
| 179919 | 180011 | fts5BufferAppendVarint(&p->rc, pBuf, iDelta); |
| 179920 | 180012 | } |
| 179921 | 180013 | |
| 179922 | 180014 | static void fts5AppendPoslist( |
| 179923 | 180015 | Fts5Index *p, |
| | @@ -180256,11 +180348,11 @@ |
| 180256 | 180348 | if( p->rc==SQLITE_OK ){ |
| 180257 | 180349 | xMerge(p, &doclist, &aBuf[i]); |
| 180258 | 180350 | } |
| 180259 | 180351 | fts5BufferFree(&aBuf[i]); |
| 180260 | 180352 | } |
| 180261 | | - fts5MultiIterFree(p, p1); |
| 180353 | + fts5MultiIterFree(p1); |
| 180262 | 180354 | |
| 180263 | 180355 | pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n); |
| 180264 | 180356 | if( pData ){ |
| 180265 | 180357 | pData->p = (u8*)&pData[1]; |
| 180266 | 180358 | pData->nn = pData->szLeaf = doclist.n; |
| | @@ -180537,11 +180629,11 @@ |
| 180537 | 180629 | }else{ |
| 180538 | 180630 | /* Scan multiple terms in the main index */ |
| 180539 | 180631 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; |
| 180540 | 180632 | buf.p[0] = FTS5_MAIN_PREFIX; |
| 180541 | 180633 | fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet); |
| 180542 | | - assert( pRet->pColset==0 ); |
| 180634 | + assert( p->rc!=SQLITE_OK || pRet->pColset==0 ); |
| 180543 | 180635 | fts5IterSetOutputCb(&p->rc, pRet); |
| 180544 | 180636 | if( p->rc==SQLITE_OK ){ |
| 180545 | 180637 | Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst]; |
| 180546 | 180638 | if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg); |
| 180547 | 180639 | } |
| | @@ -180620,11 +180712,11 @@ |
| 180620 | 180712 | */ |
| 180621 | 180713 | static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){ |
| 180622 | 180714 | if( pIndexIter ){ |
| 180623 | 180715 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 180624 | 180716 | Fts5Index *pIndex = pIter->pIndex; |
| 180625 | | - fts5MultiIterFree(pIter->pIndex, pIter); |
| 180717 | + fts5MultiIterFree(pIter); |
| 180626 | 180718 | fts5CloseReader(pIndex); |
| 180627 | 180719 | } |
| 180628 | 180720 | } |
| 180629 | 180721 | |
| 180630 | 180722 | /* |
| | @@ -181179,11 +181271,11 @@ |
| 181179 | 181271 | } |
| 181180 | 181272 | } |
| 181181 | 181273 | } |
| 181182 | 181274 | fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3); |
| 181183 | 181275 | |
| 181184 | | - fts5MultiIterFree(p, pIter); |
| 181276 | + fts5MultiIterFree(pIter); |
| 181185 | 181277 | if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT; |
| 181186 | 181278 | |
| 181187 | 181279 | fts5StructureRelease(pStruct); |
| 181188 | 181280 | #ifdef SQLITE_DEBUG |
| 181189 | 181281 | fts5BufferFree(&term); |
| | @@ -181416,10 +181508,11 @@ |
| 181416 | 181508 | int rc = SQLITE_OK; /* Return code */ |
| 181417 | 181509 | int nSpace = 0; |
| 181418 | 181510 | int eDetailNone = (sqlite3_user_data(pCtx)!=0); |
| 181419 | 181511 | |
| 181420 | 181512 | assert( nArg==2 ); |
| 181513 | + UNUSED_PARAM(nArg); |
| 181421 | 181514 | memset(&s, 0, sizeof(Fts5Buffer)); |
| 181422 | 181515 | iRowid = sqlite3_value_int64(apVal[0]); |
| 181423 | 181516 | |
| 181424 | 181517 | /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[] |
| 181425 | 181518 | ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents |
| | @@ -182744,11 +182837,11 @@ |
| 182744 | 182837 | ** 3. A full-table scan. |
| 182745 | 182838 | */ |
| 182746 | 182839 | static int fts5FilterMethod( |
| 182747 | 182840 | sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ |
| 182748 | 182841 | int idxNum, /* Strategy index */ |
| 182749 | | - const char *idxStr, /* Unused */ |
| 182842 | + const char *zUnused, /* Unused */ |
| 182750 | 182843 | int nVal, /* Number of elements in apVal */ |
| 182751 | 182844 | sqlite3_value **apVal /* Arguments for the indexing scheme */ |
| 182752 | 182845 | ){ |
| 182753 | 182846 | Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab); |
| 182754 | 182847 | Fts5Config *pConfig = pTab->pConfig; |
| | @@ -182761,10 +182854,13 @@ |
| 182761 | 182854 | sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */ |
| 182762 | 182855 | sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */ |
| 182763 | 182856 | sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */ |
| 182764 | 182857 | sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */ |
| 182765 | 182858 | char **pzErrmsg = pConfig->pzErrmsg; |
| 182859 | + |
| 182860 | + UNUSED_PARAM(zUnused); |
| 182861 | + UNUSED_PARAM(nVal); |
| 182766 | 182862 | |
| 182767 | 182863 | if( pCsr->ePlan ){ |
| 182768 | 182864 | fts5FreeCursorComponents(pCsr); |
| 182769 | 182865 | memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr)); |
| 182770 | 182866 | } |
| | @@ -183046,12 +183142,11 @@ |
| 183046 | 183142 | return rc; |
| 183047 | 183143 | } |
| 183048 | 183144 | |
| 183049 | 183145 | static int fts5SpecialDelete( |
| 183050 | 183146 | Fts5Table *pTab, |
| 183051 | | - sqlite3_value **apVal, |
| 183052 | | - sqlite3_int64 *piRowid |
| 183147 | + sqlite3_value **apVal |
| 183053 | 183148 | ){ |
| 183054 | 183149 | int rc = SQLITE_OK; |
| 183055 | 183150 | int eType1 = sqlite3_value_type(apVal[1]); |
| 183056 | 183151 | if( eType1==SQLITE_INTEGER ){ |
| 183057 | 183152 | sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]); |
| | @@ -183123,11 +183218,11 @@ |
| 183123 | 183218 | /* A "special" INSERT op. These are handled separately. */ |
| 183124 | 183219 | const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]); |
| 183125 | 183220 | if( pConfig->eContent!=FTS5_CONTENT_NORMAL |
| 183126 | 183221 | && 0==sqlite3_stricmp("delete", z) |
| 183127 | 183222 | ){ |
| 183128 | | - rc = fts5SpecialDelete(pTab, apVal, pRowid); |
| 183223 | + rc = fts5SpecialDelete(pTab, apVal); |
| 183129 | 183224 | }else{ |
| 183130 | 183225 | rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]); |
| 183131 | 183226 | } |
| 183132 | 183227 | }else{ |
| 183133 | 183228 | /* A regular INSERT, UPDATE or DELETE statement. The trick here is that |
| | @@ -183224,10 +183319,11 @@ |
| 183224 | 183319 | |
| 183225 | 183320 | /* |
| 183226 | 183321 | ** Implementation of xBegin() method. |
| 183227 | 183322 | */ |
| 183228 | 183323 | static int fts5BeginMethod(sqlite3_vtab *pVtab){ |
| 183324 | + UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */ |
| 183229 | 183325 | fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0); |
| 183230 | 183326 | return SQLITE_OK; |
| 183231 | 183327 | } |
| 183232 | 183328 | |
| 183233 | 183329 | /* |
| | @@ -183234,10 +183330,11 @@ |
| 183234 | 183330 | ** Implementation of xCommit() method. This is a no-op. The contents of |
| 183235 | 183331 | ** the pending-terms hash-table have already been flushed into the database |
| 183236 | 183332 | ** by fts5SyncMethod(). |
| 183237 | 183333 | */ |
| 183238 | 183334 | static int fts5CommitMethod(sqlite3_vtab *pVtab){ |
| 183335 | + UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */ |
| 183239 | 183336 | fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0); |
| 183240 | 183337 | return SQLITE_OK; |
| 183241 | 183338 | } |
| 183242 | 183339 | |
| 183243 | 183340 | /* |
| | @@ -183487,16 +183584,18 @@ |
| 183487 | 183584 | } |
| 183488 | 183585 | |
| 183489 | 183586 | static int fts5ColumnSizeCb( |
| 183490 | 183587 | void *pContext, /* Pointer to int */ |
| 183491 | 183588 | int tflags, |
| 183492 | | - const char *pToken, /* Buffer containing token */ |
| 183493 | | - int nToken, /* Size of token in bytes */ |
| 183494 | | - int iStart, /* Start offset of token */ |
| 183495 | | - int iEnd /* End offset of token */ |
| 183589 | + const char *pUnused, /* Buffer containing token */ |
| 183590 | + int nUnused, /* Size of token in bytes */ |
| 183591 | + int iUnused1, /* Start offset of token */ |
| 183592 | + int iUnused2 /* End offset of token */ |
| 183496 | 183593 | ){ |
| 183497 | 183594 | int *pCnt = (int*)pContext; |
| 183595 | + UNUSED_PARAM2(pUnused, nUnused); |
| 183596 | + UNUSED_PARAM2(iUnused1, iUnused2); |
| 183498 | 183597 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){ |
| 183499 | 183598 | (*pCnt)++; |
| 183500 | 183599 | } |
| 183501 | 183600 | return SQLITE_OK; |
| 183502 | 183601 | } |
| | @@ -183608,14 +183707,15 @@ |
| 183608 | 183707 | |
| 183609 | 183708 | return pRet; |
| 183610 | 183709 | } |
| 183611 | 183710 | |
| 183612 | 183711 | static void fts5ApiPhraseNext( |
| 183613 | | - Fts5Context *pCtx, |
| 183712 | + Fts5Context *pUnused, |
| 183614 | 183713 | Fts5PhraseIter *pIter, |
| 183615 | 183714 | int *piCol, int *piOff |
| 183616 | 183715 | ){ |
| 183716 | + UNUSED_PARAM(pUnused); |
| 183617 | 183717 | if( pIter->a>=pIter->b ){ |
| 183618 | 183718 | *piCol = -1; |
| 183619 | 183719 | *piOff = -1; |
| 183620 | 183720 | }else{ |
| 183621 | 183721 | int iVal; |
| | @@ -183763,16 +183863,15 @@ |
| 183763 | 183863 | int rc; |
| 183764 | 183864 | Fts5Cursor *pNew = 0; |
| 183765 | 183865 | |
| 183766 | 183866 | rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew); |
| 183767 | 183867 | if( rc==SQLITE_OK ){ |
| 183768 | | - Fts5Config *pConf = pTab->pConfig; |
| 183769 | 183868 | pNew->ePlan = FTS5_PLAN_MATCH; |
| 183770 | 183869 | pNew->iFirstRowid = SMALLEST_INT64; |
| 183771 | 183870 | pNew->iLastRowid = LARGEST_INT64; |
| 183772 | 183871 | pNew->base.pVtab = (sqlite3_vtab*)pTab; |
| 183773 | | - rc = sqlite3Fts5ExprClonePhrase(pConf, pCsr->pExpr, iPhrase, &pNew->pExpr); |
| 183872 | + rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr); |
| 183774 | 183873 | } |
| 183775 | 183874 | |
| 183776 | 183875 | if( rc==SQLITE_OK ){ |
| 183777 | 183876 | for(rc = fts5CursorFirst(pTab, pNew, 0); |
| 183778 | 183877 | rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0; |
| | @@ -183981,18 +184080,19 @@ |
| 183981 | 184080 | ** This routine implements the xFindFunction method for the FTS3 |
| 183982 | 184081 | ** virtual table. |
| 183983 | 184082 | */ |
| 183984 | 184083 | static int fts5FindFunctionMethod( |
| 183985 | 184084 | sqlite3_vtab *pVtab, /* Virtual table handle */ |
| 183986 | | - int nArg, /* Number of SQL function arguments */ |
| 184085 | + int nUnused, /* Number of SQL function arguments */ |
| 183987 | 184086 | const char *zName, /* Name of SQL function */ |
| 183988 | 184087 | void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */ |
| 183989 | 184088 | void **ppArg /* OUT: User data for *pxFunc */ |
| 183990 | 184089 | ){ |
| 183991 | 184090 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 183992 | 184091 | Fts5Auxiliary *pAux; |
| 183993 | 184092 | |
| 184093 | + UNUSED_PARAM(nUnused); |
| 183994 | 184094 | pAux = fts5FindAuxiliary(pTab, zName); |
| 183995 | 184095 | if( pAux ){ |
| 183996 | 184096 | *pxFunc = fts5ApiCallback; |
| 183997 | 184097 | *ppArg = (void*)pAux; |
| 183998 | 184098 | return 1; |
| | @@ -184018,10 +184118,11 @@ |
| 184018 | 184118 | ** |
| 184019 | 184119 | ** Flush the contents of the pending-terms table to disk. |
| 184020 | 184120 | */ |
| 184021 | 184121 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 184022 | 184122 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 184123 | + UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 184023 | 184124 | fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); |
| 184024 | 184125 | fts5TripCursors(pTab); |
| 184025 | 184126 | return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 184026 | 184127 | } |
| 184027 | 184128 | |
| | @@ -184030,10 +184131,11 @@ |
| 184030 | 184131 | ** |
| 184031 | 184132 | ** This is a no-op. |
| 184032 | 184133 | */ |
| 184033 | 184134 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 184034 | 184135 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 184136 | + UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 184035 | 184137 | fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); |
| 184036 | 184138 | fts5TripCursors(pTab); |
| 184037 | 184139 | return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 184038 | 184140 | } |
| 184039 | 184141 | |
| | @@ -184042,10 +184144,11 @@ |
| 184042 | 184144 | ** |
| 184043 | 184145 | ** Discard the contents of the pending terms table. |
| 184044 | 184146 | */ |
| 184045 | 184147 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 184046 | 184148 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 184149 | + UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 184047 | 184150 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 184048 | 184151 | fts5TripCursors(pTab); |
| 184049 | 184152 | return sqlite3Fts5StorageRollback(pTab->pStorage); |
| 184050 | 184153 | } |
| 184051 | 184154 | |
| | @@ -184221,14 +184324,15 @@ |
| 184221 | 184324 | } |
| 184222 | 184325 | |
| 184223 | 184326 | static void fts5Fts5Func( |
| 184224 | 184327 | sqlite3_context *pCtx, /* Function call context */ |
| 184225 | 184328 | int nArg, /* Number of args */ |
| 184226 | | - sqlite3_value **apVal /* Function arguments */ |
| 184329 | + sqlite3_value **apUnused /* Function arguments */ |
| 184227 | 184330 | ){ |
| 184228 | 184331 | Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx); |
| 184229 | 184332 | char buf[8]; |
| 184333 | + UNUSED_PARAM2(nArg, apUnused); |
| 184230 | 184334 | assert( nArg==0 ); |
| 184231 | 184335 | assert( sizeof(buf)>=sizeof(pGlobal) ); |
| 184232 | 184336 | memcpy(buf, (void*)&pGlobal, sizeof(pGlobal)); |
| 184233 | 184337 | sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT); |
| 184234 | 184338 | } |
| | @@ -184237,14 +184341,15 @@ |
| 184237 | 184341 | ** Implementation of fts5_source_id() function. |
| 184238 | 184342 | */ |
| 184239 | 184343 | static void fts5SourceIdFunc( |
| 184240 | 184344 | sqlite3_context *pCtx, /* Function call context */ |
| 184241 | 184345 | int nArg, /* Number of args */ |
| 184242 | | - sqlite3_value **apVal /* Function arguments */ |
| 184346 | + sqlite3_value **apUnused /* Function arguments */ |
| 184243 | 184347 | ){ |
| 184244 | 184348 | assert( nArg==0 ); |
| 184245 | | - sqlite3_result_text(pCtx, "fts5: 2016-02-09 18:28:20 51b6823f4c9376d549f572f5a33cac1e4c9783a2", -1, SQLITE_TRANSIENT); |
| 184349 | + UNUSED_PARAM2(nArg, apUnused); |
| 184350 | + sqlite3_result_text(pCtx, "fts5: 2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc", -1, SQLITE_TRANSIENT); |
| 184246 | 184351 | } |
| 184247 | 184352 | |
| 184248 | 184353 | static int fts5Init(sqlite3 *db){ |
| 184249 | 184354 | static const sqlite3_module fts5Mod = { |
| 184250 | 184355 | /* iVersion */ 2, |
| | @@ -184709,15 +184814,16 @@ |
| 184709 | 184814 | static int fts5StorageInsertCallback( |
| 184710 | 184815 | void *pContext, /* Pointer to Fts5InsertCtx object */ |
| 184711 | 184816 | int tflags, |
| 184712 | 184817 | const char *pToken, /* Buffer containing token */ |
| 184713 | 184818 | int nToken, /* Size of token in bytes */ |
| 184714 | | - int iStart, /* Start offset of token */ |
| 184715 | | - int iEnd /* End offset of token */ |
| 184819 | + int iUnused1, /* Start offset of token */ |
| 184820 | + int iUnused2 /* End offset of token */ |
| 184716 | 184821 | ){ |
| 184717 | 184822 | Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext; |
| 184718 | 184823 | Fts5Index *pIdx = pCtx->pStorage->pIndex; |
| 184824 | + UNUSED_PARAM2(iUnused1, iUnused2); |
| 184719 | 184825 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 184720 | 184826 | pCtx->szCol++; |
| 184721 | 184827 | } |
| 184722 | 184828 | return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); |
| 184723 | 184829 | } |
| | @@ -185144,20 +185250,22 @@ |
| 185144 | 185250 | static int fts5StorageIntegrityCallback( |
| 185145 | 185251 | void *pContext, /* Pointer to Fts5IntegrityCtx object */ |
| 185146 | 185252 | int tflags, |
| 185147 | 185253 | const char *pToken, /* Buffer containing token */ |
| 185148 | 185254 | int nToken, /* Size of token in bytes */ |
| 185149 | | - int iStart, /* Start offset of token */ |
| 185150 | | - int iEnd /* End offset of token */ |
| 185255 | + int iUnused1, /* Start offset of token */ |
| 185256 | + int iUnused2 /* End offset of token */ |
| 185151 | 185257 | ){ |
| 185152 | 185258 | Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext; |
| 185153 | 185259 | Fts5Termset *pTermset = pCtx->pTermset; |
| 185154 | 185260 | int bPresent; |
| 185155 | 185261 | int ii; |
| 185156 | 185262 | int rc = SQLITE_OK; |
| 185157 | 185263 | int iPos; |
| 185158 | 185264 | int iCol; |
| 185265 | + |
| 185266 | + UNUSED_PARAM2(iUnused1, iUnused2); |
| 185159 | 185267 | |
| 185160 | 185268 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 185161 | 185269 | pCtx->szCol++; |
| 185162 | 185270 | } |
| 185163 | 185271 | |
| | @@ -185532,16 +185640,17 @@ |
| 185532 | 185640 | |
| 185533 | 185641 | /* |
| 185534 | 185642 | ** Create an "ascii" tokenizer. |
| 185535 | 185643 | */ |
| 185536 | 185644 | static int fts5AsciiCreate( |
| 185537 | | - void *pCtx, |
| 185645 | + void *pUnused, |
| 185538 | 185646 | const char **azArg, int nArg, |
| 185539 | 185647 | Fts5Tokenizer **ppOut |
| 185540 | 185648 | ){ |
| 185541 | 185649 | int rc = SQLITE_OK; |
| 185542 | 185650 | AsciiTokenizer *p = 0; |
| 185651 | + UNUSED_PARAM(pUnused); |
| 185543 | 185652 | if( nArg%2 ){ |
| 185544 | 185653 | rc = SQLITE_ERROR; |
| 185545 | 185654 | }else{ |
| 185546 | 185655 | p = sqlite3_malloc(sizeof(AsciiTokenizer)); |
| 185547 | 185656 | if( p==0 ){ |
| | @@ -185586,11 +185695,11 @@ |
| 185586 | 185695 | ** Tokenize some text using the ascii tokenizer. |
| 185587 | 185696 | */ |
| 185588 | 185697 | static int fts5AsciiTokenize( |
| 185589 | 185698 | Fts5Tokenizer *pTokenizer, |
| 185590 | 185699 | void *pCtx, |
| 185591 | | - int flags, |
| 185700 | + int iUnused, |
| 185592 | 185701 | const char *pText, int nText, |
| 185593 | 185702 | int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd) |
| 185594 | 185703 | ){ |
| 185595 | 185704 | AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer; |
| 185596 | 185705 | int rc = SQLITE_OK; |
| | @@ -185599,10 +185708,12 @@ |
| 185599 | 185708 | |
| 185600 | 185709 | char aFold[64]; |
| 185601 | 185710 | int nFold = sizeof(aFold); |
| 185602 | 185711 | char *pFold = aFold; |
| 185603 | 185712 | unsigned char *a = p->aTokenChar; |
| 185713 | + |
| 185714 | + UNUSED_PARAM(iUnused); |
| 185604 | 185715 | |
| 185605 | 185716 | while( is<nText && rc==SQLITE_OK ){ |
| 185606 | 185717 | int nByte; |
| 185607 | 185718 | |
| 185608 | 185719 | /* Skip any leading divider characters. */ |
| | @@ -185793,16 +185904,18 @@ |
| 185793 | 185904 | |
| 185794 | 185905 | /* |
| 185795 | 185906 | ** Create a "unicode61" tokenizer. |
| 185796 | 185907 | */ |
| 185797 | 185908 | static int fts5UnicodeCreate( |
| 185798 | | - void *pCtx, |
| 185909 | + void *pUnused, |
| 185799 | 185910 | const char **azArg, int nArg, |
| 185800 | 185911 | Fts5Tokenizer **ppOut |
| 185801 | 185912 | ){ |
| 185802 | 185913 | int rc = SQLITE_OK; /* Return code */ |
| 185803 | 185914 | Unicode61Tokenizer *p = 0; /* New tokenizer object */ |
| 185915 | + |
| 185916 | + UNUSED_PARAM(pUnused); |
| 185804 | 185917 | |
| 185805 | 185918 | if( nArg%2 ){ |
| 185806 | 185919 | rc = SQLITE_ERROR; |
| 185807 | 185920 | }else{ |
| 185808 | 185921 | p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer)); |
| | @@ -185856,11 +185969,11 @@ |
| 185856 | 185969 | } |
| 185857 | 185970 | |
| 185858 | 185971 | static int fts5UnicodeTokenize( |
| 185859 | 185972 | Fts5Tokenizer *pTokenizer, |
| 185860 | 185973 | void *pCtx, |
| 185861 | | - int flags, |
| 185974 | + int iUnused, |
| 185862 | 185975 | const char *pText, int nText, |
| 185863 | 185976 | int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd) |
| 185864 | 185977 | ){ |
| 185865 | 185978 | Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer; |
| 185866 | 185979 | int rc = SQLITE_OK; |
| | @@ -185871,10 +185984,12 @@ |
| 185871 | 185984 | |
| 185872 | 185985 | /* Output buffer */ |
| 185873 | 185986 | char *aFold = p->aFold; |
| 185874 | 185987 | int nFold = p->nFold; |
| 185875 | 185988 | const char *pEnd = &aFold[nFold-6]; |
| 185989 | + |
| 185990 | + UNUSED_PARAM(iUnused); |
| 185876 | 185991 | |
| 185877 | 185992 | /* Each iteration of this loop gobbles up a contiguous run of separators, |
| 185878 | 185993 | ** then the next token. */ |
| 185879 | 185994 | while( rc==SQLITE_OK ){ |
| 185880 | 185995 | int iCode; /* non-ASCII codepoint read from input */ |
| | @@ -187650,19 +187765,21 @@ |
| 187650 | 187765 | |
| 187651 | 187766 | /* |
| 187652 | 187767 | ** Implementation of the xBestIndex method. |
| 187653 | 187768 | */ |
| 187654 | 187769 | static int fts5VocabBestIndexMethod( |
| 187655 | | - sqlite3_vtab *pVTab, |
| 187770 | + sqlite3_vtab *pUnused, |
| 187656 | 187771 | sqlite3_index_info *pInfo |
| 187657 | 187772 | ){ |
| 187658 | 187773 | int i; |
| 187659 | 187774 | int iTermEq = -1; |
| 187660 | 187775 | int iTermGe = -1; |
| 187661 | 187776 | int iTermLe = -1; |
| 187662 | 187777 | int idxNum = 0; |
| 187663 | 187778 | int nArg = 0; |
| 187779 | + |
| 187780 | + UNUSED_PARAM(pUnused); |
| 187664 | 187781 | |
| 187665 | 187782 | for(i=0; i<pInfo->nConstraint; i++){ |
| 187666 | 187783 | struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; |
| 187667 | 187784 | if( p->usable==0 ) continue; |
| 187668 | 187785 | if( p->iColumn==0 ){ /* term column */ |
| | @@ -187901,12 +188018,12 @@ |
| 187901 | 188018 | ** This is the xFilter implementation for the virtual table. |
| 187902 | 188019 | */ |
| 187903 | 188020 | static int fts5VocabFilterMethod( |
| 187904 | 188021 | sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ |
| 187905 | 188022 | int idxNum, /* Strategy index */ |
| 187906 | | - const char *idxStr, /* Unused */ |
| 187907 | | - int nVal, /* Number of elements in apVal */ |
| 188023 | + const char *zUnused, /* Unused */ |
| 188024 | + int nUnused, /* Number of elements in apVal */ |
| 187908 | 188025 | sqlite3_value **apVal /* Arguments for the indexing scheme */ |
| 187909 | 188026 | ){ |
| 187910 | 188027 | Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; |
| 187911 | 188028 | int rc = SQLITE_OK; |
| 187912 | 188029 | |
| | @@ -187916,10 +188033,12 @@ |
| 187916 | 188033 | int nTerm = 0; |
| 187917 | 188034 | |
| 187918 | 188035 | sqlite3_value *pEq = 0; |
| 187919 | 188036 | sqlite3_value *pGe = 0; |
| 187920 | 188037 | sqlite3_value *pLe = 0; |
| 188038 | + |
| 188039 | + UNUSED_PARAM2(zUnused, nUnused); |
| 187921 | 188040 | |
| 187922 | 188041 | fts5VocabResetCursor(pCsr); |
| 187923 | 188042 | if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++]; |
| 187924 | 188043 | if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++]; |
| 187925 | 188044 | if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++]; |
| 187926 | 188045 | |