Fossil SCM
Update the built-in SQLite to the latest 3.8.11 beta.
Commit
82206af1101569b50af4a639c46b41135e89d2bc
Parent
31c3c599ffb1b44…
2 files changed
+295
-98
+1
-1
+295
-98
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -325,11 +325,11 @@ | ||
| 325 | 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | 327 | */ |
| 328 | 328 | #define SQLITE_VERSION "3.8.11" |
| 329 | 329 | #define SQLITE_VERSION_NUMBER 3008011 |
| 330 | -#define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94" | |
| 330 | +#define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6" | |
| 331 | 331 | |
| 332 | 332 | /* |
| 333 | 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | 335 | ** |
| @@ -8361,11 +8361,11 @@ | ||
| 8361 | 8361 | |
| 8362 | 8362 | /* |
| 8363 | 8363 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 8364 | 8364 | ** compiling with an appropriate version of MSVC. |
| 8365 | 8365 | */ |
| 8366 | -#if defined(_MSC_VER) && _MSC_VER>=1300 | |
| 8366 | +#if defined(_MSC_VER) && _MSC_VER>=1300 && !defined(_WIN32_WCE) | |
| 8367 | 8367 | # include <intrin.h> |
| 8368 | 8368 | # pragma intrinsic(_byteswap_ushort) |
| 8369 | 8369 | # pragma intrinsic(_byteswap_ulong) |
| 8370 | 8370 | #endif |
| 8371 | 8371 | |
| @@ -9189,11 +9189,13 @@ | ||
| 9189 | 9189 | #endif |
| 9190 | 9190 | #ifndef SQLITE_MAX_MMAP_SIZE |
| 9191 | 9191 | # if defined(__linux__) \ |
| 9192 | 9192 | || defined(_WIN32) \ |
| 9193 | 9193 | || (defined(__APPLE__) && defined(__MACH__)) \ |
| 9194 | - || defined(__sun) | |
| 9194 | + || defined(__sun) \ | |
| 9195 | + || defined(__FreeBSD__) \ | |
| 9196 | + || defined(__DragonFly__) | |
| 9195 | 9197 | # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ |
| 9196 | 9198 | # else |
| 9197 | 9199 | # define SQLITE_MAX_MMAP_SIZE 0 |
| 9198 | 9200 | # endif |
| 9199 | 9201 | # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ |
| @@ -13883,10 +13885,11 @@ | ||
| 13883 | 13885 | ** |
| 13884 | 13886 | ************************************************************************* |
| 13885 | 13887 | ** |
| 13886 | 13888 | ** This file contains definitions of global variables and constants. |
| 13887 | 13889 | */ |
| 13890 | +/* #include "sqliteInt.h" */ | |
| 13888 | 13891 | |
| 13889 | 13892 | /* An array to map all upper-case characters into their corresponding |
| 13890 | 13893 | ** lower-case character. |
| 13891 | 13894 | ** |
| 13892 | 13895 | ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not |
| @@ -14122,10 +14125,11 @@ | ||
| 14122 | 14125 | */ |
| 14123 | 14126 | #ifndef SQLITE_OMIT_WSD |
| 14124 | 14127 | SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000; |
| 14125 | 14128 | #endif |
| 14126 | 14129 | |
| 14130 | +/* #include "opcodes.h" */ | |
| 14127 | 14131 | /* |
| 14128 | 14132 | ** Properties of opcodes. The OPFLG_INITIALIZER macro is |
| 14129 | 14133 | ** created by mkopcodeh.awk during compilation. Data is obtained |
| 14130 | 14134 | ** from the comments following the "case OP_xxxx:" statements in |
| 14131 | 14135 | ** the vdbe.c file. |
| @@ -14150,10 +14154,11 @@ | ||
| 14150 | 14154 | ** SQLite was built with. |
| 14151 | 14155 | */ |
| 14152 | 14156 | |
| 14153 | 14157 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| 14154 | 14158 | |
| 14159 | +/* #include "sqliteInt.h" */ | |
| 14155 | 14160 | |
| 14156 | 14161 | /* |
| 14157 | 14162 | ** An array of names of all compile-time options. This array should |
| 14158 | 14163 | ** be sorted A-Z. |
| 14159 | 14164 | ** |
| @@ -14579,10 +14584,11 @@ | ||
| 14579 | 14584 | ************************************************************************* |
| 14580 | 14585 | ** |
| 14581 | 14586 | ** This module implements the sqlite3_status() interface and related |
| 14582 | 14587 | ** functionality. |
| 14583 | 14588 | */ |
| 14589 | +/* #include "sqliteInt.h" */ | |
| 14584 | 14590 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 14585 | 14591 | /************** Begin file vdbeInt.h *****************************************/ |
| 14586 | 14592 | /* |
| 14587 | 14593 | ** 2003 September 6 |
| 14588 | 14594 | ** |
| @@ -15462,10 +15468,11 @@ | ||
| 15462 | 15468 | ** Astronomical Algorithms, 2nd Edition, 1998 |
| 15463 | 15469 | ** ISBM 0-943396-61-1 |
| 15464 | 15470 | ** Willmann-Bell, Inc |
| 15465 | 15471 | ** Richmond, Virginia (USA) |
| 15466 | 15472 | */ |
| 15473 | +/* #include "sqliteInt.h" */ | |
| 15467 | 15474 | /* #include <stdlib.h> */ |
| 15468 | 15475 | /* #include <assert.h> */ |
| 15469 | 15476 | #include <time.h> |
| 15470 | 15477 | |
| 15471 | 15478 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| @@ -15773,11 +15780,11 @@ | ||
| 15773 | 15780 | Z = (int)((p->iJD + 43200000)/86400000); |
| 15774 | 15781 | A = (int)((Z - 1867216.25)/36524.25); |
| 15775 | 15782 | A = Z + 1 + A - (A/4); |
| 15776 | 15783 | B = A + 1524; |
| 15777 | 15784 | C = (int)((B - 122.1)/365.25); |
| 15778 | - D = (36525*C)/100; | |
| 15785 | + D = (36525*(C&32767))/100; | |
| 15779 | 15786 | E = (int)((B-D)/30.6001); |
| 15780 | 15787 | X1 = (int)(30.6001*E); |
| 15781 | 15788 | p->D = B - D - X1; |
| 15782 | 15789 | p->M = E<14 ? E-1 : E-13; |
| 15783 | 15790 | p->Y = p->M>2 ? C - 4716 : C - 4715; |
| @@ -16574,10 +16581,11 @@ | ||
| 16574 | 16581 | ** |
| 16575 | 16582 | ** This file contains OS interface code that is common to all |
| 16576 | 16583 | ** architectures. |
| 16577 | 16584 | */ |
| 16578 | 16585 | #define _SQLITE_OS_C_ 1 |
| 16586 | +/* #include "sqliteInt.h" */ | |
| 16579 | 16587 | #undef _SQLITE_OS_C_ |
| 16580 | 16588 | |
| 16581 | 16589 | /* |
| 16582 | 16590 | ** The default SQLite sqlite3_vfs implementations do not allocate |
| 16583 | 16591 | ** memory (actually, os_unix.c allocates a small amount of memory |
| @@ -16980,10 +16988,11 @@ | ||
| 16980 | 16988 | ** is completely recoverable simply by not carrying out the resize. The |
| 16981 | 16989 | ** hash table will continue to function normally. So a malloc failure |
| 16982 | 16990 | ** during a hash table resize is a benign fault. |
| 16983 | 16991 | */ |
| 16984 | 16992 | |
| 16993 | +/* #include "sqliteInt.h" */ | |
| 16985 | 16994 | |
| 16986 | 16995 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 16987 | 16996 | |
| 16988 | 16997 | /* |
| 16989 | 16998 | ** Global variables. |
| @@ -17061,10 +17070,11 @@ | ||
| 17061 | 17070 | ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented |
| 17062 | 17071 | ** here always fail. SQLite will not operate with these drivers. These |
| 17063 | 17072 | ** are merely placeholders. Real drivers must be substituted using |
| 17064 | 17073 | ** sqlite3_config() before SQLite will operate. |
| 17065 | 17074 | */ |
| 17075 | +/* #include "sqliteInt.h" */ | |
| 17066 | 17076 | |
| 17067 | 17077 | /* |
| 17068 | 17078 | ** This version of the memory allocator is the default. It is |
| 17069 | 17079 | ** used when no other memory allocator is specified using compile-time |
| 17070 | 17080 | ** macros. |
| @@ -17147,10 +17157,11 @@ | ||
| 17147 | 17157 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| 17148 | 17158 | ** _msize() on windows systems. This might |
| 17149 | 17159 | ** be necessary when compiling for Delphi, |
| 17150 | 17160 | ** for example. |
| 17151 | 17161 | */ |
| 17162 | +/* #include "sqliteInt.h" */ | |
| 17152 | 17163 | |
| 17153 | 17164 | /* |
| 17154 | 17165 | ** This version of the memory allocator is the default. It is |
| 17155 | 17166 | ** used when no other memory allocator is specified using compile-time |
| 17156 | 17167 | ** macros. |
| @@ -17422,10 +17433,11 @@ | ||
| 17422 | 17433 | ** leaks and memory usage errors. |
| 17423 | 17434 | ** |
| 17424 | 17435 | ** This file contains implementations of the low-level memory allocation |
| 17425 | 17436 | ** routines specified in the sqlite3_mem_methods object. |
| 17426 | 17437 | */ |
| 17438 | +/* #include "sqliteInt.h" */ | |
| 17427 | 17439 | |
| 17428 | 17440 | /* |
| 17429 | 17441 | ** This version of the memory allocator is used only if the |
| 17430 | 17442 | ** SQLITE_MEMDEBUG macro is defined |
| 17431 | 17443 | */ |
| @@ -17956,10 +17968,11 @@ | ||
| 17956 | 17968 | ** be changed. |
| 17957 | 17969 | ** |
| 17958 | 17970 | ** This version of the memory allocation subsystem is included |
| 17959 | 17971 | ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. |
| 17960 | 17972 | */ |
| 17973 | +/* #include "sqliteInt.h" */ | |
| 17961 | 17974 | |
| 17962 | 17975 | /* |
| 17963 | 17976 | ** This version of the memory allocator is only built into the library |
| 17964 | 17977 | ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not |
| 17965 | 17978 | ** mean that the library will use a memory-pool by default, just that |
| @@ -18670,10 +18683,11 @@ | ||
| 18670 | 18683 | ** N >= M*(1 + log2(n)/2) - n + 1 |
| 18671 | 18684 | ** |
| 18672 | 18685 | ** The sqlite3_status() logic tracks the maximum values of n and M so |
| 18673 | 18686 | ** that an application can, at any time, verify this constraint. |
| 18674 | 18687 | */ |
| 18688 | +/* #include "sqliteInt.h" */ | |
| 18675 | 18689 | |
| 18676 | 18690 | /* |
| 18677 | 18691 | ** This version of the memory allocator is used only when |
| 18678 | 18692 | ** SQLITE_ENABLE_MEMSYS5 is defined. |
| 18679 | 18693 | */ |
| @@ -19213,10 +19227,11 @@ | ||
| 19213 | 19227 | ************************************************************************* |
| 19214 | 19228 | ** This file contains the C functions that implement mutexes. |
| 19215 | 19229 | ** |
| 19216 | 19230 | ** This file contains code that is common across all mutex implementations. |
| 19217 | 19231 | */ |
| 19232 | +/* #include "sqliteInt.h" */ | |
| 19218 | 19233 | |
| 19219 | 19234 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT) |
| 19220 | 19235 | /* |
| 19221 | 19236 | ** For debugging purposes, record when the mutex subsystem is initialized |
| 19222 | 19237 | ** and uninitialized so that we can assert() if there is an attempt to |
| @@ -19386,10 +19401,11 @@ | ||
| 19386 | 19401 | ** |
| 19387 | 19402 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted |
| 19388 | 19403 | ** that does error checking on mutexes to make sure they are being |
| 19389 | 19404 | ** called correctly. |
| 19390 | 19405 | */ |
| 19406 | +/* #include "sqliteInt.h" */ | |
| 19391 | 19407 | |
| 19392 | 19408 | #ifndef SQLITE_MUTEX_OMIT |
| 19393 | 19409 | |
| 19394 | 19410 | #ifndef SQLITE_DEBUG |
| 19395 | 19411 | /* |
| @@ -19589,10 +19605,11 @@ | ||
| 19589 | 19605 | ** May you share freely, never taking more than you give. |
| 19590 | 19606 | ** |
| 19591 | 19607 | ************************************************************************* |
| 19592 | 19608 | ** This file contains the C functions that implement mutexes for pthreads |
| 19593 | 19609 | */ |
| 19610 | +/* #include "sqliteInt.h" */ | |
| 19594 | 19611 | |
| 19595 | 19612 | /* |
| 19596 | 19613 | ** The code in this file is only used if we are compiling threadsafe |
| 19597 | 19614 | ** under unix with pthreads. |
| 19598 | 19615 | ** |
| @@ -19963,10 +19980,11 @@ | ||
| 19963 | 19980 | ** May you share freely, never taking more than you give. |
| 19964 | 19981 | ** |
| 19965 | 19982 | ************************************************************************* |
| 19966 | 19983 | ** This file contains the C functions that implement mutexes for Win32. |
| 19967 | 19984 | */ |
| 19985 | +/* #include "sqliteInt.h" */ | |
| 19968 | 19986 | |
| 19969 | 19987 | #if SQLITE_OS_WIN |
| 19970 | 19988 | /* |
| 19971 | 19989 | ** Include code that is common to all os_*.c files |
| 19972 | 19990 | */ |
| @@ -20638,10 +20656,11 @@ | ||
| 20638 | 20656 | ** |
| 20639 | 20657 | ************************************************************************* |
| 20640 | 20658 | ** |
| 20641 | 20659 | ** Memory allocation functions used throughout sqlite. |
| 20642 | 20660 | */ |
| 20661 | +/* #include "sqliteInt.h" */ | |
| 20643 | 20662 | /* #include <stdarg.h> */ |
| 20644 | 20663 | |
| 20645 | 20664 | /* |
| 20646 | 20665 | ** Attempt to release up to n bytes of non-essential memory currently |
| 20647 | 20666 | ** held by SQLite. An example of non-essential memory is memory used to |
| @@ -21449,10 +21468,11 @@ | ||
| 21449 | 21468 | ** This file contains code for a set of "printf"-like routines. These |
| 21450 | 21469 | ** routines format strings much like the printf() from the standard C |
| 21451 | 21470 | ** library, though the implementation here has enhancements to support |
| 21452 | 21471 | ** SQLite. |
| 21453 | 21472 | */ |
| 21473 | +/* #include "sqliteInt.h" */ | |
| 21454 | 21474 | |
| 21455 | 21475 | /* |
| 21456 | 21476 | ** Conversion types fall into various categories as defined by the |
| 21457 | 21477 | ** following enumeration. |
| 21458 | 21478 | */ |
| @@ -22451,10 +22471,15 @@ | ||
| 22451 | 22471 | ** stack space on small-stack systems when logging is disabled. |
| 22452 | 22472 | ** |
| 22453 | 22473 | ** sqlite3_log() must render into a static buffer. It cannot dynamically |
| 22454 | 22474 | ** allocate memory because it might be called while the memory allocator |
| 22455 | 22475 | ** mutex is held. |
| 22476 | +** | |
| 22477 | +** sqlite3VXPrintf() might ask for *temporary* memory allocations for | |
| 22478 | +** certain format characters (%q) or for very large precisions or widths. | |
| 22479 | +** Care must be taken that any sqlite3_log() calls that occur while the | |
| 22480 | +** memory mutex is held do not use these mechanisms. | |
| 22456 | 22481 | */ |
| 22457 | 22482 | static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ |
| 22458 | 22483 | StrAccum acc; /* String accumulator */ |
| 22459 | 22484 | char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ |
| 22460 | 22485 | |
| @@ -22526,10 +22551,11 @@ | ||
| 22526 | 22551 | ** analysis. |
| 22527 | 22552 | ** |
| 22528 | 22553 | ** The interfaces in this file is only available when compiling |
| 22529 | 22554 | ** with SQLITE_DEBUG. |
| 22530 | 22555 | */ |
| 22556 | +/* #include "sqliteInt.h" */ | |
| 22531 | 22557 | #ifdef SQLITE_DEBUG |
| 22532 | 22558 | |
| 22533 | 22559 | /* |
| 22534 | 22560 | ** Add a new subitem to the tree. The moreToFollow flag indicates that this |
| 22535 | 22561 | ** is not the last item in the tree. |
| @@ -22957,10 +22983,11 @@ | ||
| 22957 | 22983 | ** generator (PRNG) for SQLite. |
| 22958 | 22984 | ** |
| 22959 | 22985 | ** Random numbers are used by some of the database backends in order |
| 22960 | 22986 | ** to generate random integer keys for tables or random filenames. |
| 22961 | 22987 | */ |
| 22988 | +/* #include "sqliteInt.h" */ | |
| 22962 | 22989 | |
| 22963 | 22990 | |
| 22964 | 22991 | /* All threads share a single random number generator. |
| 22965 | 22992 | ** This structure is the current state of the generator. |
| 22966 | 22993 | */ |
| @@ -23103,11 +23130,13 @@ | ||
| 23103 | 23130 | ** single threaded systems. Nothing in SQLite requires multiple threads. |
| 23104 | 23131 | ** This interface exists so that applications that want to take advantage |
| 23105 | 23132 | ** of multiple cores can do so, while also allowing applications to stay |
| 23106 | 23133 | ** single-threaded if desired. |
| 23107 | 23134 | */ |
| 23135 | +/* #include "sqliteInt.h" */ | |
| 23108 | 23136 | #if SQLITE_OS_WIN |
| 23137 | +/* # include "os_win.h" */ | |
| 23109 | 23138 | #endif |
| 23110 | 23139 | |
| 23111 | 23140 | #if SQLITE_MAX_WORKER_THREADS>0 |
| 23112 | 23141 | |
| 23113 | 23142 | /********************************* Unix Pthreads ****************************/ |
| @@ -23377,11 +23406,13 @@ | ||
| 23377 | 23406 | ** BOM or Byte Order Mark: |
| 23378 | 23407 | ** 0xff 0xfe little-endian utf-16 follows |
| 23379 | 23408 | ** 0xfe 0xff big-endian utf-16 follows |
| 23380 | 23409 | ** |
| 23381 | 23410 | */ |
| 23411 | +/* #include "sqliteInt.h" */ | |
| 23382 | 23412 | /* #include <assert.h> */ |
| 23413 | +/* #include "vdbeInt.h" */ | |
| 23383 | 23414 | |
| 23384 | 23415 | #ifndef SQLITE_AMALGAMATION |
| 23385 | 23416 | /* |
| 23386 | 23417 | ** The following constant value is used by the SQLITE_BIGENDIAN and |
| 23387 | 23418 | ** SQLITE_LITTLEENDIAN macros. |
| @@ -23890,10 +23921,11 @@ | ||
| 23890 | 23921 | ** |
| 23891 | 23922 | ** This file contains functions for allocating memory, comparing |
| 23892 | 23923 | ** strings, and stuff like that. |
| 23893 | 23924 | ** |
| 23894 | 23925 | */ |
| 23926 | +/* #include "sqliteInt.h" */ | |
| 23895 | 23927 | /* #include <stdarg.h> */ |
| 23896 | 23928 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN |
| 23897 | 23929 | # include <math.h> |
| 23898 | 23930 | #endif |
| 23899 | 23931 | |
| @@ -25286,10 +25318,11 @@ | ||
| 25286 | 25318 | ** |
| 25287 | 25319 | ************************************************************************* |
| 25288 | 25320 | ** This is the implementation of generic hash-tables |
| 25289 | 25321 | ** used in SQLite. |
| 25290 | 25322 | */ |
| 25323 | +/* #include "sqliteInt.h" */ | |
| 25291 | 25324 | /* #include <assert.h> */ |
| 25292 | 25325 | |
| 25293 | 25326 | /* Turn bulk memory into a hash table object by initializing the |
| 25294 | 25327 | ** fields of the Hash structure. |
| 25295 | 25328 | ** |
| @@ -25763,10 +25796,11 @@ | ||
| 25763 | 25796 | ** * sqlite3_vfs method implementations. |
| 25764 | 25797 | ** * Locking primitives for the proxy uber-locking-method. (MacOSX only) |
| 25765 | 25798 | ** * Definitions of sqlite3_vfs objects for all locking methods |
| 25766 | 25799 | ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). |
| 25767 | 25800 | */ |
| 25801 | +/* #include "sqliteInt.h" */ | |
| 25768 | 25802 | #if SQLITE_OS_UNIX /* This file is used on unix only */ |
| 25769 | 25803 | |
| 25770 | 25804 | /* |
| 25771 | 25805 | ** There are various methods for file locking used for concurrency |
| 25772 | 25806 | ** control: |
| @@ -33497,10 +33531,11 @@ | ||
| 33497 | 33531 | ** |
| 33498 | 33532 | ****************************************************************************** |
| 33499 | 33533 | ** |
| 33500 | 33534 | ** This file contains code that is specific to Windows. |
| 33501 | 33535 | */ |
| 33536 | +/* #include "sqliteInt.h" */ | |
| 33502 | 33537 | #if SQLITE_OS_WIN /* This file is used for Windows only */ |
| 33503 | 33538 | |
| 33504 | 33539 | /* |
| 33505 | 33540 | ** Include code that is common to all os_*.c files |
| 33506 | 33541 | */ |
| @@ -33705,10 +33740,11 @@ | ||
| 33705 | 33740 | /************** Continuing where we left off in os_win.c *********************/ |
| 33706 | 33741 | |
| 33707 | 33742 | /* |
| 33708 | 33743 | ** Include the header file for the Windows VFS. |
| 33709 | 33744 | */ |
| 33745 | +/* #include "os_win.h" */ | |
| 33710 | 33746 | |
| 33711 | 33747 | /* |
| 33712 | 33748 | ** Compiling and using WAL mode requires several APIs that are only |
| 33713 | 33749 | ** available in Windows platforms based on the NT kernel. |
| 33714 | 33750 | */ |
| @@ -39358,10 +39394,11 @@ | ||
| 39358 | 39394 | ** sometimes grow into tens of thousands or larger. The size of the |
| 39359 | 39395 | ** Bitvec object is the number of pages in the database file at the |
| 39360 | 39396 | ** start of a transaction, and is thus usually less than a few thousand, |
| 39361 | 39397 | ** but can be as large as 2 billion for a really big database. |
| 39362 | 39398 | */ |
| 39399 | +/* #include "sqliteInt.h" */ | |
| 39363 | 39400 | |
| 39364 | 39401 | /* Size of the Bitvec structure in bytes. */ |
| 39365 | 39402 | #define BITVEC_SZ 512 |
| 39366 | 39403 | |
| 39367 | 39404 | /* Round the union size down to the nearest pointer boundary, since that's how |
| @@ -39747,10 +39784,11 @@ | ||
| 39747 | 39784 | ** May you share freely, never taking more than you give. |
| 39748 | 39785 | ** |
| 39749 | 39786 | ************************************************************************* |
| 39750 | 39787 | ** This file implements that page cache. |
| 39751 | 39788 | */ |
| 39789 | +/* #include "sqliteInt.h" */ | |
| 39752 | 39790 | |
| 39753 | 39791 | /* |
| 39754 | 39792 | ** A complete page cache is an instance of this structure. |
| 39755 | 39793 | */ |
| 39756 | 39794 | struct PCache { |
| @@ -40488,10 +40526,11 @@ | ||
| 40488 | 40526 | ** |
| 40489 | 40527 | ** Earlier versions of SQLite used only methods (1) and (2). But experiments |
| 40490 | 40528 | ** show that method (3) with N==100 provides about a 5% performance boost for |
| 40491 | 40529 | ** common workloads. |
| 40492 | 40530 | */ |
| 40531 | +/* #include "sqliteInt.h" */ | |
| 40493 | 40532 | |
| 40494 | 40533 | typedef struct PCache1 PCache1; |
| 40495 | 40534 | typedef struct PgHdr1 PgHdr1; |
| 40496 | 40535 | typedef struct PgFreeslot PgFreeslot; |
| 40497 | 40536 | typedef struct PGroup PGroup; |
| @@ -40598,10 +40637,11 @@ | ||
| 40598 | 40637 | ** fixed at sqlite3_initialize() time and do not require mutex protection. |
| 40599 | 40638 | ** The nFreeSlot and pFree values do require mutex protection. |
| 40600 | 40639 | */ |
| 40601 | 40640 | int isInit; /* True if initialized */ |
| 40602 | 40641 | int separateCache; /* Use a new PGroup for each PCache */ |
| 40642 | + int nInitPage; /* Initial bulk allocation size */ | |
| 40603 | 40643 | int szSlot; /* Size of each free slot */ |
| 40604 | 40644 | int nSlot; /* The number of pcache slots */ |
| 40605 | 40645 | int nReserve; /* Try to keep nFreeSlot above this */ |
| 40606 | 40646 | void *pStart, *pEnd; /* Bounds of global page cache memory */ |
| 40607 | 40647 | /* Above requires no mutex. Use mutex below for variable that follow. */ |
| @@ -40665,10 +40705,47 @@ | ||
| 40665 | 40705 | pBuf = (void*)&((char*)pBuf)[sz]; |
| 40666 | 40706 | } |
| 40667 | 40707 | pcache1.pEnd = pBuf; |
| 40668 | 40708 | } |
| 40669 | 40709 | } |
| 40710 | + | |
| 40711 | +/* | |
| 40712 | +** Try to initialize the pCache->pFree and pCache->pBulk fields. Return | |
| 40713 | +** true if pCache->pFree ends up containing one or more free pages. | |
| 40714 | +*/ | |
| 40715 | +static int pcache1InitBulk(PCache1 *pCache){ | |
| 40716 | + int szBulk; | |
| 40717 | + char *zBulk; | |
| 40718 | + if( pcache1.nInitPage==0 ) return 0; | |
| 40719 | + /* Do not bother with a bulk allocation if the cache size very small */ | |
| 40720 | + if( pCache->nMax<3 ) return 0; | |
| 40721 | + sqlite3BeginBenignMalloc(); | |
| 40722 | + if( pcache1.nInitPage>0 ){ | |
| 40723 | + szBulk = pCache->szAlloc * pcache1.nInitPage; | |
| 40724 | + }else{ | |
| 40725 | + szBulk = -1024*pcache1.nInitPage; | |
| 40726 | + } | |
| 40727 | + if( szBulk > pCache->szAlloc*pCache->nMax ){ | |
| 40728 | + szBulk = pCache->szAlloc*pCache->nMax; | |
| 40729 | + } | |
| 40730 | + zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); | |
| 40731 | + sqlite3EndBenignMalloc(); | |
| 40732 | + if( zBulk ){ | |
| 40733 | + int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; | |
| 40734 | + int i; | |
| 40735 | + for(i=0; i<nBulk; i++){ | |
| 40736 | + PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; | |
| 40737 | + pX->page.pBuf = zBulk; | |
| 40738 | + pX->page.pExtra = &pX[1]; | |
| 40739 | + pX->isBulkLocal = 1; | |
| 40740 | + pX->pNext = pCache->pFree; | |
| 40741 | + pCache->pFree = pX; | |
| 40742 | + zBulk += pCache->szAlloc; | |
| 40743 | + } | |
| 40744 | + } | |
| 40745 | + return pCache->pFree!=0; | |
| 40746 | +} | |
| 40670 | 40747 | |
| 40671 | 40748 | /* |
| 40672 | 40749 | ** Malloc function used within this file to allocate space from the buffer |
| 40673 | 40750 | ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no |
| 40674 | 40751 | ** such buffer exists or there is no space left in it, this function falls |
| @@ -40766,11 +40843,11 @@ | ||
| 40766 | 40843 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 40767 | 40844 | PgHdr1 *p = 0; |
| 40768 | 40845 | void *pPg; |
| 40769 | 40846 | |
| 40770 | 40847 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 40771 | - if( pCache->pFree ){ | |
| 40848 | + if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){ | |
| 40772 | 40849 | p = pCache->pFree; |
| 40773 | 40850 | pCache->pFree = p->pNext; |
| 40774 | 40851 | p->pNext = 0; |
| 40775 | 40852 | }else{ |
| 40776 | 40853 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| @@ -40970,18 +41047,23 @@ | ||
| 40970 | 41047 | |
| 40971 | 41048 | /* |
| 40972 | 41049 | ** If there are currently more than nMaxPage pages allocated, try |
| 40973 | 41050 | ** to recycle pages to reduce the number allocated to nMaxPage. |
| 40974 | 41051 | */ |
| 40975 | -static void pcache1EnforceMaxPage(PGroup *pGroup){ | |
| 41052 | +static void pcache1EnforceMaxPage(PCache1 *pCache){ | |
| 41053 | + PGroup *pGroup = pCache->pGroup; | |
| 40976 | 41054 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 40977 | 41055 | while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){ |
| 40978 | 41056 | PgHdr1 *p = pGroup->pLruTail; |
| 40979 | 41057 | assert( p->pCache->pGroup==pGroup ); |
| 40980 | 41058 | assert( p->isPinned==0 ); |
| 40981 | 41059 | pcache1PinPage(p); |
| 40982 | 41060 | pcache1RemoveFromHash(p, 1); |
| 41061 | + } | |
| 41062 | + if( pCache->nPage==0 && pCache->pBulk ){ | |
| 41063 | + sqlite3_free(pCache->pBulk); | |
| 41064 | + pCache->pBulk = pCache->pFree = 0; | |
| 40983 | 41065 | } |
| 40984 | 41066 | } |
| 40985 | 41067 | |
| 40986 | 41068 | /* |
| 40987 | 41069 | ** Discard all pages from cache pCache with a page number (key value) |
| @@ -41054,10 +41136,18 @@ | ||
| 41054 | 41136 | if( sqlite3GlobalConfig.bCoreMutex ){ |
| 41055 | 41137 | pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); |
| 41056 | 41138 | pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); |
| 41057 | 41139 | } |
| 41058 | 41140 | #endif |
| 41141 | + if( pcache1.separateCache | |
| 41142 | + && sqlite3GlobalConfig.nPage!=0 | |
| 41143 | + && sqlite3GlobalConfig.pPage==0 | |
| 41144 | + ){ | |
| 41145 | + pcache1.nInitPage = sqlite3GlobalConfig.nPage; | |
| 41146 | + }else{ | |
| 41147 | + pcache1.nInitPage = 0; | |
| 41148 | + } | |
| 41059 | 41149 | pcache1.grp.mxPinned = 10; |
| 41060 | 41150 | pcache1.isInit = 1; |
| 41061 | 41151 | return SQLITE_OK; |
| 41062 | 41152 | } |
| 41063 | 41153 | |
| @@ -41108,40 +41198,10 @@ | ||
| 41108 | 41198 | pCache->nMin = 10; |
| 41109 | 41199 | pGroup->nMinPage += pCache->nMin; |
| 41110 | 41200 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41111 | 41201 | } |
| 41112 | 41202 | pcache1LeaveMutex(pGroup); |
| 41113 | - /* Try to initialize the local bulk pagecache line allocation if using | |
| 41114 | - ** separate caches and if nPage!=0 */ | |
| 41115 | - if( pcache1.separateCache | |
| 41116 | - && sqlite3GlobalConfig.nPage!=0 | |
| 41117 | - && sqlite3GlobalConfig.pPage==0 | |
| 41118 | - ){ | |
| 41119 | - int szBulk; | |
| 41120 | - char *zBulk; | |
| 41121 | - sqlite3BeginBenignMalloc(); | |
| 41122 | - if( sqlite3GlobalConfig.nPage>0 ){ | |
| 41123 | - szBulk = pCache->szAlloc * sqlite3GlobalConfig.nPage; | |
| 41124 | - }else{ | |
| 41125 | - szBulk = -1024*sqlite3GlobalConfig.nPage; | |
| 41126 | - } | |
| 41127 | - zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); | |
| 41128 | - sqlite3EndBenignMalloc(); | |
| 41129 | - if( zBulk ){ | |
| 41130 | - int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; | |
| 41131 | - int i; | |
| 41132 | - for(i=0; i<nBulk; i++){ | |
| 41133 | - PgHdr1 *pX = (PgHdr1*)&zBulk[szPage]; | |
| 41134 | - pX->page.pBuf = zBulk; | |
| 41135 | - pX->page.pExtra = &pX[1]; | |
| 41136 | - pX->isBulkLocal = 1; | |
| 41137 | - pX->pNext = pCache->pFree; | |
| 41138 | - pCache->pFree = pX; | |
| 41139 | - zBulk += pCache->szAlloc; | |
| 41140 | - } | |
| 41141 | - } | |
| 41142 | - } | |
| 41143 | 41203 | if( pCache->nHash==0 ){ |
| 41144 | 41204 | pcache1Destroy((sqlite3_pcache*)pCache); |
| 41145 | 41205 | pCache = 0; |
| 41146 | 41206 | } |
| 41147 | 41207 | } |
| @@ -41160,11 +41220,11 @@ | ||
| 41160 | 41220 | pcache1EnterMutex(pGroup); |
| 41161 | 41221 | pGroup->nMaxPage += (nMax - pCache->nMax); |
| 41162 | 41222 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41163 | 41223 | pCache->nMax = nMax; |
| 41164 | 41224 | pCache->n90pct = pCache->nMax*9/10; |
| 41165 | - pcache1EnforceMaxPage(pGroup); | |
| 41225 | + pcache1EnforceMaxPage(pCache); | |
| 41166 | 41226 | pcache1LeaveMutex(pGroup); |
| 41167 | 41227 | } |
| 41168 | 41228 | } |
| 41169 | 41229 | |
| 41170 | 41230 | /* |
| @@ -41178,11 +41238,11 @@ | ||
| 41178 | 41238 | PGroup *pGroup = pCache->pGroup; |
| 41179 | 41239 | int savedMaxPage; |
| 41180 | 41240 | pcache1EnterMutex(pGroup); |
| 41181 | 41241 | savedMaxPage = pGroup->nMaxPage; |
| 41182 | 41242 | pGroup->nMaxPage = 0; |
| 41183 | - pcache1EnforceMaxPage(pGroup); | |
| 41243 | + pcache1EnforceMaxPage(pCache); | |
| 41184 | 41244 | pGroup->nMaxPage = savedMaxPage; |
| 41185 | 41245 | pcache1LeaveMutex(pGroup); |
| 41186 | 41246 | } |
| 41187 | 41247 | } |
| 41188 | 41248 | |
| @@ -41515,11 +41575,11 @@ | ||
| 41515 | 41575 | assert( pGroup->nMaxPage >= pCache->nMax ); |
| 41516 | 41576 | pGroup->nMaxPage -= pCache->nMax; |
| 41517 | 41577 | assert( pGroup->nMinPage >= pCache->nMin ); |
| 41518 | 41578 | pGroup->nMinPage -= pCache->nMin; |
| 41519 | 41579 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41520 | - pcache1EnforceMaxPage(pGroup); | |
| 41580 | + pcache1EnforceMaxPage(pCache); | |
| 41521 | 41581 | pcache1LeaveMutex(pGroup); |
| 41522 | 41582 | sqlite3_free(pCache->pBulk); |
| 41523 | 41583 | sqlite3_free(pCache->apHash); |
| 41524 | 41584 | sqlite3_free(pCache); |
| 41525 | 41585 | } |
| @@ -41679,10 +41739,11 @@ | ||
| 41679 | 41739 | ** primitives are constant time. The cost of DESTROY is O(N). |
| 41680 | 41740 | ** |
| 41681 | 41741 | ** There is an added cost of O(N) when switching between TEST and |
| 41682 | 41742 | ** SMALLEST primitives. |
| 41683 | 41743 | */ |
| 41744 | +/* #include "sqliteInt.h" */ | |
| 41684 | 41745 | |
| 41685 | 41746 | |
| 41686 | 41747 | /* |
| 41687 | 41748 | ** Target size for allocation chunks. |
| 41688 | 41749 | */ |
| @@ -42148,10 +42209,11 @@ | ||
| 42148 | 42209 | ** locking to prevent two processes from writing the same database |
| 42149 | 42210 | ** file simultaneously, or one process from reading the database while |
| 42150 | 42211 | ** another is writing. |
| 42151 | 42212 | */ |
| 42152 | 42213 | #ifndef SQLITE_OMIT_DISKIO |
| 42214 | +/* #include "sqliteInt.h" */ | |
| 42153 | 42215 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 42154 | 42216 | /************** Begin file wal.h *********************************************/ |
| 42155 | 42217 | /* |
| 42156 | 42218 | ** 2010 February 1 |
| 42157 | 42219 | ** |
| @@ -42169,10 +42231,11 @@ | ||
| 42169 | 42231 | */ |
| 42170 | 42232 | |
| 42171 | 42233 | #ifndef _WAL_H_ |
| 42172 | 42234 | #define _WAL_H_ |
| 42173 | 42235 | |
| 42236 | +/* #include "sqliteInt.h" */ | |
| 42174 | 42237 | |
| 42175 | 42238 | /* Additional values that can be added to the sync_flags argument of |
| 42176 | 42239 | ** sqlite3WalFrames(): |
| 42177 | 42240 | */ |
| 42178 | 42241 | #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| @@ -49783,10 +49846,11 @@ | ||
| 49783 | 49846 | ** that correspond to frames greater than the new K value are removed |
| 49784 | 49847 | ** from the hash table at this point. |
| 49785 | 49848 | */ |
| 49786 | 49849 | #ifndef SQLITE_OMIT_WAL |
| 49787 | 49850 | |
| 49851 | +/* #include "wal.h" */ | |
| 49788 | 49852 | |
| 49789 | 49853 | /* |
| 49790 | 49854 | ** Trace output macros |
| 49791 | 49855 | */ |
| 49792 | 49856 | #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) |
| @@ -51000,11 +51064,11 @@ | ||
| 51000 | 51064 | |
| 51001 | 51065 | const int nList = *pnList; /* Size of input list */ |
| 51002 | 51066 | int nMerge = 0; /* Number of elements in list aMerge */ |
| 51003 | 51067 | ht_slot *aMerge = 0; /* List to be merged */ |
| 51004 | 51068 | int iList; /* Index into input list */ |
| 51005 | - int iSub = 0; /* Index into aSub array */ | |
| 51069 | + u32 iSub = 0; /* Index into aSub array */ | |
| 51006 | 51070 | struct Sublist aSub[13]; /* Array of sub-lists */ |
| 51007 | 51071 | |
| 51008 | 51072 | memset(aSub, 0, sizeof(aSub)); |
| 51009 | 51073 | assert( nList<=HASHTABLE_NPAGE && nList>0 ); |
| 51010 | 51074 | assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) ); |
| @@ -51011,11 +51075,13 @@ | ||
| 51011 | 51075 | |
| 51012 | 51076 | for(iList=0; iList<nList; iList++){ |
| 51013 | 51077 | nMerge = 1; |
| 51014 | 51078 | aMerge = &aList[iList]; |
| 51015 | 51079 | for(iSub=0; iList & (1<<iSub); iSub++){ |
| 51016 | - struct Sublist *p = &aSub[iSub]; | |
| 51080 | + struct Sublist *p; | |
| 51081 | + assert( iSub<ArraySize(aSub) ); | |
| 51082 | + p = &aSub[iSub]; | |
| 51017 | 51083 | assert( p->aList && p->nList<=(1<<iSub) ); |
| 51018 | 51084 | assert( p->aList==&aList[iList&~((2<<iSub)-1)] ); |
| 51019 | 51085 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51020 | 51086 | } |
| 51021 | 51087 | aSub[iSub].aList = aMerge; |
| @@ -51022,11 +51088,13 @@ | ||
| 51022 | 51088 | aSub[iSub].nList = nMerge; |
| 51023 | 51089 | } |
| 51024 | 51090 | |
| 51025 | 51091 | for(iSub++; iSub<ArraySize(aSub); iSub++){ |
| 51026 | 51092 | if( nList & (1<<iSub) ){ |
| 51027 | - struct Sublist *p = &aSub[iSub]; | |
| 51093 | + struct Sublist *p; | |
| 51094 | + assert( iSub<ArraySize(aSub) ); | |
| 51095 | + p = &aSub[iSub]; | |
| 51028 | 51096 | assert( p->nList<=(1<<iSub) ); |
| 51029 | 51097 | assert( p->aList==&aList[nList&~((2<<iSub)-1)] ); |
| 51030 | 51098 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51031 | 51099 | } |
| 51032 | 51100 | } |
| @@ -52933,10 +53001,11 @@ | ||
| 52933 | 53001 | ** SIZE DESCRIPTION |
| 52934 | 53002 | ** 4 Page number of next trunk page |
| 52935 | 53003 | ** 4 Number of leaf pointers on this page |
| 52936 | 53004 | ** * zero or more pages numbers of leaves |
| 52937 | 53005 | */ |
| 53006 | +/* #include "sqliteInt.h" */ | |
| 52938 | 53007 | |
| 52939 | 53008 | |
| 52940 | 53009 | /* The following value is the maximum cell size assuming a maximum page |
| 52941 | 53010 | ** size give above. |
| 52942 | 53011 | */ |
| @@ -53730,10 +53799,11 @@ | ||
| 53730 | 53799 | ************************************************************************* |
| 53731 | 53800 | ** This file implements an external (disk-based) database using BTrees. |
| 53732 | 53801 | ** See the header comment on "btreeInt.h" for additional information. |
| 53733 | 53802 | ** Including a description of file format and an overview of operation. |
| 53734 | 53803 | */ |
| 53804 | +/* #include "btreeInt.h" */ | |
| 53735 | 53805 | |
| 53736 | 53806 | /* |
| 53737 | 53807 | ** The header string that appears at the beginning of every |
| 53738 | 53808 | ** SQLite database. |
| 53739 | 53809 | */ |
| @@ -62675,11 +62745,11 @@ | ||
| 62675 | 62745 | u32 *heap = 0; /* Min-heap used for checking cell coverage */ |
| 62676 | 62746 | u32 x, prev = 0; /* Next and previous entry on the min-heap */ |
| 62677 | 62747 | const char *saved_zPfx = pCheck->zPfx; |
| 62678 | 62748 | int saved_v1 = pCheck->v1; |
| 62679 | 62749 | int saved_v2 = pCheck->v2; |
| 62680 | - u8 savedIsInit; | |
| 62750 | + u8 savedIsInit = 0; | |
| 62681 | 62751 | |
| 62682 | 62752 | /* Check that the page exists |
| 62683 | 62753 | */ |
| 62684 | 62754 | pBt = pCheck->pBt; |
| 62685 | 62755 | usableSize = pBt->usableSize; |
| @@ -63311,10 +63381,12 @@ | ||
| 63311 | 63381 | ** |
| 63312 | 63382 | ************************************************************************* |
| 63313 | 63383 | ** This file contains the implementation of the sqlite3_backup_XXX() |
| 63314 | 63384 | ** API functions and the related features. |
| 63315 | 63385 | */ |
| 63386 | +/* #include "sqliteInt.h" */ | |
| 63387 | +/* #include "btreeInt.h" */ | |
| 63316 | 63388 | |
| 63317 | 63389 | /* |
| 63318 | 63390 | ** Structure allocated for each backup operation. |
| 63319 | 63391 | */ |
| 63320 | 63392 | struct sqlite3_backup { |
| @@ -64109,10 +64181,12 @@ | ||
| 64109 | 64181 | ** This file contains code use to manipulate "Mem" structure. A "Mem" |
| 64110 | 64182 | ** stores a single value in the VDBE. Mem is an opaque structure visible |
| 64111 | 64183 | ** only within the VDBE. Interface routines refer to a Mem using the |
| 64112 | 64184 | ** name sqlite_value |
| 64113 | 64185 | */ |
| 64186 | +/* #include "sqliteInt.h" */ | |
| 64187 | +/* #include "vdbeInt.h" */ | |
| 64114 | 64188 | |
| 64115 | 64189 | #ifdef SQLITE_DEBUG |
| 64116 | 64190 | /* |
| 64117 | 64191 | ** Check invariants on a Mem object. |
| 64118 | 64192 | ** |
| @@ -65826,10 +65900,12 @@ | ||
| 65826 | 65900 | ** |
| 65827 | 65901 | ************************************************************************* |
| 65828 | 65902 | ** This file contains code used for creating, destroying, and populating |
| 65829 | 65903 | ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) |
| 65830 | 65904 | */ |
| 65905 | +/* #include "sqliteInt.h" */ | |
| 65906 | +/* #include "vdbeInt.h" */ | |
| 65831 | 65907 | |
| 65832 | 65908 | /* |
| 65833 | 65909 | ** Create a new virtual database engine. |
| 65834 | 65910 | */ |
| 65835 | 65911 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ |
| @@ -70074,10 +70150,12 @@ | ||
| 70074 | 70150 | ************************************************************************* |
| 70075 | 70151 | ** |
| 70076 | 70152 | ** This file contains code use to implement APIs that are part of the |
| 70077 | 70153 | ** VDBE. |
| 70078 | 70154 | */ |
| 70155 | +/* #include "sqliteInt.h" */ | |
| 70156 | +/* #include "vdbeInt.h" */ | |
| 70079 | 70157 | |
| 70080 | 70158 | #ifndef SQLITE_OMIT_DEPRECATED |
| 70081 | 70159 | /* |
| 70082 | 70160 | ** Return TRUE (non-zero) of the statement supplied as an argument needs |
| 70083 | 70161 | ** to be recompiled. A statement needs to be recompiled whenever the |
| @@ -70112,10 +70190,35 @@ | ||
| 70112 | 70190 | }else{ |
| 70113 | 70191 | return vdbeSafety(p); |
| 70114 | 70192 | } |
| 70115 | 70193 | } |
| 70116 | 70194 | |
| 70195 | +#ifndef SQLITE_OMIT_TRACE | |
| 70196 | +/* | |
| 70197 | +** Invoke the profile callback. This routine is only called if we already | |
| 70198 | +** know that the profile callback is defined and needs to be invoked. | |
| 70199 | +*/ | |
| 70200 | +static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ | |
| 70201 | + sqlite3_int64 iNow; | |
| 70202 | + assert( p->startTime>0 ); | |
| 70203 | + assert( db->xProfile!=0 ); | |
| 70204 | + assert( db->init.busy==0 ); | |
| 70205 | + assert( p->zSql!=0 ); | |
| 70206 | + sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); | |
| 70207 | + db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); | |
| 70208 | + p->startTime = 0; | |
| 70209 | +} | |
| 70210 | +/* | |
| 70211 | +** The checkProfileCallback(DB,P) macro checks to see if a profile callback | |
| 70212 | +** is needed, and it invokes the callback if it is needed. | |
| 70213 | +*/ | |
| 70214 | +# define checkProfileCallback(DB,P) \ | |
| 70215 | + if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); } | |
| 70216 | +#else | |
| 70217 | +# define checkProfileCallback(DB,P) /*no-op*/ | |
| 70218 | +#endif | |
| 70219 | + | |
| 70117 | 70220 | /* |
| 70118 | 70221 | ** The following routine destroys a virtual machine that is created by |
| 70119 | 70222 | ** the sqlite3_compile() routine. The integer returned is an SQLITE_ |
| 70120 | 70223 | ** success/failure code that describes the result of executing the virtual |
| 70121 | 70224 | ** machine. |
| @@ -70132,10 +70235,11 @@ | ||
| 70132 | 70235 | }else{ |
| 70133 | 70236 | Vdbe *v = (Vdbe*)pStmt; |
| 70134 | 70237 | sqlite3 *db = v->db; |
| 70135 | 70238 | if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; |
| 70136 | 70239 | sqlite3_mutex_enter(db->mutex); |
| 70240 | + checkProfileCallback(db, v); | |
| 70137 | 70241 | rc = sqlite3VdbeFinalize(v); |
| 70138 | 70242 | rc = sqlite3ApiExit(db, rc); |
| 70139 | 70243 | sqlite3LeaveMutexAndCloseZombie(db); |
| 70140 | 70244 | } |
| 70141 | 70245 | return rc; |
| @@ -70153,16 +70257,18 @@ | ||
| 70153 | 70257 | int rc; |
| 70154 | 70258 | if( pStmt==0 ){ |
| 70155 | 70259 | rc = SQLITE_OK; |
| 70156 | 70260 | }else{ |
| 70157 | 70261 | Vdbe *v = (Vdbe*)pStmt; |
| 70158 | - sqlite3_mutex_enter(v->db->mutex); | |
| 70262 | + sqlite3 *db = v->db; | |
| 70263 | + sqlite3_mutex_enter(db->mutex); | |
| 70264 | + checkProfileCallback(db, v); | |
| 70159 | 70265 | rc = sqlite3VdbeReset(v); |
| 70160 | 70266 | sqlite3VdbeRewind(v); |
| 70161 | - assert( (rc & (v->db->errMask))==rc ); | |
| 70162 | - rc = sqlite3ApiExit(v->db, rc); | |
| 70163 | - sqlite3_mutex_leave(v->db->mutex); | |
| 70267 | + assert( (rc & (db->errMask))==rc ); | |
| 70268 | + rc = sqlite3ApiExit(db, rc); | |
| 70269 | + sqlite3_mutex_leave(db->mutex); | |
| 70164 | 70270 | } |
| 70165 | 70271 | return rc; |
| 70166 | 70272 | } |
| 70167 | 70273 | |
| 70168 | 70274 | /* |
| @@ -70508,10 +70614,11 @@ | ||
| 70508 | 70614 | } |
| 70509 | 70615 | } |
| 70510 | 70616 | #endif |
| 70511 | 70617 | return rc; |
| 70512 | 70618 | } |
| 70619 | + | |
| 70513 | 70620 | |
| 70514 | 70621 | /* |
| 70515 | 70622 | ** Execute the statement pStmt, either until a row of data is ready, the |
| 70516 | 70623 | ** statement is completely executed or an error occurs. |
| 70517 | 70624 | ** |
| @@ -70577,12 +70684,14 @@ | ||
| 70577 | 70684 | assert( db->nVdbeWrite>0 || db->autoCommit==0 |
| 70578 | 70685 | || (db->nDeferredCons==0 && db->nDeferredImmCons==0) |
| 70579 | 70686 | ); |
| 70580 | 70687 | |
| 70581 | 70688 | #ifndef SQLITE_OMIT_TRACE |
| 70582 | - if( db->xProfile && !db->init.busy ){ | |
| 70689 | + if( db->xProfile && !db->init.busy && p->zSql ){ | |
| 70583 | 70690 | sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); |
| 70691 | + }else{ | |
| 70692 | + assert( p->startTime==0 ); | |
| 70584 | 70693 | } |
| 70585 | 70694 | #endif |
| 70586 | 70695 | |
| 70587 | 70696 | db->nVdbeActive++; |
| 70588 | 70697 | if( p->readOnly==0 ) db->nVdbeWrite++; |
| @@ -70602,17 +70711,12 @@ | ||
| 70602 | 70711 | rc = sqlite3VdbeExec(p); |
| 70603 | 70712 | db->nVdbeExec--; |
| 70604 | 70713 | } |
| 70605 | 70714 | |
| 70606 | 70715 | #ifndef SQLITE_OMIT_TRACE |
| 70607 | - /* Invoke the profile callback if there is one | |
| 70608 | - */ | |
| 70609 | - if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){ | |
| 70610 | - sqlite3_int64 iNow; | |
| 70611 | - sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); | |
| 70612 | - db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); | |
| 70613 | - } | |
| 70716 | + /* If the statement completed successfully, invoke the profile callback */ | |
| 70717 | + if( rc!=SQLITE_ROW ) checkProfileCallback(db, p); | |
| 70614 | 70718 | #endif |
| 70615 | 70719 | |
| 70616 | 70720 | if( rc==SQLITE_DONE ){ |
| 70617 | 70721 | assert( p->rc==SQLITE_OK ); |
| 70618 | 70722 | p->rc = doWalCallbacks(db); |
| @@ -71685,10 +71789,12 @@ | ||
| 71685 | 71789 | ** This file contains code used to insert the values of host parameters |
| 71686 | 71790 | ** (aka "wildcards") into the SQL text output by sqlite3_trace(). |
| 71687 | 71791 | ** |
| 71688 | 71792 | ** The Vdbe parse-tree explainer is also found here. |
| 71689 | 71793 | */ |
| 71794 | +/* #include "sqliteInt.h" */ | |
| 71795 | +/* #include "vdbeInt.h" */ | |
| 71690 | 71796 | |
| 71691 | 71797 | #ifndef SQLITE_OMIT_TRACE |
| 71692 | 71798 | |
| 71693 | 71799 | /* |
| 71694 | 71800 | ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of |
| @@ -71877,10 +71983,12 @@ | ||
| 71877 | 71983 | ** documentation, headers files, or other derived files. The formatting |
| 71878 | 71984 | ** of the code in this file is, therefore, important. See other comments |
| 71879 | 71985 | ** in this file for details. If in doubt, do not deviate from existing |
| 71880 | 71986 | ** commenting and indentation practices when changing or adding code. |
| 71881 | 71987 | */ |
| 71988 | +/* #include "sqliteInt.h" */ | |
| 71989 | +/* #include "vdbeInt.h" */ | |
| 71882 | 71990 | |
| 71883 | 71991 | /* |
| 71884 | 71992 | ** Invoke this macro on memory cells just prior to changing the |
| 71885 | 71993 | ** value of the cell. This macro verifies that shallow copies are |
| 71886 | 71994 | ** not misused. A shallow copy of a string or blob just copies a |
| @@ -78635,10 +78743,12 @@ | ||
| 78635 | 78743 | ************************************************************************* |
| 78636 | 78744 | ** |
| 78637 | 78745 | ** This file contains code used to implement incremental BLOB I/O. |
| 78638 | 78746 | */ |
| 78639 | 78747 | |
| 78748 | +/* #include "sqliteInt.h" */ | |
| 78749 | +/* #include "vdbeInt.h" */ | |
| 78640 | 78750 | |
| 78641 | 78751 | #ifndef SQLITE_OMIT_INCRBLOB |
| 78642 | 78752 | |
| 78643 | 78753 | /* |
| 78644 | 78754 | ** Valid sqlite3_blob* handles point to Incrblob structures. |
| @@ -79233,10 +79343,12 @@ | ||
| 79233 | 79343 | ** than one background thread may be created. Specifically, there may be |
| 79234 | 79344 | ** one background thread for each temporary file on disk, and one background |
| 79235 | 79345 | ** thread to merge the output of each of the others to a single PMA for |
| 79236 | 79346 | ** the main thread to read from. |
| 79237 | 79347 | */ |
| 79348 | +/* #include "sqliteInt.h" */ | |
| 79349 | +/* #include "vdbeInt.h" */ | |
| 79238 | 79350 | |
| 79239 | 79351 | /* |
| 79240 | 79352 | ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various |
| 79241 | 79353 | ** messages to stderr that may be helpful in understanding the performance |
| 79242 | 79354 | ** characteristics of the sorter in multi-threaded mode. |
| @@ -81849,10 +81961,11 @@ | ||
| 81849 | 81961 | ** 1) The in-memory representation grows too large for the allocated |
| 81850 | 81962 | ** buffer, or |
| 81851 | 81963 | ** 2) The sqlite3JournalCreate() function is called. |
| 81852 | 81964 | */ |
| 81853 | 81965 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 81966 | +/* #include "sqliteInt.h" */ | |
| 81854 | 81967 | |
| 81855 | 81968 | |
| 81856 | 81969 | /* |
| 81857 | 81970 | ** A JournalFile object is a subclass of sqlite3_file used by |
| 81858 | 81971 | ** as an open file handle for journal files. |
| @@ -82096,10 +82209,11 @@ | ||
| 82096 | 82209 | ** |
| 82097 | 82210 | ** This file contains code use to implement an in-memory rollback journal. |
| 82098 | 82211 | ** The in-memory rollback journal is used to journal transactions for |
| 82099 | 82212 | ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. |
| 82100 | 82213 | */ |
| 82214 | +/* #include "sqliteInt.h" */ | |
| 82101 | 82215 | |
| 82102 | 82216 | /* Forward references to internal structures */ |
| 82103 | 82217 | typedef struct MemJournal MemJournal; |
| 82104 | 82218 | typedef struct FilePoint FilePoint; |
| 82105 | 82219 | typedef struct FileChunk FileChunk; |
| @@ -82351,10 +82465,11 @@ | ||
| 82351 | 82465 | ** |
| 82352 | 82466 | ************************************************************************* |
| 82353 | 82467 | ** This file contains routines used for walking the parser tree for |
| 82354 | 82468 | ** an SQL statement. |
| 82355 | 82469 | */ |
| 82470 | +/* #include "sqliteInt.h" */ | |
| 82356 | 82471 | /* #include <stdlib.h> */ |
| 82357 | 82472 | /* #include <string.h> */ |
| 82358 | 82473 | |
| 82359 | 82474 | |
| 82360 | 82475 | /* |
| @@ -82509,10 +82624,11 @@ | ||
| 82509 | 82624 | ** |
| 82510 | 82625 | ** This file contains routines used for walking the parser tree and |
| 82511 | 82626 | ** resolve all identifiers by associating them with a particular |
| 82512 | 82627 | ** table and column. |
| 82513 | 82628 | */ |
| 82629 | +/* #include "sqliteInt.h" */ | |
| 82514 | 82630 | /* #include <stdlib.h> */ |
| 82515 | 82631 | /* #include <string.h> */ |
| 82516 | 82632 | |
| 82517 | 82633 | /* |
| 82518 | 82634 | ** Walk the expression tree pExpr and increase the aggregate function |
| @@ -84021,10 +84137,11 @@ | ||
| 84021 | 84137 | ** |
| 84022 | 84138 | ************************************************************************* |
| 84023 | 84139 | ** This file contains routines used for analyzing expressions and |
| 84024 | 84140 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 84025 | 84141 | */ |
| 84142 | +/* #include "sqliteInt.h" */ | |
| 84026 | 84143 | |
| 84027 | 84144 | /* |
| 84028 | 84145 | ** Return the 'affinity' of the expression pExpr if any. |
| 84029 | 84146 | ** |
| 84030 | 84147 | ** If pExpr is a column, a reference to a column via an 'AS' alias, |
| @@ -88183,10 +88300,11 @@ | ||
| 88183 | 88300 | ** |
| 88184 | 88301 | ************************************************************************* |
| 88185 | 88302 | ** This file contains C code routines that used to generate VDBE code |
| 88186 | 88303 | ** that implements the ALTER TABLE command. |
| 88187 | 88304 | */ |
| 88305 | +/* #include "sqliteInt.h" */ | |
| 88188 | 88306 | |
| 88189 | 88307 | /* |
| 88190 | 88308 | ** The code in this file only exists if we are not omitting the |
| 88191 | 88309 | ** ALTER TABLE logic from the build. |
| 88192 | 88310 | */ |
| @@ -89145,10 +89263,11 @@ | ||
| 89145 | 89263 | ** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3 |
| 89146 | 89264 | ** all contain just a single integer which is the same as the first |
| 89147 | 89265 | ** integer in the equivalent columns in sqlite_stat4. |
| 89148 | 89266 | */ |
| 89149 | 89267 | #ifndef SQLITE_OMIT_ANALYZE |
| 89268 | +/* #include "sqliteInt.h" */ | |
| 89150 | 89269 | |
| 89151 | 89270 | #if defined(SQLITE_ENABLE_STAT4) |
| 89152 | 89271 | # define IsStat4 1 |
| 89153 | 89272 | # define IsStat3 0 |
| 89154 | 89273 | #elif defined(SQLITE_ENABLE_STAT3) |
| @@ -90910,10 +91029,11 @@ | ||
| 90910 | 91029 | ** May you share freely, never taking more than you give. |
| 90911 | 91030 | ** |
| 90912 | 91031 | ************************************************************************* |
| 90913 | 91032 | ** This file contains code used to implement the ATTACH and DETACH commands. |
| 90914 | 91033 | */ |
| 91034 | +/* #include "sqliteInt.h" */ | |
| 90915 | 91035 | |
| 90916 | 91036 | #ifndef SQLITE_OMIT_ATTACH |
| 90917 | 91037 | /* |
| 90918 | 91038 | ** Resolve an expression that was part of an ATTACH or DETACH statement. This |
| 90919 | 91039 | ** is slightly different from resolving a normal SQL expression, because simple |
| @@ -91499,10 +91619,11 @@ | ||
| 91499 | 91619 | ** This file contains code used to implement the sqlite3_set_authorizer() |
| 91500 | 91620 | ** API. This facility is an optional feature of the library. Embedded |
| 91501 | 91621 | ** systems that do not need this facility may omit it by recompiling |
| 91502 | 91622 | ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 |
| 91503 | 91623 | */ |
| 91624 | +/* #include "sqliteInt.h" */ | |
| 91504 | 91625 | |
| 91505 | 91626 | /* |
| 91506 | 91627 | ** All of the code in this file may be omitted by defining a single |
| 91507 | 91628 | ** macro. |
| 91508 | 91629 | */ |
| @@ -91769,10 +91890,11 @@ | ||
| 91769 | 91890 | ** creating ID lists |
| 91770 | 91891 | ** BEGIN TRANSACTION |
| 91771 | 91892 | ** COMMIT |
| 91772 | 91893 | ** ROLLBACK |
| 91773 | 91894 | */ |
| 91895 | +/* #include "sqliteInt.h" */ | |
| 91774 | 91896 | |
| 91775 | 91897 | /* |
| 91776 | 91898 | ** This routine is called when a new SQL statement is beginning to |
| 91777 | 91899 | ** be parsed. Initialize the pParse structure as needed. |
| 91778 | 91900 | */ |
| @@ -96089,10 +96211,11 @@ | ||
| 96089 | 96211 | ** |
| 96090 | 96212 | ** This file contains functions used to access the internal hash tables |
| 96091 | 96213 | ** of user defined functions and collation sequences. |
| 96092 | 96214 | */ |
| 96093 | 96215 | |
| 96216 | +/* #include "sqliteInt.h" */ | |
| 96094 | 96217 | |
| 96095 | 96218 | /* |
| 96096 | 96219 | ** Invoke the 'collation needed' callback to request a collation sequence |
| 96097 | 96220 | ** in the encoding enc of name zName, length nName. |
| 96098 | 96221 | */ |
| @@ -96566,10 +96689,11 @@ | ||
| 96566 | 96689 | ** |
| 96567 | 96690 | ************************************************************************* |
| 96568 | 96691 | ** This file contains C code routines that are called by the parser |
| 96569 | 96692 | ** in order to generate code for DELETE FROM statements. |
| 96570 | 96693 | */ |
| 96694 | +/* #include "sqliteInt.h" */ | |
| 96571 | 96695 | |
| 96572 | 96696 | /* |
| 96573 | 96697 | ** While a SrcList can in general represent multiple tables and subqueries |
| 96574 | 96698 | ** (as in the FROM clause of a SELECT statement) in this case it contains |
| 96575 | 96699 | ** the name of a single table, as one might find in an INSERT, DELETE, |
| @@ -97408,12 +97532,14 @@ | ||
| 97408 | 97532 | ************************************************************************* |
| 97409 | 97533 | ** This file contains the C-language implementations for many of the SQL |
| 97410 | 97534 | ** functions of SQLite. (Some function, and in particular the date and |
| 97411 | 97535 | ** time functions, are implemented separately.) |
| 97412 | 97536 | */ |
| 97537 | +/* #include "sqliteInt.h" */ | |
| 97413 | 97538 | /* #include <stdlib.h> */ |
| 97414 | 97539 | /* #include <assert.h> */ |
| 97540 | +/* #include "vdbeInt.h" */ | |
| 97415 | 97541 | |
| 97416 | 97542 | /* |
| 97417 | 97543 | ** Return the collating function associated with a function. |
| 97418 | 97544 | */ |
| 97419 | 97545 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -99205,10 +99331,11 @@ | ||
| 99205 | 99331 | ** |
| 99206 | 99332 | ************************************************************************* |
| 99207 | 99333 | ** This file contains code used by the compiler to add foreign key |
| 99208 | 99334 | ** support to compiled SQL statements. |
| 99209 | 99335 | */ |
| 99336 | +/* #include "sqliteInt.h" */ | |
| 99210 | 99337 | |
| 99211 | 99338 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 99212 | 99339 | #ifndef SQLITE_OMIT_TRIGGER |
| 99213 | 99340 | |
| 99214 | 99341 | /* |
| @@ -100609,10 +100736,11 @@ | ||
| 100609 | 100736 | ** |
| 100610 | 100737 | ************************************************************************* |
| 100611 | 100738 | ** This file contains C code routines that are called by the parser |
| 100612 | 100739 | ** to handle INSERT statements in SQLite. |
| 100613 | 100740 | */ |
| 100741 | +/* #include "sqliteInt.h" */ | |
| 100614 | 100742 | |
| 100615 | 100743 | /* |
| 100616 | 100744 | ** Generate code that will |
| 100617 | 100745 | ** |
| 100618 | 100746 | ** (1) acquire a lock for table pTab then |
| @@ -102671,10 +102799,11 @@ | ||
| 102671 | 102799 | ** implement the programmer interface to the library. Routines in |
| 102672 | 102800 | ** other files are for internal use by SQLite and should not be |
| 102673 | 102801 | ** accessed by users of the library. |
| 102674 | 102802 | */ |
| 102675 | 102803 | |
| 102804 | +/* #include "sqliteInt.h" */ | |
| 102676 | 102805 | |
| 102677 | 102806 | /* |
| 102678 | 102807 | ** Execute SQL code. Return one of the SQLITE_ success/failure |
| 102679 | 102808 | ** codes. Also write an error message into memory obtained from |
| 102680 | 102809 | ** malloc() and make *pzErrMsg point to that message. |
| @@ -102839,10 +102968,11 @@ | ||
| 102839 | 102968 | ** as extensions by SQLite should #include this file instead of |
| 102840 | 102969 | ** sqlite3.h. |
| 102841 | 102970 | */ |
| 102842 | 102971 | #ifndef _SQLITE3EXT_H_ |
| 102843 | 102972 | #define _SQLITE3EXT_H_ |
| 102973 | +/* #include "sqlite3.h" */ | |
| 102844 | 102974 | |
| 102845 | 102975 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 102846 | 102976 | |
| 102847 | 102977 | /* |
| 102848 | 102978 | ** The following structure holds pointers to all of the SQLite API |
| @@ -103345,10 +103475,11 @@ | ||
| 103345 | 103475 | |
| 103346 | 103476 | #endif /* _SQLITE3EXT_H_ */ |
| 103347 | 103477 | |
| 103348 | 103478 | /************** End of sqlite3ext.h ******************************************/ |
| 103349 | 103479 | /************** Continuing where we left off in loadext.c ********************/ |
| 103480 | +/* #include "sqliteInt.h" */ | |
| 103350 | 103481 | /* #include <string.h> */ |
| 103351 | 103482 | |
| 103352 | 103483 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 103353 | 103484 | |
| 103354 | 103485 | /* |
| @@ -104114,10 +104245,11 @@ | ||
| 104114 | 104245 | ** May you share freely, never taking more than you give. |
| 104115 | 104246 | ** |
| 104116 | 104247 | ************************************************************************* |
| 104117 | 104248 | ** This file contains code used to implement the PRAGMA command. |
| 104118 | 104249 | */ |
| 104250 | +/* #include "sqliteInt.h" */ | |
| 104119 | 104251 | |
| 104120 | 104252 | #if !defined(SQLITE_ENABLE_LOCKING_STYLE) |
| 104121 | 104253 | # if defined(__APPLE__) |
| 104122 | 104254 | # define SQLITE_ENABLE_LOCKING_STYLE 1 |
| 104123 | 104255 | # else |
| @@ -104220,11 +104352,11 @@ | ||
| 104220 | 104352 | /* ePragFlag: */ 0, |
| 104221 | 104353 | /* iArg: */ 0 }, |
| 104222 | 104354 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 104223 | 104355 | { /* zName: */ "cache_size", |
| 104224 | 104356 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 104225 | - /* ePragFlag: */ PragFlag_NeedSchema, | |
| 104357 | + /* ePragFlag: */ 0, | |
| 104226 | 104358 | /* iArg: */ 0 }, |
| 104227 | 104359 | #endif |
| 104228 | 104360 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 104229 | 104361 | { /* zName: */ "cache_spill", |
| 104230 | 104362 | /* ePragTyp: */ PragTyp_FLAG, |
| @@ -105290,10 +105422,11 @@ | ||
| 105290 | 105422 | ** of memory. |
| 105291 | 105423 | */ |
| 105292 | 105424 | case PragTyp_CACHE_SIZE: { |
| 105293 | 105425 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 105294 | 105426 | if( !zRight ){ |
| 105427 | + if( sqlite3ReadSchema(pParse) ) goto pragma_out; | |
| 105295 | 105428 | returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); |
| 105296 | 105429 | }else{ |
| 105297 | 105430 | int size = sqlite3Atoi(zRight); |
| 105298 | 105431 | pDb->pSchema->cache_size = size; |
| 105299 | 105432 | sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); |
| @@ -106565,10 +106698,11 @@ | ||
| 106565 | 106698 | ************************************************************************* |
| 106566 | 106699 | ** This file contains the implementation of the sqlite3_prepare() |
| 106567 | 106700 | ** interface, and routines that contribute to loading the database schema |
| 106568 | 106701 | ** from disk. |
| 106569 | 106702 | */ |
| 106703 | +/* #include "sqliteInt.h" */ | |
| 106570 | 106704 | |
| 106571 | 106705 | /* |
| 106572 | 106706 | ** Fill the InitData structure with an error message that indicates |
| 106573 | 106707 | ** that the database is corrupt. |
| 106574 | 106708 | */ |
| @@ -107459,10 +107593,11 @@ | ||
| 107459 | 107593 | ** |
| 107460 | 107594 | ************************************************************************* |
| 107461 | 107595 | ** This file contains C code routines that are called by the parser |
| 107462 | 107596 | ** to handle SELECT statements in SQLite. |
| 107463 | 107597 | */ |
| 107598 | +/* #include "sqliteInt.h" */ | |
| 107464 | 107599 | |
| 107465 | 107600 | /* |
| 107466 | 107601 | ** Trace output macros |
| 107467 | 107602 | */ |
| 107468 | 107603 | #if SELECTTRACE_ENABLED |
| @@ -108528,11 +108663,10 @@ | ||
| 108528 | 108663 | } |
| 108529 | 108664 | } |
| 108530 | 108665 | return pInfo; |
| 108531 | 108666 | } |
| 108532 | 108667 | |
| 108533 | -#ifndef SQLITE_OMIT_COMPOUND_SELECT | |
| 108534 | 108668 | /* |
| 108535 | 108669 | ** Name of the connection operator, used for error messages. |
| 108536 | 108670 | */ |
| 108537 | 108671 | static const char *selectOpName(int id){ |
| 108538 | 108672 | char *z; |
| @@ -108542,11 +108676,10 @@ | ||
| 108542 | 108676 | case TK_EXCEPT: z = "EXCEPT"; break; |
| 108543 | 108677 | default: z = "UNION"; break; |
| 108544 | 108678 | } |
| 108545 | 108679 | return z; |
| 108546 | 108680 | } |
| 108547 | -#endif /* SQLITE_OMIT_COMPOUND_SELECT */ | |
| 108548 | 108681 | |
| 108549 | 108682 | #ifndef SQLITE_OMIT_EXPLAIN |
| 108550 | 108683 | /* |
| 108551 | 108684 | ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function |
| 108552 | 108685 | ** is a no-op. Otherwise, it adds a single row of output to the EQP result, |
| @@ -109545,23 +109678,10 @@ | ||
| 109545 | 109678 | Parse *pParse, /* Parsing context */ |
| 109546 | 109679 | Select *p, /* The right-most of SELECTs to be coded */ |
| 109547 | 109680 | SelectDest *pDest /* What to do with query results */ |
| 109548 | 109681 | ); |
| 109549 | 109682 | |
| 109550 | -/* | |
| 109551 | -** Error message for when two or more terms of a compound select have different | |
| 109552 | -** size result sets. | |
| 109553 | -*/ | |
| 109554 | -SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ | |
| 109555 | - if( p->selFlags & SF_Values ){ | |
| 109556 | - sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); | |
| 109557 | - }else{ | |
| 109558 | - sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" | |
| 109559 | - " do not have the same number of result columns", selectOpName(p->op)); | |
| 109560 | - } | |
| 109561 | -} | |
| 109562 | - | |
| 109563 | 109683 | /* |
| 109564 | 109684 | ** Handle the special case of a compound-select that originates from a |
| 109565 | 109685 | ** VALUES clause. By handling this as a special case, we avoid deep |
| 109566 | 109686 | ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT |
| 109567 | 109687 | ** on a VALUES clause. |
| @@ -109983,10 +110103,23 @@ | ||
| 109983 | 110103 | pDest->nSdst = dest.nSdst; |
| 109984 | 110104 | sqlite3SelectDelete(db, pDelete); |
| 109985 | 110105 | return rc; |
| 109986 | 110106 | } |
| 109987 | 110107 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 110108 | + | |
| 110109 | +/* | |
| 110110 | +** Error message for when two or more terms of a compound select have different | |
| 110111 | +** size result sets. | |
| 110112 | +*/ | |
| 110113 | +SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ | |
| 110114 | + if( p->selFlags & SF_Values ){ | |
| 110115 | + sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); | |
| 110116 | + }else{ | |
| 110117 | + sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" | |
| 110118 | + " do not have the same number of result columns", selectOpName(p->op)); | |
| 110119 | + } | |
| 110120 | +} | |
| 109988 | 110121 | |
| 109989 | 110122 | /* |
| 109990 | 110123 | ** Code an output subroutine for a coroutine implementation of a |
| 109991 | 110124 | ** SELECT statment. |
| 109992 | 110125 | ** |
| @@ -113077,10 +113210,11 @@ | ||
| 113077 | 113210 | ** interface routine of sqlite3_exec(). |
| 113078 | 113211 | ** |
| 113079 | 113212 | ** These routines are in a separate files so that they will not be linked |
| 113080 | 113213 | ** if they are not used. |
| 113081 | 113214 | */ |
| 113215 | +/* #include "sqliteInt.h" */ | |
| 113082 | 113216 | /* #include <stdlib.h> */ |
| 113083 | 113217 | /* #include <string.h> */ |
| 113084 | 113218 | |
| 113085 | 113219 | #ifndef SQLITE_OMIT_GET_TABLE |
| 113086 | 113220 | |
| @@ -113273,10 +113407,11 @@ | ||
| 113273 | 113407 | ** May you share freely, never taking more than you give. |
| 113274 | 113408 | ** |
| 113275 | 113409 | ************************************************************************* |
| 113276 | 113410 | ** This file contains the implementation for TRIGGERs |
| 113277 | 113411 | */ |
| 113412 | +/* #include "sqliteInt.h" */ | |
| 113278 | 113413 | |
| 113279 | 113414 | #ifndef SQLITE_OMIT_TRIGGER |
| 113280 | 113415 | /* |
| 113281 | 113416 | ** Delete a linked list of TriggerStep structures. |
| 113282 | 113417 | */ |
| @@ -114396,10 +114531,11 @@ | ||
| 114396 | 114531 | ** |
| 114397 | 114532 | ************************************************************************* |
| 114398 | 114533 | ** This file contains C code routines that are called by the parser |
| 114399 | 114534 | ** to handle UPDATE statements. |
| 114400 | 114535 | */ |
| 114536 | +/* #include "sqliteInt.h" */ | |
| 114401 | 114537 | |
| 114402 | 114538 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 114403 | 114539 | /* Forward declaration */ |
| 114404 | 114540 | static void updateVirtualTable( |
| 114405 | 114541 | Parse *pParse, /* The parsing context */ |
| @@ -115172,10 +115308,12 @@ | ||
| 115172 | 115308 | ** This file contains code used to implement the VACUUM command. |
| 115173 | 115309 | ** |
| 115174 | 115310 | ** Most of the code in this file may be omitted by defining the |
| 115175 | 115311 | ** SQLITE_OMIT_VACUUM macro. |
| 115176 | 115312 | */ |
| 115313 | +/* #include "sqliteInt.h" */ | |
| 115314 | +/* #include "vdbeInt.h" */ | |
| 115177 | 115315 | |
| 115178 | 115316 | #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) |
| 115179 | 115317 | /* |
| 115180 | 115318 | ** Finalize a prepared statement. If there was an error, store the |
| 115181 | 115319 | ** text of the error message in *pzErrMsg. Return the result code. |
| @@ -115544,10 +115682,11 @@ | ||
| 115544 | 115682 | ** |
| 115545 | 115683 | ************************************************************************* |
| 115546 | 115684 | ** This file contains code used to help implement virtual tables. |
| 115547 | 115685 | */ |
| 115548 | 115686 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 115687 | +/* #include "sqliteInt.h" */ | |
| 115549 | 115688 | |
| 115550 | 115689 | /* |
| 115551 | 115690 | ** Before a virtual table xCreate() or xConnect() method is invoked, the |
| 115552 | 115691 | ** sqlite3.pVtabCtx member variable is set to point to an instance of |
| 115553 | 115692 | ** this struct allocated on the stack. It is used by the implementation of |
| @@ -116702,10 +116841,11 @@ | ||
| 116702 | 116841 | ** This file was split off from where.c on 2015-06-06 in order to reduce the |
| 116703 | 116842 | ** size of where.c and make it easier to edit. This file contains the routines |
| 116704 | 116843 | ** that actually generate the bulk of the WHERE loop code. The original where.c |
| 116705 | 116844 | ** file retains the code that does query planning and analysis. |
| 116706 | 116845 | */ |
| 116846 | +/* #include "sqliteInt.h" */ | |
| 116707 | 116847 | /************** Include whereInt.h in the middle of wherecode.c **************/ |
| 116708 | 116848 | /************** Begin file whereInt.h ****************************************/ |
| 116709 | 116849 | /* |
| 116710 | 116850 | ** 2013-11-12 |
| 116711 | 116851 | ** |
| @@ -118737,10 +118877,12 @@ | ||
| 118737 | 118877 | ** |
| 118738 | 118878 | ** This file was originally part of where.c but was split out to improve |
| 118739 | 118879 | ** readability and editabiliity. This file contains utility routines for |
| 118740 | 118880 | ** analyzing Expr objects in the WHERE clause. |
| 118741 | 118881 | */ |
| 118882 | +/* #include "sqliteInt.h" */ | |
| 118883 | +/* #include "whereInt.h" */ | |
| 118742 | 118884 | |
| 118743 | 118885 | /* Forward declarations */ |
| 118744 | 118886 | static void exprAnalyze(SrcList*, WhereClause*, int); |
| 118745 | 118887 | |
| 118746 | 118888 | /* |
| @@ -119987,10 +120129,12 @@ | ||
| 119987 | 120129 | ** generating the code that loops through a table looking for applicable |
| 119988 | 120130 | ** rows. Indices are selected and used to speed the search when doing |
| 119989 | 120131 | ** so is applicable. Because this module is responsible for selecting |
| 119990 | 120132 | ** indices, you might also think of this module as the "query optimizer". |
| 119991 | 120133 | */ |
| 120134 | +/* #include "sqliteInt.h" */ | |
| 120135 | +/* #include "whereInt.h" */ | |
| 119992 | 120136 | |
| 119993 | 120137 | /* Forward declaration of methods */ |
| 119994 | 120138 | static int whereLoopResize(sqlite3*, WhereLoop*, int); |
| 119995 | 120139 | |
| 119996 | 120140 | /* Test variable that can be set to enable WHERE tracing */ |
| @@ -124486,10 +124630,11 @@ | ||
| 124486 | 124630 | */ |
| 124487 | 124631 | /* First off, code is included that follows the "include" declaration |
| 124488 | 124632 | ** in the input grammar file. */ |
| 124489 | 124633 | /* #include <stdio.h> */ |
| 124490 | 124634 | |
| 124635 | +/* #include "sqliteInt.h" */ | |
| 124491 | 124636 | |
| 124492 | 124637 | /* |
| 124493 | 124638 | ** Disable all error recovery processing in the parser push-down |
| 124494 | 124639 | ** automaton. |
| 124495 | 124640 | */ |
| @@ -128071,10 +128216,11 @@ | ||
| 128071 | 128216 | ** |
| 128072 | 128217 | ** This file contains C code that splits an SQL input string up into |
| 128073 | 128218 | ** individual tokens and sends those tokens one-by-one over to the |
| 128074 | 128219 | ** parser for analysis. |
| 128075 | 128220 | */ |
| 128221 | +/* #include "sqliteInt.h" */ | |
| 128076 | 128222 | /* #include <stdlib.h> */ |
| 128077 | 128223 | |
| 128078 | 128224 | /* |
| 128079 | 128225 | ** The charMap() macro maps alphabetic characters into their |
| 128080 | 128226 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -128880,10 +129026,11 @@ | ||
| 128880 | 129026 | ** This file contains C code that implements the sqlite3_complete() API. |
| 128881 | 129027 | ** This code used to be part of the tokenizer.c source file. But by |
| 128882 | 129028 | ** separating it out, the code will be automatically omitted from |
| 128883 | 129029 | ** static links that do not use it. |
| 128884 | 129030 | */ |
| 129031 | +/* #include "sqliteInt.h" */ | |
| 128885 | 129032 | #ifndef SQLITE_OMIT_COMPLETE |
| 128886 | 129033 | |
| 128887 | 129034 | /* |
| 128888 | 129035 | ** This is defined in tokenize.c. We just have to import the definition. |
| 128889 | 129036 | */ |
| @@ -129170,10 +129317,11 @@ | ||
| 129170 | 129317 | ** Main file for the SQLite library. The routines in this file |
| 129171 | 129318 | ** implement the programmer interface to the library. Routines in |
| 129172 | 129319 | ** other files are for internal use by SQLite and should not be |
| 129173 | 129320 | ** accessed by users of the library. |
| 129174 | 129321 | */ |
| 129322 | +/* #include "sqliteInt.h" */ | |
| 129175 | 129323 | |
| 129176 | 129324 | #ifdef SQLITE_ENABLE_FTS3 |
| 129177 | 129325 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 129178 | 129326 | /************** Begin file fts3.h ********************************************/ |
| 129179 | 129327 | /* |
| @@ -129189,10 +129337,11 @@ | ||
| 129189 | 129337 | ****************************************************************************** |
| 129190 | 129338 | ** |
| 129191 | 129339 | ** This header file is used by programs that want to link against the |
| 129192 | 129340 | ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface. |
| 129193 | 129341 | */ |
| 129342 | +/* #include "sqlite3.h" */ | |
| 129194 | 129343 | |
| 129195 | 129344 | #if 0 |
| 129196 | 129345 | extern "C" { |
| 129197 | 129346 | #endif /* __cplusplus */ |
| 129198 | 129347 | |
| @@ -129221,10 +129370,11 @@ | ||
| 129221 | 129370 | ****************************************************************************** |
| 129222 | 129371 | ** |
| 129223 | 129372 | ** This header file is used by programs that want to link against the |
| 129224 | 129373 | ** RTREE library. All it does is declare the sqlite3RtreeInit() interface. |
| 129225 | 129374 | */ |
| 129375 | +/* #include "sqlite3.h" */ | |
| 129226 | 129376 | |
| 129227 | 129377 | #if 0 |
| 129228 | 129378 | extern "C" { |
| 129229 | 129379 | #endif /* __cplusplus */ |
| 129230 | 129380 | |
| @@ -129253,10 +129403,11 @@ | ||
| 129253 | 129403 | ****************************************************************************** |
| 129254 | 129404 | ** |
| 129255 | 129405 | ** This header file is used by programs that want to link against the |
| 129256 | 129406 | ** ICU extension. All it does is declare the sqlite3IcuInit() interface. |
| 129257 | 129407 | */ |
| 129408 | +/* #include "sqlite3.h" */ | |
| 129258 | 129409 | |
| 129259 | 129410 | #if 0 |
| 129260 | 129411 | extern "C" { |
| 129261 | 129412 | #endif /* __cplusplus */ |
| 129262 | 129413 | |
| @@ -133045,10 +133196,12 @@ | ||
| 133045 | 133196 | ************************************************************************* |
| 133046 | 133197 | ** |
| 133047 | 133198 | ** This file contains the implementation of the sqlite3_unlock_notify() |
| 133048 | 133199 | ** API method and its associated functionality. |
| 133049 | 133200 | */ |
| 133201 | +/* #include "sqliteInt.h" */ | |
| 133202 | +/* #include "btreeInt.h" */ | |
| 133050 | 133203 | |
| 133051 | 133204 | /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ |
| 133052 | 133205 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 133053 | 133206 | |
| 133054 | 133207 | /* |
| @@ -133688,13 +133841,15 @@ | ||
| 133688 | 133841 | |
| 133689 | 133842 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 133690 | 133843 | |
| 133691 | 133844 | /* If not building as part of the core, include sqlite3ext.h. */ |
| 133692 | 133845 | #ifndef SQLITE_CORE |
| 133846 | +/* # include "sqlite3ext.h" */ | |
| 133693 | 133847 | SQLITE_EXTENSION_INIT3 |
| 133694 | 133848 | #endif |
| 133695 | 133849 | |
| 133850 | +/* #include "sqlite3.h" */ | |
| 133696 | 133851 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 133697 | 133852 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 133698 | 133853 | /* |
| 133699 | 133854 | ** 2006 July 10 |
| 133700 | 133855 | ** |
| @@ -133719,10 +133874,11 @@ | ||
| 133719 | 133874 | |
| 133720 | 133875 | /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time. |
| 133721 | 133876 | ** If tokenizers are to be allowed to call sqlite3_*() functions, then |
| 133722 | 133877 | ** we will need a way to register the API consistently. |
| 133723 | 133878 | */ |
| 133879 | +/* #include "sqlite3.h" */ | |
| 133724 | 133880 | |
| 133725 | 133881 | /* |
| 133726 | 133882 | ** Structures used by the tokenizer interface. When a new tokenizer |
| 133727 | 133883 | ** implementation is registered, the caller provides a pointer to |
| 133728 | 133884 | ** an sqlite3_tokenizer_module containing pointers to the callback |
| @@ -134559,11 +134715,13 @@ | ||
| 134559 | 134715 | /* #include <stddef.h> */ |
| 134560 | 134716 | /* #include <stdio.h> */ |
| 134561 | 134717 | /* #include <string.h> */ |
| 134562 | 134718 | /* #include <stdarg.h> */ |
| 134563 | 134719 | |
| 134720 | +/* #include "fts3.h" */ | |
| 134564 | 134721 | #ifndef SQLITE_CORE |
| 134722 | +/* # include "sqlite3ext.h" */ | |
| 134565 | 134723 | SQLITE_EXTENSION_INIT1 |
| 134566 | 134724 | #endif |
| 134567 | 134725 | |
| 134568 | 134726 | static int fts3EvalNext(Fts3Cursor *pCsr); |
| 134569 | 134727 | static int fts3EvalStart(Fts3Cursor *pCsr); |
| @@ -138606,10 +138764,11 @@ | ||
| 138606 | 138764 | if( p==0 ){ |
| 138607 | 138765 | p = aDoclist; |
| 138608 | 138766 | p += sqlite3Fts3GetVarint(p, piDocid); |
| 138609 | 138767 | }else{ |
| 138610 | 138768 | fts3PoslistCopy(0, &p); |
| 138769 | + while( p<&aDoclist[nDoclist] && *p==0 ) p++; | |
| 138611 | 138770 | if( p>=&aDoclist[nDoclist] ){ |
| 138612 | 138771 | *pbEof = 1; |
| 138613 | 138772 | }else{ |
| 138614 | 138773 | sqlite3_int64 iVar; |
| 138615 | 138774 | p += sqlite3Fts3GetVarint(p, &iVar); |
| @@ -140012,14 +140171,14 @@ | ||
| 140012 | 140171 | pIter = pPhrase->doclist.pList; |
| 140013 | 140172 | if( iDocid!=pCsr->iPrevId || pExpr->bEof ){ |
| 140014 | 140173 | int rc = SQLITE_OK; |
| 140015 | 140174 | int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */ |
| 140016 | 140175 | int bOr = 0; |
| 140017 | - u8 bEof = 0; | |
| 140018 | 140176 | u8 bTreeEof = 0; |
| 140019 | 140177 | Fts3Expr *p; /* Used to iterate from pExpr to root */ |
| 140020 | 140178 | Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */ |
| 140179 | + int bMatch; | |
| 140021 | 140180 | |
| 140022 | 140181 | /* Check if this phrase descends from an OR expression node. If not, |
| 140023 | 140182 | ** return NULL. Otherwise, the entry that corresponds to docid |
| 140024 | 140183 | ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the |
| 140025 | 140184 | ** tree that the node is part of has been marked as EOF, but the node |
| @@ -140049,35 +140208,51 @@ | ||
| 140049 | 140208 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 140050 | 140209 | } |
| 140051 | 140210 | } |
| 140052 | 140211 | if( rc!=SQLITE_OK ) return rc; |
| 140053 | 140212 | |
| 140054 | - pIter = pPhrase->pOrPoslist; | |
| 140055 | - iDocid = pPhrase->iOrDocid; | |
| 140056 | - if( pCsr->bDesc==bDescDoclist ){ | |
| 140057 | - bEof = !pPhrase->doclist.nAll || | |
| 140058 | - (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll)); | |
| 140059 | - while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){ | |
| 140060 | - sqlite3Fts3DoclistNext( | |
| 140061 | - bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, | |
| 140062 | - &pIter, &iDocid, &bEof | |
| 140063 | - ); | |
| 140064 | - } | |
| 140065 | - }else{ | |
| 140066 | - bEof = !pPhrase->doclist.nAll || (pIter && pIter<=pPhrase->doclist.aAll); | |
| 140067 | - while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){ | |
| 140068 | - int dummy; | |
| 140069 | - sqlite3Fts3DoclistPrev( | |
| 140070 | - bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, | |
| 140071 | - &pIter, &iDocid, &dummy, &bEof | |
| 140072 | - ); | |
| 140073 | - } | |
| 140074 | - } | |
| 140075 | - pPhrase->pOrPoslist = pIter; | |
| 140076 | - pPhrase->iOrDocid = iDocid; | |
| 140077 | - | |
| 140078 | - if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0; | |
| 140213 | + bMatch = 1; | |
| 140214 | + for(p=pNear; p; p=p->pLeft){ | |
| 140215 | + u8 bEof = 0; | |
| 140216 | + Fts3Expr *pTest = p; | |
| 140217 | + Fts3Phrase *pPh; | |
| 140218 | + assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE ); | |
| 140219 | + if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight; | |
| 140220 | + assert( pTest->eType==FTSQUERY_PHRASE ); | |
| 140221 | + pPh = pTest->pPhrase; | |
| 140222 | + | |
| 140223 | + pIter = pPh->pOrPoslist; | |
| 140224 | + iDocid = pPh->iOrDocid; | |
| 140225 | + if( pCsr->bDesc==bDescDoclist ){ | |
| 140226 | + bEof = !pPh->doclist.nAll || | |
| 140227 | + (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll)); | |
| 140228 | + while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){ | |
| 140229 | + sqlite3Fts3DoclistNext( | |
| 140230 | + bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, | |
| 140231 | + &pIter, &iDocid, &bEof | |
| 140232 | + ); | |
| 140233 | + } | |
| 140234 | + }else{ | |
| 140235 | + bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll); | |
| 140236 | + while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){ | |
| 140237 | + int dummy; | |
| 140238 | + sqlite3Fts3DoclistPrev( | |
| 140239 | + bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, | |
| 140240 | + &pIter, &iDocid, &dummy, &bEof | |
| 140241 | + ); | |
| 140242 | + } | |
| 140243 | + } | |
| 140244 | + pPh->pOrPoslist = pIter; | |
| 140245 | + pPh->iOrDocid = iDocid; | |
| 140246 | + if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0; | |
| 140247 | + } | |
| 140248 | + | |
| 140249 | + if( bMatch ){ | |
| 140250 | + pIter = pPhrase->pOrPoslist; | |
| 140251 | + }else{ | |
| 140252 | + pIter = 0; | |
| 140253 | + } | |
| 140079 | 140254 | } |
| 140080 | 140255 | if( pIter==0 ) return SQLITE_OK; |
| 140081 | 140256 | |
| 140082 | 140257 | if( *pIter==0x01 ){ |
| 140083 | 140258 | pIter++; |
| @@ -140161,10 +140336,11 @@ | ||
| 140161 | 140336 | ** May you share freely, never taking more than you give. |
| 140162 | 140337 | ** |
| 140163 | 140338 | ****************************************************************************** |
| 140164 | 140339 | ** |
| 140165 | 140340 | */ |
| 140341 | +/* #include "fts3Int.h" */ | |
| 140166 | 140342 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140167 | 140343 | |
| 140168 | 140344 | /* #include <string.h> */ |
| 140169 | 140345 | /* #include <assert.h> */ |
| 140170 | 140346 | |
| @@ -140717,10 +140893,11 @@ | ||
| 140717 | 140893 | ** This module contains code that implements a parser for fts3 query strings |
| 140718 | 140894 | ** (the right-hand argument to the MATCH operator). Because the supported |
| 140719 | 140895 | ** syntax is relatively simple, the whole tokenizer/parser system is |
| 140720 | 140896 | ** hand-coded. |
| 140721 | 140897 | */ |
| 140898 | +/* #include "fts3Int.h" */ | |
| 140722 | 140899 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140723 | 140900 | |
| 140724 | 140901 | /* |
| 140725 | 140902 | ** By default, this module parses the legacy syntax that has been |
| 140726 | 140903 | ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS |
| @@ -142010,16 +142187,18 @@ | ||
| 142010 | 142187 | ** (in which case SQLITE_CORE is not defined), or |
| 142011 | 142188 | ** |
| 142012 | 142189 | ** * The FTS3 module is being built into the core of |
| 142013 | 142190 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142014 | 142191 | */ |
| 142192 | +/* #include "fts3Int.h" */ | |
| 142015 | 142193 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142016 | 142194 | |
| 142017 | 142195 | /* #include <assert.h> */ |
| 142018 | 142196 | /* #include <stdlib.h> */ |
| 142019 | 142197 | /* #include <string.h> */ |
| 142020 | 142198 | |
| 142199 | +/* #include "fts3_hash.h" */ | |
| 142021 | 142200 | |
| 142022 | 142201 | /* |
| 142023 | 142202 | ** Malloc and Free functions |
| 142024 | 142203 | */ |
| 142025 | 142204 | static void *fts3HashMalloc(int n){ |
| @@ -142393,17 +142572,19 @@ | ||
| 142393 | 142572 | ** (in which case SQLITE_CORE is not defined), or |
| 142394 | 142573 | ** |
| 142395 | 142574 | ** * The FTS3 module is being built into the core of |
| 142396 | 142575 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142397 | 142576 | */ |
| 142577 | +/* #include "fts3Int.h" */ | |
| 142398 | 142578 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142399 | 142579 | |
| 142400 | 142580 | /* #include <assert.h> */ |
| 142401 | 142581 | /* #include <stdlib.h> */ |
| 142402 | 142582 | /* #include <stdio.h> */ |
| 142403 | 142583 | /* #include <string.h> */ |
| 142404 | 142584 | |
| 142585 | +/* #include "fts3_tokenizer.h" */ | |
| 142405 | 142586 | |
| 142406 | 142587 | /* |
| 142407 | 142588 | ** Class derived from sqlite3_tokenizer |
| 142408 | 142589 | */ |
| 142409 | 142590 | typedef struct porter_tokenizer { |
| @@ -143057,10 +143238,11 @@ | ||
| 143057 | 143238 | ** (in which case SQLITE_CORE is not defined), or |
| 143058 | 143239 | ** |
| 143059 | 143240 | ** * The FTS3 module is being built into the core of |
| 143060 | 143241 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143061 | 143242 | */ |
| 143243 | +/* #include "fts3Int.h" */ | |
| 143062 | 143244 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143063 | 143245 | |
| 143064 | 143246 | /* #include <assert.h> */ |
| 143065 | 143247 | /* #include <string.h> */ |
| 143066 | 143248 | |
| @@ -143552,17 +143734,19 @@ | ||
| 143552 | 143734 | ** (in which case SQLITE_CORE is not defined), or |
| 143553 | 143735 | ** |
| 143554 | 143736 | ** * The FTS3 module is being built into the core of |
| 143555 | 143737 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143556 | 143738 | */ |
| 143739 | +/* #include "fts3Int.h" */ | |
| 143557 | 143740 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143558 | 143741 | |
| 143559 | 143742 | /* #include <assert.h> */ |
| 143560 | 143743 | /* #include <stdlib.h> */ |
| 143561 | 143744 | /* #include <stdio.h> */ |
| 143562 | 143745 | /* #include <string.h> */ |
| 143563 | 143746 | |
| 143747 | +/* #include "fts3_tokenizer.h" */ | |
| 143564 | 143748 | |
| 143565 | 143749 | typedef struct simple_tokenizer { |
| 143566 | 143750 | sqlite3_tokenizer base; |
| 143567 | 143751 | char delim[128]; /* flag ASCII delimiters */ |
| 143568 | 143752 | } simple_tokenizer; |
| @@ -143803,10 +143987,11 @@ | ||
| 143803 | 143987 | ** end: Byte offset of the byte immediately following the end of the |
| 143804 | 143988 | ** token within the input string. |
| 143805 | 143989 | ** pos: Token offset of token within input. |
| 143806 | 143990 | ** |
| 143807 | 143991 | */ |
| 143992 | +/* #include "fts3Int.h" */ | |
| 143808 | 143993 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143809 | 143994 | |
| 143810 | 143995 | /* #include <string.h> */ |
| 143811 | 143996 | /* #include <assert.h> */ |
| 143812 | 143997 | |
| @@ -144238,10 +144423,11 @@ | ||
| 144238 | 144423 | ** tables. It also contains code to merge FTS3 b-tree segments. Some |
| 144239 | 144424 | ** of the sub-routines used to merge segments are also used by the query |
| 144240 | 144425 | ** code in fts3.c. |
| 144241 | 144426 | */ |
| 144242 | 144427 | |
| 144428 | +/* #include "fts3Int.h" */ | |
| 144243 | 144429 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 144244 | 144430 | |
| 144245 | 144431 | /* #include <string.h> */ |
| 144246 | 144432 | /* #include <assert.h> */ |
| 144247 | 144433 | /* #include <stdlib.h> */ |
| @@ -149898,10 +150084,11 @@ | ||
| 149898 | 150084 | ** May you share freely, never taking more than you give. |
| 149899 | 150085 | ** |
| 149900 | 150086 | ****************************************************************************** |
| 149901 | 150087 | */ |
| 149902 | 150088 | |
| 150089 | +/* #include "fts3Int.h" */ | |
| 149903 | 150090 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 149904 | 150091 | |
| 149905 | 150092 | /* #include <string.h> */ |
| 149906 | 150093 | /* #include <assert.h> */ |
| 149907 | 150094 | |
| @@ -151610,17 +151797,19 @@ | ||
| 151610 | 151797 | ** Implementation of the "unicode" full-text-search tokenizer. |
| 151611 | 151798 | */ |
| 151612 | 151799 | |
| 151613 | 151800 | #ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 151614 | 151801 | |
| 151802 | +/* #include "fts3Int.h" */ | |
| 151615 | 151803 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 151616 | 151804 | |
| 151617 | 151805 | /* #include <assert.h> */ |
| 151618 | 151806 | /* #include <stdlib.h> */ |
| 151619 | 151807 | /* #include <stdio.h> */ |
| 151620 | 151808 | /* #include <string.h> */ |
| 151621 | 151809 | |
| 151810 | +/* #include "fts3_tokenizer.h" */ | |
| 151622 | 151811 | |
| 151623 | 151812 | /* |
| 151624 | 151813 | ** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied |
| 151625 | 151814 | ** from the sqlite3 source file utf.c. If this file is compiled as part |
| 151626 | 151815 | ** of the amalgamation, they are not required. |
| @@ -152412,12 +152601,14 @@ | ||
| 152412 | 152601 | */ |
| 152413 | 152602 | |
| 152414 | 152603 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) |
| 152415 | 152604 | |
| 152416 | 152605 | #ifndef SQLITE_CORE |
| 152606 | +/* #include "sqlite3ext.h" */ | |
| 152417 | 152607 | SQLITE_EXTENSION_INIT1 |
| 152418 | 152608 | #else |
| 152609 | +/* #include "sqlite3.h" */ | |
| 152419 | 152610 | #endif |
| 152420 | 152611 | |
| 152421 | 152612 | /* #include <string.h> */ |
| 152422 | 152613 | /* #include <assert.h> */ |
| 152423 | 152614 | /* #include <stdio.h> */ |
| @@ -155909,12 +156100,14 @@ | ||
| 155909 | 156100 | #include <unicode/ucol.h> |
| 155910 | 156101 | |
| 155911 | 156102 | /* #include <assert.h> */ |
| 155912 | 156103 | |
| 155913 | 156104 | #ifndef SQLITE_CORE |
| 156105 | +/* #include "sqlite3ext.h" */ | |
| 155914 | 156106 | SQLITE_EXTENSION_INIT1 |
| 155915 | 156107 | #else |
| 156108 | +/* #include "sqlite3.h" */ | |
| 155916 | 156109 | #endif |
| 155917 | 156110 | |
| 155918 | 156111 | /* |
| 155919 | 156112 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB |
| 155920 | 156113 | ** operator. |
| @@ -156386,15 +156579,17 @@ | ||
| 156386 | 156579 | ** May you share freely, never taking more than you give. |
| 156387 | 156580 | ** |
| 156388 | 156581 | ************************************************************************* |
| 156389 | 156582 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 156390 | 156583 | */ |
| 156584 | +/* #include "fts3Int.h" */ | |
| 156391 | 156585 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 156392 | 156586 | #ifdef SQLITE_ENABLE_ICU |
| 156393 | 156587 | |
| 156394 | 156588 | /* #include <assert.h> */ |
| 156395 | 156589 | /* #include <string.h> */ |
| 156590 | +/* #include "fts3_tokenizer.h" */ | |
| 156396 | 156591 | |
| 156397 | 156592 | #include <unicode/ubrk.h> |
| 156398 | 156593 | /* #include <unicode/ucol.h> */ |
| 156399 | 156594 | /* #include <unicode/ustring.h> */ |
| 156400 | 156595 | #include <unicode/utf16.h> |
| @@ -156723,10 +156918,11 @@ | ||
| 156723 | 156918 | /* #include <assert.h> */ |
| 156724 | 156919 | /* #include <string.h> */ |
| 156725 | 156920 | /* #include <stdio.h> */ |
| 156726 | 156921 | /* #include <unistd.h> */ |
| 156727 | 156922 | |
| 156923 | +/* #include "sqlite3.h" */ | |
| 156728 | 156924 | |
| 156729 | 156925 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA) |
| 156730 | 156926 | /************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/ |
| 156731 | 156927 | /************** Begin file sqlite3ota.h **************************************/ |
| 156732 | 156928 | /* |
| @@ -156976,10 +157172,11 @@ | ||
| 156976 | 157172 | */ |
| 156977 | 157173 | |
| 156978 | 157174 | #ifndef _SQLITE3OTA_H |
| 156979 | 157175 | #define _SQLITE3OTA_H |
| 156980 | 157176 | |
| 157177 | +/* #include "sqlite3.h" ** Required for error code definitions ** */ | |
| 156981 | 157178 | |
| 156982 | 157179 | typedef struct sqlite3ota sqlite3ota; |
| 156983 | 157180 | |
| 156984 | 157181 | /* |
| 156985 | 157182 | ** Open an OTA handle. |
| @@ -157144,11 +157341,10 @@ | ||
| 157144 | 157341 | ** are undefined. |
| 157145 | 157342 | */ |
| 157146 | 157343 | SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName); |
| 157147 | 157344 | |
| 157148 | 157345 | #endif /* _SQLITE3OTA_H */ |
| 157149 | - | |
| 157150 | 157346 | |
| 157151 | 157347 | /************** End of sqlite3ota.h ******************************************/ |
| 157152 | 157348 | /************** Continuing where we left off in sqlite3ota.c *****************/ |
| 157153 | 157349 | |
| 157154 | 157350 | /* Maximum number of prepared UPDATE statements held by this module */ |
| @@ -160741,10 +160937,11 @@ | ||
| 160741 | 160937 | ** information from an SQLite database in order to implement the |
| 160742 | 160938 | ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script |
| 160743 | 160939 | ** for an example implementation. |
| 160744 | 160940 | */ |
| 160745 | 160941 | |
| 160942 | +/* #include "sqliteInt.h" ** Requires access to internal data structures ** */ | |
| 160746 | 160943 | #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \ |
| 160747 | 160944 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 160748 | 160945 | |
| 160749 | 160946 | /* |
| 160750 | 160947 | ** Page paths: |
| 160751 | 160948 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -325,11 +325,11 @@ | |
| 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | */ |
| 328 | #define SQLITE_VERSION "3.8.11" |
| 329 | #define SQLITE_VERSION_NUMBER 3008011 |
| 330 | #define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94" |
| 331 | |
| 332 | /* |
| 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | ** |
| @@ -8361,11 +8361,11 @@ | |
| 8361 | |
| 8362 | /* |
| 8363 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 8364 | ** compiling with an appropriate version of MSVC. |
| 8365 | */ |
| 8366 | #if defined(_MSC_VER) && _MSC_VER>=1300 |
| 8367 | # include <intrin.h> |
| 8368 | # pragma intrinsic(_byteswap_ushort) |
| 8369 | # pragma intrinsic(_byteswap_ulong) |
| 8370 | #endif |
| 8371 | |
| @@ -9189,11 +9189,13 @@ | |
| 9189 | #endif |
| 9190 | #ifndef SQLITE_MAX_MMAP_SIZE |
| 9191 | # if defined(__linux__) \ |
| 9192 | || defined(_WIN32) \ |
| 9193 | || (defined(__APPLE__) && defined(__MACH__)) \ |
| 9194 | || defined(__sun) |
| 9195 | # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ |
| 9196 | # else |
| 9197 | # define SQLITE_MAX_MMAP_SIZE 0 |
| 9198 | # endif |
| 9199 | # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ |
| @@ -13883,10 +13885,11 @@ | |
| 13883 | ** |
| 13884 | ************************************************************************* |
| 13885 | ** |
| 13886 | ** This file contains definitions of global variables and constants. |
| 13887 | */ |
| 13888 | |
| 13889 | /* An array to map all upper-case characters into their corresponding |
| 13890 | ** lower-case character. |
| 13891 | ** |
| 13892 | ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not |
| @@ -14122,10 +14125,11 @@ | |
| 14122 | */ |
| 14123 | #ifndef SQLITE_OMIT_WSD |
| 14124 | SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000; |
| 14125 | #endif |
| 14126 | |
| 14127 | /* |
| 14128 | ** Properties of opcodes. The OPFLG_INITIALIZER macro is |
| 14129 | ** created by mkopcodeh.awk during compilation. Data is obtained |
| 14130 | ** from the comments following the "case OP_xxxx:" statements in |
| 14131 | ** the vdbe.c file. |
| @@ -14150,10 +14154,11 @@ | |
| 14150 | ** SQLite was built with. |
| 14151 | */ |
| 14152 | |
| 14153 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| 14154 | |
| 14155 | |
| 14156 | /* |
| 14157 | ** An array of names of all compile-time options. This array should |
| 14158 | ** be sorted A-Z. |
| 14159 | ** |
| @@ -14579,10 +14584,11 @@ | |
| 14579 | ************************************************************************* |
| 14580 | ** |
| 14581 | ** This module implements the sqlite3_status() interface and related |
| 14582 | ** functionality. |
| 14583 | */ |
| 14584 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 14585 | /************** Begin file vdbeInt.h *****************************************/ |
| 14586 | /* |
| 14587 | ** 2003 September 6 |
| 14588 | ** |
| @@ -15462,10 +15468,11 @@ | |
| 15462 | ** Astronomical Algorithms, 2nd Edition, 1998 |
| 15463 | ** ISBM 0-943396-61-1 |
| 15464 | ** Willmann-Bell, Inc |
| 15465 | ** Richmond, Virginia (USA) |
| 15466 | */ |
| 15467 | /* #include <stdlib.h> */ |
| 15468 | /* #include <assert.h> */ |
| 15469 | #include <time.h> |
| 15470 | |
| 15471 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| @@ -15773,11 +15780,11 @@ | |
| 15773 | Z = (int)((p->iJD + 43200000)/86400000); |
| 15774 | A = (int)((Z - 1867216.25)/36524.25); |
| 15775 | A = Z + 1 + A - (A/4); |
| 15776 | B = A + 1524; |
| 15777 | C = (int)((B - 122.1)/365.25); |
| 15778 | D = (36525*C)/100; |
| 15779 | E = (int)((B-D)/30.6001); |
| 15780 | X1 = (int)(30.6001*E); |
| 15781 | p->D = B - D - X1; |
| 15782 | p->M = E<14 ? E-1 : E-13; |
| 15783 | p->Y = p->M>2 ? C - 4716 : C - 4715; |
| @@ -16574,10 +16581,11 @@ | |
| 16574 | ** |
| 16575 | ** This file contains OS interface code that is common to all |
| 16576 | ** architectures. |
| 16577 | */ |
| 16578 | #define _SQLITE_OS_C_ 1 |
| 16579 | #undef _SQLITE_OS_C_ |
| 16580 | |
| 16581 | /* |
| 16582 | ** The default SQLite sqlite3_vfs implementations do not allocate |
| 16583 | ** memory (actually, os_unix.c allocates a small amount of memory |
| @@ -16980,10 +16988,11 @@ | |
| 16980 | ** is completely recoverable simply by not carrying out the resize. The |
| 16981 | ** hash table will continue to function normally. So a malloc failure |
| 16982 | ** during a hash table resize is a benign fault. |
| 16983 | */ |
| 16984 | |
| 16985 | |
| 16986 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 16987 | |
| 16988 | /* |
| 16989 | ** Global variables. |
| @@ -17061,10 +17070,11 @@ | |
| 17061 | ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented |
| 17062 | ** here always fail. SQLite will not operate with these drivers. These |
| 17063 | ** are merely placeholders. Real drivers must be substituted using |
| 17064 | ** sqlite3_config() before SQLite will operate. |
| 17065 | */ |
| 17066 | |
| 17067 | /* |
| 17068 | ** This version of the memory allocator is the default. It is |
| 17069 | ** used when no other memory allocator is specified using compile-time |
| 17070 | ** macros. |
| @@ -17147,10 +17157,11 @@ | |
| 17147 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| 17148 | ** _msize() on windows systems. This might |
| 17149 | ** be necessary when compiling for Delphi, |
| 17150 | ** for example. |
| 17151 | */ |
| 17152 | |
| 17153 | /* |
| 17154 | ** This version of the memory allocator is the default. It is |
| 17155 | ** used when no other memory allocator is specified using compile-time |
| 17156 | ** macros. |
| @@ -17422,10 +17433,11 @@ | |
| 17422 | ** leaks and memory usage errors. |
| 17423 | ** |
| 17424 | ** This file contains implementations of the low-level memory allocation |
| 17425 | ** routines specified in the sqlite3_mem_methods object. |
| 17426 | */ |
| 17427 | |
| 17428 | /* |
| 17429 | ** This version of the memory allocator is used only if the |
| 17430 | ** SQLITE_MEMDEBUG macro is defined |
| 17431 | */ |
| @@ -17956,10 +17968,11 @@ | |
| 17956 | ** be changed. |
| 17957 | ** |
| 17958 | ** This version of the memory allocation subsystem is included |
| 17959 | ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. |
| 17960 | */ |
| 17961 | |
| 17962 | /* |
| 17963 | ** This version of the memory allocator is only built into the library |
| 17964 | ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not |
| 17965 | ** mean that the library will use a memory-pool by default, just that |
| @@ -18670,10 +18683,11 @@ | |
| 18670 | ** N >= M*(1 + log2(n)/2) - n + 1 |
| 18671 | ** |
| 18672 | ** The sqlite3_status() logic tracks the maximum values of n and M so |
| 18673 | ** that an application can, at any time, verify this constraint. |
| 18674 | */ |
| 18675 | |
| 18676 | /* |
| 18677 | ** This version of the memory allocator is used only when |
| 18678 | ** SQLITE_ENABLE_MEMSYS5 is defined. |
| 18679 | */ |
| @@ -19213,10 +19227,11 @@ | |
| 19213 | ************************************************************************* |
| 19214 | ** This file contains the C functions that implement mutexes. |
| 19215 | ** |
| 19216 | ** This file contains code that is common across all mutex implementations. |
| 19217 | */ |
| 19218 | |
| 19219 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT) |
| 19220 | /* |
| 19221 | ** For debugging purposes, record when the mutex subsystem is initialized |
| 19222 | ** and uninitialized so that we can assert() if there is an attempt to |
| @@ -19386,10 +19401,11 @@ | |
| 19386 | ** |
| 19387 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted |
| 19388 | ** that does error checking on mutexes to make sure they are being |
| 19389 | ** called correctly. |
| 19390 | */ |
| 19391 | |
| 19392 | #ifndef SQLITE_MUTEX_OMIT |
| 19393 | |
| 19394 | #ifndef SQLITE_DEBUG |
| 19395 | /* |
| @@ -19589,10 +19605,11 @@ | |
| 19589 | ** May you share freely, never taking more than you give. |
| 19590 | ** |
| 19591 | ************************************************************************* |
| 19592 | ** This file contains the C functions that implement mutexes for pthreads |
| 19593 | */ |
| 19594 | |
| 19595 | /* |
| 19596 | ** The code in this file is only used if we are compiling threadsafe |
| 19597 | ** under unix with pthreads. |
| 19598 | ** |
| @@ -19963,10 +19980,11 @@ | |
| 19963 | ** May you share freely, never taking more than you give. |
| 19964 | ** |
| 19965 | ************************************************************************* |
| 19966 | ** This file contains the C functions that implement mutexes for Win32. |
| 19967 | */ |
| 19968 | |
| 19969 | #if SQLITE_OS_WIN |
| 19970 | /* |
| 19971 | ** Include code that is common to all os_*.c files |
| 19972 | */ |
| @@ -20638,10 +20656,11 @@ | |
| 20638 | ** |
| 20639 | ************************************************************************* |
| 20640 | ** |
| 20641 | ** Memory allocation functions used throughout sqlite. |
| 20642 | */ |
| 20643 | /* #include <stdarg.h> */ |
| 20644 | |
| 20645 | /* |
| 20646 | ** Attempt to release up to n bytes of non-essential memory currently |
| 20647 | ** held by SQLite. An example of non-essential memory is memory used to |
| @@ -21449,10 +21468,11 @@ | |
| 21449 | ** This file contains code for a set of "printf"-like routines. These |
| 21450 | ** routines format strings much like the printf() from the standard C |
| 21451 | ** library, though the implementation here has enhancements to support |
| 21452 | ** SQLite. |
| 21453 | */ |
| 21454 | |
| 21455 | /* |
| 21456 | ** Conversion types fall into various categories as defined by the |
| 21457 | ** following enumeration. |
| 21458 | */ |
| @@ -22451,10 +22471,15 @@ | |
| 22451 | ** stack space on small-stack systems when logging is disabled. |
| 22452 | ** |
| 22453 | ** sqlite3_log() must render into a static buffer. It cannot dynamically |
| 22454 | ** allocate memory because it might be called while the memory allocator |
| 22455 | ** mutex is held. |
| 22456 | */ |
| 22457 | static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ |
| 22458 | StrAccum acc; /* String accumulator */ |
| 22459 | char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ |
| 22460 | |
| @@ -22526,10 +22551,11 @@ | |
| 22526 | ** analysis. |
| 22527 | ** |
| 22528 | ** The interfaces in this file is only available when compiling |
| 22529 | ** with SQLITE_DEBUG. |
| 22530 | */ |
| 22531 | #ifdef SQLITE_DEBUG |
| 22532 | |
| 22533 | /* |
| 22534 | ** Add a new subitem to the tree. The moreToFollow flag indicates that this |
| 22535 | ** is not the last item in the tree. |
| @@ -22957,10 +22983,11 @@ | |
| 22957 | ** generator (PRNG) for SQLite. |
| 22958 | ** |
| 22959 | ** Random numbers are used by some of the database backends in order |
| 22960 | ** to generate random integer keys for tables or random filenames. |
| 22961 | */ |
| 22962 | |
| 22963 | |
| 22964 | /* All threads share a single random number generator. |
| 22965 | ** This structure is the current state of the generator. |
| 22966 | */ |
| @@ -23103,11 +23130,13 @@ | |
| 23103 | ** single threaded systems. Nothing in SQLite requires multiple threads. |
| 23104 | ** This interface exists so that applications that want to take advantage |
| 23105 | ** of multiple cores can do so, while also allowing applications to stay |
| 23106 | ** single-threaded if desired. |
| 23107 | */ |
| 23108 | #if SQLITE_OS_WIN |
| 23109 | #endif |
| 23110 | |
| 23111 | #if SQLITE_MAX_WORKER_THREADS>0 |
| 23112 | |
| 23113 | /********************************* Unix Pthreads ****************************/ |
| @@ -23377,11 +23406,13 @@ | |
| 23377 | ** BOM or Byte Order Mark: |
| 23378 | ** 0xff 0xfe little-endian utf-16 follows |
| 23379 | ** 0xfe 0xff big-endian utf-16 follows |
| 23380 | ** |
| 23381 | */ |
| 23382 | /* #include <assert.h> */ |
| 23383 | |
| 23384 | #ifndef SQLITE_AMALGAMATION |
| 23385 | /* |
| 23386 | ** The following constant value is used by the SQLITE_BIGENDIAN and |
| 23387 | ** SQLITE_LITTLEENDIAN macros. |
| @@ -23890,10 +23921,11 @@ | |
| 23890 | ** |
| 23891 | ** This file contains functions for allocating memory, comparing |
| 23892 | ** strings, and stuff like that. |
| 23893 | ** |
| 23894 | */ |
| 23895 | /* #include <stdarg.h> */ |
| 23896 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN |
| 23897 | # include <math.h> |
| 23898 | #endif |
| 23899 | |
| @@ -25286,10 +25318,11 @@ | |
| 25286 | ** |
| 25287 | ************************************************************************* |
| 25288 | ** This is the implementation of generic hash-tables |
| 25289 | ** used in SQLite. |
| 25290 | */ |
| 25291 | /* #include <assert.h> */ |
| 25292 | |
| 25293 | /* Turn bulk memory into a hash table object by initializing the |
| 25294 | ** fields of the Hash structure. |
| 25295 | ** |
| @@ -25763,10 +25796,11 @@ | |
| 25763 | ** * sqlite3_vfs method implementations. |
| 25764 | ** * Locking primitives for the proxy uber-locking-method. (MacOSX only) |
| 25765 | ** * Definitions of sqlite3_vfs objects for all locking methods |
| 25766 | ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). |
| 25767 | */ |
| 25768 | #if SQLITE_OS_UNIX /* This file is used on unix only */ |
| 25769 | |
| 25770 | /* |
| 25771 | ** There are various methods for file locking used for concurrency |
| 25772 | ** control: |
| @@ -33497,10 +33531,11 @@ | |
| 33497 | ** |
| 33498 | ****************************************************************************** |
| 33499 | ** |
| 33500 | ** This file contains code that is specific to Windows. |
| 33501 | */ |
| 33502 | #if SQLITE_OS_WIN /* This file is used for Windows only */ |
| 33503 | |
| 33504 | /* |
| 33505 | ** Include code that is common to all os_*.c files |
| 33506 | */ |
| @@ -33705,10 +33740,11 @@ | |
| 33705 | /************** Continuing where we left off in os_win.c *********************/ |
| 33706 | |
| 33707 | /* |
| 33708 | ** Include the header file for the Windows VFS. |
| 33709 | */ |
| 33710 | |
| 33711 | /* |
| 33712 | ** Compiling and using WAL mode requires several APIs that are only |
| 33713 | ** available in Windows platforms based on the NT kernel. |
| 33714 | */ |
| @@ -39358,10 +39394,11 @@ | |
| 39358 | ** sometimes grow into tens of thousands or larger. The size of the |
| 39359 | ** Bitvec object is the number of pages in the database file at the |
| 39360 | ** start of a transaction, and is thus usually less than a few thousand, |
| 39361 | ** but can be as large as 2 billion for a really big database. |
| 39362 | */ |
| 39363 | |
| 39364 | /* Size of the Bitvec structure in bytes. */ |
| 39365 | #define BITVEC_SZ 512 |
| 39366 | |
| 39367 | /* Round the union size down to the nearest pointer boundary, since that's how |
| @@ -39747,10 +39784,11 @@ | |
| 39747 | ** May you share freely, never taking more than you give. |
| 39748 | ** |
| 39749 | ************************************************************************* |
| 39750 | ** This file implements that page cache. |
| 39751 | */ |
| 39752 | |
| 39753 | /* |
| 39754 | ** A complete page cache is an instance of this structure. |
| 39755 | */ |
| 39756 | struct PCache { |
| @@ -40488,10 +40526,11 @@ | |
| 40488 | ** |
| 40489 | ** Earlier versions of SQLite used only methods (1) and (2). But experiments |
| 40490 | ** show that method (3) with N==100 provides about a 5% performance boost for |
| 40491 | ** common workloads. |
| 40492 | */ |
| 40493 | |
| 40494 | typedef struct PCache1 PCache1; |
| 40495 | typedef struct PgHdr1 PgHdr1; |
| 40496 | typedef struct PgFreeslot PgFreeslot; |
| 40497 | typedef struct PGroup PGroup; |
| @@ -40598,10 +40637,11 @@ | |
| 40598 | ** fixed at sqlite3_initialize() time and do not require mutex protection. |
| 40599 | ** The nFreeSlot and pFree values do require mutex protection. |
| 40600 | */ |
| 40601 | int isInit; /* True if initialized */ |
| 40602 | int separateCache; /* Use a new PGroup for each PCache */ |
| 40603 | int szSlot; /* Size of each free slot */ |
| 40604 | int nSlot; /* The number of pcache slots */ |
| 40605 | int nReserve; /* Try to keep nFreeSlot above this */ |
| 40606 | void *pStart, *pEnd; /* Bounds of global page cache memory */ |
| 40607 | /* Above requires no mutex. Use mutex below for variable that follow. */ |
| @@ -40665,10 +40705,47 @@ | |
| 40665 | pBuf = (void*)&((char*)pBuf)[sz]; |
| 40666 | } |
| 40667 | pcache1.pEnd = pBuf; |
| 40668 | } |
| 40669 | } |
| 40670 | |
| 40671 | /* |
| 40672 | ** Malloc function used within this file to allocate space from the buffer |
| 40673 | ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no |
| 40674 | ** such buffer exists or there is no space left in it, this function falls |
| @@ -40766,11 +40843,11 @@ | |
| 40766 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 40767 | PgHdr1 *p = 0; |
| 40768 | void *pPg; |
| 40769 | |
| 40770 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 40771 | if( pCache->pFree ){ |
| 40772 | p = pCache->pFree; |
| 40773 | pCache->pFree = p->pNext; |
| 40774 | p->pNext = 0; |
| 40775 | }else{ |
| 40776 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| @@ -40970,18 +41047,23 @@ | |
| 40970 | |
| 40971 | /* |
| 40972 | ** If there are currently more than nMaxPage pages allocated, try |
| 40973 | ** to recycle pages to reduce the number allocated to nMaxPage. |
| 40974 | */ |
| 40975 | static void pcache1EnforceMaxPage(PGroup *pGroup){ |
| 40976 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 40977 | while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){ |
| 40978 | PgHdr1 *p = pGroup->pLruTail; |
| 40979 | assert( p->pCache->pGroup==pGroup ); |
| 40980 | assert( p->isPinned==0 ); |
| 40981 | pcache1PinPage(p); |
| 40982 | pcache1RemoveFromHash(p, 1); |
| 40983 | } |
| 40984 | } |
| 40985 | |
| 40986 | /* |
| 40987 | ** Discard all pages from cache pCache with a page number (key value) |
| @@ -41054,10 +41136,18 @@ | |
| 41054 | if( sqlite3GlobalConfig.bCoreMutex ){ |
| 41055 | pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); |
| 41056 | pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); |
| 41057 | } |
| 41058 | #endif |
| 41059 | pcache1.grp.mxPinned = 10; |
| 41060 | pcache1.isInit = 1; |
| 41061 | return SQLITE_OK; |
| 41062 | } |
| 41063 | |
| @@ -41108,40 +41198,10 @@ | |
| 41108 | pCache->nMin = 10; |
| 41109 | pGroup->nMinPage += pCache->nMin; |
| 41110 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41111 | } |
| 41112 | pcache1LeaveMutex(pGroup); |
| 41113 | /* Try to initialize the local bulk pagecache line allocation if using |
| 41114 | ** separate caches and if nPage!=0 */ |
| 41115 | if( pcache1.separateCache |
| 41116 | && sqlite3GlobalConfig.nPage!=0 |
| 41117 | && sqlite3GlobalConfig.pPage==0 |
| 41118 | ){ |
| 41119 | int szBulk; |
| 41120 | char *zBulk; |
| 41121 | sqlite3BeginBenignMalloc(); |
| 41122 | if( sqlite3GlobalConfig.nPage>0 ){ |
| 41123 | szBulk = pCache->szAlloc * sqlite3GlobalConfig.nPage; |
| 41124 | }else{ |
| 41125 | szBulk = -1024*sqlite3GlobalConfig.nPage; |
| 41126 | } |
| 41127 | zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); |
| 41128 | sqlite3EndBenignMalloc(); |
| 41129 | if( zBulk ){ |
| 41130 | int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; |
| 41131 | int i; |
| 41132 | for(i=0; i<nBulk; i++){ |
| 41133 | PgHdr1 *pX = (PgHdr1*)&zBulk[szPage]; |
| 41134 | pX->page.pBuf = zBulk; |
| 41135 | pX->page.pExtra = &pX[1]; |
| 41136 | pX->isBulkLocal = 1; |
| 41137 | pX->pNext = pCache->pFree; |
| 41138 | pCache->pFree = pX; |
| 41139 | zBulk += pCache->szAlloc; |
| 41140 | } |
| 41141 | } |
| 41142 | } |
| 41143 | if( pCache->nHash==0 ){ |
| 41144 | pcache1Destroy((sqlite3_pcache*)pCache); |
| 41145 | pCache = 0; |
| 41146 | } |
| 41147 | } |
| @@ -41160,11 +41220,11 @@ | |
| 41160 | pcache1EnterMutex(pGroup); |
| 41161 | pGroup->nMaxPage += (nMax - pCache->nMax); |
| 41162 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41163 | pCache->nMax = nMax; |
| 41164 | pCache->n90pct = pCache->nMax*9/10; |
| 41165 | pcache1EnforceMaxPage(pGroup); |
| 41166 | pcache1LeaveMutex(pGroup); |
| 41167 | } |
| 41168 | } |
| 41169 | |
| 41170 | /* |
| @@ -41178,11 +41238,11 @@ | |
| 41178 | PGroup *pGroup = pCache->pGroup; |
| 41179 | int savedMaxPage; |
| 41180 | pcache1EnterMutex(pGroup); |
| 41181 | savedMaxPage = pGroup->nMaxPage; |
| 41182 | pGroup->nMaxPage = 0; |
| 41183 | pcache1EnforceMaxPage(pGroup); |
| 41184 | pGroup->nMaxPage = savedMaxPage; |
| 41185 | pcache1LeaveMutex(pGroup); |
| 41186 | } |
| 41187 | } |
| 41188 | |
| @@ -41515,11 +41575,11 @@ | |
| 41515 | assert( pGroup->nMaxPage >= pCache->nMax ); |
| 41516 | pGroup->nMaxPage -= pCache->nMax; |
| 41517 | assert( pGroup->nMinPage >= pCache->nMin ); |
| 41518 | pGroup->nMinPage -= pCache->nMin; |
| 41519 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41520 | pcache1EnforceMaxPage(pGroup); |
| 41521 | pcache1LeaveMutex(pGroup); |
| 41522 | sqlite3_free(pCache->pBulk); |
| 41523 | sqlite3_free(pCache->apHash); |
| 41524 | sqlite3_free(pCache); |
| 41525 | } |
| @@ -41679,10 +41739,11 @@ | |
| 41679 | ** primitives are constant time. The cost of DESTROY is O(N). |
| 41680 | ** |
| 41681 | ** There is an added cost of O(N) when switching between TEST and |
| 41682 | ** SMALLEST primitives. |
| 41683 | */ |
| 41684 | |
| 41685 | |
| 41686 | /* |
| 41687 | ** Target size for allocation chunks. |
| 41688 | */ |
| @@ -42148,10 +42209,11 @@ | |
| 42148 | ** locking to prevent two processes from writing the same database |
| 42149 | ** file simultaneously, or one process from reading the database while |
| 42150 | ** another is writing. |
| 42151 | */ |
| 42152 | #ifndef SQLITE_OMIT_DISKIO |
| 42153 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 42154 | /************** Begin file wal.h *********************************************/ |
| 42155 | /* |
| 42156 | ** 2010 February 1 |
| 42157 | ** |
| @@ -42169,10 +42231,11 @@ | |
| 42169 | */ |
| 42170 | |
| 42171 | #ifndef _WAL_H_ |
| 42172 | #define _WAL_H_ |
| 42173 | |
| 42174 | |
| 42175 | /* Additional values that can be added to the sync_flags argument of |
| 42176 | ** sqlite3WalFrames(): |
| 42177 | */ |
| 42178 | #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| @@ -49783,10 +49846,11 @@ | |
| 49783 | ** that correspond to frames greater than the new K value are removed |
| 49784 | ** from the hash table at this point. |
| 49785 | */ |
| 49786 | #ifndef SQLITE_OMIT_WAL |
| 49787 | |
| 49788 | |
| 49789 | /* |
| 49790 | ** Trace output macros |
| 49791 | */ |
| 49792 | #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) |
| @@ -51000,11 +51064,11 @@ | |
| 51000 | |
| 51001 | const int nList = *pnList; /* Size of input list */ |
| 51002 | int nMerge = 0; /* Number of elements in list aMerge */ |
| 51003 | ht_slot *aMerge = 0; /* List to be merged */ |
| 51004 | int iList; /* Index into input list */ |
| 51005 | int iSub = 0; /* Index into aSub array */ |
| 51006 | struct Sublist aSub[13]; /* Array of sub-lists */ |
| 51007 | |
| 51008 | memset(aSub, 0, sizeof(aSub)); |
| 51009 | assert( nList<=HASHTABLE_NPAGE && nList>0 ); |
| 51010 | assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) ); |
| @@ -51011,11 +51075,13 @@ | |
| 51011 | |
| 51012 | for(iList=0; iList<nList; iList++){ |
| 51013 | nMerge = 1; |
| 51014 | aMerge = &aList[iList]; |
| 51015 | for(iSub=0; iList & (1<<iSub); iSub++){ |
| 51016 | struct Sublist *p = &aSub[iSub]; |
| 51017 | assert( p->aList && p->nList<=(1<<iSub) ); |
| 51018 | assert( p->aList==&aList[iList&~((2<<iSub)-1)] ); |
| 51019 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51020 | } |
| 51021 | aSub[iSub].aList = aMerge; |
| @@ -51022,11 +51088,13 @@ | |
| 51022 | aSub[iSub].nList = nMerge; |
| 51023 | } |
| 51024 | |
| 51025 | for(iSub++; iSub<ArraySize(aSub); iSub++){ |
| 51026 | if( nList & (1<<iSub) ){ |
| 51027 | struct Sublist *p = &aSub[iSub]; |
| 51028 | assert( p->nList<=(1<<iSub) ); |
| 51029 | assert( p->aList==&aList[nList&~((2<<iSub)-1)] ); |
| 51030 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51031 | } |
| 51032 | } |
| @@ -52933,10 +53001,11 @@ | |
| 52933 | ** SIZE DESCRIPTION |
| 52934 | ** 4 Page number of next trunk page |
| 52935 | ** 4 Number of leaf pointers on this page |
| 52936 | ** * zero or more pages numbers of leaves |
| 52937 | */ |
| 52938 | |
| 52939 | |
| 52940 | /* The following value is the maximum cell size assuming a maximum page |
| 52941 | ** size give above. |
| 52942 | */ |
| @@ -53730,10 +53799,11 @@ | |
| 53730 | ************************************************************************* |
| 53731 | ** This file implements an external (disk-based) database using BTrees. |
| 53732 | ** See the header comment on "btreeInt.h" for additional information. |
| 53733 | ** Including a description of file format and an overview of operation. |
| 53734 | */ |
| 53735 | |
| 53736 | /* |
| 53737 | ** The header string that appears at the beginning of every |
| 53738 | ** SQLite database. |
| 53739 | */ |
| @@ -62675,11 +62745,11 @@ | |
| 62675 | u32 *heap = 0; /* Min-heap used for checking cell coverage */ |
| 62676 | u32 x, prev = 0; /* Next and previous entry on the min-heap */ |
| 62677 | const char *saved_zPfx = pCheck->zPfx; |
| 62678 | int saved_v1 = pCheck->v1; |
| 62679 | int saved_v2 = pCheck->v2; |
| 62680 | u8 savedIsInit; |
| 62681 | |
| 62682 | /* Check that the page exists |
| 62683 | */ |
| 62684 | pBt = pCheck->pBt; |
| 62685 | usableSize = pBt->usableSize; |
| @@ -63311,10 +63381,12 @@ | |
| 63311 | ** |
| 63312 | ************************************************************************* |
| 63313 | ** This file contains the implementation of the sqlite3_backup_XXX() |
| 63314 | ** API functions and the related features. |
| 63315 | */ |
| 63316 | |
| 63317 | /* |
| 63318 | ** Structure allocated for each backup operation. |
| 63319 | */ |
| 63320 | struct sqlite3_backup { |
| @@ -64109,10 +64181,12 @@ | |
| 64109 | ** This file contains code use to manipulate "Mem" structure. A "Mem" |
| 64110 | ** stores a single value in the VDBE. Mem is an opaque structure visible |
| 64111 | ** only within the VDBE. Interface routines refer to a Mem using the |
| 64112 | ** name sqlite_value |
| 64113 | */ |
| 64114 | |
| 64115 | #ifdef SQLITE_DEBUG |
| 64116 | /* |
| 64117 | ** Check invariants on a Mem object. |
| 64118 | ** |
| @@ -65826,10 +65900,12 @@ | |
| 65826 | ** |
| 65827 | ************************************************************************* |
| 65828 | ** This file contains code used for creating, destroying, and populating |
| 65829 | ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) |
| 65830 | */ |
| 65831 | |
| 65832 | /* |
| 65833 | ** Create a new virtual database engine. |
| 65834 | */ |
| 65835 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ |
| @@ -70074,10 +70150,12 @@ | |
| 70074 | ************************************************************************* |
| 70075 | ** |
| 70076 | ** This file contains code use to implement APIs that are part of the |
| 70077 | ** VDBE. |
| 70078 | */ |
| 70079 | |
| 70080 | #ifndef SQLITE_OMIT_DEPRECATED |
| 70081 | /* |
| 70082 | ** Return TRUE (non-zero) of the statement supplied as an argument needs |
| 70083 | ** to be recompiled. A statement needs to be recompiled whenever the |
| @@ -70112,10 +70190,35 @@ | |
| 70112 | }else{ |
| 70113 | return vdbeSafety(p); |
| 70114 | } |
| 70115 | } |
| 70116 | |
| 70117 | /* |
| 70118 | ** The following routine destroys a virtual machine that is created by |
| 70119 | ** the sqlite3_compile() routine. The integer returned is an SQLITE_ |
| 70120 | ** success/failure code that describes the result of executing the virtual |
| 70121 | ** machine. |
| @@ -70132,10 +70235,11 @@ | |
| 70132 | }else{ |
| 70133 | Vdbe *v = (Vdbe*)pStmt; |
| 70134 | sqlite3 *db = v->db; |
| 70135 | if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; |
| 70136 | sqlite3_mutex_enter(db->mutex); |
| 70137 | rc = sqlite3VdbeFinalize(v); |
| 70138 | rc = sqlite3ApiExit(db, rc); |
| 70139 | sqlite3LeaveMutexAndCloseZombie(db); |
| 70140 | } |
| 70141 | return rc; |
| @@ -70153,16 +70257,18 @@ | |
| 70153 | int rc; |
| 70154 | if( pStmt==0 ){ |
| 70155 | rc = SQLITE_OK; |
| 70156 | }else{ |
| 70157 | Vdbe *v = (Vdbe*)pStmt; |
| 70158 | sqlite3_mutex_enter(v->db->mutex); |
| 70159 | rc = sqlite3VdbeReset(v); |
| 70160 | sqlite3VdbeRewind(v); |
| 70161 | assert( (rc & (v->db->errMask))==rc ); |
| 70162 | rc = sqlite3ApiExit(v->db, rc); |
| 70163 | sqlite3_mutex_leave(v->db->mutex); |
| 70164 | } |
| 70165 | return rc; |
| 70166 | } |
| 70167 | |
| 70168 | /* |
| @@ -70508,10 +70614,11 @@ | |
| 70508 | } |
| 70509 | } |
| 70510 | #endif |
| 70511 | return rc; |
| 70512 | } |
| 70513 | |
| 70514 | /* |
| 70515 | ** Execute the statement pStmt, either until a row of data is ready, the |
| 70516 | ** statement is completely executed or an error occurs. |
| 70517 | ** |
| @@ -70577,12 +70684,14 @@ | |
| 70577 | assert( db->nVdbeWrite>0 || db->autoCommit==0 |
| 70578 | || (db->nDeferredCons==0 && db->nDeferredImmCons==0) |
| 70579 | ); |
| 70580 | |
| 70581 | #ifndef SQLITE_OMIT_TRACE |
| 70582 | if( db->xProfile && !db->init.busy ){ |
| 70583 | sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); |
| 70584 | } |
| 70585 | #endif |
| 70586 | |
| 70587 | db->nVdbeActive++; |
| 70588 | if( p->readOnly==0 ) db->nVdbeWrite++; |
| @@ -70602,17 +70711,12 @@ | |
| 70602 | rc = sqlite3VdbeExec(p); |
| 70603 | db->nVdbeExec--; |
| 70604 | } |
| 70605 | |
| 70606 | #ifndef SQLITE_OMIT_TRACE |
| 70607 | /* Invoke the profile callback if there is one |
| 70608 | */ |
| 70609 | if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){ |
| 70610 | sqlite3_int64 iNow; |
| 70611 | sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); |
| 70612 | db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); |
| 70613 | } |
| 70614 | #endif |
| 70615 | |
| 70616 | if( rc==SQLITE_DONE ){ |
| 70617 | assert( p->rc==SQLITE_OK ); |
| 70618 | p->rc = doWalCallbacks(db); |
| @@ -71685,10 +71789,12 @@ | |
| 71685 | ** This file contains code used to insert the values of host parameters |
| 71686 | ** (aka "wildcards") into the SQL text output by sqlite3_trace(). |
| 71687 | ** |
| 71688 | ** The Vdbe parse-tree explainer is also found here. |
| 71689 | */ |
| 71690 | |
| 71691 | #ifndef SQLITE_OMIT_TRACE |
| 71692 | |
| 71693 | /* |
| 71694 | ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of |
| @@ -71877,10 +71983,12 @@ | |
| 71877 | ** documentation, headers files, or other derived files. The formatting |
| 71878 | ** of the code in this file is, therefore, important. See other comments |
| 71879 | ** in this file for details. If in doubt, do not deviate from existing |
| 71880 | ** commenting and indentation practices when changing or adding code. |
| 71881 | */ |
| 71882 | |
| 71883 | /* |
| 71884 | ** Invoke this macro on memory cells just prior to changing the |
| 71885 | ** value of the cell. This macro verifies that shallow copies are |
| 71886 | ** not misused. A shallow copy of a string or blob just copies a |
| @@ -78635,10 +78743,12 @@ | |
| 78635 | ************************************************************************* |
| 78636 | ** |
| 78637 | ** This file contains code used to implement incremental BLOB I/O. |
| 78638 | */ |
| 78639 | |
| 78640 | |
| 78641 | #ifndef SQLITE_OMIT_INCRBLOB |
| 78642 | |
| 78643 | /* |
| 78644 | ** Valid sqlite3_blob* handles point to Incrblob structures. |
| @@ -79233,10 +79343,12 @@ | |
| 79233 | ** than one background thread may be created. Specifically, there may be |
| 79234 | ** one background thread for each temporary file on disk, and one background |
| 79235 | ** thread to merge the output of each of the others to a single PMA for |
| 79236 | ** the main thread to read from. |
| 79237 | */ |
| 79238 | |
| 79239 | /* |
| 79240 | ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various |
| 79241 | ** messages to stderr that may be helpful in understanding the performance |
| 79242 | ** characteristics of the sorter in multi-threaded mode. |
| @@ -81849,10 +81961,11 @@ | |
| 81849 | ** 1) The in-memory representation grows too large for the allocated |
| 81850 | ** buffer, or |
| 81851 | ** 2) The sqlite3JournalCreate() function is called. |
| 81852 | */ |
| 81853 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 81854 | |
| 81855 | |
| 81856 | /* |
| 81857 | ** A JournalFile object is a subclass of sqlite3_file used by |
| 81858 | ** as an open file handle for journal files. |
| @@ -82096,10 +82209,11 @@ | |
| 82096 | ** |
| 82097 | ** This file contains code use to implement an in-memory rollback journal. |
| 82098 | ** The in-memory rollback journal is used to journal transactions for |
| 82099 | ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. |
| 82100 | */ |
| 82101 | |
| 82102 | /* Forward references to internal structures */ |
| 82103 | typedef struct MemJournal MemJournal; |
| 82104 | typedef struct FilePoint FilePoint; |
| 82105 | typedef struct FileChunk FileChunk; |
| @@ -82351,10 +82465,11 @@ | |
| 82351 | ** |
| 82352 | ************************************************************************* |
| 82353 | ** This file contains routines used for walking the parser tree for |
| 82354 | ** an SQL statement. |
| 82355 | */ |
| 82356 | /* #include <stdlib.h> */ |
| 82357 | /* #include <string.h> */ |
| 82358 | |
| 82359 | |
| 82360 | /* |
| @@ -82509,10 +82624,11 @@ | |
| 82509 | ** |
| 82510 | ** This file contains routines used for walking the parser tree and |
| 82511 | ** resolve all identifiers by associating them with a particular |
| 82512 | ** table and column. |
| 82513 | */ |
| 82514 | /* #include <stdlib.h> */ |
| 82515 | /* #include <string.h> */ |
| 82516 | |
| 82517 | /* |
| 82518 | ** Walk the expression tree pExpr and increase the aggregate function |
| @@ -84021,10 +84137,11 @@ | |
| 84021 | ** |
| 84022 | ************************************************************************* |
| 84023 | ** This file contains routines used for analyzing expressions and |
| 84024 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 84025 | */ |
| 84026 | |
| 84027 | /* |
| 84028 | ** Return the 'affinity' of the expression pExpr if any. |
| 84029 | ** |
| 84030 | ** If pExpr is a column, a reference to a column via an 'AS' alias, |
| @@ -88183,10 +88300,11 @@ | |
| 88183 | ** |
| 88184 | ************************************************************************* |
| 88185 | ** This file contains C code routines that used to generate VDBE code |
| 88186 | ** that implements the ALTER TABLE command. |
| 88187 | */ |
| 88188 | |
| 88189 | /* |
| 88190 | ** The code in this file only exists if we are not omitting the |
| 88191 | ** ALTER TABLE logic from the build. |
| 88192 | */ |
| @@ -89145,10 +89263,11 @@ | |
| 89145 | ** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3 |
| 89146 | ** all contain just a single integer which is the same as the first |
| 89147 | ** integer in the equivalent columns in sqlite_stat4. |
| 89148 | */ |
| 89149 | #ifndef SQLITE_OMIT_ANALYZE |
| 89150 | |
| 89151 | #if defined(SQLITE_ENABLE_STAT4) |
| 89152 | # define IsStat4 1 |
| 89153 | # define IsStat3 0 |
| 89154 | #elif defined(SQLITE_ENABLE_STAT3) |
| @@ -90910,10 +91029,11 @@ | |
| 90910 | ** May you share freely, never taking more than you give. |
| 90911 | ** |
| 90912 | ************************************************************************* |
| 90913 | ** This file contains code used to implement the ATTACH and DETACH commands. |
| 90914 | */ |
| 90915 | |
| 90916 | #ifndef SQLITE_OMIT_ATTACH |
| 90917 | /* |
| 90918 | ** Resolve an expression that was part of an ATTACH or DETACH statement. This |
| 90919 | ** is slightly different from resolving a normal SQL expression, because simple |
| @@ -91499,10 +91619,11 @@ | |
| 91499 | ** This file contains code used to implement the sqlite3_set_authorizer() |
| 91500 | ** API. This facility is an optional feature of the library. Embedded |
| 91501 | ** systems that do not need this facility may omit it by recompiling |
| 91502 | ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 |
| 91503 | */ |
| 91504 | |
| 91505 | /* |
| 91506 | ** All of the code in this file may be omitted by defining a single |
| 91507 | ** macro. |
| 91508 | */ |
| @@ -91769,10 +91890,11 @@ | |
| 91769 | ** creating ID lists |
| 91770 | ** BEGIN TRANSACTION |
| 91771 | ** COMMIT |
| 91772 | ** ROLLBACK |
| 91773 | */ |
| 91774 | |
| 91775 | /* |
| 91776 | ** This routine is called when a new SQL statement is beginning to |
| 91777 | ** be parsed. Initialize the pParse structure as needed. |
| 91778 | */ |
| @@ -96089,10 +96211,11 @@ | |
| 96089 | ** |
| 96090 | ** This file contains functions used to access the internal hash tables |
| 96091 | ** of user defined functions and collation sequences. |
| 96092 | */ |
| 96093 | |
| 96094 | |
| 96095 | /* |
| 96096 | ** Invoke the 'collation needed' callback to request a collation sequence |
| 96097 | ** in the encoding enc of name zName, length nName. |
| 96098 | */ |
| @@ -96566,10 +96689,11 @@ | |
| 96566 | ** |
| 96567 | ************************************************************************* |
| 96568 | ** This file contains C code routines that are called by the parser |
| 96569 | ** in order to generate code for DELETE FROM statements. |
| 96570 | */ |
| 96571 | |
| 96572 | /* |
| 96573 | ** While a SrcList can in general represent multiple tables and subqueries |
| 96574 | ** (as in the FROM clause of a SELECT statement) in this case it contains |
| 96575 | ** the name of a single table, as one might find in an INSERT, DELETE, |
| @@ -97408,12 +97532,14 @@ | |
| 97408 | ************************************************************************* |
| 97409 | ** This file contains the C-language implementations for many of the SQL |
| 97410 | ** functions of SQLite. (Some function, and in particular the date and |
| 97411 | ** time functions, are implemented separately.) |
| 97412 | */ |
| 97413 | /* #include <stdlib.h> */ |
| 97414 | /* #include <assert.h> */ |
| 97415 | |
| 97416 | /* |
| 97417 | ** Return the collating function associated with a function. |
| 97418 | */ |
| 97419 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -99205,10 +99331,11 @@ | |
| 99205 | ** |
| 99206 | ************************************************************************* |
| 99207 | ** This file contains code used by the compiler to add foreign key |
| 99208 | ** support to compiled SQL statements. |
| 99209 | */ |
| 99210 | |
| 99211 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 99212 | #ifndef SQLITE_OMIT_TRIGGER |
| 99213 | |
| 99214 | /* |
| @@ -100609,10 +100736,11 @@ | |
| 100609 | ** |
| 100610 | ************************************************************************* |
| 100611 | ** This file contains C code routines that are called by the parser |
| 100612 | ** to handle INSERT statements in SQLite. |
| 100613 | */ |
| 100614 | |
| 100615 | /* |
| 100616 | ** Generate code that will |
| 100617 | ** |
| 100618 | ** (1) acquire a lock for table pTab then |
| @@ -102671,10 +102799,11 @@ | |
| 102671 | ** implement the programmer interface to the library. Routines in |
| 102672 | ** other files are for internal use by SQLite and should not be |
| 102673 | ** accessed by users of the library. |
| 102674 | */ |
| 102675 | |
| 102676 | |
| 102677 | /* |
| 102678 | ** Execute SQL code. Return one of the SQLITE_ success/failure |
| 102679 | ** codes. Also write an error message into memory obtained from |
| 102680 | ** malloc() and make *pzErrMsg point to that message. |
| @@ -102839,10 +102968,11 @@ | |
| 102839 | ** as extensions by SQLite should #include this file instead of |
| 102840 | ** sqlite3.h. |
| 102841 | */ |
| 102842 | #ifndef _SQLITE3EXT_H_ |
| 102843 | #define _SQLITE3EXT_H_ |
| 102844 | |
| 102845 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 102846 | |
| 102847 | /* |
| 102848 | ** The following structure holds pointers to all of the SQLite API |
| @@ -103345,10 +103475,11 @@ | |
| 103345 | |
| 103346 | #endif /* _SQLITE3EXT_H_ */ |
| 103347 | |
| 103348 | /************** End of sqlite3ext.h ******************************************/ |
| 103349 | /************** Continuing where we left off in loadext.c ********************/ |
| 103350 | /* #include <string.h> */ |
| 103351 | |
| 103352 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 103353 | |
| 103354 | /* |
| @@ -104114,10 +104245,11 @@ | |
| 104114 | ** May you share freely, never taking more than you give. |
| 104115 | ** |
| 104116 | ************************************************************************* |
| 104117 | ** This file contains code used to implement the PRAGMA command. |
| 104118 | */ |
| 104119 | |
| 104120 | #if !defined(SQLITE_ENABLE_LOCKING_STYLE) |
| 104121 | # if defined(__APPLE__) |
| 104122 | # define SQLITE_ENABLE_LOCKING_STYLE 1 |
| 104123 | # else |
| @@ -104220,11 +104352,11 @@ | |
| 104220 | /* ePragFlag: */ 0, |
| 104221 | /* iArg: */ 0 }, |
| 104222 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 104223 | { /* zName: */ "cache_size", |
| 104224 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 104225 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 104226 | /* iArg: */ 0 }, |
| 104227 | #endif |
| 104228 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 104229 | { /* zName: */ "cache_spill", |
| 104230 | /* ePragTyp: */ PragTyp_FLAG, |
| @@ -105290,10 +105422,11 @@ | |
| 105290 | ** of memory. |
| 105291 | */ |
| 105292 | case PragTyp_CACHE_SIZE: { |
| 105293 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 105294 | if( !zRight ){ |
| 105295 | returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); |
| 105296 | }else{ |
| 105297 | int size = sqlite3Atoi(zRight); |
| 105298 | pDb->pSchema->cache_size = size; |
| 105299 | sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); |
| @@ -106565,10 +106698,11 @@ | |
| 106565 | ************************************************************************* |
| 106566 | ** This file contains the implementation of the sqlite3_prepare() |
| 106567 | ** interface, and routines that contribute to loading the database schema |
| 106568 | ** from disk. |
| 106569 | */ |
| 106570 | |
| 106571 | /* |
| 106572 | ** Fill the InitData structure with an error message that indicates |
| 106573 | ** that the database is corrupt. |
| 106574 | */ |
| @@ -107459,10 +107593,11 @@ | |
| 107459 | ** |
| 107460 | ************************************************************************* |
| 107461 | ** This file contains C code routines that are called by the parser |
| 107462 | ** to handle SELECT statements in SQLite. |
| 107463 | */ |
| 107464 | |
| 107465 | /* |
| 107466 | ** Trace output macros |
| 107467 | */ |
| 107468 | #if SELECTTRACE_ENABLED |
| @@ -108528,11 +108663,10 @@ | |
| 108528 | } |
| 108529 | } |
| 108530 | return pInfo; |
| 108531 | } |
| 108532 | |
| 108533 | #ifndef SQLITE_OMIT_COMPOUND_SELECT |
| 108534 | /* |
| 108535 | ** Name of the connection operator, used for error messages. |
| 108536 | */ |
| 108537 | static const char *selectOpName(int id){ |
| 108538 | char *z; |
| @@ -108542,11 +108676,10 @@ | |
| 108542 | case TK_EXCEPT: z = "EXCEPT"; break; |
| 108543 | default: z = "UNION"; break; |
| 108544 | } |
| 108545 | return z; |
| 108546 | } |
| 108547 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 108548 | |
| 108549 | #ifndef SQLITE_OMIT_EXPLAIN |
| 108550 | /* |
| 108551 | ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function |
| 108552 | ** is a no-op. Otherwise, it adds a single row of output to the EQP result, |
| @@ -109545,23 +109678,10 @@ | |
| 109545 | Parse *pParse, /* Parsing context */ |
| 109546 | Select *p, /* The right-most of SELECTs to be coded */ |
| 109547 | SelectDest *pDest /* What to do with query results */ |
| 109548 | ); |
| 109549 | |
| 109550 | /* |
| 109551 | ** Error message for when two or more terms of a compound select have different |
| 109552 | ** size result sets. |
| 109553 | */ |
| 109554 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ |
| 109555 | if( p->selFlags & SF_Values ){ |
| 109556 | sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); |
| 109557 | }else{ |
| 109558 | sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" |
| 109559 | " do not have the same number of result columns", selectOpName(p->op)); |
| 109560 | } |
| 109561 | } |
| 109562 | |
| 109563 | /* |
| 109564 | ** Handle the special case of a compound-select that originates from a |
| 109565 | ** VALUES clause. By handling this as a special case, we avoid deep |
| 109566 | ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT |
| 109567 | ** on a VALUES clause. |
| @@ -109983,10 +110103,23 @@ | |
| 109983 | pDest->nSdst = dest.nSdst; |
| 109984 | sqlite3SelectDelete(db, pDelete); |
| 109985 | return rc; |
| 109986 | } |
| 109987 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 109988 | |
| 109989 | /* |
| 109990 | ** Code an output subroutine for a coroutine implementation of a |
| 109991 | ** SELECT statment. |
| 109992 | ** |
| @@ -113077,10 +113210,11 @@ | |
| 113077 | ** interface routine of sqlite3_exec(). |
| 113078 | ** |
| 113079 | ** These routines are in a separate files so that they will not be linked |
| 113080 | ** if they are not used. |
| 113081 | */ |
| 113082 | /* #include <stdlib.h> */ |
| 113083 | /* #include <string.h> */ |
| 113084 | |
| 113085 | #ifndef SQLITE_OMIT_GET_TABLE |
| 113086 | |
| @@ -113273,10 +113407,11 @@ | |
| 113273 | ** May you share freely, never taking more than you give. |
| 113274 | ** |
| 113275 | ************************************************************************* |
| 113276 | ** This file contains the implementation for TRIGGERs |
| 113277 | */ |
| 113278 | |
| 113279 | #ifndef SQLITE_OMIT_TRIGGER |
| 113280 | /* |
| 113281 | ** Delete a linked list of TriggerStep structures. |
| 113282 | */ |
| @@ -114396,10 +114531,11 @@ | |
| 114396 | ** |
| 114397 | ************************************************************************* |
| 114398 | ** This file contains C code routines that are called by the parser |
| 114399 | ** to handle UPDATE statements. |
| 114400 | */ |
| 114401 | |
| 114402 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 114403 | /* Forward declaration */ |
| 114404 | static void updateVirtualTable( |
| 114405 | Parse *pParse, /* The parsing context */ |
| @@ -115172,10 +115308,12 @@ | |
| 115172 | ** This file contains code used to implement the VACUUM command. |
| 115173 | ** |
| 115174 | ** Most of the code in this file may be omitted by defining the |
| 115175 | ** SQLITE_OMIT_VACUUM macro. |
| 115176 | */ |
| 115177 | |
| 115178 | #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) |
| 115179 | /* |
| 115180 | ** Finalize a prepared statement. If there was an error, store the |
| 115181 | ** text of the error message in *pzErrMsg. Return the result code. |
| @@ -115544,10 +115682,11 @@ | |
| 115544 | ** |
| 115545 | ************************************************************************* |
| 115546 | ** This file contains code used to help implement virtual tables. |
| 115547 | */ |
| 115548 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 115549 | |
| 115550 | /* |
| 115551 | ** Before a virtual table xCreate() or xConnect() method is invoked, the |
| 115552 | ** sqlite3.pVtabCtx member variable is set to point to an instance of |
| 115553 | ** this struct allocated on the stack. It is used by the implementation of |
| @@ -116702,10 +116841,11 @@ | |
| 116702 | ** This file was split off from where.c on 2015-06-06 in order to reduce the |
| 116703 | ** size of where.c and make it easier to edit. This file contains the routines |
| 116704 | ** that actually generate the bulk of the WHERE loop code. The original where.c |
| 116705 | ** file retains the code that does query planning and analysis. |
| 116706 | */ |
| 116707 | /************** Include whereInt.h in the middle of wherecode.c **************/ |
| 116708 | /************** Begin file whereInt.h ****************************************/ |
| 116709 | /* |
| 116710 | ** 2013-11-12 |
| 116711 | ** |
| @@ -118737,10 +118877,12 @@ | |
| 118737 | ** |
| 118738 | ** This file was originally part of where.c but was split out to improve |
| 118739 | ** readability and editabiliity. This file contains utility routines for |
| 118740 | ** analyzing Expr objects in the WHERE clause. |
| 118741 | */ |
| 118742 | |
| 118743 | /* Forward declarations */ |
| 118744 | static void exprAnalyze(SrcList*, WhereClause*, int); |
| 118745 | |
| 118746 | /* |
| @@ -119987,10 +120129,12 @@ | |
| 119987 | ** generating the code that loops through a table looking for applicable |
| 119988 | ** rows. Indices are selected and used to speed the search when doing |
| 119989 | ** so is applicable. Because this module is responsible for selecting |
| 119990 | ** indices, you might also think of this module as the "query optimizer". |
| 119991 | */ |
| 119992 | |
| 119993 | /* Forward declaration of methods */ |
| 119994 | static int whereLoopResize(sqlite3*, WhereLoop*, int); |
| 119995 | |
| 119996 | /* Test variable that can be set to enable WHERE tracing */ |
| @@ -124486,10 +124630,11 @@ | |
| 124486 | */ |
| 124487 | /* First off, code is included that follows the "include" declaration |
| 124488 | ** in the input grammar file. */ |
| 124489 | /* #include <stdio.h> */ |
| 124490 | |
| 124491 | |
| 124492 | /* |
| 124493 | ** Disable all error recovery processing in the parser push-down |
| 124494 | ** automaton. |
| 124495 | */ |
| @@ -128071,10 +128216,11 @@ | |
| 128071 | ** |
| 128072 | ** This file contains C code that splits an SQL input string up into |
| 128073 | ** individual tokens and sends those tokens one-by-one over to the |
| 128074 | ** parser for analysis. |
| 128075 | */ |
| 128076 | /* #include <stdlib.h> */ |
| 128077 | |
| 128078 | /* |
| 128079 | ** The charMap() macro maps alphabetic characters into their |
| 128080 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -128880,10 +129026,11 @@ | |
| 128880 | ** This file contains C code that implements the sqlite3_complete() API. |
| 128881 | ** This code used to be part of the tokenizer.c source file. But by |
| 128882 | ** separating it out, the code will be automatically omitted from |
| 128883 | ** static links that do not use it. |
| 128884 | */ |
| 128885 | #ifndef SQLITE_OMIT_COMPLETE |
| 128886 | |
| 128887 | /* |
| 128888 | ** This is defined in tokenize.c. We just have to import the definition. |
| 128889 | */ |
| @@ -129170,10 +129317,11 @@ | |
| 129170 | ** Main file for the SQLite library. The routines in this file |
| 129171 | ** implement the programmer interface to the library. Routines in |
| 129172 | ** other files are for internal use by SQLite and should not be |
| 129173 | ** accessed by users of the library. |
| 129174 | */ |
| 129175 | |
| 129176 | #ifdef SQLITE_ENABLE_FTS3 |
| 129177 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 129178 | /************** Begin file fts3.h ********************************************/ |
| 129179 | /* |
| @@ -129189,10 +129337,11 @@ | |
| 129189 | ****************************************************************************** |
| 129190 | ** |
| 129191 | ** This header file is used by programs that want to link against the |
| 129192 | ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface. |
| 129193 | */ |
| 129194 | |
| 129195 | #if 0 |
| 129196 | extern "C" { |
| 129197 | #endif /* __cplusplus */ |
| 129198 | |
| @@ -129221,10 +129370,11 @@ | |
| 129221 | ****************************************************************************** |
| 129222 | ** |
| 129223 | ** This header file is used by programs that want to link against the |
| 129224 | ** RTREE library. All it does is declare the sqlite3RtreeInit() interface. |
| 129225 | */ |
| 129226 | |
| 129227 | #if 0 |
| 129228 | extern "C" { |
| 129229 | #endif /* __cplusplus */ |
| 129230 | |
| @@ -129253,10 +129403,11 @@ | |
| 129253 | ****************************************************************************** |
| 129254 | ** |
| 129255 | ** This header file is used by programs that want to link against the |
| 129256 | ** ICU extension. All it does is declare the sqlite3IcuInit() interface. |
| 129257 | */ |
| 129258 | |
| 129259 | #if 0 |
| 129260 | extern "C" { |
| 129261 | #endif /* __cplusplus */ |
| 129262 | |
| @@ -133045,10 +133196,12 @@ | |
| 133045 | ************************************************************************* |
| 133046 | ** |
| 133047 | ** This file contains the implementation of the sqlite3_unlock_notify() |
| 133048 | ** API method and its associated functionality. |
| 133049 | */ |
| 133050 | |
| 133051 | /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ |
| 133052 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 133053 | |
| 133054 | /* |
| @@ -133688,13 +133841,15 @@ | |
| 133688 | |
| 133689 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 133690 | |
| 133691 | /* If not building as part of the core, include sqlite3ext.h. */ |
| 133692 | #ifndef SQLITE_CORE |
| 133693 | SQLITE_EXTENSION_INIT3 |
| 133694 | #endif |
| 133695 | |
| 133696 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 133697 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 133698 | /* |
| 133699 | ** 2006 July 10 |
| 133700 | ** |
| @@ -133719,10 +133874,11 @@ | |
| 133719 | |
| 133720 | /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time. |
| 133721 | ** If tokenizers are to be allowed to call sqlite3_*() functions, then |
| 133722 | ** we will need a way to register the API consistently. |
| 133723 | */ |
| 133724 | |
| 133725 | /* |
| 133726 | ** Structures used by the tokenizer interface. When a new tokenizer |
| 133727 | ** implementation is registered, the caller provides a pointer to |
| 133728 | ** an sqlite3_tokenizer_module containing pointers to the callback |
| @@ -134559,11 +134715,13 @@ | |
| 134559 | /* #include <stddef.h> */ |
| 134560 | /* #include <stdio.h> */ |
| 134561 | /* #include <string.h> */ |
| 134562 | /* #include <stdarg.h> */ |
| 134563 | |
| 134564 | #ifndef SQLITE_CORE |
| 134565 | SQLITE_EXTENSION_INIT1 |
| 134566 | #endif |
| 134567 | |
| 134568 | static int fts3EvalNext(Fts3Cursor *pCsr); |
| 134569 | static int fts3EvalStart(Fts3Cursor *pCsr); |
| @@ -138606,10 +138764,11 @@ | |
| 138606 | if( p==0 ){ |
| 138607 | p = aDoclist; |
| 138608 | p += sqlite3Fts3GetVarint(p, piDocid); |
| 138609 | }else{ |
| 138610 | fts3PoslistCopy(0, &p); |
| 138611 | if( p>=&aDoclist[nDoclist] ){ |
| 138612 | *pbEof = 1; |
| 138613 | }else{ |
| 138614 | sqlite3_int64 iVar; |
| 138615 | p += sqlite3Fts3GetVarint(p, &iVar); |
| @@ -140012,14 +140171,14 @@ | |
| 140012 | pIter = pPhrase->doclist.pList; |
| 140013 | if( iDocid!=pCsr->iPrevId || pExpr->bEof ){ |
| 140014 | int rc = SQLITE_OK; |
| 140015 | int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */ |
| 140016 | int bOr = 0; |
| 140017 | u8 bEof = 0; |
| 140018 | u8 bTreeEof = 0; |
| 140019 | Fts3Expr *p; /* Used to iterate from pExpr to root */ |
| 140020 | Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */ |
| 140021 | |
| 140022 | /* Check if this phrase descends from an OR expression node. If not, |
| 140023 | ** return NULL. Otherwise, the entry that corresponds to docid |
| 140024 | ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the |
| 140025 | ** tree that the node is part of has been marked as EOF, but the node |
| @@ -140049,35 +140208,51 @@ | |
| 140049 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 140050 | } |
| 140051 | } |
| 140052 | if( rc!=SQLITE_OK ) return rc; |
| 140053 | |
| 140054 | pIter = pPhrase->pOrPoslist; |
| 140055 | iDocid = pPhrase->iOrDocid; |
| 140056 | if( pCsr->bDesc==bDescDoclist ){ |
| 140057 | bEof = !pPhrase->doclist.nAll || |
| 140058 | (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll)); |
| 140059 | while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){ |
| 140060 | sqlite3Fts3DoclistNext( |
| 140061 | bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, |
| 140062 | &pIter, &iDocid, &bEof |
| 140063 | ); |
| 140064 | } |
| 140065 | }else{ |
| 140066 | bEof = !pPhrase->doclist.nAll || (pIter && pIter<=pPhrase->doclist.aAll); |
| 140067 | while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){ |
| 140068 | int dummy; |
| 140069 | sqlite3Fts3DoclistPrev( |
| 140070 | bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, |
| 140071 | &pIter, &iDocid, &dummy, &bEof |
| 140072 | ); |
| 140073 | } |
| 140074 | } |
| 140075 | pPhrase->pOrPoslist = pIter; |
| 140076 | pPhrase->iOrDocid = iDocid; |
| 140077 | |
| 140078 | if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0; |
| 140079 | } |
| 140080 | if( pIter==0 ) return SQLITE_OK; |
| 140081 | |
| 140082 | if( *pIter==0x01 ){ |
| 140083 | pIter++; |
| @@ -140161,10 +140336,11 @@ | |
| 140161 | ** May you share freely, never taking more than you give. |
| 140162 | ** |
| 140163 | ****************************************************************************** |
| 140164 | ** |
| 140165 | */ |
| 140166 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140167 | |
| 140168 | /* #include <string.h> */ |
| 140169 | /* #include <assert.h> */ |
| 140170 | |
| @@ -140717,10 +140893,11 @@ | |
| 140717 | ** This module contains code that implements a parser for fts3 query strings |
| 140718 | ** (the right-hand argument to the MATCH operator). Because the supported |
| 140719 | ** syntax is relatively simple, the whole tokenizer/parser system is |
| 140720 | ** hand-coded. |
| 140721 | */ |
| 140722 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140723 | |
| 140724 | /* |
| 140725 | ** By default, this module parses the legacy syntax that has been |
| 140726 | ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS |
| @@ -142010,16 +142187,18 @@ | |
| 142010 | ** (in which case SQLITE_CORE is not defined), or |
| 142011 | ** |
| 142012 | ** * The FTS3 module is being built into the core of |
| 142013 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142014 | */ |
| 142015 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142016 | |
| 142017 | /* #include <assert.h> */ |
| 142018 | /* #include <stdlib.h> */ |
| 142019 | /* #include <string.h> */ |
| 142020 | |
| 142021 | |
| 142022 | /* |
| 142023 | ** Malloc and Free functions |
| 142024 | */ |
| 142025 | static void *fts3HashMalloc(int n){ |
| @@ -142393,17 +142572,19 @@ | |
| 142393 | ** (in which case SQLITE_CORE is not defined), or |
| 142394 | ** |
| 142395 | ** * The FTS3 module is being built into the core of |
| 142396 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142397 | */ |
| 142398 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142399 | |
| 142400 | /* #include <assert.h> */ |
| 142401 | /* #include <stdlib.h> */ |
| 142402 | /* #include <stdio.h> */ |
| 142403 | /* #include <string.h> */ |
| 142404 | |
| 142405 | |
| 142406 | /* |
| 142407 | ** Class derived from sqlite3_tokenizer |
| 142408 | */ |
| 142409 | typedef struct porter_tokenizer { |
| @@ -143057,10 +143238,11 @@ | |
| 143057 | ** (in which case SQLITE_CORE is not defined), or |
| 143058 | ** |
| 143059 | ** * The FTS3 module is being built into the core of |
| 143060 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143061 | */ |
| 143062 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143063 | |
| 143064 | /* #include <assert.h> */ |
| 143065 | /* #include <string.h> */ |
| 143066 | |
| @@ -143552,17 +143734,19 @@ | |
| 143552 | ** (in which case SQLITE_CORE is not defined), or |
| 143553 | ** |
| 143554 | ** * The FTS3 module is being built into the core of |
| 143555 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143556 | */ |
| 143557 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143558 | |
| 143559 | /* #include <assert.h> */ |
| 143560 | /* #include <stdlib.h> */ |
| 143561 | /* #include <stdio.h> */ |
| 143562 | /* #include <string.h> */ |
| 143563 | |
| 143564 | |
| 143565 | typedef struct simple_tokenizer { |
| 143566 | sqlite3_tokenizer base; |
| 143567 | char delim[128]; /* flag ASCII delimiters */ |
| 143568 | } simple_tokenizer; |
| @@ -143803,10 +143987,11 @@ | |
| 143803 | ** end: Byte offset of the byte immediately following the end of the |
| 143804 | ** token within the input string. |
| 143805 | ** pos: Token offset of token within input. |
| 143806 | ** |
| 143807 | */ |
| 143808 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143809 | |
| 143810 | /* #include <string.h> */ |
| 143811 | /* #include <assert.h> */ |
| 143812 | |
| @@ -144238,10 +144423,11 @@ | |
| 144238 | ** tables. It also contains code to merge FTS3 b-tree segments. Some |
| 144239 | ** of the sub-routines used to merge segments are also used by the query |
| 144240 | ** code in fts3.c. |
| 144241 | */ |
| 144242 | |
| 144243 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 144244 | |
| 144245 | /* #include <string.h> */ |
| 144246 | /* #include <assert.h> */ |
| 144247 | /* #include <stdlib.h> */ |
| @@ -149898,10 +150084,11 @@ | |
| 149898 | ** May you share freely, never taking more than you give. |
| 149899 | ** |
| 149900 | ****************************************************************************** |
| 149901 | */ |
| 149902 | |
| 149903 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 149904 | |
| 149905 | /* #include <string.h> */ |
| 149906 | /* #include <assert.h> */ |
| 149907 | |
| @@ -151610,17 +151797,19 @@ | |
| 151610 | ** Implementation of the "unicode" full-text-search tokenizer. |
| 151611 | */ |
| 151612 | |
| 151613 | #ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 151614 | |
| 151615 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 151616 | |
| 151617 | /* #include <assert.h> */ |
| 151618 | /* #include <stdlib.h> */ |
| 151619 | /* #include <stdio.h> */ |
| 151620 | /* #include <string.h> */ |
| 151621 | |
| 151622 | |
| 151623 | /* |
| 151624 | ** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied |
| 151625 | ** from the sqlite3 source file utf.c. If this file is compiled as part |
| 151626 | ** of the amalgamation, they are not required. |
| @@ -152412,12 +152601,14 @@ | |
| 152412 | */ |
| 152413 | |
| 152414 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) |
| 152415 | |
| 152416 | #ifndef SQLITE_CORE |
| 152417 | SQLITE_EXTENSION_INIT1 |
| 152418 | #else |
| 152419 | #endif |
| 152420 | |
| 152421 | /* #include <string.h> */ |
| 152422 | /* #include <assert.h> */ |
| 152423 | /* #include <stdio.h> */ |
| @@ -155909,12 +156100,14 @@ | |
| 155909 | #include <unicode/ucol.h> |
| 155910 | |
| 155911 | /* #include <assert.h> */ |
| 155912 | |
| 155913 | #ifndef SQLITE_CORE |
| 155914 | SQLITE_EXTENSION_INIT1 |
| 155915 | #else |
| 155916 | #endif |
| 155917 | |
| 155918 | /* |
| 155919 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB |
| 155920 | ** operator. |
| @@ -156386,15 +156579,17 @@ | |
| 156386 | ** May you share freely, never taking more than you give. |
| 156387 | ** |
| 156388 | ************************************************************************* |
| 156389 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 156390 | */ |
| 156391 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 156392 | #ifdef SQLITE_ENABLE_ICU |
| 156393 | |
| 156394 | /* #include <assert.h> */ |
| 156395 | /* #include <string.h> */ |
| 156396 | |
| 156397 | #include <unicode/ubrk.h> |
| 156398 | /* #include <unicode/ucol.h> */ |
| 156399 | /* #include <unicode/ustring.h> */ |
| 156400 | #include <unicode/utf16.h> |
| @@ -156723,10 +156918,11 @@ | |
| 156723 | /* #include <assert.h> */ |
| 156724 | /* #include <string.h> */ |
| 156725 | /* #include <stdio.h> */ |
| 156726 | /* #include <unistd.h> */ |
| 156727 | |
| 156728 | |
| 156729 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA) |
| 156730 | /************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/ |
| 156731 | /************** Begin file sqlite3ota.h **************************************/ |
| 156732 | /* |
| @@ -156976,10 +157172,11 @@ | |
| 156976 | */ |
| 156977 | |
| 156978 | #ifndef _SQLITE3OTA_H |
| 156979 | #define _SQLITE3OTA_H |
| 156980 | |
| 156981 | |
| 156982 | typedef struct sqlite3ota sqlite3ota; |
| 156983 | |
| 156984 | /* |
| 156985 | ** Open an OTA handle. |
| @@ -157144,11 +157341,10 @@ | |
| 157144 | ** are undefined. |
| 157145 | */ |
| 157146 | SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName); |
| 157147 | |
| 157148 | #endif /* _SQLITE3OTA_H */ |
| 157149 | |
| 157150 | |
| 157151 | /************** End of sqlite3ota.h ******************************************/ |
| 157152 | /************** Continuing where we left off in sqlite3ota.c *****************/ |
| 157153 | |
| 157154 | /* Maximum number of prepared UPDATE statements held by this module */ |
| @@ -160741,10 +160937,11 @@ | |
| 160741 | ** information from an SQLite database in order to implement the |
| 160742 | ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script |
| 160743 | ** for an example implementation. |
| 160744 | */ |
| 160745 | |
| 160746 | #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \ |
| 160747 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 160748 | |
| 160749 | /* |
| 160750 | ** Page paths: |
| 160751 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -325,11 +325,11 @@ | |
| 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | */ |
| 328 | #define SQLITE_VERSION "3.8.11" |
| 329 | #define SQLITE_VERSION_NUMBER 3008011 |
| 330 | #define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6" |
| 331 | |
| 332 | /* |
| 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | ** |
| @@ -8361,11 +8361,11 @@ | |
| 8361 | |
| 8362 | /* |
| 8363 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 8364 | ** compiling with an appropriate version of MSVC. |
| 8365 | */ |
| 8366 | #if defined(_MSC_VER) && _MSC_VER>=1300 && !defined(_WIN32_WCE) |
| 8367 | # include <intrin.h> |
| 8368 | # pragma intrinsic(_byteswap_ushort) |
| 8369 | # pragma intrinsic(_byteswap_ulong) |
| 8370 | #endif |
| 8371 | |
| @@ -9189,11 +9189,13 @@ | |
| 9189 | #endif |
| 9190 | #ifndef SQLITE_MAX_MMAP_SIZE |
| 9191 | # if defined(__linux__) \ |
| 9192 | || defined(_WIN32) \ |
| 9193 | || (defined(__APPLE__) && defined(__MACH__)) \ |
| 9194 | || defined(__sun) \ |
| 9195 | || defined(__FreeBSD__) \ |
| 9196 | || defined(__DragonFly__) |
| 9197 | # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ |
| 9198 | # else |
| 9199 | # define SQLITE_MAX_MMAP_SIZE 0 |
| 9200 | # endif |
| 9201 | # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ |
| @@ -13883,10 +13885,11 @@ | |
| 13885 | ** |
| 13886 | ************************************************************************* |
| 13887 | ** |
| 13888 | ** This file contains definitions of global variables and constants. |
| 13889 | */ |
| 13890 | /* #include "sqliteInt.h" */ |
| 13891 | |
| 13892 | /* An array to map all upper-case characters into their corresponding |
| 13893 | ** lower-case character. |
| 13894 | ** |
| 13895 | ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not |
| @@ -14122,10 +14125,11 @@ | |
| 14125 | */ |
| 14126 | #ifndef SQLITE_OMIT_WSD |
| 14127 | SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000; |
| 14128 | #endif |
| 14129 | |
| 14130 | /* #include "opcodes.h" */ |
| 14131 | /* |
| 14132 | ** Properties of opcodes. The OPFLG_INITIALIZER macro is |
| 14133 | ** created by mkopcodeh.awk during compilation. Data is obtained |
| 14134 | ** from the comments following the "case OP_xxxx:" statements in |
| 14135 | ** the vdbe.c file. |
| @@ -14150,10 +14154,11 @@ | |
| 14154 | ** SQLite was built with. |
| 14155 | */ |
| 14156 | |
| 14157 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| 14158 | |
| 14159 | /* #include "sqliteInt.h" */ |
| 14160 | |
| 14161 | /* |
| 14162 | ** An array of names of all compile-time options. This array should |
| 14163 | ** be sorted A-Z. |
| 14164 | ** |
| @@ -14579,10 +14584,11 @@ | |
| 14584 | ************************************************************************* |
| 14585 | ** |
| 14586 | ** This module implements the sqlite3_status() interface and related |
| 14587 | ** functionality. |
| 14588 | */ |
| 14589 | /* #include "sqliteInt.h" */ |
| 14590 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 14591 | /************** Begin file vdbeInt.h *****************************************/ |
| 14592 | /* |
| 14593 | ** 2003 September 6 |
| 14594 | ** |
| @@ -15462,10 +15468,11 @@ | |
| 15468 | ** Astronomical Algorithms, 2nd Edition, 1998 |
| 15469 | ** ISBM 0-943396-61-1 |
| 15470 | ** Willmann-Bell, Inc |
| 15471 | ** Richmond, Virginia (USA) |
| 15472 | */ |
| 15473 | /* #include "sqliteInt.h" */ |
| 15474 | /* #include <stdlib.h> */ |
| 15475 | /* #include <assert.h> */ |
| 15476 | #include <time.h> |
| 15477 | |
| 15478 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| @@ -15773,11 +15780,11 @@ | |
| 15780 | Z = (int)((p->iJD + 43200000)/86400000); |
| 15781 | A = (int)((Z - 1867216.25)/36524.25); |
| 15782 | A = Z + 1 + A - (A/4); |
| 15783 | B = A + 1524; |
| 15784 | C = (int)((B - 122.1)/365.25); |
| 15785 | D = (36525*(C&32767))/100; |
| 15786 | E = (int)((B-D)/30.6001); |
| 15787 | X1 = (int)(30.6001*E); |
| 15788 | p->D = B - D - X1; |
| 15789 | p->M = E<14 ? E-1 : E-13; |
| 15790 | p->Y = p->M>2 ? C - 4716 : C - 4715; |
| @@ -16574,10 +16581,11 @@ | |
| 16581 | ** |
| 16582 | ** This file contains OS interface code that is common to all |
| 16583 | ** architectures. |
| 16584 | */ |
| 16585 | #define _SQLITE_OS_C_ 1 |
| 16586 | /* #include "sqliteInt.h" */ |
| 16587 | #undef _SQLITE_OS_C_ |
| 16588 | |
| 16589 | /* |
| 16590 | ** The default SQLite sqlite3_vfs implementations do not allocate |
| 16591 | ** memory (actually, os_unix.c allocates a small amount of memory |
| @@ -16980,10 +16988,11 @@ | |
| 16988 | ** is completely recoverable simply by not carrying out the resize. The |
| 16989 | ** hash table will continue to function normally. So a malloc failure |
| 16990 | ** during a hash table resize is a benign fault. |
| 16991 | */ |
| 16992 | |
| 16993 | /* #include "sqliteInt.h" */ |
| 16994 | |
| 16995 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 16996 | |
| 16997 | /* |
| 16998 | ** Global variables. |
| @@ -17061,10 +17070,11 @@ | |
| 17070 | ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented |
| 17071 | ** here always fail. SQLite will not operate with these drivers. These |
| 17072 | ** are merely placeholders. Real drivers must be substituted using |
| 17073 | ** sqlite3_config() before SQLite will operate. |
| 17074 | */ |
| 17075 | /* #include "sqliteInt.h" */ |
| 17076 | |
| 17077 | /* |
| 17078 | ** This version of the memory allocator is the default. It is |
| 17079 | ** used when no other memory allocator is specified using compile-time |
| 17080 | ** macros. |
| @@ -17147,10 +17157,11 @@ | |
| 17157 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| 17158 | ** _msize() on windows systems. This might |
| 17159 | ** be necessary when compiling for Delphi, |
| 17160 | ** for example. |
| 17161 | */ |
| 17162 | /* #include "sqliteInt.h" */ |
| 17163 | |
| 17164 | /* |
| 17165 | ** This version of the memory allocator is the default. It is |
| 17166 | ** used when no other memory allocator is specified using compile-time |
| 17167 | ** macros. |
| @@ -17422,10 +17433,11 @@ | |
| 17433 | ** leaks and memory usage errors. |
| 17434 | ** |
| 17435 | ** This file contains implementations of the low-level memory allocation |
| 17436 | ** routines specified in the sqlite3_mem_methods object. |
| 17437 | */ |
| 17438 | /* #include "sqliteInt.h" */ |
| 17439 | |
| 17440 | /* |
| 17441 | ** This version of the memory allocator is used only if the |
| 17442 | ** SQLITE_MEMDEBUG macro is defined |
| 17443 | */ |
| @@ -17956,10 +17968,11 @@ | |
| 17968 | ** be changed. |
| 17969 | ** |
| 17970 | ** This version of the memory allocation subsystem is included |
| 17971 | ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. |
| 17972 | */ |
| 17973 | /* #include "sqliteInt.h" */ |
| 17974 | |
| 17975 | /* |
| 17976 | ** This version of the memory allocator is only built into the library |
| 17977 | ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not |
| 17978 | ** mean that the library will use a memory-pool by default, just that |
| @@ -18670,10 +18683,11 @@ | |
| 18683 | ** N >= M*(1 + log2(n)/2) - n + 1 |
| 18684 | ** |
| 18685 | ** The sqlite3_status() logic tracks the maximum values of n and M so |
| 18686 | ** that an application can, at any time, verify this constraint. |
| 18687 | */ |
| 18688 | /* #include "sqliteInt.h" */ |
| 18689 | |
| 18690 | /* |
| 18691 | ** This version of the memory allocator is used only when |
| 18692 | ** SQLITE_ENABLE_MEMSYS5 is defined. |
| 18693 | */ |
| @@ -19213,10 +19227,11 @@ | |
| 19227 | ************************************************************************* |
| 19228 | ** This file contains the C functions that implement mutexes. |
| 19229 | ** |
| 19230 | ** This file contains code that is common across all mutex implementations. |
| 19231 | */ |
| 19232 | /* #include "sqliteInt.h" */ |
| 19233 | |
| 19234 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT) |
| 19235 | /* |
| 19236 | ** For debugging purposes, record when the mutex subsystem is initialized |
| 19237 | ** and uninitialized so that we can assert() if there is an attempt to |
| @@ -19386,10 +19401,11 @@ | |
| 19401 | ** |
| 19402 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted |
| 19403 | ** that does error checking on mutexes to make sure they are being |
| 19404 | ** called correctly. |
| 19405 | */ |
| 19406 | /* #include "sqliteInt.h" */ |
| 19407 | |
| 19408 | #ifndef SQLITE_MUTEX_OMIT |
| 19409 | |
| 19410 | #ifndef SQLITE_DEBUG |
| 19411 | /* |
| @@ -19589,10 +19605,11 @@ | |
| 19605 | ** May you share freely, never taking more than you give. |
| 19606 | ** |
| 19607 | ************************************************************************* |
| 19608 | ** This file contains the C functions that implement mutexes for pthreads |
| 19609 | */ |
| 19610 | /* #include "sqliteInt.h" */ |
| 19611 | |
| 19612 | /* |
| 19613 | ** The code in this file is only used if we are compiling threadsafe |
| 19614 | ** under unix with pthreads. |
| 19615 | ** |
| @@ -19963,10 +19980,11 @@ | |
| 19980 | ** May you share freely, never taking more than you give. |
| 19981 | ** |
| 19982 | ************************************************************************* |
| 19983 | ** This file contains the C functions that implement mutexes for Win32. |
| 19984 | */ |
| 19985 | /* #include "sqliteInt.h" */ |
| 19986 | |
| 19987 | #if SQLITE_OS_WIN |
| 19988 | /* |
| 19989 | ** Include code that is common to all os_*.c files |
| 19990 | */ |
| @@ -20638,10 +20656,11 @@ | |
| 20656 | ** |
| 20657 | ************************************************************************* |
| 20658 | ** |
| 20659 | ** Memory allocation functions used throughout sqlite. |
| 20660 | */ |
| 20661 | /* #include "sqliteInt.h" */ |
| 20662 | /* #include <stdarg.h> */ |
| 20663 | |
| 20664 | /* |
| 20665 | ** Attempt to release up to n bytes of non-essential memory currently |
| 20666 | ** held by SQLite. An example of non-essential memory is memory used to |
| @@ -21449,10 +21468,11 @@ | |
| 21468 | ** This file contains code for a set of "printf"-like routines. These |
| 21469 | ** routines format strings much like the printf() from the standard C |
| 21470 | ** library, though the implementation here has enhancements to support |
| 21471 | ** SQLite. |
| 21472 | */ |
| 21473 | /* #include "sqliteInt.h" */ |
| 21474 | |
| 21475 | /* |
| 21476 | ** Conversion types fall into various categories as defined by the |
| 21477 | ** following enumeration. |
| 21478 | */ |
| @@ -22451,10 +22471,15 @@ | |
| 22471 | ** stack space on small-stack systems when logging is disabled. |
| 22472 | ** |
| 22473 | ** sqlite3_log() must render into a static buffer. It cannot dynamically |
| 22474 | ** allocate memory because it might be called while the memory allocator |
| 22475 | ** mutex is held. |
| 22476 | ** |
| 22477 | ** sqlite3VXPrintf() might ask for *temporary* memory allocations for |
| 22478 | ** certain format characters (%q) or for very large precisions or widths. |
| 22479 | ** Care must be taken that any sqlite3_log() calls that occur while the |
| 22480 | ** memory mutex is held do not use these mechanisms. |
| 22481 | */ |
| 22482 | static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ |
| 22483 | StrAccum acc; /* String accumulator */ |
| 22484 | char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ |
| 22485 | |
| @@ -22526,10 +22551,11 @@ | |
| 22551 | ** analysis. |
| 22552 | ** |
| 22553 | ** The interfaces in this file is only available when compiling |
| 22554 | ** with SQLITE_DEBUG. |
| 22555 | */ |
| 22556 | /* #include "sqliteInt.h" */ |
| 22557 | #ifdef SQLITE_DEBUG |
| 22558 | |
| 22559 | /* |
| 22560 | ** Add a new subitem to the tree. The moreToFollow flag indicates that this |
| 22561 | ** is not the last item in the tree. |
| @@ -22957,10 +22983,11 @@ | |
| 22983 | ** generator (PRNG) for SQLite. |
| 22984 | ** |
| 22985 | ** Random numbers are used by some of the database backends in order |
| 22986 | ** to generate random integer keys for tables or random filenames. |
| 22987 | */ |
| 22988 | /* #include "sqliteInt.h" */ |
| 22989 | |
| 22990 | |
| 22991 | /* All threads share a single random number generator. |
| 22992 | ** This structure is the current state of the generator. |
| 22993 | */ |
| @@ -23103,11 +23130,13 @@ | |
| 23130 | ** single threaded systems. Nothing in SQLite requires multiple threads. |
| 23131 | ** This interface exists so that applications that want to take advantage |
| 23132 | ** of multiple cores can do so, while also allowing applications to stay |
| 23133 | ** single-threaded if desired. |
| 23134 | */ |
| 23135 | /* #include "sqliteInt.h" */ |
| 23136 | #if SQLITE_OS_WIN |
| 23137 | /* # include "os_win.h" */ |
| 23138 | #endif |
| 23139 | |
| 23140 | #if SQLITE_MAX_WORKER_THREADS>0 |
| 23141 | |
| 23142 | /********************************* Unix Pthreads ****************************/ |
| @@ -23377,11 +23406,13 @@ | |
| 23406 | ** BOM or Byte Order Mark: |
| 23407 | ** 0xff 0xfe little-endian utf-16 follows |
| 23408 | ** 0xfe 0xff big-endian utf-16 follows |
| 23409 | ** |
| 23410 | */ |
| 23411 | /* #include "sqliteInt.h" */ |
| 23412 | /* #include <assert.h> */ |
| 23413 | /* #include "vdbeInt.h" */ |
| 23414 | |
| 23415 | #ifndef SQLITE_AMALGAMATION |
| 23416 | /* |
| 23417 | ** The following constant value is used by the SQLITE_BIGENDIAN and |
| 23418 | ** SQLITE_LITTLEENDIAN macros. |
| @@ -23890,10 +23921,11 @@ | |
| 23921 | ** |
| 23922 | ** This file contains functions for allocating memory, comparing |
| 23923 | ** strings, and stuff like that. |
| 23924 | ** |
| 23925 | */ |
| 23926 | /* #include "sqliteInt.h" */ |
| 23927 | /* #include <stdarg.h> */ |
| 23928 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN |
| 23929 | # include <math.h> |
| 23930 | #endif |
| 23931 | |
| @@ -25286,10 +25318,11 @@ | |
| 25318 | ** |
| 25319 | ************************************************************************* |
| 25320 | ** This is the implementation of generic hash-tables |
| 25321 | ** used in SQLite. |
| 25322 | */ |
| 25323 | /* #include "sqliteInt.h" */ |
| 25324 | /* #include <assert.h> */ |
| 25325 | |
| 25326 | /* Turn bulk memory into a hash table object by initializing the |
| 25327 | ** fields of the Hash structure. |
| 25328 | ** |
| @@ -25763,10 +25796,11 @@ | |
| 25796 | ** * sqlite3_vfs method implementations. |
| 25797 | ** * Locking primitives for the proxy uber-locking-method. (MacOSX only) |
| 25798 | ** * Definitions of sqlite3_vfs objects for all locking methods |
| 25799 | ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). |
| 25800 | */ |
| 25801 | /* #include "sqliteInt.h" */ |
| 25802 | #if SQLITE_OS_UNIX /* This file is used on unix only */ |
| 25803 | |
| 25804 | /* |
| 25805 | ** There are various methods for file locking used for concurrency |
| 25806 | ** control: |
| @@ -33497,10 +33531,11 @@ | |
| 33531 | ** |
| 33532 | ****************************************************************************** |
| 33533 | ** |
| 33534 | ** This file contains code that is specific to Windows. |
| 33535 | */ |
| 33536 | /* #include "sqliteInt.h" */ |
| 33537 | #if SQLITE_OS_WIN /* This file is used for Windows only */ |
| 33538 | |
| 33539 | /* |
| 33540 | ** Include code that is common to all os_*.c files |
| 33541 | */ |
| @@ -33705,10 +33740,11 @@ | |
| 33740 | /************** Continuing where we left off in os_win.c *********************/ |
| 33741 | |
| 33742 | /* |
| 33743 | ** Include the header file for the Windows VFS. |
| 33744 | */ |
| 33745 | /* #include "os_win.h" */ |
| 33746 | |
| 33747 | /* |
| 33748 | ** Compiling and using WAL mode requires several APIs that are only |
| 33749 | ** available in Windows platforms based on the NT kernel. |
| 33750 | */ |
| @@ -39358,10 +39394,11 @@ | |
| 39394 | ** sometimes grow into tens of thousands or larger. The size of the |
| 39395 | ** Bitvec object is the number of pages in the database file at the |
| 39396 | ** start of a transaction, and is thus usually less than a few thousand, |
| 39397 | ** but can be as large as 2 billion for a really big database. |
| 39398 | */ |
| 39399 | /* #include "sqliteInt.h" */ |
| 39400 | |
| 39401 | /* Size of the Bitvec structure in bytes. */ |
| 39402 | #define BITVEC_SZ 512 |
| 39403 | |
| 39404 | /* Round the union size down to the nearest pointer boundary, since that's how |
| @@ -39747,10 +39784,11 @@ | |
| 39784 | ** May you share freely, never taking more than you give. |
| 39785 | ** |
| 39786 | ************************************************************************* |
| 39787 | ** This file implements that page cache. |
| 39788 | */ |
| 39789 | /* #include "sqliteInt.h" */ |
| 39790 | |
| 39791 | /* |
| 39792 | ** A complete page cache is an instance of this structure. |
| 39793 | */ |
| 39794 | struct PCache { |
| @@ -40488,10 +40526,11 @@ | |
| 40526 | ** |
| 40527 | ** Earlier versions of SQLite used only methods (1) and (2). But experiments |
| 40528 | ** show that method (3) with N==100 provides about a 5% performance boost for |
| 40529 | ** common workloads. |
| 40530 | */ |
| 40531 | /* #include "sqliteInt.h" */ |
| 40532 | |
| 40533 | typedef struct PCache1 PCache1; |
| 40534 | typedef struct PgHdr1 PgHdr1; |
| 40535 | typedef struct PgFreeslot PgFreeslot; |
| 40536 | typedef struct PGroup PGroup; |
| @@ -40598,10 +40637,11 @@ | |
| 40637 | ** fixed at sqlite3_initialize() time and do not require mutex protection. |
| 40638 | ** The nFreeSlot and pFree values do require mutex protection. |
| 40639 | */ |
| 40640 | int isInit; /* True if initialized */ |
| 40641 | int separateCache; /* Use a new PGroup for each PCache */ |
| 40642 | int nInitPage; /* Initial bulk allocation size */ |
| 40643 | int szSlot; /* Size of each free slot */ |
| 40644 | int nSlot; /* The number of pcache slots */ |
| 40645 | int nReserve; /* Try to keep nFreeSlot above this */ |
| 40646 | void *pStart, *pEnd; /* Bounds of global page cache memory */ |
| 40647 | /* Above requires no mutex. Use mutex below for variable that follow. */ |
| @@ -40665,10 +40705,47 @@ | |
| 40705 | pBuf = (void*)&((char*)pBuf)[sz]; |
| 40706 | } |
| 40707 | pcache1.pEnd = pBuf; |
| 40708 | } |
| 40709 | } |
| 40710 | |
| 40711 | /* |
| 40712 | ** Try to initialize the pCache->pFree and pCache->pBulk fields. Return |
| 40713 | ** true if pCache->pFree ends up containing one or more free pages. |
| 40714 | */ |
| 40715 | static int pcache1InitBulk(PCache1 *pCache){ |
| 40716 | int szBulk; |
| 40717 | char *zBulk; |
| 40718 | if( pcache1.nInitPage==0 ) return 0; |
| 40719 | /* Do not bother with a bulk allocation if the cache size very small */ |
| 40720 | if( pCache->nMax<3 ) return 0; |
| 40721 | sqlite3BeginBenignMalloc(); |
| 40722 | if( pcache1.nInitPage>0 ){ |
| 40723 | szBulk = pCache->szAlloc * pcache1.nInitPage; |
| 40724 | }else{ |
| 40725 | szBulk = -1024*pcache1.nInitPage; |
| 40726 | } |
| 40727 | if( szBulk > pCache->szAlloc*pCache->nMax ){ |
| 40728 | szBulk = pCache->szAlloc*pCache->nMax; |
| 40729 | } |
| 40730 | zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); |
| 40731 | sqlite3EndBenignMalloc(); |
| 40732 | if( zBulk ){ |
| 40733 | int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; |
| 40734 | int i; |
| 40735 | for(i=0; i<nBulk; i++){ |
| 40736 | PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; |
| 40737 | pX->page.pBuf = zBulk; |
| 40738 | pX->page.pExtra = &pX[1]; |
| 40739 | pX->isBulkLocal = 1; |
| 40740 | pX->pNext = pCache->pFree; |
| 40741 | pCache->pFree = pX; |
| 40742 | zBulk += pCache->szAlloc; |
| 40743 | } |
| 40744 | } |
| 40745 | return pCache->pFree!=0; |
| 40746 | } |
| 40747 | |
| 40748 | /* |
| 40749 | ** Malloc function used within this file to allocate space from the buffer |
| 40750 | ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no |
| 40751 | ** such buffer exists or there is no space left in it, this function falls |
| @@ -40766,11 +40843,11 @@ | |
| 40843 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 40844 | PgHdr1 *p = 0; |
| 40845 | void *pPg; |
| 40846 | |
| 40847 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 40848 | if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){ |
| 40849 | p = pCache->pFree; |
| 40850 | pCache->pFree = p->pNext; |
| 40851 | p->pNext = 0; |
| 40852 | }else{ |
| 40853 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| @@ -40970,18 +41047,23 @@ | |
| 41047 | |
| 41048 | /* |
| 41049 | ** If there are currently more than nMaxPage pages allocated, try |
| 41050 | ** to recycle pages to reduce the number allocated to nMaxPage. |
| 41051 | */ |
| 41052 | static void pcache1EnforceMaxPage(PCache1 *pCache){ |
| 41053 | PGroup *pGroup = pCache->pGroup; |
| 41054 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 41055 | while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){ |
| 41056 | PgHdr1 *p = pGroup->pLruTail; |
| 41057 | assert( p->pCache->pGroup==pGroup ); |
| 41058 | assert( p->isPinned==0 ); |
| 41059 | pcache1PinPage(p); |
| 41060 | pcache1RemoveFromHash(p, 1); |
| 41061 | } |
| 41062 | if( pCache->nPage==0 && pCache->pBulk ){ |
| 41063 | sqlite3_free(pCache->pBulk); |
| 41064 | pCache->pBulk = pCache->pFree = 0; |
| 41065 | } |
| 41066 | } |
| 41067 | |
| 41068 | /* |
| 41069 | ** Discard all pages from cache pCache with a page number (key value) |
| @@ -41054,10 +41136,18 @@ | |
| 41136 | if( sqlite3GlobalConfig.bCoreMutex ){ |
| 41137 | pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); |
| 41138 | pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); |
| 41139 | } |
| 41140 | #endif |
| 41141 | if( pcache1.separateCache |
| 41142 | && sqlite3GlobalConfig.nPage!=0 |
| 41143 | && sqlite3GlobalConfig.pPage==0 |
| 41144 | ){ |
| 41145 | pcache1.nInitPage = sqlite3GlobalConfig.nPage; |
| 41146 | }else{ |
| 41147 | pcache1.nInitPage = 0; |
| 41148 | } |
| 41149 | pcache1.grp.mxPinned = 10; |
| 41150 | pcache1.isInit = 1; |
| 41151 | return SQLITE_OK; |
| 41152 | } |
| 41153 | |
| @@ -41108,40 +41198,10 @@ | |
| 41198 | pCache->nMin = 10; |
| 41199 | pGroup->nMinPage += pCache->nMin; |
| 41200 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41201 | } |
| 41202 | pcache1LeaveMutex(pGroup); |
| 41203 | if( pCache->nHash==0 ){ |
| 41204 | pcache1Destroy((sqlite3_pcache*)pCache); |
| 41205 | pCache = 0; |
| 41206 | } |
| 41207 | } |
| @@ -41160,11 +41220,11 @@ | |
| 41220 | pcache1EnterMutex(pGroup); |
| 41221 | pGroup->nMaxPage += (nMax - pCache->nMax); |
| 41222 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41223 | pCache->nMax = nMax; |
| 41224 | pCache->n90pct = pCache->nMax*9/10; |
| 41225 | pcache1EnforceMaxPage(pCache); |
| 41226 | pcache1LeaveMutex(pGroup); |
| 41227 | } |
| 41228 | } |
| 41229 | |
| 41230 | /* |
| @@ -41178,11 +41238,11 @@ | |
| 41238 | PGroup *pGroup = pCache->pGroup; |
| 41239 | int savedMaxPage; |
| 41240 | pcache1EnterMutex(pGroup); |
| 41241 | savedMaxPage = pGroup->nMaxPage; |
| 41242 | pGroup->nMaxPage = 0; |
| 41243 | pcache1EnforceMaxPage(pCache); |
| 41244 | pGroup->nMaxPage = savedMaxPage; |
| 41245 | pcache1LeaveMutex(pGroup); |
| 41246 | } |
| 41247 | } |
| 41248 | |
| @@ -41515,11 +41575,11 @@ | |
| 41575 | assert( pGroup->nMaxPage >= pCache->nMax ); |
| 41576 | pGroup->nMaxPage -= pCache->nMax; |
| 41577 | assert( pGroup->nMinPage >= pCache->nMin ); |
| 41578 | pGroup->nMinPage -= pCache->nMin; |
| 41579 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 41580 | pcache1EnforceMaxPage(pCache); |
| 41581 | pcache1LeaveMutex(pGroup); |
| 41582 | sqlite3_free(pCache->pBulk); |
| 41583 | sqlite3_free(pCache->apHash); |
| 41584 | sqlite3_free(pCache); |
| 41585 | } |
| @@ -41679,10 +41739,11 @@ | |
| 41739 | ** primitives are constant time. The cost of DESTROY is O(N). |
| 41740 | ** |
| 41741 | ** There is an added cost of O(N) when switching between TEST and |
| 41742 | ** SMALLEST primitives. |
| 41743 | */ |
| 41744 | /* #include "sqliteInt.h" */ |
| 41745 | |
| 41746 | |
| 41747 | /* |
| 41748 | ** Target size for allocation chunks. |
| 41749 | */ |
| @@ -42148,10 +42209,11 @@ | |
| 42209 | ** locking to prevent two processes from writing the same database |
| 42210 | ** file simultaneously, or one process from reading the database while |
| 42211 | ** another is writing. |
| 42212 | */ |
| 42213 | #ifndef SQLITE_OMIT_DISKIO |
| 42214 | /* #include "sqliteInt.h" */ |
| 42215 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 42216 | /************** Begin file wal.h *********************************************/ |
| 42217 | /* |
| 42218 | ** 2010 February 1 |
| 42219 | ** |
| @@ -42169,10 +42231,11 @@ | |
| 42231 | */ |
| 42232 | |
| 42233 | #ifndef _WAL_H_ |
| 42234 | #define _WAL_H_ |
| 42235 | |
| 42236 | /* #include "sqliteInt.h" */ |
| 42237 | |
| 42238 | /* Additional values that can be added to the sync_flags argument of |
| 42239 | ** sqlite3WalFrames(): |
| 42240 | */ |
| 42241 | #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| @@ -49783,10 +49846,11 @@ | |
| 49846 | ** that correspond to frames greater than the new K value are removed |
| 49847 | ** from the hash table at this point. |
| 49848 | */ |
| 49849 | #ifndef SQLITE_OMIT_WAL |
| 49850 | |
| 49851 | /* #include "wal.h" */ |
| 49852 | |
| 49853 | /* |
| 49854 | ** Trace output macros |
| 49855 | */ |
| 49856 | #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) |
| @@ -51000,11 +51064,11 @@ | |
| 51064 | |
| 51065 | const int nList = *pnList; /* Size of input list */ |
| 51066 | int nMerge = 0; /* Number of elements in list aMerge */ |
| 51067 | ht_slot *aMerge = 0; /* List to be merged */ |
| 51068 | int iList; /* Index into input list */ |
| 51069 | u32 iSub = 0; /* Index into aSub array */ |
| 51070 | struct Sublist aSub[13]; /* Array of sub-lists */ |
| 51071 | |
| 51072 | memset(aSub, 0, sizeof(aSub)); |
| 51073 | assert( nList<=HASHTABLE_NPAGE && nList>0 ); |
| 51074 | assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) ); |
| @@ -51011,11 +51075,13 @@ | |
| 51075 | |
| 51076 | for(iList=0; iList<nList; iList++){ |
| 51077 | nMerge = 1; |
| 51078 | aMerge = &aList[iList]; |
| 51079 | for(iSub=0; iList & (1<<iSub); iSub++){ |
| 51080 | struct Sublist *p; |
| 51081 | assert( iSub<ArraySize(aSub) ); |
| 51082 | p = &aSub[iSub]; |
| 51083 | assert( p->aList && p->nList<=(1<<iSub) ); |
| 51084 | assert( p->aList==&aList[iList&~((2<<iSub)-1)] ); |
| 51085 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51086 | } |
| 51087 | aSub[iSub].aList = aMerge; |
| @@ -51022,11 +51088,13 @@ | |
| 51088 | aSub[iSub].nList = nMerge; |
| 51089 | } |
| 51090 | |
| 51091 | for(iSub++; iSub<ArraySize(aSub); iSub++){ |
| 51092 | if( nList & (1<<iSub) ){ |
| 51093 | struct Sublist *p; |
| 51094 | assert( iSub<ArraySize(aSub) ); |
| 51095 | p = &aSub[iSub]; |
| 51096 | assert( p->nList<=(1<<iSub) ); |
| 51097 | assert( p->aList==&aList[nList&~((2<<iSub)-1)] ); |
| 51098 | walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer); |
| 51099 | } |
| 51100 | } |
| @@ -52933,10 +53001,11 @@ | |
| 53001 | ** SIZE DESCRIPTION |
| 53002 | ** 4 Page number of next trunk page |
| 53003 | ** 4 Number of leaf pointers on this page |
| 53004 | ** * zero or more pages numbers of leaves |
| 53005 | */ |
| 53006 | /* #include "sqliteInt.h" */ |
| 53007 | |
| 53008 | |
| 53009 | /* The following value is the maximum cell size assuming a maximum page |
| 53010 | ** size give above. |
| 53011 | */ |
| @@ -53730,10 +53799,11 @@ | |
| 53799 | ************************************************************************* |
| 53800 | ** This file implements an external (disk-based) database using BTrees. |
| 53801 | ** See the header comment on "btreeInt.h" for additional information. |
| 53802 | ** Including a description of file format and an overview of operation. |
| 53803 | */ |
| 53804 | /* #include "btreeInt.h" */ |
| 53805 | |
| 53806 | /* |
| 53807 | ** The header string that appears at the beginning of every |
| 53808 | ** SQLite database. |
| 53809 | */ |
| @@ -62675,11 +62745,11 @@ | |
| 62745 | u32 *heap = 0; /* Min-heap used for checking cell coverage */ |
| 62746 | u32 x, prev = 0; /* Next and previous entry on the min-heap */ |
| 62747 | const char *saved_zPfx = pCheck->zPfx; |
| 62748 | int saved_v1 = pCheck->v1; |
| 62749 | int saved_v2 = pCheck->v2; |
| 62750 | u8 savedIsInit = 0; |
| 62751 | |
| 62752 | /* Check that the page exists |
| 62753 | */ |
| 62754 | pBt = pCheck->pBt; |
| 62755 | usableSize = pBt->usableSize; |
| @@ -63311,10 +63381,12 @@ | |
| 63381 | ** |
| 63382 | ************************************************************************* |
| 63383 | ** This file contains the implementation of the sqlite3_backup_XXX() |
| 63384 | ** API functions and the related features. |
| 63385 | */ |
| 63386 | /* #include "sqliteInt.h" */ |
| 63387 | /* #include "btreeInt.h" */ |
| 63388 | |
| 63389 | /* |
| 63390 | ** Structure allocated for each backup operation. |
| 63391 | */ |
| 63392 | struct sqlite3_backup { |
| @@ -64109,10 +64181,12 @@ | |
| 64181 | ** This file contains code use to manipulate "Mem" structure. A "Mem" |
| 64182 | ** stores a single value in the VDBE. Mem is an opaque structure visible |
| 64183 | ** only within the VDBE. Interface routines refer to a Mem using the |
| 64184 | ** name sqlite_value |
| 64185 | */ |
| 64186 | /* #include "sqliteInt.h" */ |
| 64187 | /* #include "vdbeInt.h" */ |
| 64188 | |
| 64189 | #ifdef SQLITE_DEBUG |
| 64190 | /* |
| 64191 | ** Check invariants on a Mem object. |
| 64192 | ** |
| @@ -65826,10 +65900,12 @@ | |
| 65900 | ** |
| 65901 | ************************************************************************* |
| 65902 | ** This file contains code used for creating, destroying, and populating |
| 65903 | ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) |
| 65904 | */ |
| 65905 | /* #include "sqliteInt.h" */ |
| 65906 | /* #include "vdbeInt.h" */ |
| 65907 | |
| 65908 | /* |
| 65909 | ** Create a new virtual database engine. |
| 65910 | */ |
| 65911 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ |
| @@ -70074,10 +70150,12 @@ | |
| 70150 | ************************************************************************* |
| 70151 | ** |
| 70152 | ** This file contains code use to implement APIs that are part of the |
| 70153 | ** VDBE. |
| 70154 | */ |
| 70155 | /* #include "sqliteInt.h" */ |
| 70156 | /* #include "vdbeInt.h" */ |
| 70157 | |
| 70158 | #ifndef SQLITE_OMIT_DEPRECATED |
| 70159 | /* |
| 70160 | ** Return TRUE (non-zero) of the statement supplied as an argument needs |
| 70161 | ** to be recompiled. A statement needs to be recompiled whenever the |
| @@ -70112,10 +70190,35 @@ | |
| 70190 | }else{ |
| 70191 | return vdbeSafety(p); |
| 70192 | } |
| 70193 | } |
| 70194 | |
| 70195 | #ifndef SQLITE_OMIT_TRACE |
| 70196 | /* |
| 70197 | ** Invoke the profile callback. This routine is only called if we already |
| 70198 | ** know that the profile callback is defined and needs to be invoked. |
| 70199 | */ |
| 70200 | static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ |
| 70201 | sqlite3_int64 iNow; |
| 70202 | assert( p->startTime>0 ); |
| 70203 | assert( db->xProfile!=0 ); |
| 70204 | assert( db->init.busy==0 ); |
| 70205 | assert( p->zSql!=0 ); |
| 70206 | sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); |
| 70207 | db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); |
| 70208 | p->startTime = 0; |
| 70209 | } |
| 70210 | /* |
| 70211 | ** The checkProfileCallback(DB,P) macro checks to see if a profile callback |
| 70212 | ** is needed, and it invokes the callback if it is needed. |
| 70213 | */ |
| 70214 | # define checkProfileCallback(DB,P) \ |
| 70215 | if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); } |
| 70216 | #else |
| 70217 | # define checkProfileCallback(DB,P) /*no-op*/ |
| 70218 | #endif |
| 70219 | |
| 70220 | /* |
| 70221 | ** The following routine destroys a virtual machine that is created by |
| 70222 | ** the sqlite3_compile() routine. The integer returned is an SQLITE_ |
| 70223 | ** success/failure code that describes the result of executing the virtual |
| 70224 | ** machine. |
| @@ -70132,10 +70235,11 @@ | |
| 70235 | }else{ |
| 70236 | Vdbe *v = (Vdbe*)pStmt; |
| 70237 | sqlite3 *db = v->db; |
| 70238 | if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; |
| 70239 | sqlite3_mutex_enter(db->mutex); |
| 70240 | checkProfileCallback(db, v); |
| 70241 | rc = sqlite3VdbeFinalize(v); |
| 70242 | rc = sqlite3ApiExit(db, rc); |
| 70243 | sqlite3LeaveMutexAndCloseZombie(db); |
| 70244 | } |
| 70245 | return rc; |
| @@ -70153,16 +70257,18 @@ | |
| 70257 | int rc; |
| 70258 | if( pStmt==0 ){ |
| 70259 | rc = SQLITE_OK; |
| 70260 | }else{ |
| 70261 | Vdbe *v = (Vdbe*)pStmt; |
| 70262 | sqlite3 *db = v->db; |
| 70263 | sqlite3_mutex_enter(db->mutex); |
| 70264 | checkProfileCallback(db, v); |
| 70265 | rc = sqlite3VdbeReset(v); |
| 70266 | sqlite3VdbeRewind(v); |
| 70267 | assert( (rc & (db->errMask))==rc ); |
| 70268 | rc = sqlite3ApiExit(db, rc); |
| 70269 | sqlite3_mutex_leave(db->mutex); |
| 70270 | } |
| 70271 | return rc; |
| 70272 | } |
| 70273 | |
| 70274 | /* |
| @@ -70508,10 +70614,11 @@ | |
| 70614 | } |
| 70615 | } |
| 70616 | #endif |
| 70617 | return rc; |
| 70618 | } |
| 70619 | |
| 70620 | |
| 70621 | /* |
| 70622 | ** Execute the statement pStmt, either until a row of data is ready, the |
| 70623 | ** statement is completely executed or an error occurs. |
| 70624 | ** |
| @@ -70577,12 +70684,14 @@ | |
| 70684 | assert( db->nVdbeWrite>0 || db->autoCommit==0 |
| 70685 | || (db->nDeferredCons==0 && db->nDeferredImmCons==0) |
| 70686 | ); |
| 70687 | |
| 70688 | #ifndef SQLITE_OMIT_TRACE |
| 70689 | if( db->xProfile && !db->init.busy && p->zSql ){ |
| 70690 | sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); |
| 70691 | }else{ |
| 70692 | assert( p->startTime==0 ); |
| 70693 | } |
| 70694 | #endif |
| 70695 | |
| 70696 | db->nVdbeActive++; |
| 70697 | if( p->readOnly==0 ) db->nVdbeWrite++; |
| @@ -70602,17 +70711,12 @@ | |
| 70711 | rc = sqlite3VdbeExec(p); |
| 70712 | db->nVdbeExec--; |
| 70713 | } |
| 70714 | |
| 70715 | #ifndef SQLITE_OMIT_TRACE |
| 70716 | /* If the statement completed successfully, invoke the profile callback */ |
| 70717 | if( rc!=SQLITE_ROW ) checkProfileCallback(db, p); |
| 70718 | #endif |
| 70719 | |
| 70720 | if( rc==SQLITE_DONE ){ |
| 70721 | assert( p->rc==SQLITE_OK ); |
| 70722 | p->rc = doWalCallbacks(db); |
| @@ -71685,10 +71789,12 @@ | |
| 71789 | ** This file contains code used to insert the values of host parameters |
| 71790 | ** (aka "wildcards") into the SQL text output by sqlite3_trace(). |
| 71791 | ** |
| 71792 | ** The Vdbe parse-tree explainer is also found here. |
| 71793 | */ |
| 71794 | /* #include "sqliteInt.h" */ |
| 71795 | /* #include "vdbeInt.h" */ |
| 71796 | |
| 71797 | #ifndef SQLITE_OMIT_TRACE |
| 71798 | |
| 71799 | /* |
| 71800 | ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of |
| @@ -71877,10 +71983,12 @@ | |
| 71983 | ** documentation, headers files, or other derived files. The formatting |
| 71984 | ** of the code in this file is, therefore, important. See other comments |
| 71985 | ** in this file for details. If in doubt, do not deviate from existing |
| 71986 | ** commenting and indentation practices when changing or adding code. |
| 71987 | */ |
| 71988 | /* #include "sqliteInt.h" */ |
| 71989 | /* #include "vdbeInt.h" */ |
| 71990 | |
| 71991 | /* |
| 71992 | ** Invoke this macro on memory cells just prior to changing the |
| 71993 | ** value of the cell. This macro verifies that shallow copies are |
| 71994 | ** not misused. A shallow copy of a string or blob just copies a |
| @@ -78635,10 +78743,12 @@ | |
| 78743 | ************************************************************************* |
| 78744 | ** |
| 78745 | ** This file contains code used to implement incremental BLOB I/O. |
| 78746 | */ |
| 78747 | |
| 78748 | /* #include "sqliteInt.h" */ |
| 78749 | /* #include "vdbeInt.h" */ |
| 78750 | |
| 78751 | #ifndef SQLITE_OMIT_INCRBLOB |
| 78752 | |
| 78753 | /* |
| 78754 | ** Valid sqlite3_blob* handles point to Incrblob structures. |
| @@ -79233,10 +79343,12 @@ | |
| 79343 | ** than one background thread may be created. Specifically, there may be |
| 79344 | ** one background thread for each temporary file on disk, and one background |
| 79345 | ** thread to merge the output of each of the others to a single PMA for |
| 79346 | ** the main thread to read from. |
| 79347 | */ |
| 79348 | /* #include "sqliteInt.h" */ |
| 79349 | /* #include "vdbeInt.h" */ |
| 79350 | |
| 79351 | /* |
| 79352 | ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various |
| 79353 | ** messages to stderr that may be helpful in understanding the performance |
| 79354 | ** characteristics of the sorter in multi-threaded mode. |
| @@ -81849,10 +81961,11 @@ | |
| 81961 | ** 1) The in-memory representation grows too large for the allocated |
| 81962 | ** buffer, or |
| 81963 | ** 2) The sqlite3JournalCreate() function is called. |
| 81964 | */ |
| 81965 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 81966 | /* #include "sqliteInt.h" */ |
| 81967 | |
| 81968 | |
| 81969 | /* |
| 81970 | ** A JournalFile object is a subclass of sqlite3_file used by |
| 81971 | ** as an open file handle for journal files. |
| @@ -82096,10 +82209,11 @@ | |
| 82209 | ** |
| 82210 | ** This file contains code use to implement an in-memory rollback journal. |
| 82211 | ** The in-memory rollback journal is used to journal transactions for |
| 82212 | ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. |
| 82213 | */ |
| 82214 | /* #include "sqliteInt.h" */ |
| 82215 | |
| 82216 | /* Forward references to internal structures */ |
| 82217 | typedef struct MemJournal MemJournal; |
| 82218 | typedef struct FilePoint FilePoint; |
| 82219 | typedef struct FileChunk FileChunk; |
| @@ -82351,10 +82465,11 @@ | |
| 82465 | ** |
| 82466 | ************************************************************************* |
| 82467 | ** This file contains routines used for walking the parser tree for |
| 82468 | ** an SQL statement. |
| 82469 | */ |
| 82470 | /* #include "sqliteInt.h" */ |
| 82471 | /* #include <stdlib.h> */ |
| 82472 | /* #include <string.h> */ |
| 82473 | |
| 82474 | |
| 82475 | /* |
| @@ -82509,10 +82624,11 @@ | |
| 82624 | ** |
| 82625 | ** This file contains routines used for walking the parser tree and |
| 82626 | ** resolve all identifiers by associating them with a particular |
| 82627 | ** table and column. |
| 82628 | */ |
| 82629 | /* #include "sqliteInt.h" */ |
| 82630 | /* #include <stdlib.h> */ |
| 82631 | /* #include <string.h> */ |
| 82632 | |
| 82633 | /* |
| 82634 | ** Walk the expression tree pExpr and increase the aggregate function |
| @@ -84021,10 +84137,11 @@ | |
| 84137 | ** |
| 84138 | ************************************************************************* |
| 84139 | ** This file contains routines used for analyzing expressions and |
| 84140 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 84141 | */ |
| 84142 | /* #include "sqliteInt.h" */ |
| 84143 | |
| 84144 | /* |
| 84145 | ** Return the 'affinity' of the expression pExpr if any. |
| 84146 | ** |
| 84147 | ** If pExpr is a column, a reference to a column via an 'AS' alias, |
| @@ -88183,10 +88300,11 @@ | |
| 88300 | ** |
| 88301 | ************************************************************************* |
| 88302 | ** This file contains C code routines that used to generate VDBE code |
| 88303 | ** that implements the ALTER TABLE command. |
| 88304 | */ |
| 88305 | /* #include "sqliteInt.h" */ |
| 88306 | |
| 88307 | /* |
| 88308 | ** The code in this file only exists if we are not omitting the |
| 88309 | ** ALTER TABLE logic from the build. |
| 88310 | */ |
| @@ -89145,10 +89263,11 @@ | |
| 89263 | ** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3 |
| 89264 | ** all contain just a single integer which is the same as the first |
| 89265 | ** integer in the equivalent columns in sqlite_stat4. |
| 89266 | */ |
| 89267 | #ifndef SQLITE_OMIT_ANALYZE |
| 89268 | /* #include "sqliteInt.h" */ |
| 89269 | |
| 89270 | #if defined(SQLITE_ENABLE_STAT4) |
| 89271 | # define IsStat4 1 |
| 89272 | # define IsStat3 0 |
| 89273 | #elif defined(SQLITE_ENABLE_STAT3) |
| @@ -90910,10 +91029,11 @@ | |
| 91029 | ** May you share freely, never taking more than you give. |
| 91030 | ** |
| 91031 | ************************************************************************* |
| 91032 | ** This file contains code used to implement the ATTACH and DETACH commands. |
| 91033 | */ |
| 91034 | /* #include "sqliteInt.h" */ |
| 91035 | |
| 91036 | #ifndef SQLITE_OMIT_ATTACH |
| 91037 | /* |
| 91038 | ** Resolve an expression that was part of an ATTACH or DETACH statement. This |
| 91039 | ** is slightly different from resolving a normal SQL expression, because simple |
| @@ -91499,10 +91619,11 @@ | |
| 91619 | ** This file contains code used to implement the sqlite3_set_authorizer() |
| 91620 | ** API. This facility is an optional feature of the library. Embedded |
| 91621 | ** systems that do not need this facility may omit it by recompiling |
| 91622 | ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 |
| 91623 | */ |
| 91624 | /* #include "sqliteInt.h" */ |
| 91625 | |
| 91626 | /* |
| 91627 | ** All of the code in this file may be omitted by defining a single |
| 91628 | ** macro. |
| 91629 | */ |
| @@ -91769,10 +91890,11 @@ | |
| 91890 | ** creating ID lists |
| 91891 | ** BEGIN TRANSACTION |
| 91892 | ** COMMIT |
| 91893 | ** ROLLBACK |
| 91894 | */ |
| 91895 | /* #include "sqliteInt.h" */ |
| 91896 | |
| 91897 | /* |
| 91898 | ** This routine is called when a new SQL statement is beginning to |
| 91899 | ** be parsed. Initialize the pParse structure as needed. |
| 91900 | */ |
| @@ -96089,10 +96211,11 @@ | |
| 96211 | ** |
| 96212 | ** This file contains functions used to access the internal hash tables |
| 96213 | ** of user defined functions and collation sequences. |
| 96214 | */ |
| 96215 | |
| 96216 | /* #include "sqliteInt.h" */ |
| 96217 | |
| 96218 | /* |
| 96219 | ** Invoke the 'collation needed' callback to request a collation sequence |
| 96220 | ** in the encoding enc of name zName, length nName. |
| 96221 | */ |
| @@ -96566,10 +96689,11 @@ | |
| 96689 | ** |
| 96690 | ************************************************************************* |
| 96691 | ** This file contains C code routines that are called by the parser |
| 96692 | ** in order to generate code for DELETE FROM statements. |
| 96693 | */ |
| 96694 | /* #include "sqliteInt.h" */ |
| 96695 | |
| 96696 | /* |
| 96697 | ** While a SrcList can in general represent multiple tables and subqueries |
| 96698 | ** (as in the FROM clause of a SELECT statement) in this case it contains |
| 96699 | ** the name of a single table, as one might find in an INSERT, DELETE, |
| @@ -97408,12 +97532,14 @@ | |
| 97532 | ************************************************************************* |
| 97533 | ** This file contains the C-language implementations for many of the SQL |
| 97534 | ** functions of SQLite. (Some function, and in particular the date and |
| 97535 | ** time functions, are implemented separately.) |
| 97536 | */ |
| 97537 | /* #include "sqliteInt.h" */ |
| 97538 | /* #include <stdlib.h> */ |
| 97539 | /* #include <assert.h> */ |
| 97540 | /* #include "vdbeInt.h" */ |
| 97541 | |
| 97542 | /* |
| 97543 | ** Return the collating function associated with a function. |
| 97544 | */ |
| 97545 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -99205,10 +99331,11 @@ | |
| 99331 | ** |
| 99332 | ************************************************************************* |
| 99333 | ** This file contains code used by the compiler to add foreign key |
| 99334 | ** support to compiled SQL statements. |
| 99335 | */ |
| 99336 | /* #include "sqliteInt.h" */ |
| 99337 | |
| 99338 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 99339 | #ifndef SQLITE_OMIT_TRIGGER |
| 99340 | |
| 99341 | /* |
| @@ -100609,10 +100736,11 @@ | |
| 100736 | ** |
| 100737 | ************************************************************************* |
| 100738 | ** This file contains C code routines that are called by the parser |
| 100739 | ** to handle INSERT statements in SQLite. |
| 100740 | */ |
| 100741 | /* #include "sqliteInt.h" */ |
| 100742 | |
| 100743 | /* |
| 100744 | ** Generate code that will |
| 100745 | ** |
| 100746 | ** (1) acquire a lock for table pTab then |
| @@ -102671,10 +102799,11 @@ | |
| 102799 | ** implement the programmer interface to the library. Routines in |
| 102800 | ** other files are for internal use by SQLite and should not be |
| 102801 | ** accessed by users of the library. |
| 102802 | */ |
| 102803 | |
| 102804 | /* #include "sqliteInt.h" */ |
| 102805 | |
| 102806 | /* |
| 102807 | ** Execute SQL code. Return one of the SQLITE_ success/failure |
| 102808 | ** codes. Also write an error message into memory obtained from |
| 102809 | ** malloc() and make *pzErrMsg point to that message. |
| @@ -102839,10 +102968,11 @@ | |
| 102968 | ** as extensions by SQLite should #include this file instead of |
| 102969 | ** sqlite3.h. |
| 102970 | */ |
| 102971 | #ifndef _SQLITE3EXT_H_ |
| 102972 | #define _SQLITE3EXT_H_ |
| 102973 | /* #include "sqlite3.h" */ |
| 102974 | |
| 102975 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 102976 | |
| 102977 | /* |
| 102978 | ** The following structure holds pointers to all of the SQLite API |
| @@ -103345,10 +103475,11 @@ | |
| 103475 | |
| 103476 | #endif /* _SQLITE3EXT_H_ */ |
| 103477 | |
| 103478 | /************** End of sqlite3ext.h ******************************************/ |
| 103479 | /************** Continuing where we left off in loadext.c ********************/ |
| 103480 | /* #include "sqliteInt.h" */ |
| 103481 | /* #include <string.h> */ |
| 103482 | |
| 103483 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 103484 | |
| 103485 | /* |
| @@ -104114,10 +104245,11 @@ | |
| 104245 | ** May you share freely, never taking more than you give. |
| 104246 | ** |
| 104247 | ************************************************************************* |
| 104248 | ** This file contains code used to implement the PRAGMA command. |
| 104249 | */ |
| 104250 | /* #include "sqliteInt.h" */ |
| 104251 | |
| 104252 | #if !defined(SQLITE_ENABLE_LOCKING_STYLE) |
| 104253 | # if defined(__APPLE__) |
| 104254 | # define SQLITE_ENABLE_LOCKING_STYLE 1 |
| 104255 | # else |
| @@ -104220,11 +104352,11 @@ | |
| 104352 | /* ePragFlag: */ 0, |
| 104353 | /* iArg: */ 0 }, |
| 104354 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 104355 | { /* zName: */ "cache_size", |
| 104356 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 104357 | /* ePragFlag: */ 0, |
| 104358 | /* iArg: */ 0 }, |
| 104359 | #endif |
| 104360 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 104361 | { /* zName: */ "cache_spill", |
| 104362 | /* ePragTyp: */ PragTyp_FLAG, |
| @@ -105290,10 +105422,11 @@ | |
| 105422 | ** of memory. |
| 105423 | */ |
| 105424 | case PragTyp_CACHE_SIZE: { |
| 105425 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 105426 | if( !zRight ){ |
| 105427 | if( sqlite3ReadSchema(pParse) ) goto pragma_out; |
| 105428 | returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); |
| 105429 | }else{ |
| 105430 | int size = sqlite3Atoi(zRight); |
| 105431 | pDb->pSchema->cache_size = size; |
| 105432 | sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); |
| @@ -106565,10 +106698,11 @@ | |
| 106698 | ************************************************************************* |
| 106699 | ** This file contains the implementation of the sqlite3_prepare() |
| 106700 | ** interface, and routines that contribute to loading the database schema |
| 106701 | ** from disk. |
| 106702 | */ |
| 106703 | /* #include "sqliteInt.h" */ |
| 106704 | |
| 106705 | /* |
| 106706 | ** Fill the InitData structure with an error message that indicates |
| 106707 | ** that the database is corrupt. |
| 106708 | */ |
| @@ -107459,10 +107593,11 @@ | |
| 107593 | ** |
| 107594 | ************************************************************************* |
| 107595 | ** This file contains C code routines that are called by the parser |
| 107596 | ** to handle SELECT statements in SQLite. |
| 107597 | */ |
| 107598 | /* #include "sqliteInt.h" */ |
| 107599 | |
| 107600 | /* |
| 107601 | ** Trace output macros |
| 107602 | */ |
| 107603 | #if SELECTTRACE_ENABLED |
| @@ -108528,11 +108663,10 @@ | |
| 108663 | } |
| 108664 | } |
| 108665 | return pInfo; |
| 108666 | } |
| 108667 | |
| 108668 | /* |
| 108669 | ** Name of the connection operator, used for error messages. |
| 108670 | */ |
| 108671 | static const char *selectOpName(int id){ |
| 108672 | char *z; |
| @@ -108542,11 +108676,10 @@ | |
| 108676 | case TK_EXCEPT: z = "EXCEPT"; break; |
| 108677 | default: z = "UNION"; break; |
| 108678 | } |
| 108679 | return z; |
| 108680 | } |
| 108681 | |
| 108682 | #ifndef SQLITE_OMIT_EXPLAIN |
| 108683 | /* |
| 108684 | ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function |
| 108685 | ** is a no-op. Otherwise, it adds a single row of output to the EQP result, |
| @@ -109545,23 +109678,10 @@ | |
| 109678 | Parse *pParse, /* Parsing context */ |
| 109679 | Select *p, /* The right-most of SELECTs to be coded */ |
| 109680 | SelectDest *pDest /* What to do with query results */ |
| 109681 | ); |
| 109682 | |
| 109683 | /* |
| 109684 | ** Handle the special case of a compound-select that originates from a |
| 109685 | ** VALUES clause. By handling this as a special case, we avoid deep |
| 109686 | ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT |
| 109687 | ** on a VALUES clause. |
| @@ -109983,10 +110103,23 @@ | |
| 110103 | pDest->nSdst = dest.nSdst; |
| 110104 | sqlite3SelectDelete(db, pDelete); |
| 110105 | return rc; |
| 110106 | } |
| 110107 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 110108 | |
| 110109 | /* |
| 110110 | ** Error message for when two or more terms of a compound select have different |
| 110111 | ** size result sets. |
| 110112 | */ |
| 110113 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ |
| 110114 | if( p->selFlags & SF_Values ){ |
| 110115 | sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); |
| 110116 | }else{ |
| 110117 | sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" |
| 110118 | " do not have the same number of result columns", selectOpName(p->op)); |
| 110119 | } |
| 110120 | } |
| 110121 | |
| 110122 | /* |
| 110123 | ** Code an output subroutine for a coroutine implementation of a |
| 110124 | ** SELECT statment. |
| 110125 | ** |
| @@ -113077,10 +113210,11 @@ | |
| 113210 | ** interface routine of sqlite3_exec(). |
| 113211 | ** |
| 113212 | ** These routines are in a separate files so that they will not be linked |
| 113213 | ** if they are not used. |
| 113214 | */ |
| 113215 | /* #include "sqliteInt.h" */ |
| 113216 | /* #include <stdlib.h> */ |
| 113217 | /* #include <string.h> */ |
| 113218 | |
| 113219 | #ifndef SQLITE_OMIT_GET_TABLE |
| 113220 | |
| @@ -113273,10 +113407,11 @@ | |
| 113407 | ** May you share freely, never taking more than you give. |
| 113408 | ** |
| 113409 | ************************************************************************* |
| 113410 | ** This file contains the implementation for TRIGGERs |
| 113411 | */ |
| 113412 | /* #include "sqliteInt.h" */ |
| 113413 | |
| 113414 | #ifndef SQLITE_OMIT_TRIGGER |
| 113415 | /* |
| 113416 | ** Delete a linked list of TriggerStep structures. |
| 113417 | */ |
| @@ -114396,10 +114531,11 @@ | |
| 114531 | ** |
| 114532 | ************************************************************************* |
| 114533 | ** This file contains C code routines that are called by the parser |
| 114534 | ** to handle UPDATE statements. |
| 114535 | */ |
| 114536 | /* #include "sqliteInt.h" */ |
| 114537 | |
| 114538 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 114539 | /* Forward declaration */ |
| 114540 | static void updateVirtualTable( |
| 114541 | Parse *pParse, /* The parsing context */ |
| @@ -115172,10 +115308,12 @@ | |
| 115308 | ** This file contains code used to implement the VACUUM command. |
| 115309 | ** |
| 115310 | ** Most of the code in this file may be omitted by defining the |
| 115311 | ** SQLITE_OMIT_VACUUM macro. |
| 115312 | */ |
| 115313 | /* #include "sqliteInt.h" */ |
| 115314 | /* #include "vdbeInt.h" */ |
| 115315 | |
| 115316 | #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) |
| 115317 | /* |
| 115318 | ** Finalize a prepared statement. If there was an error, store the |
| 115319 | ** text of the error message in *pzErrMsg. Return the result code. |
| @@ -115544,10 +115682,11 @@ | |
| 115682 | ** |
| 115683 | ************************************************************************* |
| 115684 | ** This file contains code used to help implement virtual tables. |
| 115685 | */ |
| 115686 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 115687 | /* #include "sqliteInt.h" */ |
| 115688 | |
| 115689 | /* |
| 115690 | ** Before a virtual table xCreate() or xConnect() method is invoked, the |
| 115691 | ** sqlite3.pVtabCtx member variable is set to point to an instance of |
| 115692 | ** this struct allocated on the stack. It is used by the implementation of |
| @@ -116702,10 +116841,11 @@ | |
| 116841 | ** This file was split off from where.c on 2015-06-06 in order to reduce the |
| 116842 | ** size of where.c and make it easier to edit. This file contains the routines |
| 116843 | ** that actually generate the bulk of the WHERE loop code. The original where.c |
| 116844 | ** file retains the code that does query planning and analysis. |
| 116845 | */ |
| 116846 | /* #include "sqliteInt.h" */ |
| 116847 | /************** Include whereInt.h in the middle of wherecode.c **************/ |
| 116848 | /************** Begin file whereInt.h ****************************************/ |
| 116849 | /* |
| 116850 | ** 2013-11-12 |
| 116851 | ** |
| @@ -118737,10 +118877,12 @@ | |
| 118877 | ** |
| 118878 | ** This file was originally part of where.c but was split out to improve |
| 118879 | ** readability and editabiliity. This file contains utility routines for |
| 118880 | ** analyzing Expr objects in the WHERE clause. |
| 118881 | */ |
| 118882 | /* #include "sqliteInt.h" */ |
| 118883 | /* #include "whereInt.h" */ |
| 118884 | |
| 118885 | /* Forward declarations */ |
| 118886 | static void exprAnalyze(SrcList*, WhereClause*, int); |
| 118887 | |
| 118888 | /* |
| @@ -119987,10 +120129,12 @@ | |
| 120129 | ** generating the code that loops through a table looking for applicable |
| 120130 | ** rows. Indices are selected and used to speed the search when doing |
| 120131 | ** so is applicable. Because this module is responsible for selecting |
| 120132 | ** indices, you might also think of this module as the "query optimizer". |
| 120133 | */ |
| 120134 | /* #include "sqliteInt.h" */ |
| 120135 | /* #include "whereInt.h" */ |
| 120136 | |
| 120137 | /* Forward declaration of methods */ |
| 120138 | static int whereLoopResize(sqlite3*, WhereLoop*, int); |
| 120139 | |
| 120140 | /* Test variable that can be set to enable WHERE tracing */ |
| @@ -124486,10 +124630,11 @@ | |
| 124630 | */ |
| 124631 | /* First off, code is included that follows the "include" declaration |
| 124632 | ** in the input grammar file. */ |
| 124633 | /* #include <stdio.h> */ |
| 124634 | |
| 124635 | /* #include "sqliteInt.h" */ |
| 124636 | |
| 124637 | /* |
| 124638 | ** Disable all error recovery processing in the parser push-down |
| 124639 | ** automaton. |
| 124640 | */ |
| @@ -128071,10 +128216,11 @@ | |
| 128216 | ** |
| 128217 | ** This file contains C code that splits an SQL input string up into |
| 128218 | ** individual tokens and sends those tokens one-by-one over to the |
| 128219 | ** parser for analysis. |
| 128220 | */ |
| 128221 | /* #include "sqliteInt.h" */ |
| 128222 | /* #include <stdlib.h> */ |
| 128223 | |
| 128224 | /* |
| 128225 | ** The charMap() macro maps alphabetic characters into their |
| 128226 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -128880,10 +129026,11 @@ | |
| 129026 | ** This file contains C code that implements the sqlite3_complete() API. |
| 129027 | ** This code used to be part of the tokenizer.c source file. But by |
| 129028 | ** separating it out, the code will be automatically omitted from |
| 129029 | ** static links that do not use it. |
| 129030 | */ |
| 129031 | /* #include "sqliteInt.h" */ |
| 129032 | #ifndef SQLITE_OMIT_COMPLETE |
| 129033 | |
| 129034 | /* |
| 129035 | ** This is defined in tokenize.c. We just have to import the definition. |
| 129036 | */ |
| @@ -129170,10 +129317,11 @@ | |
| 129317 | ** Main file for the SQLite library. The routines in this file |
| 129318 | ** implement the programmer interface to the library. Routines in |
| 129319 | ** other files are for internal use by SQLite and should not be |
| 129320 | ** accessed by users of the library. |
| 129321 | */ |
| 129322 | /* #include "sqliteInt.h" */ |
| 129323 | |
| 129324 | #ifdef SQLITE_ENABLE_FTS3 |
| 129325 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 129326 | /************** Begin file fts3.h ********************************************/ |
| 129327 | /* |
| @@ -129189,10 +129337,11 @@ | |
| 129337 | ****************************************************************************** |
| 129338 | ** |
| 129339 | ** This header file is used by programs that want to link against the |
| 129340 | ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface. |
| 129341 | */ |
| 129342 | /* #include "sqlite3.h" */ |
| 129343 | |
| 129344 | #if 0 |
| 129345 | extern "C" { |
| 129346 | #endif /* __cplusplus */ |
| 129347 | |
| @@ -129221,10 +129370,11 @@ | |
| 129370 | ****************************************************************************** |
| 129371 | ** |
| 129372 | ** This header file is used by programs that want to link against the |
| 129373 | ** RTREE library. All it does is declare the sqlite3RtreeInit() interface. |
| 129374 | */ |
| 129375 | /* #include "sqlite3.h" */ |
| 129376 | |
| 129377 | #if 0 |
| 129378 | extern "C" { |
| 129379 | #endif /* __cplusplus */ |
| 129380 | |
| @@ -129253,10 +129403,11 @@ | |
| 129403 | ****************************************************************************** |
| 129404 | ** |
| 129405 | ** This header file is used by programs that want to link against the |
| 129406 | ** ICU extension. All it does is declare the sqlite3IcuInit() interface. |
| 129407 | */ |
| 129408 | /* #include "sqlite3.h" */ |
| 129409 | |
| 129410 | #if 0 |
| 129411 | extern "C" { |
| 129412 | #endif /* __cplusplus */ |
| 129413 | |
| @@ -133045,10 +133196,12 @@ | |
| 133196 | ************************************************************************* |
| 133197 | ** |
| 133198 | ** This file contains the implementation of the sqlite3_unlock_notify() |
| 133199 | ** API method and its associated functionality. |
| 133200 | */ |
| 133201 | /* #include "sqliteInt.h" */ |
| 133202 | /* #include "btreeInt.h" */ |
| 133203 | |
| 133204 | /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ |
| 133205 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 133206 | |
| 133207 | /* |
| @@ -133688,13 +133841,15 @@ | |
| 133841 | |
| 133842 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 133843 | |
| 133844 | /* If not building as part of the core, include sqlite3ext.h. */ |
| 133845 | #ifndef SQLITE_CORE |
| 133846 | /* # include "sqlite3ext.h" */ |
| 133847 | SQLITE_EXTENSION_INIT3 |
| 133848 | #endif |
| 133849 | |
| 133850 | /* #include "sqlite3.h" */ |
| 133851 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 133852 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 133853 | /* |
| 133854 | ** 2006 July 10 |
| 133855 | ** |
| @@ -133719,10 +133874,11 @@ | |
| 133874 | |
| 133875 | /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time. |
| 133876 | ** If tokenizers are to be allowed to call sqlite3_*() functions, then |
| 133877 | ** we will need a way to register the API consistently. |
| 133878 | */ |
| 133879 | /* #include "sqlite3.h" */ |
| 133880 | |
| 133881 | /* |
| 133882 | ** Structures used by the tokenizer interface. When a new tokenizer |
| 133883 | ** implementation is registered, the caller provides a pointer to |
| 133884 | ** an sqlite3_tokenizer_module containing pointers to the callback |
| @@ -134559,11 +134715,13 @@ | |
| 134715 | /* #include <stddef.h> */ |
| 134716 | /* #include <stdio.h> */ |
| 134717 | /* #include <string.h> */ |
| 134718 | /* #include <stdarg.h> */ |
| 134719 | |
| 134720 | /* #include "fts3.h" */ |
| 134721 | #ifndef SQLITE_CORE |
| 134722 | /* # include "sqlite3ext.h" */ |
| 134723 | SQLITE_EXTENSION_INIT1 |
| 134724 | #endif |
| 134725 | |
| 134726 | static int fts3EvalNext(Fts3Cursor *pCsr); |
| 134727 | static int fts3EvalStart(Fts3Cursor *pCsr); |
| @@ -138606,10 +138764,11 @@ | |
| 138764 | if( p==0 ){ |
| 138765 | p = aDoclist; |
| 138766 | p += sqlite3Fts3GetVarint(p, piDocid); |
| 138767 | }else{ |
| 138768 | fts3PoslistCopy(0, &p); |
| 138769 | while( p<&aDoclist[nDoclist] && *p==0 ) p++; |
| 138770 | if( p>=&aDoclist[nDoclist] ){ |
| 138771 | *pbEof = 1; |
| 138772 | }else{ |
| 138773 | sqlite3_int64 iVar; |
| 138774 | p += sqlite3Fts3GetVarint(p, &iVar); |
| @@ -140012,14 +140171,14 @@ | |
| 140171 | pIter = pPhrase->doclist.pList; |
| 140172 | if( iDocid!=pCsr->iPrevId || pExpr->bEof ){ |
| 140173 | int rc = SQLITE_OK; |
| 140174 | int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */ |
| 140175 | int bOr = 0; |
| 140176 | u8 bTreeEof = 0; |
| 140177 | Fts3Expr *p; /* Used to iterate from pExpr to root */ |
| 140178 | Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */ |
| 140179 | int bMatch; |
| 140180 | |
| 140181 | /* Check if this phrase descends from an OR expression node. If not, |
| 140182 | ** return NULL. Otherwise, the entry that corresponds to docid |
| 140183 | ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the |
| 140184 | ** tree that the node is part of has been marked as EOF, but the node |
| @@ -140049,35 +140208,51 @@ | |
| 140208 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 140209 | } |
| 140210 | } |
| 140211 | if( rc!=SQLITE_OK ) return rc; |
| 140212 | |
| 140213 | bMatch = 1; |
| 140214 | for(p=pNear; p; p=p->pLeft){ |
| 140215 | u8 bEof = 0; |
| 140216 | Fts3Expr *pTest = p; |
| 140217 | Fts3Phrase *pPh; |
| 140218 | assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE ); |
| 140219 | if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight; |
| 140220 | assert( pTest->eType==FTSQUERY_PHRASE ); |
| 140221 | pPh = pTest->pPhrase; |
| 140222 | |
| 140223 | pIter = pPh->pOrPoslist; |
| 140224 | iDocid = pPh->iOrDocid; |
| 140225 | if( pCsr->bDesc==bDescDoclist ){ |
| 140226 | bEof = !pPh->doclist.nAll || |
| 140227 | (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll)); |
| 140228 | while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){ |
| 140229 | sqlite3Fts3DoclistNext( |
| 140230 | bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, |
| 140231 | &pIter, &iDocid, &bEof |
| 140232 | ); |
| 140233 | } |
| 140234 | }else{ |
| 140235 | bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll); |
| 140236 | while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){ |
| 140237 | int dummy; |
| 140238 | sqlite3Fts3DoclistPrev( |
| 140239 | bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, |
| 140240 | &pIter, &iDocid, &dummy, &bEof |
| 140241 | ); |
| 140242 | } |
| 140243 | } |
| 140244 | pPh->pOrPoslist = pIter; |
| 140245 | pPh->iOrDocid = iDocid; |
| 140246 | if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0; |
| 140247 | } |
| 140248 | |
| 140249 | if( bMatch ){ |
| 140250 | pIter = pPhrase->pOrPoslist; |
| 140251 | }else{ |
| 140252 | pIter = 0; |
| 140253 | } |
| 140254 | } |
| 140255 | if( pIter==0 ) return SQLITE_OK; |
| 140256 | |
| 140257 | if( *pIter==0x01 ){ |
| 140258 | pIter++; |
| @@ -140161,10 +140336,11 @@ | |
| 140336 | ** May you share freely, never taking more than you give. |
| 140337 | ** |
| 140338 | ****************************************************************************** |
| 140339 | ** |
| 140340 | */ |
| 140341 | /* #include "fts3Int.h" */ |
| 140342 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140343 | |
| 140344 | /* #include <string.h> */ |
| 140345 | /* #include <assert.h> */ |
| 140346 | |
| @@ -140717,10 +140893,11 @@ | |
| 140893 | ** This module contains code that implements a parser for fts3 query strings |
| 140894 | ** (the right-hand argument to the MATCH operator). Because the supported |
| 140895 | ** syntax is relatively simple, the whole tokenizer/parser system is |
| 140896 | ** hand-coded. |
| 140897 | */ |
| 140898 | /* #include "fts3Int.h" */ |
| 140899 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 140900 | |
| 140901 | /* |
| 140902 | ** By default, this module parses the legacy syntax that has been |
| 140903 | ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS |
| @@ -142010,16 +142187,18 @@ | |
| 142187 | ** (in which case SQLITE_CORE is not defined), or |
| 142188 | ** |
| 142189 | ** * The FTS3 module is being built into the core of |
| 142190 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142191 | */ |
| 142192 | /* #include "fts3Int.h" */ |
| 142193 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142194 | |
| 142195 | /* #include <assert.h> */ |
| 142196 | /* #include <stdlib.h> */ |
| 142197 | /* #include <string.h> */ |
| 142198 | |
| 142199 | /* #include "fts3_hash.h" */ |
| 142200 | |
| 142201 | /* |
| 142202 | ** Malloc and Free functions |
| 142203 | */ |
| 142204 | static void *fts3HashMalloc(int n){ |
| @@ -142393,17 +142572,19 @@ | |
| 142572 | ** (in which case SQLITE_CORE is not defined), or |
| 142573 | ** |
| 142574 | ** * The FTS3 module is being built into the core of |
| 142575 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 142576 | */ |
| 142577 | /* #include "fts3Int.h" */ |
| 142578 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 142579 | |
| 142580 | /* #include <assert.h> */ |
| 142581 | /* #include <stdlib.h> */ |
| 142582 | /* #include <stdio.h> */ |
| 142583 | /* #include <string.h> */ |
| 142584 | |
| 142585 | /* #include "fts3_tokenizer.h" */ |
| 142586 | |
| 142587 | /* |
| 142588 | ** Class derived from sqlite3_tokenizer |
| 142589 | */ |
| 142590 | typedef struct porter_tokenizer { |
| @@ -143057,10 +143238,11 @@ | |
| 143238 | ** (in which case SQLITE_CORE is not defined), or |
| 143239 | ** |
| 143240 | ** * The FTS3 module is being built into the core of |
| 143241 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143242 | */ |
| 143243 | /* #include "fts3Int.h" */ |
| 143244 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143245 | |
| 143246 | /* #include <assert.h> */ |
| 143247 | /* #include <string.h> */ |
| 143248 | |
| @@ -143552,17 +143734,19 @@ | |
| 143734 | ** (in which case SQLITE_CORE is not defined), or |
| 143735 | ** |
| 143736 | ** * The FTS3 module is being built into the core of |
| 143737 | ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). |
| 143738 | */ |
| 143739 | /* #include "fts3Int.h" */ |
| 143740 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143741 | |
| 143742 | /* #include <assert.h> */ |
| 143743 | /* #include <stdlib.h> */ |
| 143744 | /* #include <stdio.h> */ |
| 143745 | /* #include <string.h> */ |
| 143746 | |
| 143747 | /* #include "fts3_tokenizer.h" */ |
| 143748 | |
| 143749 | typedef struct simple_tokenizer { |
| 143750 | sqlite3_tokenizer base; |
| 143751 | char delim[128]; /* flag ASCII delimiters */ |
| 143752 | } simple_tokenizer; |
| @@ -143803,10 +143987,11 @@ | |
| 143987 | ** end: Byte offset of the byte immediately following the end of the |
| 143988 | ** token within the input string. |
| 143989 | ** pos: Token offset of token within input. |
| 143990 | ** |
| 143991 | */ |
| 143992 | /* #include "fts3Int.h" */ |
| 143993 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143994 | |
| 143995 | /* #include <string.h> */ |
| 143996 | /* #include <assert.h> */ |
| 143997 | |
| @@ -144238,10 +144423,11 @@ | |
| 144423 | ** tables. It also contains code to merge FTS3 b-tree segments. Some |
| 144424 | ** of the sub-routines used to merge segments are also used by the query |
| 144425 | ** code in fts3.c. |
| 144426 | */ |
| 144427 | |
| 144428 | /* #include "fts3Int.h" */ |
| 144429 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 144430 | |
| 144431 | /* #include <string.h> */ |
| 144432 | /* #include <assert.h> */ |
| 144433 | /* #include <stdlib.h> */ |
| @@ -149898,10 +150084,11 @@ | |
| 150084 | ** May you share freely, never taking more than you give. |
| 150085 | ** |
| 150086 | ****************************************************************************** |
| 150087 | */ |
| 150088 | |
| 150089 | /* #include "fts3Int.h" */ |
| 150090 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 150091 | |
| 150092 | /* #include <string.h> */ |
| 150093 | /* #include <assert.h> */ |
| 150094 | |
| @@ -151610,17 +151797,19 @@ | |
| 151797 | ** Implementation of the "unicode" full-text-search tokenizer. |
| 151798 | */ |
| 151799 | |
| 151800 | #ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 151801 | |
| 151802 | /* #include "fts3Int.h" */ |
| 151803 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 151804 | |
| 151805 | /* #include <assert.h> */ |
| 151806 | /* #include <stdlib.h> */ |
| 151807 | /* #include <stdio.h> */ |
| 151808 | /* #include <string.h> */ |
| 151809 | |
| 151810 | /* #include "fts3_tokenizer.h" */ |
| 151811 | |
| 151812 | /* |
| 151813 | ** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied |
| 151814 | ** from the sqlite3 source file utf.c. If this file is compiled as part |
| 151815 | ** of the amalgamation, they are not required. |
| @@ -152412,12 +152601,14 @@ | |
| 152601 | */ |
| 152602 | |
| 152603 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) |
| 152604 | |
| 152605 | #ifndef SQLITE_CORE |
| 152606 | /* #include "sqlite3ext.h" */ |
| 152607 | SQLITE_EXTENSION_INIT1 |
| 152608 | #else |
| 152609 | /* #include "sqlite3.h" */ |
| 152610 | #endif |
| 152611 | |
| 152612 | /* #include <string.h> */ |
| 152613 | /* #include <assert.h> */ |
| 152614 | /* #include <stdio.h> */ |
| @@ -155909,12 +156100,14 @@ | |
| 156100 | #include <unicode/ucol.h> |
| 156101 | |
| 156102 | /* #include <assert.h> */ |
| 156103 | |
| 156104 | #ifndef SQLITE_CORE |
| 156105 | /* #include "sqlite3ext.h" */ |
| 156106 | SQLITE_EXTENSION_INIT1 |
| 156107 | #else |
| 156108 | /* #include "sqlite3.h" */ |
| 156109 | #endif |
| 156110 | |
| 156111 | /* |
| 156112 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB |
| 156113 | ** operator. |
| @@ -156386,15 +156579,17 @@ | |
| 156579 | ** May you share freely, never taking more than you give. |
| 156580 | ** |
| 156581 | ************************************************************************* |
| 156582 | ** This file implements a tokenizer for fts3 based on the ICU library. |
| 156583 | */ |
| 156584 | /* #include "fts3Int.h" */ |
| 156585 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 156586 | #ifdef SQLITE_ENABLE_ICU |
| 156587 | |
| 156588 | /* #include <assert.h> */ |
| 156589 | /* #include <string.h> */ |
| 156590 | /* #include "fts3_tokenizer.h" */ |
| 156591 | |
| 156592 | #include <unicode/ubrk.h> |
| 156593 | /* #include <unicode/ucol.h> */ |
| 156594 | /* #include <unicode/ustring.h> */ |
| 156595 | #include <unicode/utf16.h> |
| @@ -156723,10 +156918,11 @@ | |
| 156918 | /* #include <assert.h> */ |
| 156919 | /* #include <string.h> */ |
| 156920 | /* #include <stdio.h> */ |
| 156921 | /* #include <unistd.h> */ |
| 156922 | |
| 156923 | /* #include "sqlite3.h" */ |
| 156924 | |
| 156925 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA) |
| 156926 | /************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/ |
| 156927 | /************** Begin file sqlite3ota.h **************************************/ |
| 156928 | /* |
| @@ -156976,10 +157172,11 @@ | |
| 157172 | */ |
| 157173 | |
| 157174 | #ifndef _SQLITE3OTA_H |
| 157175 | #define _SQLITE3OTA_H |
| 157176 | |
| 157177 | /* #include "sqlite3.h" ** Required for error code definitions ** */ |
| 157178 | |
| 157179 | typedef struct sqlite3ota sqlite3ota; |
| 157180 | |
| 157181 | /* |
| 157182 | ** Open an OTA handle. |
| @@ -157144,11 +157341,10 @@ | |
| 157341 | ** are undefined. |
| 157342 | */ |
| 157343 | SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName); |
| 157344 | |
| 157345 | #endif /* _SQLITE3OTA_H */ |
| 157346 | |
| 157347 | /************** End of sqlite3ota.h ******************************************/ |
| 157348 | /************** Continuing where we left off in sqlite3ota.c *****************/ |
| 157349 | |
| 157350 | /* Maximum number of prepared UPDATE statements held by this module */ |
| @@ -160741,10 +160937,11 @@ | |
| 160937 | ** information from an SQLite database in order to implement the |
| 160938 | ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script |
| 160939 | ** for an example implementation. |
| 160940 | */ |
| 160941 | |
| 160942 | /* #include "sqliteInt.h" ** Requires access to internal data structures ** */ |
| 160943 | #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \ |
| 160944 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 160945 | |
| 160946 | /* |
| 160947 | ** Page paths: |
| 160948 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -111,11 +111,11 @@ | ||
| 111 | 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | 113 | */ |
| 114 | 114 | #define SQLITE_VERSION "3.8.11" |
| 115 | 115 | #define SQLITE_VERSION_NUMBER 3008011 |
| 116 | -#define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94" | |
| 116 | +#define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6" | |
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | 121 | ** |
| 122 | 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.8.11" |
| 115 | #define SQLITE_VERSION_NUMBER 3008011 |
| 116 | #define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.8.11" |
| 115 | #define SQLITE_VERSION_NUMBER 3008011 |
| 116 | #define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |