OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 15 | 2 ** 2001 September 15 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** Internal interface definitions for SQLite. | 12 ** Internal interface definitions for SQLite. |
13 ** | 13 ** |
14 */ | 14 */ |
15 #ifndef _SQLITEINT_H_ | 15 #ifndef _SQLITEINT_H_ |
16 #define _SQLITEINT_H_ | 16 #define _SQLITEINT_H_ |
17 | 17 |
18 /* | 18 /* |
| 19 ** Include the header file used to customize the compiler options for MSVC. |
| 20 ** This should be done first so that it can successfully prevent spurious |
| 21 ** compiler warnings due to subsequent content in this file and other files |
| 22 ** that are included by this file. |
| 23 */ |
| 24 #include "msvc.h" |
| 25 |
| 26 /* |
| 27 ** Special setup for VxWorks |
| 28 */ |
| 29 #include "vxworks.h" |
| 30 |
| 31 /* |
19 ** These #defines should enable >2GB file support on POSIX if the | 32 ** These #defines should enable >2GB file support on POSIX if the |
20 ** underlying operating system supports it. If the OS lacks | 33 ** underlying operating system supports it. If the OS lacks |
21 ** large file support, or if the OS is windows, these should be no-ops. | 34 ** large file support, or if the OS is windows, these should be no-ops. |
22 ** | 35 ** |
23 ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any | 36 ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any |
24 ** system #includes. Hence, this block of code must be the very first | 37 ** system #includes. Hence, this block of code must be the very first |
25 ** code in all source files. | 38 ** code in all source files. |
26 ** | 39 ** |
27 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch | 40 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch |
28 ** on the compiler command line. This is necessary if you are compiling | 41 ** on the compiler command line. This is necessary if you are compiling |
(...skipping 11 matching lines...) Expand all Loading... |
40 ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later. | 53 ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later. |
41 */ | 54 */ |
42 #ifndef SQLITE_DISABLE_LFS | 55 #ifndef SQLITE_DISABLE_LFS |
43 # define _LARGE_FILE 1 | 56 # define _LARGE_FILE 1 |
44 # ifndef _FILE_OFFSET_BITS | 57 # ifndef _FILE_OFFSET_BITS |
45 # define _FILE_OFFSET_BITS 64 | 58 # define _FILE_OFFSET_BITS 64 |
46 # endif | 59 # endif |
47 # define _LARGEFILE_SOURCE 1 | 60 # define _LARGEFILE_SOURCE 1 |
48 #endif | 61 #endif |
49 | 62 |
| 63 /* What version of GCC is being used. 0 means GCC is not being used */ |
| 64 #ifdef __GNUC__ |
| 65 # define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__) |
| 66 #else |
| 67 # define GCC_VERSION 0 |
| 68 #endif |
| 69 |
50 /* Needed for various definitions... */ | 70 /* Needed for various definitions... */ |
51 #if defined(__GNUC__) && !defined(_GNU_SOURCE) | 71 #if defined(__GNUC__) && !defined(_GNU_SOURCE) |
52 # define _GNU_SOURCE | 72 # define _GNU_SOURCE |
53 #endif | 73 #endif |
54 | 74 |
55 #if defined(__OpenBSD__) && !defined(_BSD_SOURCE) | 75 #if defined(__OpenBSD__) && !defined(_BSD_SOURCE) |
56 # define _BSD_SOURCE | 76 # define _BSD_SOURCE |
57 #endif | 77 #endif |
58 | 78 |
59 /* | 79 /* |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) | 167 # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) |
148 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */ | 168 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */ |
149 # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) | 169 # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) |
150 # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) | 170 # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) |
151 #else /* Generates a warning - but it always works */ | 171 #else /* Generates a warning - but it always works */ |
152 # define SQLITE_INT_TO_PTR(X) ((void*)(X)) | 172 # define SQLITE_INT_TO_PTR(X) ((void*)(X)) |
153 # define SQLITE_PTR_TO_INT(X) ((int)(X)) | 173 # define SQLITE_PTR_TO_INT(X) ((int)(X)) |
154 #endif | 174 #endif |
155 | 175 |
156 /* | 176 /* |
| 177 ** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to |
| 178 ** something between S (inclusive) and E (exclusive). |
| 179 ** |
| 180 ** In other words, S is a buffer and E is a pointer to the first byte after |
| 181 ** the end of buffer S. This macro returns true if P points to something |
| 182 ** contained within the buffer S. |
| 183 */ |
| 184 #if defined(HAVE_STDINT_H) |
| 185 # define SQLITE_WITHIN(P,S,E) \ |
| 186 ((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E)) |
| 187 #else |
| 188 # define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E)) |
| 189 #endif |
| 190 |
| 191 /* |
157 ** A macro to hint to the compiler that a function should not be | 192 ** A macro to hint to the compiler that a function should not be |
158 ** inlined. | 193 ** inlined. |
159 */ | 194 */ |
160 #if defined(__GNUC__) | 195 #if defined(__GNUC__) |
161 # define SQLITE_NOINLINE __attribute__((noinline)) | 196 # define SQLITE_NOINLINE __attribute__((noinline)) |
162 #elif defined(_MSC_VER) && _MSC_VER>=1310 | 197 #elif defined(_MSC_VER) && _MSC_VER>=1310 |
163 # define SQLITE_NOINLINE __declspec(noinline) | 198 # define SQLITE_NOINLINE __declspec(noinline) |
164 #else | 199 #else |
165 # define SQLITE_NOINLINE | 200 # define SQLITE_NOINLINE |
166 #endif | 201 #endif |
167 | 202 |
168 /* | 203 /* |
| 204 ** Make sure that the compiler intrinsics we desire are enabled when |
| 205 ** compiling with an appropriate version of MSVC unless prevented by |
| 206 ** the SQLITE_DISABLE_INTRINSIC define. |
| 207 */ |
| 208 #if !defined(SQLITE_DISABLE_INTRINSIC) |
| 209 # if defined(_MSC_VER) && _MSC_VER>=1300 |
| 210 # if !defined(_WIN32_WCE) |
| 211 # include <intrin.h> |
| 212 # pragma intrinsic(_byteswap_ushort) |
| 213 # pragma intrinsic(_byteswap_ulong) |
| 214 # pragma intrinsic(_ReadWriteBarrier) |
| 215 # else |
| 216 # include <cmnintrin.h> |
| 217 # endif |
| 218 # endif |
| 219 #endif |
| 220 |
| 221 /* |
169 ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. | 222 ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
170 ** 0 means mutexes are permanently disable and the library is never | 223 ** 0 means mutexes are permanently disable and the library is never |
171 ** threadsafe. 1 means the library is serialized which is the highest | 224 ** threadsafe. 1 means the library is serialized which is the highest |
172 ** level of threadsafety. 2 means the library is multithreaded - multiple | 225 ** level of threadsafety. 2 means the library is multithreaded - multiple |
173 ** threads can use SQLite as long as no two threads try to use the same | 226 ** threads can use SQLite as long as no two threads try to use the same |
174 ** database connection at the same time. | 227 ** database connection at the same time. |
175 ** | 228 ** |
176 ** Older versions of SQLite used an optional THREADSAFE macro. | 229 ** Older versions of SQLite used an optional THREADSAFE macro. |
177 ** We support that for legacy. | 230 ** We support that for legacy. |
178 */ | 231 */ |
179 #if !defined(SQLITE_THREADSAFE) | 232 #if !defined(SQLITE_THREADSAFE) |
180 # if defined(THREADSAFE) | 233 # if defined(THREADSAFE) |
181 # define SQLITE_THREADSAFE THREADSAFE | 234 # define SQLITE_THREADSAFE THREADSAFE |
182 # else | 235 # else |
183 # define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */ | 236 # define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */ |
184 # endif | 237 # endif |
185 #endif | 238 #endif |
186 | 239 |
187 /* | 240 /* |
188 ** Powersafe overwrite is on by default. But can be turned off using | 241 ** Powersafe overwrite is on by default. But can be turned off using |
189 ** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option. | 242 ** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option. |
190 */ | 243 */ |
191 #ifndef SQLITE_POWERSAFE_OVERWRITE | 244 #ifndef SQLITE_POWERSAFE_OVERWRITE |
192 # define SQLITE_POWERSAFE_OVERWRITE 1 | 245 # define SQLITE_POWERSAFE_OVERWRITE 1 |
193 #endif | 246 #endif |
194 | 247 |
195 /* | 248 /* |
196 ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1. | 249 ** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by |
197 ** It determines whether or not the features related to | 250 ** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in |
198 ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can | 251 ** which case memory allocation statistics are disabled by default. |
199 ** be overridden at runtime using the sqlite3_config() API. | |
200 */ | 252 */ |
201 #if !defined(SQLITE_DEFAULT_MEMSTATUS) | 253 #if !defined(SQLITE_DEFAULT_MEMSTATUS) |
202 # define SQLITE_DEFAULT_MEMSTATUS 1 | 254 # define SQLITE_DEFAULT_MEMSTATUS 1 |
203 #endif | 255 #endif |
204 | 256 |
205 /* | 257 /* |
206 ** Exactly one of the following macros must be defined in order to | 258 ** Exactly one of the following macros must be defined in order to |
207 ** specify which memory allocation subsystem to use. | 259 ** specify which memory allocation subsystem to use. |
208 ** | 260 ** |
209 ** SQLITE_SYSTEM_MALLOC // Use normal system malloc() | 261 ** SQLITE_SYSTEM_MALLOC // Use normal system malloc() |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 # define NEVER(X) (0) | 396 # define NEVER(X) (0) |
345 #elif !defined(NDEBUG) | 397 #elif !defined(NDEBUG) |
346 # define ALWAYS(X) ((X)?1:(assert(0),0)) | 398 # define ALWAYS(X) ((X)?1:(assert(0),0)) |
347 # define NEVER(X) ((X)?(assert(0),1):0) | 399 # define NEVER(X) ((X)?(assert(0),1):0) |
348 #else | 400 #else |
349 # define ALWAYS(X) (X) | 401 # define ALWAYS(X) (X) |
350 # define NEVER(X) (X) | 402 # define NEVER(X) (X) |
351 #endif | 403 #endif |
352 | 404 |
353 /* | 405 /* |
| 406 ** Declarations used for tracing the operating system interfaces. |
| 407 */ |
| 408 #if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \ |
| 409 (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) |
| 410 extern int sqlite3OSTrace; |
| 411 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X |
| 412 # define SQLITE_HAVE_OS_TRACE |
| 413 #else |
| 414 # define OSTRACE(X) |
| 415 # undef SQLITE_HAVE_OS_TRACE |
| 416 #endif |
| 417 |
| 418 /* |
| 419 ** Is the sqlite3ErrName() function needed in the build? Currently, |
| 420 ** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when |
| 421 ** OSTRACE is enabled), and by several "test*.c" files (which are |
| 422 ** compiled using SQLITE_TEST). |
| 423 */ |
| 424 #if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \ |
| 425 (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) |
| 426 # define SQLITE_NEED_ERR_NAME |
| 427 #else |
| 428 # undef SQLITE_NEED_ERR_NAME |
| 429 #endif |
| 430 |
| 431 /* |
354 ** Return true (non-zero) if the input is an integer that is too large | 432 ** Return true (non-zero) if the input is an integer that is too large |
355 ** to fit in 32-bits. This macro is used inside of various testcase() | 433 ** to fit in 32-bits. This macro is used inside of various testcase() |
356 ** macros to verify that we have tested SQLite for large-file support. | 434 ** macros to verify that we have tested SQLite for large-file support. |
357 */ | 435 */ |
358 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) | 436 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) |
359 | 437 |
360 /* | 438 /* |
361 ** The macro unlikely() is a hint that surrounds a boolean | 439 ** The macro unlikely() is a hint that surrounds a boolean |
362 ** expression that is usually false. Macro likely() surrounds | 440 ** expression that is usually false. Macro likely() surrounds |
363 ** a boolean expression that is usually true. These hints could, | 441 ** a boolean expression that is usually true. These hints could, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 # define SQLITE_MAX_WORKER_THREADS 8 | 525 # define SQLITE_MAX_WORKER_THREADS 8 |
448 #endif | 526 #endif |
449 #ifndef SQLITE_DEFAULT_WORKER_THREADS | 527 #ifndef SQLITE_DEFAULT_WORKER_THREADS |
450 # define SQLITE_DEFAULT_WORKER_THREADS 0 | 528 # define SQLITE_DEFAULT_WORKER_THREADS 0 |
451 #endif | 529 #endif |
452 #if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS | 530 #if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS |
453 # undef SQLITE_MAX_WORKER_THREADS | 531 # undef SQLITE_MAX_WORKER_THREADS |
454 # define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS | 532 # define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS |
455 #endif | 533 #endif |
456 | 534 |
| 535 /* |
| 536 ** The default initial allocation for the pagecache when using separate |
| 537 ** pagecaches for each database connection. A positive number is the |
| 538 ** number of pages. A negative number N translations means that a buffer |
| 539 ** of -1024*N bytes is allocated and used for as many pages as it will hold. |
| 540 */ |
| 541 #ifndef SQLITE_DEFAULT_PCACHE_INITSZ |
| 542 # define SQLITE_DEFAULT_PCACHE_INITSZ 100 |
| 543 #endif |
457 | 544 |
458 /* | 545 /* |
459 ** GCC does not define the offsetof() macro so we'll have to do it | 546 ** GCC does not define the offsetof() macro so we'll have to do it |
460 ** ourselves. | 547 ** ourselves. |
461 */ | 548 */ |
462 #ifndef offsetof | 549 #ifndef offsetof |
463 #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) | 550 #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) |
464 #endif | 551 #endif |
465 | 552 |
466 /* | 553 /* |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 #else | 643 #else |
557 typedef u32 tRowcnt; /* 32-bit is the default */ | 644 typedef u32 tRowcnt; /* 32-bit is the default */ |
558 #endif | 645 #endif |
559 | 646 |
560 /* | 647 /* |
561 ** Estimated quantities used for query planning are stored as 16-bit | 648 ** Estimated quantities used for query planning are stored as 16-bit |
562 ** logarithms. For quantity X, the value stored is 10*log2(X). This | 649 ** logarithms. For quantity X, the value stored is 10*log2(X). This |
563 ** gives a possible range of values of approximately 1.0e986 to 1e-986. | 650 ** gives a possible range of values of approximately 1.0e986 to 1e-986. |
564 ** But the allowed values are "grainy". Not every value is representable. | 651 ** But the allowed values are "grainy". Not every value is representable. |
565 ** For example, quantities 16 and 17 are both represented by a LogEst | 652 ** For example, quantities 16 and 17 are both represented by a LogEst |
566 ** of 40. However, since LogEst quantaties are suppose to be estimates, | 653 ** of 40. However, since LogEst quantities are suppose to be estimates, |
567 ** not exact values, this imprecision is not a problem. | 654 ** not exact values, this imprecision is not a problem. |
568 ** | 655 ** |
569 ** "LogEst" is short for "Logarithmic Estimate". | 656 ** "LogEst" is short for "Logarithmic Estimate". |
570 ** | 657 ** |
571 ** Examples: | 658 ** Examples: |
572 ** 1 -> 0 20 -> 43 10000 -> 132 | 659 ** 1 -> 0 20 -> 43 10000 -> 132 |
573 ** 2 -> 10 25 -> 46 25000 -> 146 | 660 ** 2 -> 10 25 -> 46 25000 -> 146 |
574 ** 3 -> 16 100 -> 66 1000000 -> 199 | 661 ** 3 -> 16 100 -> 66 1000000 -> 199 |
575 ** 4 -> 20 1000 -> 99 1048576 -> 200 | 662 ** 4 -> 20 1000 -> 99 1048576 -> 200 |
576 ** 10 -> 33 1024 -> 100 4294967296 -> 320 | 663 ** 10 -> 33 1024 -> 100 4294967296 -> 320 |
577 ** | 664 ** |
578 ** The LogEst can be negative to indicate fractional values. | 665 ** The LogEst can be negative to indicate fractional values. |
579 ** Examples: | 666 ** Examples: |
580 ** | 667 ** |
581 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40 | 668 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40 |
582 */ | 669 */ |
583 typedef INT16_TYPE LogEst; | 670 typedef INT16_TYPE LogEst; |
584 | 671 |
585 /* | 672 /* |
| 673 ** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer |
| 674 */ |
| 675 #ifndef SQLITE_PTRSIZE |
| 676 # if defined(__SIZEOF_POINTER__) |
| 677 # define SQLITE_PTRSIZE __SIZEOF_POINTER__ |
| 678 # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 679 defined(_M_ARM) || defined(__arm__) || defined(__x86) |
| 680 # define SQLITE_PTRSIZE 4 |
| 681 # else |
| 682 # define SQLITE_PTRSIZE 8 |
| 683 # endif |
| 684 #endif |
| 685 |
| 686 /* |
586 ** Macros to determine whether the machine is big or little endian, | 687 ** Macros to determine whether the machine is big or little endian, |
587 ** and whether or not that determination is run-time or compile-time. | 688 ** and whether or not that determination is run-time or compile-time. |
588 ** | 689 ** |
589 ** For best performance, an attempt is made to guess at the byte-order | 690 ** For best performance, an attempt is made to guess at the byte-order |
590 ** using C-preprocessor macros. If that is unsuccessful, or if | 691 ** using C-preprocessor macros. If that is unsuccessful, or if |
591 ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined | 692 ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
592 ** at run-time. | 693 ** at run-time. |
593 */ | 694 */ |
594 #ifdef SQLITE_AMALGAMATION | |
595 const int sqlite3one = 1; | |
596 #else | |
597 extern const int sqlite3one; | |
598 #endif | |
599 #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | 695 #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
600 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ | 696 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
601 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ | 697 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
602 defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) | 698 defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) |
603 # define SQLITE_BYTEORDER 1234 | 699 # define SQLITE_BYTEORDER 1234 |
604 # define SQLITE_BIGENDIAN 0 | 700 # define SQLITE_BIGENDIAN 0 |
605 # define SQLITE_LITTLEENDIAN 1 | 701 # define SQLITE_LITTLEENDIAN 1 |
606 # define SQLITE_UTF16NATIVE SQLITE_UTF16LE | 702 # define SQLITE_UTF16NATIVE SQLITE_UTF16LE |
607 #endif | 703 #endif |
608 #if (defined(sparc) || defined(__ppc__)) \ | 704 #if (defined(sparc) || defined(__ppc__)) \ |
609 && !defined(SQLITE_RUNTIME_BYTEORDER) | 705 && !defined(SQLITE_RUNTIME_BYTEORDER) |
610 # define SQLITE_BYTEORDER 4321 | 706 # define SQLITE_BYTEORDER 4321 |
611 # define SQLITE_BIGENDIAN 1 | 707 # define SQLITE_BIGENDIAN 1 |
612 # define SQLITE_LITTLEENDIAN 0 | 708 # define SQLITE_LITTLEENDIAN 0 |
613 # define SQLITE_UTF16NATIVE SQLITE_UTF16BE | 709 # define SQLITE_UTF16NATIVE SQLITE_UTF16BE |
614 #endif | 710 #endif |
615 #if !defined(SQLITE_BYTEORDER) | 711 #if !defined(SQLITE_BYTEORDER) |
| 712 # ifdef SQLITE_AMALGAMATION |
| 713 const int sqlite3one = 1; |
| 714 # else |
| 715 extern const int sqlite3one; |
| 716 # endif |
616 # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ | 717 # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ |
617 # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) | 718 # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) |
618 # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) | 719 # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) |
619 # define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) | 720 # define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) |
620 #endif | 721 #endif |
621 | 722 |
622 /* | 723 /* |
623 ** Constants for the largest and smallest possible 64-bit signed integers. | 724 ** Constants for the largest and smallest possible 64-bit signed integers. |
624 ** These macros are designed to work correctly on both 32-bit and 64-bit | 725 ** These macros are designed to work correctly on both 32-bit and 64-bit |
625 ** compilers. | 726 ** compilers. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 # include <TargetConditionals.h> | 769 # include <TargetConditionals.h> |
669 # if TARGET_OS_IPHONE | 770 # if TARGET_OS_IPHONE |
670 # undef SQLITE_MAX_MMAP_SIZE | 771 # undef SQLITE_MAX_MMAP_SIZE |
671 # define SQLITE_MAX_MMAP_SIZE 0 | 772 # define SQLITE_MAX_MMAP_SIZE 0 |
672 # endif | 773 # endif |
673 #endif | 774 #endif |
674 #ifndef SQLITE_MAX_MMAP_SIZE | 775 #ifndef SQLITE_MAX_MMAP_SIZE |
675 # if defined(__linux__) \ | 776 # if defined(__linux__) \ |
676 || defined(_WIN32) \ | 777 || defined(_WIN32) \ |
677 || (defined(__APPLE__) && defined(__MACH__)) \ | 778 || (defined(__APPLE__) && defined(__MACH__)) \ |
678 || defined(__sun) | 779 || defined(__sun) \ |
| 780 || defined(__FreeBSD__) \ |
| 781 || defined(__DragonFly__) |
679 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ | 782 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ |
680 # else | 783 # else |
681 # define SQLITE_MAX_MMAP_SIZE 0 | 784 # define SQLITE_MAX_MMAP_SIZE 0 |
682 # endif | 785 # endif |
683 # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ | 786 # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ |
684 #endif | 787 #endif |
685 | 788 |
686 /* | 789 /* |
687 ** The default MMAP_SIZE is zero on all platforms. Or, even if a larger | 790 ** The default MMAP_SIZE is zero on all platforms. Or, even if a larger |
688 ** default MMAP_SIZE is specified at compile-time, make sure that it does | 791 ** default MMAP_SIZE is specified at compile-time, make sure that it does |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 sqlite3_mutex *mutex; /* Connection mutex */ | 1156 sqlite3_mutex *mutex; /* Connection mutex */ |
1054 Db *aDb; /* All backends */ | 1157 Db *aDb; /* All backends */ |
1055 int nDb; /* Number of backends currently in use */ | 1158 int nDb; /* Number of backends currently in use */ |
1056 int flags; /* Miscellaneous flags. See below */ | 1159 int flags; /* Miscellaneous flags. See below */ |
1057 i64 lastRowid; /* ROWID of most recent insert (see above) */ | 1160 i64 lastRowid; /* ROWID of most recent insert (see above) */ |
1058 i64 szMmap; /* Default mmap_size setting */ | 1161 i64 szMmap; /* Default mmap_size setting */ |
1059 unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ | 1162 unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ |
1060 int errCode; /* Most recent error code (SQLITE_*) */ | 1163 int errCode; /* Most recent error code (SQLITE_*) */ |
1061 int errMask; /* & result codes with this before returning */ | 1164 int errMask; /* & result codes with this before returning */ |
1062 u16 dbOptFlags; /* Flags to enable/disable optimizations */ | 1165 u16 dbOptFlags; /* Flags to enable/disable optimizations */ |
| 1166 u8 enc; /* Text encoding */ |
1063 u8 autoCommit; /* The auto-commit flag. */ | 1167 u8 autoCommit; /* The auto-commit flag. */ |
1064 u8 temp_store; /* 1: file 2: memory 0: default */ | 1168 u8 temp_store; /* 1: file 2: memory 0: default */ |
1065 u8 mallocFailed; /* True if we have seen a malloc failure */ | 1169 u8 mallocFailed; /* True if we have seen a malloc failure */ |
1066 u8 dfltLockMode; /* Default locking-mode for attached dbs */ | 1170 u8 dfltLockMode; /* Default locking-mode for attached dbs */ |
1067 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ | 1171 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ |
1068 u8 suppressErr; /* Do not issue error messages if true */ | 1172 u8 suppressErr; /* Do not issue error messages if true */ |
1069 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ | 1173 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ |
1070 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ | 1174 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ |
1071 int nextPagesize; /* Pagesize after VACUUM if >0 */ | 1175 int nextPagesize; /* Pagesize after VACUUM if >0 */ |
1072 u32 magic; /* Magic number for detect library misuse */ | 1176 u32 magic; /* Magic number for detect library misuse */ |
1073 int nChange; /* Value returned by sqlite3_changes() */ | 1177 int nChange; /* Value returned by sqlite3_changes() */ |
1074 int nTotalChange; /* Value returned by sqlite3_total_changes() */ | 1178 int nTotalChange; /* Value returned by sqlite3_total_changes() */ |
1075 int aLimit[SQLITE_N_LIMIT]; /* Limits */ | 1179 int aLimit[SQLITE_N_LIMIT]; /* Limits */ |
1076 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ | 1180 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ |
1077 struct sqlite3InitInfo { /* Information used during initialization */ | 1181 struct sqlite3InitInfo { /* Information used during initialization */ |
1078 int newTnum; /* Rootpage of table being initialized */ | 1182 int newTnum; /* Rootpage of table being initialized */ |
1079 u8 iDb; /* Which db file is being initialized */ | 1183 u8 iDb; /* Which db file is being initialized */ |
1080 u8 busy; /* TRUE if currently initializing */ | 1184 u8 busy; /* TRUE if currently initializing */ |
1081 u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ | 1185 u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ |
| 1186 u8 imposterTable; /* Building an imposter table */ |
1082 } init; | 1187 } init; |
1083 int nVdbeActive; /* Number of VDBEs currently running */ | 1188 int nVdbeActive; /* Number of VDBEs currently running */ |
1084 int nVdbeRead; /* Number of active VDBEs that read or write */ | 1189 int nVdbeRead; /* Number of active VDBEs that read or write */ |
1085 int nVdbeWrite; /* Number of active VDBEs that read and write */ | 1190 int nVdbeWrite; /* Number of active VDBEs that read and write */ |
1086 int nVdbeExec; /* Number of nested calls to VdbeExec() */ | 1191 int nVdbeExec; /* Number of nested calls to VdbeExec() */ |
| 1192 int nVDestroy; /* Number of active OP_VDestroy operations */ |
1087 int nExtension; /* Number of loaded extensions */ | 1193 int nExtension; /* Number of loaded extensions */ |
1088 void **aExtension; /* Array of shared library handles */ | 1194 void **aExtension; /* Array of shared library handles */ |
1089 void (*xTrace)(void*,const char*); /* Trace function */ | 1195 void (*xTrace)(void*,const char*); /* Trace function */ |
1090 void *pTraceArg; /* Argument to the trace function */ | 1196 void *pTraceArg; /* Argument to the trace function */ |
1091 void (*xProfile)(void*,const char*,u64); /* Profiling function */ | 1197 void (*xProfile)(void*,const char*,u64); /* Profiling function */ |
1092 void *pProfileArg; /* Argument to profile function */ | 1198 void *pProfileArg; /* Argument to profile function */ |
1093 void *pCommitArg; /* Argument to xCommitCallback() */ | 1199 void *pCommitArg; /* Argument to xCommitCallback() */ |
1094 int (*xCommitCallback)(void*); /* Invoked at every commit. */ | 1200 int (*xCommitCallback)(void*); /* Invoked at every commit. */ |
1095 void *pRollbackArg; /* Argument to xRollbackCallback() */ | 1201 void *pRollbackArg; /* Argument to xRollbackCallback() */ |
1096 void (*xRollbackCallback)(void*); /* Invoked at every commit. */ | 1202 void (*xRollbackCallback)(void*); /* Invoked at every commit. */ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ | 1260 sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ |
1155 #endif | 1261 #endif |
1156 #ifdef SQLITE_USER_AUTHENTICATION | 1262 #ifdef SQLITE_USER_AUTHENTICATION |
1157 sqlite3_userauth auth; /* User authentication information */ | 1263 sqlite3_userauth auth; /* User authentication information */ |
1158 #endif | 1264 #endif |
1159 }; | 1265 }; |
1160 | 1266 |
1161 /* | 1267 /* |
1162 ** A macro to discover the encoding of a database. | 1268 ** A macro to discover the encoding of a database. |
1163 */ | 1269 */ |
1164 #define ENC(db) ((db)->aDb[0].pSchema->enc) | 1270 #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc) |
| 1271 #define ENC(db) ((db)->enc) |
1165 | 1272 |
1166 /* | 1273 /* |
1167 ** Possible values for the sqlite3.flags. | 1274 ** Possible values for the sqlite3.flags. |
1168 */ | 1275 */ |
1169 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ | 1276 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ |
1170 #define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */ | 1277 #define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */ |
1171 #define SQLITE_FullFSync 0x00000004 /* Use full fsync on the backend */ | 1278 #define SQLITE_FullFSync 0x00000004 /* Use full fsync on the backend */ |
1172 #define SQLITE_CkptFullFSync 0x00000008 /* Use full fsync for checkpoint */ | 1279 #define SQLITE_CkptFullFSync 0x00000008 /* Use full fsync for checkpoint */ |
1173 #define SQLITE_CacheSpill 0x00000010 /* OK to spill pager cache */ | 1280 #define SQLITE_CacheSpill 0x00000010 /* OK to spill pager cache */ |
1174 #define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */ | 1281 #define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */ |
(...skipping 14 matching lines...) Expand all Loading... |
1189 #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */ | 1296 #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */ |
1190 #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */ | 1297 #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */ |
1191 #define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */ | 1298 #define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */ |
1192 #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */ | 1299 #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */ |
1193 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */ | 1300 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */ |
1194 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ | 1301 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ |
1195 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */ | 1302 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */ |
1196 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */ | 1303 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */ |
1197 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */ | 1304 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */ |
1198 #define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */ | 1305 #define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */ |
| 1306 #define SQLITE_Vacuum 0x08000000 /* Currently in a VACUUM */ |
| 1307 #define SQLITE_CellSizeCk 0x10000000 /* Check btree cell sizes on load */ |
1199 | 1308 |
1200 | 1309 |
1201 /* | 1310 /* |
1202 ** Bits of the sqlite3.dbOptFlags field that are used by the | 1311 ** Bits of the sqlite3.dbOptFlags field that are used by the |
1203 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to | 1312 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to |
1204 ** selectively disable various optimizations. | 1313 ** selectively disable various optimizations. |
1205 */ | 1314 */ |
1206 #define SQLITE_QueryFlattener 0x0001 /* Query flattening */ | 1315 #define SQLITE_QueryFlattener 0x0001 /* Query flattening */ |
1207 #define SQLITE_ColumnCache 0x0002 /* Column cache */ | 1316 #define SQLITE_ColumnCache 0x0002 /* Column cache */ |
1208 #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */ | 1317 #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */ |
1209 #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */ | 1318 #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */ |
1210 /* not used 0x0010 // Was: SQLITE_IdxRealAsInt */ | 1319 /* not used 0x0010 // Was: SQLITE_IdxRealAsInt */ |
1211 #define SQLITE_DistinctOpt 0x0020 /* DISTINCT using indexes */ | 1320 #define SQLITE_DistinctOpt 0x0020 /* DISTINCT using indexes */ |
1212 #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */ | 1321 #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */ |
1213 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */ | 1322 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */ |
1214 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */ | 1323 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */ |
1215 #define SQLITE_Transitive 0x0200 /* Transitive constraints */ | 1324 #define SQLITE_Transitive 0x0200 /* Transitive constraints */ |
1216 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */ | 1325 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */ |
1217 #define SQLITE_Stat3 0x0800 /* Use the SQLITE_STAT3 table */ | 1326 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */ |
| 1327 #define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */ |
1218 #define SQLITE_AllOpts 0xffff /* All optimizations */ | 1328 #define SQLITE_AllOpts 0xffff /* All optimizations */ |
1219 | 1329 |
1220 /* | 1330 /* |
1221 ** Macros for testing whether or not optimizations are enabled or disabled. | 1331 ** Macros for testing whether or not optimizations are enabled or disabled. |
1222 */ | 1332 */ |
1223 #ifndef SQLITE_OMIT_BUILTIN_TEST | 1333 #ifndef SQLITE_OMIT_BUILTIN_TEST |
1224 #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) | 1334 #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) |
1225 #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) | 1335 #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) |
1226 #else | 1336 #else |
1227 #define OptimizationDisabled(db, mask) 0 | 1337 #define OptimizationDisabled(db, mask) 0 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 ** is invoked and the FuncDestructor structure freed. | 1390 ** is invoked and the FuncDestructor structure freed. |
1281 */ | 1391 */ |
1282 struct FuncDestructor { | 1392 struct FuncDestructor { |
1283 int nRef; | 1393 int nRef; |
1284 void (*xDestroy)(void *); | 1394 void (*xDestroy)(void *); |
1285 void *pUserData; | 1395 void *pUserData; |
1286 }; | 1396 }; |
1287 | 1397 |
1288 /* | 1398 /* |
1289 ** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF | 1399 ** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF |
1290 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There | 1400 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. And |
| 1401 ** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC. There |
1291 ** are assert() statements in the code to verify this. | 1402 ** are assert() statements in the code to verify this. |
1292 */ | 1403 */ |
1293 #define SQLITE_FUNC_ENCMASK 0x003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ | 1404 #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ |
1294 #define SQLITE_FUNC_LIKE 0x004 /* Candidate for the LIKE optimization */ | 1405 #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */ |
1295 #define SQLITE_FUNC_CASE 0x008 /* Case-sensitive LIKE-type function */ | 1406 #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */ |
1296 #define SQLITE_FUNC_EPHEM 0x010 /* Ephemeral. Delete with VDBE */ | 1407 #define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */ |
1297 #define SQLITE_FUNC_NEEDCOLL 0x020 /* sqlite3GetFuncCollSeq() might be called */ | 1408 #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/ |
1298 #define SQLITE_FUNC_LENGTH 0x040 /* Built-in length() function */ | 1409 #define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */ |
1299 #define SQLITE_FUNC_TYPEOF 0x080 /* Built-in typeof() function */ | 1410 #define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */ |
1300 #define SQLITE_FUNC_COUNT 0x100 /* Built-in count(*) aggregate */ | 1411 #define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */ |
1301 #define SQLITE_FUNC_COALESCE 0x200 /* Built-in coalesce() or ifnull() */ | 1412 #define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */ |
1302 #define SQLITE_FUNC_UNLIKELY 0x400 /* Built-in unlikely() function */ | 1413 #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */ |
1303 #define SQLITE_FUNC_CONSTANT 0x800 /* Constant inputs give a constant output */ | 1414 #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ |
1304 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ | 1415 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ |
| 1416 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a |
| 1417 ** single query - might change over time */ |
1305 | 1418 |
1306 /* | 1419 /* |
1307 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are | 1420 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
1308 ** used to create the initializers for the FuncDef structures. | 1421 ** used to create the initializers for the FuncDef structures. |
1309 ** | 1422 ** |
1310 ** FUNCTION(zName, nArg, iArg, bNC, xFunc) | 1423 ** FUNCTION(zName, nArg, iArg, bNC, xFunc) |
1311 ** Used to create a scalar function definition of a function zName | 1424 ** Used to create a scalar function definition of a function zName |
1312 ** implemented by C function xFunc that accepts nArg arguments. The | 1425 ** implemented by C function xFunc that accepts nArg arguments. The |
1313 ** value passed as iArg is cast to a (void*) and made available | 1426 ** value passed as iArg is cast to a (void*) and made available |
1314 ** as the user-data (sqlite3_user_data()) for the function. If | 1427 ** as the user-data (sqlite3_user_data()) for the function. If |
1315 ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. | 1428 ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. |
1316 ** | 1429 ** |
1317 ** VFUNCTION(zName, nArg, iArg, bNC, xFunc) | 1430 ** VFUNCTION(zName, nArg, iArg, bNC, xFunc) |
1318 ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag. | 1431 ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag. |
1319 ** | 1432 ** |
| 1433 ** DFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 1434 ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and |
| 1435 ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions |
| 1436 ** and functions like sqlite_version() that can change, but not during |
| 1437 ** a single query. |
| 1438 ** |
1320 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) | 1439 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) |
1321 ** Used to create an aggregate function definition implemented by | 1440 ** Used to create an aggregate function definition implemented by |
1322 ** the C functions xStep and xFinal. The first four parameters | 1441 ** the C functions xStep and xFinal. The first four parameters |
1323 ** are interpreted in the same way as the first 4 parameters to | 1442 ** are interpreted in the same way as the first 4 parameters to |
1324 ** FUNCTION(). | 1443 ** FUNCTION(). |
1325 ** | 1444 ** |
1326 ** LIKEFUNC(zName, nArg, pArg, flags) | 1445 ** LIKEFUNC(zName, nArg, pArg, flags) |
1327 ** Used to create a scalar function definition of a function zName | 1446 ** Used to create a scalar function definition of a function zName |
1328 ** that accepts nArg arguments and is implemented by a call to C | 1447 ** that accepts nArg arguments and is implemented by a call to C |
1329 ** function likeFunc. Argument pArg is cast to a (void *) and made | 1448 ** function likeFunc. Argument pArg is cast to a (void *) and made |
1330 ** available as the function user-data (sqlite3_user_data()). The | 1449 ** available as the function user-data (sqlite3_user_data()). The |
1331 ** FuncDef.flags variable is set to the value passed as the flags | 1450 ** FuncDef.flags variable is set to the value passed as the flags |
1332 ** parameter. | 1451 ** parameter. |
1333 */ | 1452 */ |
1334 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 1453 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
1335 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 1454 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
1336 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} | 1455 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
1337 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 1456 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
1338 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 1457 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
1339 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} | 1458 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 1459 #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 1460 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 1461 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
1340 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ | 1462 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
1341 {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ | 1463 {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
1342 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} | 1464 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
1343 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ | 1465 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
1344 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 1466 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
1345 pArg, 0, xFunc, 0, 0, #zName, 0, 0} | 1467 pArg, 0, xFunc, 0, 0, #zName, 0, 0} |
1346 #define LIKEFUNC(zName, nArg, arg, flags) \ | 1468 #define LIKEFUNC(zName, nArg, arg, flags) \ |
1347 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ | 1469 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
1348 (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0} | 1470 (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0} |
1349 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ | 1471 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ |
1350 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ | 1472 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ |
1351 SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} | 1473 SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} |
1352 #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ | 1474 #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ |
1353 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ | 1475 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ |
1354 SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} | 1476 SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} |
(...skipping 23 matching lines...) Expand all Loading... |
1378 /* | 1500 /* |
1379 ** Each SQLite module (virtual table definition) is defined by an | 1501 ** Each SQLite module (virtual table definition) is defined by an |
1380 ** instance of the following structure, stored in the sqlite3.aModule | 1502 ** instance of the following structure, stored in the sqlite3.aModule |
1381 ** hash table. | 1503 ** hash table. |
1382 */ | 1504 */ |
1383 struct Module { | 1505 struct Module { |
1384 const sqlite3_module *pModule; /* Callback pointers */ | 1506 const sqlite3_module *pModule; /* Callback pointers */ |
1385 const char *zName; /* Name passed to create_module() */ | 1507 const char *zName; /* Name passed to create_module() */ |
1386 void *pAux; /* pAux passed to create_module() */ | 1508 void *pAux; /* pAux passed to create_module() */ |
1387 void (*xDestroy)(void *); /* Module destructor function */ | 1509 void (*xDestroy)(void *); /* Module destructor function */ |
| 1510 Table *pEpoTab; /* Eponymous table for this module */ |
1388 }; | 1511 }; |
1389 | 1512 |
1390 /* | 1513 /* |
1391 ** information about each column of an SQL table is held in an instance | 1514 ** information about each column of an SQL table is held in an instance |
1392 ** of this structure. | 1515 ** of this structure. |
1393 */ | 1516 */ |
1394 struct Column { | 1517 struct Column { |
1395 char *zName; /* Name of this column */ | 1518 char *zName; /* Name of this column */ |
1396 Expr *pDflt; /* Default value of this column */ | 1519 Expr *pDflt; /* Default value of this column */ |
1397 char *zDflt; /* Original text of the default value */ | 1520 char *zDflt; /* Original text of the default value */ |
1398 char *zType; /* Data type for this column */ | 1521 char *zType; /* Data type for this column */ |
1399 char *zColl; /* Collating sequence. If NULL, use the default */ | 1522 char *zColl; /* Collating sequence. If NULL, use the default */ |
1400 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ | 1523 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ |
1401 char affinity; /* One of the SQLITE_AFF_... values */ | 1524 char affinity; /* One of the SQLITE_AFF_... values */ |
1402 u8 szEst; /* Estimated size of this column. INT==1 */ | 1525 u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ |
1403 u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ | 1526 u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ |
1404 }; | 1527 }; |
1405 | 1528 |
1406 /* Allowed values for Column.colFlags: | 1529 /* Allowed values for Column.colFlags: |
1407 */ | 1530 */ |
1408 #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ | 1531 #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
1409 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ | 1532 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
1410 | 1533 |
1411 /* | 1534 /* |
1412 ** A "Collating Sequence" is defined by an instance of the following | 1535 ** A "Collating Sequence" is defined by an instance of the following |
(...skipping 10 matching lines...) Expand all Loading... |
1423 void *pUser; /* First argument to xCmp() */ | 1546 void *pUser; /* First argument to xCmp() */ |
1424 int (*xCmp)(void*,int, const void*, int, const void*); | 1547 int (*xCmp)(void*,int, const void*, int, const void*); |
1425 void (*xDel)(void*); /* Destructor for pUser */ | 1548 void (*xDel)(void*); /* Destructor for pUser */ |
1426 }; | 1549 }; |
1427 | 1550 |
1428 /* | 1551 /* |
1429 ** A sort order can be either ASC or DESC. | 1552 ** A sort order can be either ASC or DESC. |
1430 */ | 1553 */ |
1431 #define SQLITE_SO_ASC 0 /* Sort in ascending order */ | 1554 #define SQLITE_SO_ASC 0 /* Sort in ascending order */ |
1432 #define SQLITE_SO_DESC 1 /* Sort in ascending order */ | 1555 #define SQLITE_SO_DESC 1 /* Sort in ascending order */ |
| 1556 #define SQLITE_SO_UNDEFINED -1 /* No sort order specified */ |
1433 | 1557 |
1434 /* | 1558 /* |
1435 ** Column affinity types. | 1559 ** Column affinity types. |
1436 ** | 1560 ** |
1437 ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and | 1561 ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and |
1438 ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve | 1562 ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve |
1439 ** the speed a little by numbering the values consecutively. | 1563 ** the speed a little by numbering the values consecutively. |
1440 ** | 1564 ** |
1441 ** But rather than start with 0 or 1, we begin with 'A'. That way, | 1565 ** But rather than start with 0 or 1, we begin with 'A'. That way, |
1442 ** when multiple affinity types are concatenated into a string and | 1566 ** when multiple affinity types are concatenated into a string and |
1443 ** used as the P4 operand, they will be more readable. | 1567 ** used as the P4 operand, they will be more readable. |
1444 ** | 1568 ** |
1445 ** Note also that the numeric types are grouped together so that testing | 1569 ** Note also that the numeric types are grouped together so that testing |
1446 ** for a numeric type is a single comparison. And the NONE type is first. | 1570 ** for a numeric type is a single comparison. And the BLOB type is first. |
1447 */ | 1571 */ |
1448 #define SQLITE_AFF_NONE 'A' | 1572 #define SQLITE_AFF_BLOB 'A' |
1449 #define SQLITE_AFF_TEXT 'B' | 1573 #define SQLITE_AFF_TEXT 'B' |
1450 #define SQLITE_AFF_NUMERIC 'C' | 1574 #define SQLITE_AFF_NUMERIC 'C' |
1451 #define SQLITE_AFF_INTEGER 'D' | 1575 #define SQLITE_AFF_INTEGER 'D' |
1452 #define SQLITE_AFF_REAL 'E' | 1576 #define SQLITE_AFF_REAL 'E' |
1453 | 1577 |
1454 #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) | 1578 #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) |
1455 | 1579 |
1456 /* | 1580 /* |
1457 ** The SQLITE_AFF_MASK values masks off the significant bits of an | 1581 ** The SQLITE_AFF_MASK values masks off the significant bits of an |
1458 ** affinity value. | 1582 ** affinity value. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 sqlite3 *db; /* Database connection associated with this table */ | 1643 sqlite3 *db; /* Database connection associated with this table */ |
1520 Module *pMod; /* Pointer to module implementation */ | 1644 Module *pMod; /* Pointer to module implementation */ |
1521 sqlite3_vtab *pVtab; /* Pointer to vtab instance */ | 1645 sqlite3_vtab *pVtab; /* Pointer to vtab instance */ |
1522 int nRef; /* Number of pointers to this structure */ | 1646 int nRef; /* Number of pointers to this structure */ |
1523 u8 bConstraint; /* True if constraints are supported */ | 1647 u8 bConstraint; /* True if constraints are supported */ |
1524 int iSavepoint; /* Depth of the SAVEPOINT stack */ | 1648 int iSavepoint; /* Depth of the SAVEPOINT stack */ |
1525 VTable *pNext; /* Next in linked list (see above) */ | 1649 VTable *pNext; /* Next in linked list (see above) */ |
1526 }; | 1650 }; |
1527 | 1651 |
1528 /* | 1652 /* |
1529 ** Each SQL table is represented in memory by an instance of the | 1653 ** The schema for each SQL table and view is represented in memory |
1530 ** following structure. | 1654 ** by an instance of the following structure. |
1531 ** | |
1532 ** Table.zName is the name of the table. The case of the original | |
1533 ** CREATE TABLE statement is stored, but case is not significant for | |
1534 ** comparisons. | |
1535 ** | |
1536 ** Table.nCol is the number of columns in this table. Table.aCol is a | |
1537 ** pointer to an array of Column structures, one for each column. | |
1538 ** | |
1539 ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of | |
1540 ** the column that is that key. Otherwise Table.iPKey is negative. Note | |
1541 ** that the datatype of the PRIMARY KEY must be INTEGER for this field to | |
1542 ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of | |
1543 ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid | |
1544 ** is generated for each row of the table. TF_HasPrimaryKey is set if | |
1545 ** the table has any PRIMARY KEY, INTEGER or otherwise. | |
1546 ** | |
1547 ** Table.tnum is the page number for the root BTree page of the table in the | |
1548 ** database file. If Table.iDb is the index of the database table backend | |
1549 ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that | |
1550 ** holds temporary tables and indices. If TF_Ephemeral is set | |
1551 ** then the table is stored in a file that is automatically deleted | |
1552 ** when the VDBE cursor to the table is closed. In this case Table.tnum | |
1553 ** refers VDBE cursor number that holds the table open, not to the root | |
1554 ** page number. Transient tables are used to hold the results of a | |
1555 ** sub-query that appears instead of a real table name in the FROM clause | |
1556 ** of a SELECT statement. | |
1557 */ | 1655 */ |
1558 struct Table { | 1656 struct Table { |
1559 char *zName; /* Name of the table or view */ | 1657 char *zName; /* Name of the table or view */ |
1560 Column *aCol; /* Information about each column */ | 1658 Column *aCol; /* Information about each column */ |
1561 Index *pIndex; /* List of SQL indexes on this table. */ | 1659 Index *pIndex; /* List of SQL indexes on this table. */ |
1562 Select *pSelect; /* NULL for tables. Points to definition if a view. */ | 1660 Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
1563 FKey *pFKey; /* Linked list of all foreign keys in this table */ | 1661 FKey *pFKey; /* Linked list of all foreign keys in this table */ |
1564 char *zColAff; /* String defining the affinity of each column */ | 1662 char *zColAff; /* String defining the affinity of each column */ |
1565 #ifndef SQLITE_OMIT_CHECK | |
1566 ExprList *pCheck; /* All CHECK constraints */ | 1663 ExprList *pCheck; /* All CHECK constraints */ |
1567 #endif | 1664 /* ... also used as column name list in a VIEW */ |
1568 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ | 1665 int tnum; /* Root BTree page for this table */ |
1569 int tnum; /* Root BTree node for this table (see note above) */ | 1666 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */ |
1570 i16 iPKey; /* If not negative, use aCol[iPKey] as the primary key */ | |
1571 i16 nCol; /* Number of columns in this table */ | 1667 i16 nCol; /* Number of columns in this table */ |
1572 u16 nRef; /* Number of pointers to this Table */ | 1668 u16 nRef; /* Number of pointers to this Table */ |
| 1669 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ |
1573 LogEst szTabRow; /* Estimated size of each table row in bytes */ | 1670 LogEst szTabRow; /* Estimated size of each table row in bytes */ |
1574 #ifdef SQLITE_ENABLE_COSTMULT | 1671 #ifdef SQLITE_ENABLE_COSTMULT |
1575 LogEst costMult; /* Cost multiplier for using this table */ | 1672 LogEst costMult; /* Cost multiplier for using this table */ |
1576 #endif | 1673 #endif |
1577 u8 tabFlags; /* Mask of TF_* values */ | 1674 u8 tabFlags; /* Mask of TF_* values */ |
1578 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ | 1675 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
1579 #ifndef SQLITE_OMIT_ALTERTABLE | 1676 #ifndef SQLITE_OMIT_ALTERTABLE |
1580 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ | 1677 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
1581 #endif | 1678 #endif |
1582 #ifndef SQLITE_OMIT_VIRTUALTABLE | 1679 #ifndef SQLITE_OMIT_VIRTUALTABLE |
1583 int nModuleArg; /* Number of arguments to the module */ | 1680 int nModuleArg; /* Number of arguments to the module */ |
1584 char **azModuleArg; /* Text of all module args. [0] is module name */ | 1681 char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */ |
1585 VTable *pVTable; /* List of VTable objects. */ | 1682 VTable *pVTable; /* List of VTable objects. */ |
1586 #endif | 1683 #endif |
1587 Trigger *pTrigger; /* List of triggers stored in pSchema */ | 1684 Trigger *pTrigger; /* List of triggers stored in pSchema */ |
1588 Schema *pSchema; /* Schema that contains this table */ | 1685 Schema *pSchema; /* Schema that contains this table */ |
1589 Table *pNextZombie; /* Next on the Parse.pZombieTab list */ | 1686 Table *pNextZombie; /* Next on the Parse.pZombieTab list */ |
1590 }; | 1687 }; |
1591 | 1688 |
1592 /* | 1689 /* |
1593 ** Allowed values for Table.tabFlags. | 1690 ** Allowed values for Table.tabFlags. |
| 1691 ** |
| 1692 ** TF_OOOHidden applies to tables or view that have hidden columns that are |
| 1693 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING |
| 1694 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, |
| 1695 ** the TF_OOOHidden attribute would apply in this case. Such tables require |
| 1696 ** special handling during INSERT processing. |
1594 */ | 1697 */ |
1595 #define TF_Readonly 0x01 /* Read-only system table */ | 1698 #define TF_Readonly 0x01 /* Read-only system table */ |
1596 #define TF_Ephemeral 0x02 /* An ephemeral table */ | 1699 #define TF_Ephemeral 0x02 /* An ephemeral table */ |
1597 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */ | 1700 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */ |
1598 #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ | 1701 #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ |
1599 #define TF_Virtual 0x10 /* Is a virtual table */ | 1702 #define TF_Virtual 0x10 /* Is a virtual table */ |
1600 #define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */ | 1703 #define TF_WithoutRowid 0x20 /* No rowid. PRIMARY KEY is the key */ |
| 1704 #define TF_NoVisibleRowid 0x40 /* No user-visible "rowid" column */ |
| 1705 #define TF_OOOHidden 0x80 /* Out-of-Order hidden columns */ |
1601 | 1706 |
1602 | 1707 |
1603 /* | 1708 /* |
1604 ** Test to see whether or not a table is a virtual table. This is | 1709 ** Test to see whether or not a table is a virtual table. This is |
1605 ** done as a macro so that it will be optimized out when virtual | 1710 ** done as a macro so that it will be optimized out when virtual |
1606 ** table support is omitted from the build. | 1711 ** table support is omitted from the build. |
1607 */ | 1712 */ |
1608 #ifndef SQLITE_OMIT_VIRTUALTABLE | 1713 #ifndef SQLITE_OMIT_VIRTUALTABLE |
1609 # define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) | 1714 # define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) |
1610 # define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0) | |
1611 #else | 1715 #else |
1612 # define IsVirtual(X) 0 | 1716 # define IsVirtual(X) 0 |
1613 # define IsHiddenColumn(X) 0 | |
1614 #endif | 1717 #endif |
1615 | 1718 |
| 1719 /* |
| 1720 ** Macros to determine if a column is hidden. IsOrdinaryHiddenColumn() |
| 1721 ** only works for non-virtual tables (ordinary tables and views) and is |
| 1722 ** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined. The |
| 1723 ** IsHiddenColumn() macro is general purpose. |
| 1724 */ |
| 1725 #if defined(SQLITE_ENABLE_HIDDEN_COLUMNS) |
| 1726 # define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0) |
| 1727 # define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0) |
| 1728 #elif !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 1729 # define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0) |
| 1730 # define IsOrdinaryHiddenColumn(X) 0 |
| 1731 #else |
| 1732 # define IsHiddenColumn(X) 0 |
| 1733 # define IsOrdinaryHiddenColumn(X) 0 |
| 1734 #endif |
| 1735 |
| 1736 |
1616 /* Does the table have a rowid */ | 1737 /* Does the table have a rowid */ |
1617 #define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0) | 1738 #define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0) |
| 1739 #define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0) |
1618 | 1740 |
1619 /* | 1741 /* |
1620 ** Each foreign key constraint is an instance of the following structure. | 1742 ** Each foreign key constraint is an instance of the following structure. |
1621 ** | 1743 ** |
1622 ** A foreign key is associated with two tables. The "from" table is | 1744 ** A foreign key is associated with two tables. The "from" table is |
1623 ** the table that contains the REFERENCES clause that creates the foreign | 1745 ** the table that contains the REFERENCES clause that creates the foreign |
1624 ** key. The "to" table is the table that is named in the REFERENCES clause. | 1746 ** key. The "to" table is the table that is named in the REFERENCES clause. |
1625 ** Consider this example: | 1747 ** Consider this example: |
1626 ** | 1748 ** |
1627 ** CREATE TABLE ex1( | 1749 ** CREATE TABLE ex1( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 u32 nRef; /* Number of references to this KeyInfo object */ | 1836 u32 nRef; /* Number of references to this KeyInfo object */ |
1715 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ | 1837 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ |
1716 u16 nField; /* Number of key columns in the index */ | 1838 u16 nField; /* Number of key columns in the index */ |
1717 u16 nXField; /* Number of columns beyond the key columns */ | 1839 u16 nXField; /* Number of columns beyond the key columns */ |
1718 sqlite3 *db; /* The database connection */ | 1840 sqlite3 *db; /* The database connection */ |
1719 u8 *aSortOrder; /* Sort order for each column. */ | 1841 u8 *aSortOrder; /* Sort order for each column. */ |
1720 CollSeq *aColl[1]; /* Collating sequence for each term of the key */ | 1842 CollSeq *aColl[1]; /* Collating sequence for each term of the key */ |
1721 }; | 1843 }; |
1722 | 1844 |
1723 /* | 1845 /* |
1724 ** An instance of the following structure holds information about a | 1846 ** This object holds a record which has been parsed out into individual |
1725 ** single index record that has already been parsed out into individual | 1847 ** fields, for the purposes of doing a comparison. |
1726 ** values. | |
1727 ** | 1848 ** |
1728 ** A record is an object that contains one or more fields of data. | 1849 ** A record is an object that contains one or more fields of data. |
1729 ** Records are used to store the content of a table row and to store | 1850 ** Records are used to store the content of a table row and to store |
1730 ** the key of an index. A blob encoding of a record is created by | 1851 ** the key of an index. A blob encoding of a record is created by |
1731 ** the OP_MakeRecord opcode of the VDBE and is disassembled by the | 1852 ** the OP_MakeRecord opcode of the VDBE and is disassembled by the |
1732 ** OP_Column opcode. | 1853 ** OP_Column opcode. |
1733 ** | 1854 ** |
1734 ** This structure holds a record that has already been disassembled | 1855 ** An instance of this object serves as a "key" for doing a search on |
1735 ** into its constituent fields. | 1856 ** an index b+tree. The goal of the search is to find the entry that |
| 1857 ** is closed to the key described by this object. This object might hold |
| 1858 ** just a prefix of the key. The number of fields is given by |
| 1859 ** pKeyInfo->nField. |
1736 ** | 1860 ** |
1737 ** The r1 and r2 member variables are only used by the optimized comparison | 1861 ** The r1 and r2 fields are the values to return if this key is less than |
1738 ** functions vdbeRecordCompareInt() and vdbeRecordCompareString(). | 1862 ** or greater than a key in the btree, respectively. These are normally |
| 1863 ** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree |
| 1864 ** is in DESC order. |
| 1865 ** |
| 1866 ** The key comparison functions actually return default_rc when they find |
| 1867 ** an equals comparison. default_rc can be -1, 0, or +1. If there are |
| 1868 ** multiple entries in the b-tree with the same key (when only looking |
| 1869 ** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to |
| 1870 ** cause the search to find the last match, or +1 to cause the search to |
| 1871 ** find the first match. |
| 1872 ** |
| 1873 ** The key comparison functions will set eqSeen to true if they ever |
| 1874 ** get and equal results when comparing this structure to a b-tree record. |
| 1875 ** When default_rc!=0, the search might end up on the record immediately |
| 1876 ** before the first match or immediately after the last match. The |
| 1877 ** eqSeen field will indicate whether or not an exact match exists in the |
| 1878 ** b-tree. |
1739 */ | 1879 */ |
1740 struct UnpackedRecord { | 1880 struct UnpackedRecord { |
1741 KeyInfo *pKeyInfo; /* Collation and sort-order information */ | 1881 KeyInfo *pKeyInfo; /* Collation and sort-order information */ |
| 1882 Mem *aMem; /* Values */ |
1742 u16 nField; /* Number of entries in apMem[] */ | 1883 u16 nField; /* Number of entries in apMem[] */ |
1743 i8 default_rc; /* Comparison result if keys are equal */ | 1884 i8 default_rc; /* Comparison result if keys are equal */ |
1744 u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */ | 1885 u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */ |
1745 Mem *aMem; /* Values */ | 1886 i8 r1; /* Value to return if (lhs > rhs) */ |
1746 int r1; /* Value to return if (lhs > rhs) */ | 1887 i8 r2; /* Value to return if (rhs < lhs) */ |
1747 int r2; /* Value to return if (rhs < lhs) */ | 1888 u8 eqSeen; /* True if an equality comparison has been seen */ |
1748 }; | 1889 }; |
1749 | 1890 |
1750 | 1891 |
1751 /* | 1892 /* |
1752 ** Each SQL index is represented in memory by an | 1893 ** Each SQL index is represented in memory by an |
1753 ** instance of the following structure. | 1894 ** instance of the following structure. |
1754 ** | 1895 ** |
1755 ** The columns of the table that are to be indexed are described | 1896 ** The columns of the table that are to be indexed are described |
1756 ** by the aiColumn[] field of this structure. For example, suppose | 1897 ** by the aiColumn[] field of this structure. For example, suppose |
1757 ** we have the following table and index: | 1898 ** we have the following table and index: |
1758 ** | 1899 ** |
1759 ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); | 1900 ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); |
1760 ** CREATE INDEX Ex2 ON Ex1(c3,c1); | 1901 ** CREATE INDEX Ex2 ON Ex1(c3,c1); |
1761 ** | 1902 ** |
1762 ** In the Table structure describing Ex1, nCol==3 because there are | 1903 ** In the Table structure describing Ex1, nCol==3 because there are |
1763 ** three columns in the table. In the Index structure describing | 1904 ** three columns in the table. In the Index structure describing |
1764 ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. | 1905 ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. |
1765 ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the | 1906 ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the |
1766 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. | 1907 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. |
1767 ** The second column to be indexed (c1) has an index of 0 in | 1908 ** The second column to be indexed (c1) has an index of 0 in |
1768 ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. | 1909 ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. |
1769 ** | 1910 ** |
1770 ** The Index.onError field determines whether or not the indexed columns | 1911 ** The Index.onError field determines whether or not the indexed columns |
1771 ** must be unique and what to do if they are not. When Index.onError=OE_None, | 1912 ** must be unique and what to do if they are not. When Index.onError=OE_None, |
1772 ** it means this is not a unique index. Otherwise it is a unique index | 1913 ** it means this is not a unique index. Otherwise it is a unique index |
1773 ** and the value of Index.onError indicate the which conflict resolution | 1914 ** and the value of Index.onError indicate the which conflict resolution |
1774 ** algorithm to employ whenever an attempt is made to insert a non-unique | 1915 ** algorithm to employ whenever an attempt is made to insert a non-unique |
1775 ** element. | 1916 ** element. |
| 1917 ** |
| 1918 ** While parsing a CREATE TABLE or CREATE INDEX statement in order to |
| 1919 ** generate VDBE code (as opposed to parsing one read from an sqlite_master |
| 1920 ** table as part of parsing an existing database schema), transient instances |
| 1921 ** of this structure may be created. In this case the Index.tnum variable is |
| 1922 ** used to store the address of a VDBE instruction, not a database page |
| 1923 ** number (it cannot - the database page is not allocated until the VDBE |
| 1924 ** program is executed). See convertToWithoutRowidTable() for details. |
1776 */ | 1925 */ |
1777 struct Index { | 1926 struct Index { |
1778 char *zName; /* Name of this index */ | 1927 char *zName; /* Name of this index */ |
1779 i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */ | 1928 i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
1780 LogEst *aiRowLogEst; /* From ANALYZE: Est. rows selected by each column */ | 1929 LogEst *aiRowLogEst; /* From ANALYZE: Est. rows selected by each column */ |
1781 Table *pTable; /* The SQL table being indexed */ | 1930 Table *pTable; /* The SQL table being indexed */ |
1782 char *zColAff; /* String defining the affinity of each column */ | 1931 char *zColAff; /* String defining the affinity of each column */ |
1783 Index *pNext; /* The next index associated with the same table */ | 1932 Index *pNext; /* The next index associated with the same table */ |
1784 Schema *pSchema; /* Schema containing this index */ | 1933 Schema *pSchema; /* Schema containing this index */ |
1785 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ | 1934 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ |
1786 char **azColl; /* Array of collation sequence names for index */ | 1935 const char **azColl; /* Array of collation sequence names for index */ |
1787 Expr *pPartIdxWhere; /* WHERE clause for partial indices */ | 1936 Expr *pPartIdxWhere; /* WHERE clause for partial indices */ |
1788 KeyInfo *pKeyInfo; /* A KeyInfo object suitable for this index */ | 1937 ExprList *aColExpr; /* Column expressions */ |
1789 int tnum; /* DB Page containing root of this index */ | 1938 int tnum; /* DB Page containing root of this index */ |
1790 LogEst szIdxRow; /* Estimated average row size in bytes */ | 1939 LogEst szIdxRow; /* Estimated average row size in bytes */ |
1791 u16 nKeyCol; /* Number of columns forming the key */ | 1940 u16 nKeyCol; /* Number of columns forming the key */ |
1792 u16 nColumn; /* Number of columns stored in the index */ | 1941 u16 nColumn; /* Number of columns stored in the index */ |
1793 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ | 1942 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
1794 unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ | 1943 unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ |
1795 unsigned bUnordered:1; /* Use this index for == or IN queries only */ | 1944 unsigned bUnordered:1; /* Use this index for == or IN queries only */ |
1796 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ | 1945 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ |
1797 unsigned isResized:1; /* True if resizeIndexObject() has been called */ | 1946 unsigned isResized:1; /* True if resizeIndexObject() has been called */ |
1798 unsigned isCovering:1; /* True if this is a covering index */ | 1947 unsigned isCovering:1; /* True if this is a covering index */ |
| 1948 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ |
1799 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 | 1949 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
1800 int nSample; /* Number of elements in aSample[] */ | 1950 int nSample; /* Number of elements in aSample[] */ |
1801 int nSampleCol; /* Size of IndexSample.anEq[] and so on */ | 1951 int nSampleCol; /* Size of IndexSample.anEq[] and so on */ |
1802 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ | 1952 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ |
1803 IndexSample *aSample; /* Samples of the left-most key */ | 1953 IndexSample *aSample; /* Samples of the left-most key */ |
1804 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this table */ | 1954 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */ |
| 1955 tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */ |
1805 #endif | 1956 #endif |
1806 }; | 1957 }; |
1807 | 1958 |
1808 /* | 1959 /* |
1809 ** Allowed values for Index.idxType | 1960 ** Allowed values for Index.idxType |
1810 */ | 1961 */ |
1811 #define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */ | 1962 #define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */ |
1812 #define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */ | 1963 #define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */ |
1813 #define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */ | 1964 #define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */ |
1814 | 1965 |
1815 /* Return true if index X is a PRIMARY KEY index */ | 1966 /* Return true if index X is a PRIMARY KEY index */ |
1816 #define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY) | 1967 #define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY) |
1817 | 1968 |
1818 /* Return true if index X is a UNIQUE index */ | 1969 /* Return true if index X is a UNIQUE index */ |
1819 #define IsUniqueIndex(X) ((X)->onError!=OE_None) | 1970 #define IsUniqueIndex(X) ((X)->onError!=OE_None) |
1820 | 1971 |
| 1972 /* The Index.aiColumn[] values are normally positive integer. But |
| 1973 ** there are some negative values that have special meaning: |
| 1974 */ |
| 1975 #define XN_ROWID (-1) /* Indexed column is the rowid */ |
| 1976 #define XN_EXPR (-2) /* Indexed column is an expression */ |
| 1977 |
1821 /* | 1978 /* |
1822 ** Each sample stored in the sqlite_stat3 table is represented in memory | 1979 ** Each sample stored in the sqlite_stat3 table is represented in memory |
1823 ** using a structure of this type. See documentation at the top of the | 1980 ** using a structure of this type. See documentation at the top of the |
1824 ** analyze.c source file for additional information. | 1981 ** analyze.c source file for additional information. |
1825 */ | 1982 */ |
1826 struct IndexSample { | 1983 struct IndexSample { |
1827 void *p; /* Pointer to sampled record */ | 1984 void *p; /* Pointer to sampled record */ |
1828 int n; /* Size of record in bytes */ | 1985 int n; /* Size of record in bytes */ |
1829 tRowcnt *anEq; /* Est. number of rows where the key equals this sample */ | 1986 tRowcnt *anEq; /* Est. number of rows where the key equals this sample */ |
1830 tRowcnt *anLt; /* Est. number of rows where key is less than this sample */ | 1987 tRowcnt *anLt; /* Est. number of rows where key is less than this sample */ |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 ** space is allocated for the fields below this point. An attempt to | 2149 ** space is allocated for the fields below this point. An attempt to |
1993 ** access them will result in a segfault or malfunction. | 2150 ** access them will result in a segfault or malfunction. |
1994 *********************************************************************/ | 2151 *********************************************************************/ |
1995 | 2152 |
1996 #if SQLITE_MAX_EXPR_DEPTH>0 | 2153 #if SQLITE_MAX_EXPR_DEPTH>0 |
1997 int nHeight; /* Height of the tree headed by this node */ | 2154 int nHeight; /* Height of the tree headed by this node */ |
1998 #endif | 2155 #endif |
1999 int iTable; /* TK_COLUMN: cursor number of table holding column | 2156 int iTable; /* TK_COLUMN: cursor number of table holding column |
2000 ** TK_REGISTER: register number | 2157 ** TK_REGISTER: register number |
2001 ** TK_TRIGGER: 1 -> new, 0 -> old | 2158 ** TK_TRIGGER: 1 -> new, 0 -> old |
2002 ** EP_Unlikely: 1000 times likelihood */ | 2159 ** EP_Unlikely: 134217728 times likelihood */ |
2003 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. | 2160 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. |
2004 ** TK_VARIABLE: variable number (always >= 1). */ | 2161 ** TK_VARIABLE: variable number (always >= 1). */ |
2005 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ | 2162 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
2006 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ | 2163 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
2007 u8 op2; /* TK_REGISTER: original value of Expr.op | 2164 u8 op2; /* TK_REGISTER: original value of Expr.op |
2008 ** TK_COLUMN: the value of p5 for OP_Column | 2165 ** TK_COLUMN: the value of p5 for OP_Column |
2009 ** TK_AGG_FUNCTION: nesting depth */ | 2166 ** TK_AGG_FUNCTION: nesting depth */ |
2010 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ | 2167 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
2011 Table *pTab; /* Table for TK_COLUMN expressions. */ | 2168 Table *pTab; /* Table for TK_COLUMN expressions. */ |
2012 }; | 2169 }; |
(...skipping 13 matching lines...) Expand all Loading... |
2026 #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */ | 2183 #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */ |
2027 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ | 2184 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ |
2028 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ | 2185 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ |
2029 #define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */ | 2186 #define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */ |
2030 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ | 2187 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
2031 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ | 2188 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
2032 #define EP_Static 0x008000 /* Held in memory not obtained from malloc() */ | 2189 #define EP_Static 0x008000 /* Held in memory not obtained from malloc() */ |
2033 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ | 2190 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ |
2034 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */ | 2191 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */ |
2035 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ | 2192 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ |
2036 #define EP_Constant 0x080000 /* Node is a constant */ | 2193 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
2037 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ | 2194 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ |
| 2195 #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ |
| 2196 #define EP_Alias 0x400000 /* Is an alias for a result set column */ |
| 2197 |
| 2198 /* |
| 2199 ** Combinations of two or more EP_* flags |
| 2200 */ |
| 2201 #define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */ |
2038 | 2202 |
2039 /* | 2203 /* |
2040 ** These macros can be used to test, set, or clear bits in the | 2204 ** These macros can be used to test, set, or clear bits in the |
2041 ** Expr.flags field. | 2205 ** Expr.flags field. |
2042 */ | 2206 */ |
2043 #define ExprHasProperty(E,P) (((E)->flags&(P))!=0) | 2207 #define ExprHasProperty(E,P) (((E)->flags&(P))!=0) |
2044 #define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P)) | 2208 #define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P)) |
2045 #define ExprSetProperty(E,P) (E)->flags|=(P) | 2209 #define ExprSetProperty(E,P) (E)->flags|=(P) |
2046 #define ExprClearProperty(E,P) (E)->flags&=~(P) | 2210 #define ExprClearProperty(E,P) (E)->flags&=~(P) |
2047 | 2211 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 struct SrcList_item { | 2349 struct SrcList_item { |
2186 Schema *pSchema; /* Schema to which this item is fixed */ | 2350 Schema *pSchema; /* Schema to which this item is fixed */ |
2187 char *zDatabase; /* Name of database holding this table */ | 2351 char *zDatabase; /* Name of database holding this table */ |
2188 char *zName; /* Name of the table */ | 2352 char *zName; /* Name of the table */ |
2189 char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ | 2353 char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ |
2190 Table *pTab; /* An SQL table corresponding to zName */ | 2354 Table *pTab; /* An SQL table corresponding to zName */ |
2191 Select *pSelect; /* A SELECT statement used in place of a table name */ | 2355 Select *pSelect; /* A SELECT statement used in place of a table name */ |
2192 int addrFillSub; /* Address of subroutine to manifest a subquery */ | 2356 int addrFillSub; /* Address of subroutine to manifest a subquery */ |
2193 int regReturn; /* Register holding return address of addrFillSub */ | 2357 int regReturn; /* Register holding return address of addrFillSub */ |
2194 int regResult; /* Registers holding results of a co-routine */ | 2358 int regResult; /* Registers holding results of a co-routine */ |
2195 u8 jointype; /* Type of join between this able and the previous */ | 2359 struct { |
2196 unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ | 2360 u8 jointype; /* Type of join between this able and the previous */ |
2197 unsigned isCorrelated :1; /* True if sub-query is correlated */ | 2361 unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ |
2198 unsigned viaCoroutine :1; /* Implemented as a co-routine */ | 2362 unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ |
2199 unsigned isRecursive :1; /* True for recursive reference in WITH */ | 2363 unsigned isTabFunc :1; /* True if table-valued-function syntax */ |
| 2364 unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 2365 unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 2366 unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 2367 } fg; |
2200 #ifndef SQLITE_OMIT_EXPLAIN | 2368 #ifndef SQLITE_OMIT_EXPLAIN |
2201 u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ | 2369 u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ |
2202 #endif | 2370 #endif |
2203 int iCursor; /* The VDBE cursor number used to access this table */ | 2371 int iCursor; /* The VDBE cursor number used to access this table */ |
2204 Expr *pOn; /* The ON clause of a join */ | 2372 Expr *pOn; /* The ON clause of a join */ |
2205 IdList *pUsing; /* The USING clause of a join */ | 2373 IdList *pUsing; /* The USING clause of a join */ |
2206 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ | 2374 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
2207 char *zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */ | 2375 union { |
2208 Index *pIndex; /* Index structure corresponding to zIndex, if any */ | 2376 char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| 2377 ExprList *pFuncArg; /* Arguments to table-valued-function */ |
| 2378 } u1; |
| 2379 Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ |
2209 } a[1]; /* One entry for each identifier on the list */ | 2380 } a[1]; /* One entry for each identifier on the list */ |
2210 }; | 2381 }; |
2211 | 2382 |
2212 /* | 2383 /* |
2213 ** Permitted values of the SrcList.a.jointype field | 2384 ** Permitted values of the SrcList.a.jointype field |
2214 */ | 2385 */ |
2215 #define JT_INNER 0x0001 /* Any kind of inner or cross join */ | 2386 #define JT_INNER 0x0001 /* Any kind of inner or cross join */ |
2216 #define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ | 2387 #define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ |
2217 #define JT_NATURAL 0x0004 /* True for a "natural" join */ | 2388 #define JT_NATURAL 0x0004 /* True for a "natural" join */ |
2218 #define JT_LEFT 0x0008 /* Left outer join */ | 2389 #define JT_LEFT 0x0008 /* Left outer join */ |
2219 #define JT_RIGHT 0x0010 /* Right outer join */ | 2390 #define JT_RIGHT 0x0010 /* Right outer join */ |
2220 #define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ | 2391 #define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ |
2221 #define JT_ERROR 0x0040 /* unknown or unsupported join type */ | 2392 #define JT_ERROR 0x0040 /* unknown or unsupported join type */ |
2222 | 2393 |
2223 | 2394 |
2224 /* | 2395 /* |
2225 ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() | 2396 ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() |
2226 ** and the WhereInfo.wctrlFlags member. | 2397 ** and the WhereInfo.wctrlFlags member. |
2227 */ | 2398 */ |
2228 #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ | 2399 #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
2229 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ | 2400 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
2230 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ | 2401 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
2231 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ | 2402 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
2232 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ | 2403 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
2233 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ | 2404 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ |
2234 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ | 2405 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ |
2235 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ | 2406 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ |
2236 /* 0x0080 // not currently used */ | 2407 #define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */ |
2237 #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ | 2408 #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ |
2238 #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ | 2409 #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ |
2239 #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ | 2410 #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ |
2240 #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ | 2411 #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ |
2241 #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ | 2412 #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ |
| 2413 #define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */ |
2242 | 2414 |
2243 /* Allowed return values from sqlite3WhereIsDistinct() | 2415 /* Allowed return values from sqlite3WhereIsDistinct() |
2244 */ | 2416 */ |
2245 #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */ | 2417 #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */ |
2246 #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */ | 2418 #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */ |
2247 #define WHERE_DISTINCT_ORDERED 2 /* All duplicates are adjacent */ | 2419 #define WHERE_DISTINCT_ORDERED 2 /* All duplicates are adjacent */ |
2248 #define WHERE_DISTINCT_UNORDERED 3 /* Duplicates are scattered */ | 2420 #define WHERE_DISTINCT_UNORDERED 3 /* Duplicates are scattered */ |
2249 | 2421 |
2250 /* | 2422 /* |
2251 ** A NameContext defines a context in which to resolve table and column | 2423 ** A NameContext defines a context in which to resolve table and column |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 ** | 2456 ** |
2285 ** Note: NC_MinMaxAgg must have the same value as SF_MinMaxAgg and | 2457 ** Note: NC_MinMaxAgg must have the same value as SF_MinMaxAgg and |
2286 ** SQLITE_FUNC_MINMAX. | 2458 ** SQLITE_FUNC_MINMAX. |
2287 ** | 2459 ** |
2288 */ | 2460 */ |
2289 #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ | 2461 #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ |
2290 #define NC_HasAgg 0x0002 /* One or more aggregate functions seen */ | 2462 #define NC_HasAgg 0x0002 /* One or more aggregate functions seen */ |
2291 #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ | 2463 #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ |
2292 #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ | 2464 #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ |
2293 #define NC_PartIdx 0x0010 /* True if resolving a partial index WHERE */ | 2465 #define NC_PartIdx 0x0010 /* True if resolving a partial index WHERE */ |
| 2466 #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ |
2294 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ | 2467 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ |
2295 | 2468 |
2296 /* | 2469 /* |
2297 ** An instance of the following structure contains all information | 2470 ** An instance of the following structure contains all information |
2298 ** needed to generate code for a single SELECT statement. | 2471 ** needed to generate code for a single SELECT statement. |
2299 ** | 2472 ** |
2300 ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. | 2473 ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. |
2301 ** If there is a LIMIT clause, the parser sets nLimit to the value of the | 2474 ** If there is a LIMIT clause, the parser sets nLimit to the value of the |
2302 ** limit and nOffset to the value of the offset (or 0 if there is not | 2475 ** limit and nOffset to the value of the offset (or 0 if there is not |
2303 ** offset). But later on, nLimit and nOffset become the memory locations | 2476 ** offset). But later on, nLimit and nOffset become the memory locations |
(...skipping 29 matching lines...) Expand all Loading... |
2333 Expr *pLimit; /* LIMIT expression. NULL means not used. */ | 2506 Expr *pLimit; /* LIMIT expression. NULL means not used. */ |
2334 Expr *pOffset; /* OFFSET expression. NULL means not used. */ | 2507 Expr *pOffset; /* OFFSET expression. NULL means not used. */ |
2335 With *pWith; /* WITH clause attached to this select. Or NULL. */ | 2508 With *pWith; /* WITH clause attached to this select. Or NULL. */ |
2336 }; | 2509 }; |
2337 | 2510 |
2338 /* | 2511 /* |
2339 ** Allowed values for Select.selFlags. The "SF" prefix stands for | 2512 ** Allowed values for Select.selFlags. The "SF" prefix stands for |
2340 ** "Select Flag". | 2513 ** "Select Flag". |
2341 */ | 2514 */ |
2342 #define SF_Distinct 0x0001 /* Output should be DISTINCT */ | 2515 #define SF_Distinct 0x0001 /* Output should be DISTINCT */ |
2343 #define SF_Resolved 0x0002 /* Identifiers have been resolved */ | 2516 #define SF_All 0x0002 /* Includes the ALL keyword */ |
2344 #define SF_Aggregate 0x0004 /* Contains aggregate functions */ | 2517 #define SF_Resolved 0x0004 /* Identifiers have been resolved */ |
2345 #define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ | 2518 #define SF_Aggregate 0x0008 /* Contains aggregate functions */ |
2346 #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ | 2519 #define SF_UsesEphemeral 0x0010 /* Uses the OpenEphemeral opcode */ |
2347 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ | 2520 #define SF_Expanded 0x0020 /* sqlite3SelectExpand() called on this */ |
2348 #define SF_Compound 0x0040 /* Part of a compound query */ | 2521 #define SF_HasTypeInfo 0x0040 /* FROM subqueries have Table metadata */ |
2349 #define SF_Values 0x0080 /* Synthesized from VALUES clause */ | 2522 #define SF_Compound 0x0080 /* Part of a compound query */ |
2350 /* 0x0100 NOT USED */ | 2523 #define SF_Values 0x0100 /* Synthesized from VALUES clause */ |
2351 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ | 2524 #define SF_MultiValue 0x0200 /* Single VALUES term with multiple rows */ |
2352 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */ | 2525 #define SF_NestedFrom 0x0400 /* Part of a parenthesized FROM clause */ |
2353 #define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */ | 2526 #define SF_MaybeConvert 0x0800 /* Need convertCompoundSelectToSubquery() */ |
2354 #define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */ | 2527 #define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */ |
| 2528 #define SF_Recursive 0x2000 /* The recursive part of a recursive CTE */ |
| 2529 #define SF_Converted 0x4000 /* By convertCompoundSelectToSubquery() */ |
| 2530 #define SF_IncludeHidden 0x8000 /* Include hidden columns in output */ |
2355 | 2531 |
2356 | 2532 |
2357 /* | 2533 /* |
2358 ** The results of a SELECT can be distributed in several ways, as defined | 2534 ** The results of a SELECT can be distributed in several ways, as defined |
2359 ** by one of the following macros. The "SRT" prefix means "SELECT Result | 2535 ** by one of the following macros. The "SRT" prefix means "SELECT Result |
2360 ** Type". | 2536 ** Type". |
2361 ** | 2537 ** |
2362 ** SRT_Union Store results as a key in a temporary index | 2538 ** SRT_Union Store results as a key in a temporary index |
2363 ** identified by pDest->iSDParm. | 2539 ** identified by pDest->iSDParm. |
2364 ** | 2540 ** |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 u8 okConstFactor; /* OK to factor out constants */ | 2725 u8 okConstFactor; /* OK to factor out constants */ |
2550 int aTempReg[8]; /* Holding area for temporary registers */ | 2726 int aTempReg[8]; /* Holding area for temporary registers */ |
2551 int nRangeReg; /* Size of the temporary register block */ | 2727 int nRangeReg; /* Size of the temporary register block */ |
2552 int iRangeReg; /* First register in temporary register block */ | 2728 int iRangeReg; /* First register in temporary register block */ |
2553 int nErr; /* Number of errors seen */ | 2729 int nErr; /* Number of errors seen */ |
2554 int nTab; /* Number of previously allocated VDBE cursors */ | 2730 int nTab; /* Number of previously allocated VDBE cursors */ |
2555 int nMem; /* Number of memory cells used so far */ | 2731 int nMem; /* Number of memory cells used so far */ |
2556 int nSet; /* Number of sets used so far */ | 2732 int nSet; /* Number of sets used so far */ |
2557 int nOnce; /* Number of OP_Once instructions so far */ | 2733 int nOnce; /* Number of OP_Once instructions so far */ |
2558 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ | 2734 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ |
| 2735 int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ |
2559 int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ | 2736 int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ |
2560 int ckBase; /* Base register of data during check constraints */ | 2737 int ckBase; /* Base register of data during check constraints */ |
2561 int iPartIdxTab; /* Table corresponding to a partial index */ | 2738 int iSelfTab; /* Table of an index whose exprs are being coded */ |
2562 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ | 2739 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
2563 int iCacheCnt; /* Counter used to generate aColCache[].lru values */ | 2740 int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
2564 int nLabel; /* Number of labels used */ | 2741 int nLabel; /* Number of labels used */ |
2565 int *aLabel; /* Space to hold the labels */ | 2742 int *aLabel; /* Space to hold the labels */ |
2566 struct yColCache { | 2743 struct yColCache { |
2567 int iTable; /* Table cursor number */ | 2744 int iTable; /* Table cursor number */ |
2568 i16 iColumn; /* Table column number */ | 2745 i16 iColumn; /* Table column number */ |
2569 u8 tempReg; /* iReg is a temp register that needs to be freed */ | 2746 u8 tempReg; /* iReg is a temp register that needs to be freed */ |
2570 int iLevel; /* Nesting level */ | 2747 int iLevel; /* Nesting level */ |
2571 int iReg; /* Reg with value of this column. 0 means none. */ | 2748 int iReg; /* Reg with value of this column. 0 means none. */ |
(...skipping 14 matching lines...) Expand all Loading... |
2586 #ifndef SQLITE_OMIT_SHARED_CACHE | 2763 #ifndef SQLITE_OMIT_SHARED_CACHE |
2587 int nTableLock; /* Number of locks in aTableLock */ | 2764 int nTableLock; /* Number of locks in aTableLock */ |
2588 TableLock *aTableLock; /* Required table locks for shared-cache mode */ | 2765 TableLock *aTableLock; /* Required table locks for shared-cache mode */ |
2589 #endif | 2766 #endif |
2590 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ | 2767 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
2591 | 2768 |
2592 /* Information used while coding trigger programs. */ | 2769 /* Information used while coding trigger programs. */ |
2593 Parse *pToplevel; /* Parse structure for main program (or NULL) */ | 2770 Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
2594 Table *pTriggerTab; /* Table triggers are being coded for */ | 2771 Table *pTriggerTab; /* Table triggers are being coded for */ |
2595 int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */ | 2772 int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */ |
2596 int addrSkipPK; /* Address of instruction to skip PRIMARY KEY index */ | |
2597 u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ | 2773 u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ |
2598 u32 oldmask; /* Mask of old.* columns referenced */ | 2774 u32 oldmask; /* Mask of old.* columns referenced */ |
2599 u32 newmask; /* Mask of new.* columns referenced */ | 2775 u32 newmask; /* Mask of new.* columns referenced */ |
2600 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ | 2776 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
2601 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ | 2777 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
2602 u8 disableTriggers; /* True to disable triggers */ | 2778 u8 disableTriggers; /* True to disable triggers */ |
2603 | 2779 |
2604 /************************************************************************ | 2780 /************************************************************************ |
2605 ** Above is constant between recursions. Below is reset before and after | 2781 ** Above is constant between recursions. Below is reset before and after |
2606 ** each recursion. The boundary between these two regions is determined | 2782 ** each recursion. The boundary between these two regions is determined |
2607 ** using offsetof(Parse,nVar) so the nVar field must be the first field | 2783 ** using offsetof(Parse,nVar) so the nVar field must be the first field |
2608 ** in the recursive region. | 2784 ** in the recursive region. |
2609 ************************************************************************/ | 2785 ************************************************************************/ |
2610 | 2786 |
2611 int nVar; /* Number of '?' variables seen in the SQL so far */ | 2787 int nVar; /* Number of '?' variables seen in the SQL so far */ |
2612 int nzVar; /* Number of available slots in azVar[] */ | 2788 int nzVar; /* Number of available slots in azVar[] */ |
2613 u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */ | 2789 u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */ |
2614 u8 bFreeWith; /* True if pWith should be freed with parser */ | |
2615 u8 explain; /* True if the EXPLAIN flag is found on the query */ | 2790 u8 explain; /* True if the EXPLAIN flag is found on the query */ |
2616 #ifndef SQLITE_OMIT_VIRTUALTABLE | 2791 #ifndef SQLITE_OMIT_VIRTUALTABLE |
2617 u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ | 2792 u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ |
2618 int nVtabLock; /* Number of virtual tables to lock */ | 2793 int nVtabLock; /* Number of virtual tables to lock */ |
2619 #endif | 2794 #endif |
2620 int nAlias; /* Number of aliased result set columns */ | 2795 int nAlias; /* Number of aliased result set columns */ |
2621 int nHeight; /* Expression tree height of current sub-select */ | 2796 int nHeight; /* Expression tree height of current sub-select */ |
2622 #ifndef SQLITE_OMIT_EXPLAIN | 2797 #ifndef SQLITE_OMIT_EXPLAIN |
2623 int iSelectId; /* ID of current select for EXPLAIN output */ | 2798 int iSelectId; /* ID of current select for EXPLAIN output */ |
2624 int iNextSelectId; /* Next available select ID for EXPLAIN output */ | 2799 int iNextSelectId; /* Next available select ID for EXPLAIN output */ |
2625 #endif | 2800 #endif |
2626 char **azVar; /* Pointers to names of parameters */ | 2801 char **azVar; /* Pointers to names of parameters */ |
2627 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ | 2802 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ |
2628 const char *zTail; /* All SQL text past the last semicolon parsed */ | 2803 const char *zTail; /* All SQL text past the last semicolon parsed */ |
2629 Table *pNewTable; /* A table being constructed by CREATE TABLE */ | 2804 Table *pNewTable; /* A table being constructed by CREATE TABLE */ |
2630 Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ | 2805 Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ |
2631 const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ | 2806 const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ |
2632 Token sNameToken; /* Token with unqualified schema object name */ | 2807 Token sNameToken; /* Token with unqualified schema object name */ |
2633 Token sLastToken; /* The last token parsed */ | 2808 Token sLastToken; /* The last token parsed */ |
2634 #ifndef SQLITE_OMIT_VIRTUALTABLE | 2809 #ifndef SQLITE_OMIT_VIRTUALTABLE |
2635 Token sArg; /* Complete text of a module argument */ | 2810 Token sArg; /* Complete text of a module argument */ |
2636 Table **apVtabLock; /* Pointer to virtual tables needing locking */ | 2811 Table **apVtabLock; /* Pointer to virtual tables needing locking */ |
2637 #endif | 2812 #endif |
2638 Table *pZombieTab; /* List of Table objects to delete after code gen */ | 2813 Table *pZombieTab; /* List of Table objects to delete after code gen */ |
2639 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ | 2814 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ |
2640 With *pWith; /* Current WITH clause, or NULL */ | 2815 With *pWith; /* Current WITH clause, or NULL */ |
| 2816 With *pWithToFree; /* Free this WITH object at the end of the parse */ |
2641 }; | 2817 }; |
2642 | 2818 |
2643 /* | 2819 /* |
2644 ** Return true if currently inside an sqlite3_declare_vtab() call. | 2820 ** Return true if currently inside an sqlite3_declare_vtab() call. |
2645 */ | 2821 */ |
2646 #ifdef SQLITE_OMIT_VIRTUALTABLE | 2822 #ifdef SQLITE_OMIT_VIRTUALTABLE |
2647 #define IN_DECLARE_VTAB 0 | 2823 #define IN_DECLARE_VTAB 0 |
2648 #else | 2824 #else |
2649 #define IN_DECLARE_VTAB (pParse->declareVtab) | 2825 #define IN_DECLARE_VTAB (pParse->declareVtab) |
2650 #endif | 2826 #endif |
(...skipping 12 matching lines...) Expand all Loading... |
2663 */ | 2839 */ |
2664 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ | 2840 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ |
2665 #define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */ | 2841 #define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */ |
2666 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ | 2842 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ |
2667 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ | 2843 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ |
2668 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ | 2844 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ |
2669 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ | 2845 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ |
2670 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ | 2846 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ |
2671 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ | 2847 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ |
2672 #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ | 2848 #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ |
2673 #define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */ | 2849 #define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */ |
| 2850 #define OPFLAG_FORDELETE 0x08 /* OP_Open is opening for-delete csr */ |
| 2851 #define OPFLAG_P2ISREG 0x10 /* P2 to OP_Open** is a register number */ |
2674 #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */ | 2852 #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */ |
2675 | 2853 |
2676 /* | 2854 /* |
2677 * Each trigger present in the database schema is stored as an instance of | 2855 * Each trigger present in the database schema is stored as an instance of |
2678 * struct Trigger. | 2856 * struct Trigger. |
2679 * | 2857 * |
2680 * Pointers to instances of struct Trigger are stored in two ways. | 2858 * Pointers to instances of struct Trigger are stored in two ways. |
2681 * 1. In the "trigHash" hash table (part of the sqlite3* that represents the | 2859 * 1. In the "trigHash" hash table (part of the sqlite3* that represents the |
2682 * database). This allows Trigger structures to be retrieved by name. | 2860 * database). This allows Trigger structures to be retrieved by name. |
2683 * 2. All triggers associated with a single table form a linked list, using the | 2861 * 2. All triggers associated with a single table form a linked list, using the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 * the first step of the trigger-program. | 2900 * the first step of the trigger-program. |
2723 * | 2901 * |
2724 * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or | 2902 * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or |
2725 * "SELECT" statement. The meanings of the other members is determined by the | 2903 * "SELECT" statement. The meanings of the other members is determined by the |
2726 * value of "op" as follows: | 2904 * value of "op" as follows: |
2727 * | 2905 * |
2728 * (op == TK_INSERT) | 2906 * (op == TK_INSERT) |
2729 * orconf -> stores the ON CONFLICT algorithm | 2907 * orconf -> stores the ON CONFLICT algorithm |
2730 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then | 2908 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then |
2731 * this stores a pointer to the SELECT statement. Otherwise NULL. | 2909 * this stores a pointer to the SELECT statement. Otherwise NULL. |
2732 * target -> A token holding the quoted name of the table to insert into. | 2910 * zTarget -> Dequoted name of the table to insert into. |
2733 * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then | 2911 * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then |
2734 * this stores values to be inserted. Otherwise NULL. | 2912 * this stores values to be inserted. Otherwise NULL. |
2735 * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ... | 2913 * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ... |
2736 * statement, then this stores the column-names to be | 2914 * statement, then this stores the column-names to be |
2737 * inserted into. | 2915 * inserted into. |
2738 * | 2916 * |
2739 * (op == TK_DELETE) | 2917 * (op == TK_DELETE) |
2740 * target -> A token holding the quoted name of the table to delete from. | 2918 * zTarget -> Dequoted name of the table to delete from. |
2741 * pWhere -> The WHERE clause of the DELETE statement if one is specified. | 2919 * pWhere -> The WHERE clause of the DELETE statement if one is specified. |
2742 * Otherwise NULL. | 2920 * Otherwise NULL. |
2743 * | 2921 * |
2744 * (op == TK_UPDATE) | 2922 * (op == TK_UPDATE) |
2745 * target -> A token holding the quoted name of the table to update rows of. | 2923 * zTarget -> Dequoted name of the table to update. |
2746 * pWhere -> The WHERE clause of the UPDATE statement if one is specified. | 2924 * pWhere -> The WHERE clause of the UPDATE statement if one is specified. |
2747 * Otherwise NULL. | 2925 * Otherwise NULL. |
2748 * pExprList -> A list of the columns to update and the expressions to update | 2926 * pExprList -> A list of the columns to update and the expressions to update |
2749 * them to. See sqlite3Update() documentation of "pChanges" | 2927 * them to. See sqlite3Update() documentation of "pChanges" |
2750 * argument. | 2928 * argument. |
2751 * | 2929 * |
2752 */ | 2930 */ |
2753 struct TriggerStep { | 2931 struct TriggerStep { |
2754 u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ | 2932 u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ |
2755 u8 orconf; /* OE_Rollback etc. */ | 2933 u8 orconf; /* OE_Rollback etc. */ |
2756 Trigger *pTrig; /* The trigger that this step is a part of */ | 2934 Trigger *pTrig; /* The trigger that this step is a part of */ |
2757 Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ | 2935 Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ |
2758 Token target; /* Target table for DELETE, UPDATE, INSERT */ | 2936 char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ |
2759 Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ | 2937 Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ |
2760 ExprList *pExprList; /* SET clause for UPDATE. */ | 2938 ExprList *pExprList; /* SET clause for UPDATE. */ |
2761 IdList *pIdList; /* Column names for INSERT */ | 2939 IdList *pIdList; /* Column names for INSERT */ |
2762 TriggerStep *pNext; /* Next in the link-list */ | 2940 TriggerStep *pNext; /* Next in the link-list */ |
2763 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */ | 2941 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */ |
2764 }; | 2942 }; |
2765 | 2943 |
2766 /* | 2944 /* |
2767 ** The following structure contains information used by the sqliteFix... | 2945 ** The following structure contains information used by the sqliteFix... |
2768 ** routines as they walk the parse tree to make database references | 2946 ** routines as they walk the parse tree to make database references |
(...skipping 10 matching lines...) Expand all Loading... |
2779 }; | 2957 }; |
2780 | 2958 |
2781 /* | 2959 /* |
2782 ** An objected used to accumulate the text of a string where we | 2960 ** An objected used to accumulate the text of a string where we |
2783 ** do not necessarily know how big the string will be in the end. | 2961 ** do not necessarily know how big the string will be in the end. |
2784 */ | 2962 */ |
2785 struct StrAccum { | 2963 struct StrAccum { |
2786 sqlite3 *db; /* Optional database for lookaside. Can be NULL */ | 2964 sqlite3 *db; /* Optional database for lookaside. Can be NULL */ |
2787 char *zBase; /* A base allocation. Not from malloc. */ | 2965 char *zBase; /* A base allocation. Not from malloc. */ |
2788 char *zText; /* The string collected so far */ | 2966 char *zText; /* The string collected so far */ |
2789 int nChar; /* Length of the string so far */ | 2967 u32 nChar; /* Length of the string so far */ |
2790 int nAlloc; /* Amount of space allocated in zText */ | 2968 u32 nAlloc; /* Amount of space allocated in zText */ |
2791 int mxAlloc; /* Maximum allowed string length */ | 2969 u32 mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ |
2792 u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ | |
2793 u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ | 2970 u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ |
| 2971 u8 bMalloced; /* zText points to allocated space */ |
2794 }; | 2972 }; |
2795 #define STRACCUM_NOMEM 1 | 2973 #define STRACCUM_NOMEM 1 |
2796 #define STRACCUM_TOOBIG 2 | 2974 #define STRACCUM_TOOBIG 2 |
2797 | 2975 |
2798 /* | 2976 /* |
2799 ** A pointer to this structure is used to communicate information | 2977 ** A pointer to this structure is used to communicate information |
2800 ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. | 2978 ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. |
2801 */ | 2979 */ |
2802 typedef struct { | 2980 typedef struct { |
2803 sqlite3 *db; /* The database being initialized */ | 2981 sqlite3 *db; /* The database being initialized */ |
(...skipping 26 matching lines...) Expand all Loading... |
2830 sqlite3_int64 szMmap; /* mmap() space per open file */ | 3008 sqlite3_int64 szMmap; /* mmap() space per open file */ |
2831 sqlite3_int64 mxMmap; /* Maximum value for szMmap */ | 3009 sqlite3_int64 mxMmap; /* Maximum value for szMmap */ |
2832 void *pScratch; /* Scratch memory */ | 3010 void *pScratch; /* Scratch memory */ |
2833 int szScratch; /* Size of each scratch buffer */ | 3011 int szScratch; /* Size of each scratch buffer */ |
2834 int nScratch; /* Number of scratch buffers */ | 3012 int nScratch; /* Number of scratch buffers */ |
2835 void *pPage; /* Page cache memory */ | 3013 void *pPage; /* Page cache memory */ |
2836 int szPage; /* Size of each page in pPage[] */ | 3014 int szPage; /* Size of each page in pPage[] */ |
2837 int nPage; /* Number of pages in pPage[] */ | 3015 int nPage; /* Number of pages in pPage[] */ |
2838 int mxParserStack; /* maximum depth of the parser stack */ | 3016 int mxParserStack; /* maximum depth of the parser stack */ |
2839 int sharedCacheEnabled; /* true if shared-cache mode enabled */ | 3017 int sharedCacheEnabled; /* true if shared-cache mode enabled */ |
| 3018 u32 szPma; /* Maximum Sorter PMA size */ |
2840 /* The above might be initialized to non-zero. The following need to always | 3019 /* The above might be initialized to non-zero. The following need to always |
2841 ** initially be zero, however. */ | 3020 ** initially be zero, however. */ |
2842 int isInit; /* True after initialization has finished */ | 3021 int isInit; /* True after initialization has finished */ |
2843 int inProgress; /* True while initialization in progress */ | 3022 int inProgress; /* True while initialization in progress */ |
2844 int isMutexInit; /* True after mutexes are initialized */ | 3023 int isMutexInit; /* True after mutexes are initialized */ |
2845 int isMallocInit; /* True after malloc is initialized */ | 3024 int isMallocInit; /* True after malloc is initialized */ |
2846 int isPCacheInit; /* True after malloc is initialized */ | 3025 int isPCacheInit; /* True after malloc is initialized */ |
2847 int nRefInitMutex; /* Number of users of pInitMutex */ | 3026 int nRefInitMutex; /* Number of users of pInitMutex */ |
2848 sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ | 3027 sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ |
2849 void (*xLog)(void*,int,const char*); /* Function for logging */ | 3028 void (*xLog)(void*,int,const char*); /* Function for logging */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 | 3064 |
2886 /* | 3065 /* |
2887 ** Context pointer passed down through the tree-walk. | 3066 ** Context pointer passed down through the tree-walk. |
2888 */ | 3067 */ |
2889 struct Walker { | 3068 struct Walker { |
2890 int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */ | 3069 int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */ |
2891 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ | 3070 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ |
2892 void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ | 3071 void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ |
2893 Parse *pParse; /* Parser context. */ | 3072 Parse *pParse; /* Parser context. */ |
2894 int walkerDepth; /* Number of subqueries */ | 3073 int walkerDepth; /* Number of subqueries */ |
| 3074 u8 eCode; /* A small processing code */ |
2895 union { /* Extra data for callback */ | 3075 union { /* Extra data for callback */ |
2896 NameContext *pNC; /* Naming context */ | 3076 NameContext *pNC; /* Naming context */ |
2897 int i; /* Integer value */ | 3077 int n; /* A counter */ |
| 3078 int iCur; /* A cursor number */ |
2898 SrcList *pSrcList; /* FROM clause */ | 3079 SrcList *pSrcList; /* FROM clause */ |
2899 struct SrcCount *pSrcCount; /* Counting column references */ | 3080 struct SrcCount *pSrcCount; /* Counting column references */ |
| 3081 struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
2900 } u; | 3082 } u; |
2901 }; | 3083 }; |
2902 | 3084 |
2903 /* Forward declarations */ | 3085 /* Forward declarations */ |
2904 int sqlite3WalkExpr(Walker*, Expr*); | 3086 int sqlite3WalkExpr(Walker*, Expr*); |
2905 int sqlite3WalkExprList(Walker*, ExprList*); | 3087 int sqlite3WalkExprList(Walker*, ExprList*); |
2906 int sqlite3WalkSelect(Walker*, Select*); | 3088 int sqlite3WalkSelect(Walker*, Select*); |
2907 int sqlite3WalkSelectExpr(Walker*, Select*); | 3089 int sqlite3WalkSelectExpr(Walker*, Select*); |
2908 int sqlite3WalkSelectFrom(Walker*, Select*); | 3090 int sqlite3WalkSelectFrom(Walker*, Select*); |
| 3091 int sqlite3ExprWalkNoop(Walker*, Expr*); |
2909 | 3092 |
2910 /* | 3093 /* |
2911 ** Return code from the parse-tree walking primitives and their | 3094 ** Return code from the parse-tree walking primitives and their |
2912 ** callbacks. | 3095 ** callbacks. |
2913 */ | 3096 */ |
2914 #define WRC_Continue 0 /* Continue down into children */ | 3097 #define WRC_Continue 0 /* Continue down into children */ |
2915 #define WRC_Prune 1 /* Omit children but continue walking siblings */ | 3098 #define WRC_Prune 1 /* Omit children but continue walking siblings */ |
2916 #define WRC_Abort 2 /* Abandon the tree walk */ | 3099 #define WRC_Abort 2 /* Abandon the tree walk */ |
2917 | 3100 |
2918 /* | 3101 /* |
2919 ** An instance of this structure represents a set of one or more CTEs | 3102 ** An instance of this structure represents a set of one or more CTEs |
2920 ** (common table expressions) created by a single WITH clause. | 3103 ** (common table expressions) created by a single WITH clause. |
2921 */ | 3104 */ |
2922 struct With { | 3105 struct With { |
2923 int nCte; /* Number of CTEs in the WITH clause */ | 3106 int nCte; /* Number of CTEs in the WITH clause */ |
2924 With *pOuter; /* Containing WITH clause, or NULL */ | 3107 With *pOuter; /* Containing WITH clause, or NULL */ |
2925 struct Cte { /* For each CTE in the WITH clause.... */ | 3108 struct Cte { /* For each CTE in the WITH clause.... */ |
2926 char *zName; /* Name of this CTE */ | 3109 char *zName; /* Name of this CTE */ |
2927 ExprList *pCols; /* List of explicit column names, or NULL */ | 3110 ExprList *pCols; /* List of explicit column names, or NULL */ |
2928 Select *pSelect; /* The definition of this CTE */ | 3111 Select *pSelect; /* The definition of this CTE */ |
2929 const char *zErr; /* Error message for circular references */ | 3112 const char *zCteErr; /* Error message for circular references */ |
2930 } a[1]; | 3113 } a[1]; |
2931 }; | 3114 }; |
2932 | 3115 |
2933 #ifdef SQLITE_DEBUG | 3116 #ifdef SQLITE_DEBUG |
2934 /* | 3117 /* |
2935 ** An instance of the TreeView object is used for printing the content of | 3118 ** An instance of the TreeView object is used for printing the content of |
2936 ** data structures on sqlite3DebugPrintf() using a tree-like view. | 3119 ** data structures on sqlite3DebugPrintf() using a tree-like view. |
2937 */ | 3120 */ |
2938 struct TreeView { | 3121 struct TreeView { |
2939 int iLevel; /* Which level of the tree we are on */ | 3122 int iLevel; /* Which level of the tree we are on */ |
(...skipping 25 matching lines...) Expand all Loading... |
2965 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) | 3148 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) |
2966 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) | 3149 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) |
2967 | 3150 |
2968 | 3151 |
2969 /* | 3152 /* |
2970 ** FTS4 is really an extension for FTS3. It is enabled using the | 3153 ** FTS4 is really an extension for FTS3. It is enabled using the |
2971 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call | 3154 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call |
2972 ** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3. | 3155 ** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3. |
2973 */ | 3156 */ |
2974 #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) | 3157 #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) |
2975 # define SQLITE_ENABLE_FTS3 | 3158 # define SQLITE_ENABLE_FTS3 1 |
2976 #endif | 3159 #endif |
2977 | 3160 |
2978 /* | 3161 /* |
2979 ** The ctype.h header is needed for non-ASCII systems. It is also | 3162 ** The ctype.h header is needed for non-ASCII systems. It is also |
2980 ** needed by FTS3 when FTS3 is included in the amalgamation. | 3163 ** needed by FTS3 when FTS3 is included in the amalgamation. |
2981 */ | 3164 */ |
2982 #if !defined(SQLITE_ASCII) || \ | 3165 #if !defined(SQLITE_ASCII) || \ |
2983 (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) | 3166 (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) |
2984 # include <ctype.h> | 3167 # include <ctype.h> |
2985 #endif | 3168 #endif |
2986 | 3169 |
2987 /* | 3170 /* |
2988 ** The CoreServices.h and CoreFoundation.h headers are needed for excluding a | |
2989 ** -journal file from Time Machine backups when its associated database has | |
2990 ** previously been excluded by the client code. | |
2991 */ | |
2992 #if defined(__APPLE__) | |
2993 #include <CoreServices/CoreServices.h> | |
2994 #include <CoreFoundation/CoreFoundation.h> | |
2995 #endif | |
2996 | |
2997 /* | |
2998 ** The following macros mimic the standard library functions toupper(), | 3171 ** The following macros mimic the standard library functions toupper(), |
2999 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The | 3172 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The |
3000 ** sqlite versions only work for ASCII characters, regardless of locale. | 3173 ** sqlite versions only work for ASCII characters, regardless of locale. |
3001 */ | 3174 */ |
3002 #ifdef SQLITE_ASCII | 3175 #ifdef SQLITE_ASCII |
3003 # define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) | 3176 # define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) |
3004 # define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) | 3177 # define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) |
3005 # define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) | 3178 # define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) |
3006 # define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) | 3179 # define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) |
3007 # define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) | 3180 # define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) |
3008 # define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) | 3181 # define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) |
3009 # define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) | 3182 # define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) |
3010 #else | 3183 #else |
3011 # define sqlite3Toupper(x) toupper((unsigned char)(x)) | 3184 # define sqlite3Toupper(x) toupper((unsigned char)(x)) |
3012 # define sqlite3Isspace(x) isspace((unsigned char)(x)) | 3185 # define sqlite3Isspace(x) isspace((unsigned char)(x)) |
3013 # define sqlite3Isalnum(x) isalnum((unsigned char)(x)) | 3186 # define sqlite3Isalnum(x) isalnum((unsigned char)(x)) |
3014 # define sqlite3Isalpha(x) isalpha((unsigned char)(x)) | 3187 # define sqlite3Isalpha(x) isalpha((unsigned char)(x)) |
3015 # define sqlite3Isdigit(x) isdigit((unsigned char)(x)) | 3188 # define sqlite3Isdigit(x) isdigit((unsigned char)(x)) |
3016 # define sqlite3Isxdigit(x) isxdigit((unsigned char)(x)) | 3189 # define sqlite3Isxdigit(x) isxdigit((unsigned char)(x)) |
3017 # define sqlite3Tolower(x) tolower((unsigned char)(x)) | 3190 # define sqlite3Tolower(x) tolower((unsigned char)(x)) |
3018 #endif | 3191 #endif |
| 3192 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
3019 int sqlite3IsIdChar(u8); | 3193 int sqlite3IsIdChar(u8); |
| 3194 #endif |
3020 | 3195 |
3021 /* | 3196 /* |
3022 ** Internal function prototypes | 3197 ** Internal function prototypes |
3023 */ | 3198 */ |
3024 #define sqlite3StrICmp sqlite3_stricmp | 3199 #define sqlite3StrICmp sqlite3_stricmp |
3025 int sqlite3Strlen30(const char*); | 3200 int sqlite3Strlen30(const char*); |
3026 #define sqlite3StrNICmp sqlite3_strnicmp | 3201 #define sqlite3StrNICmp sqlite3_strnicmp |
3027 | 3202 |
3028 int sqlite3MallocInit(void); | 3203 int sqlite3MallocInit(void); |
3029 void sqlite3MallocEnd(void); | 3204 void sqlite3MallocEnd(void); |
3030 void *sqlite3Malloc(u64); | 3205 void *sqlite3Malloc(u64); |
3031 void *sqlite3MallocZero(u64); | 3206 void *sqlite3MallocZero(u64); |
3032 void *sqlite3DbMallocZero(sqlite3*, u64); | 3207 void *sqlite3DbMallocZero(sqlite3*, u64); |
3033 void *sqlite3DbMallocRaw(sqlite3*, u64); | 3208 void *sqlite3DbMallocRaw(sqlite3*, u64); |
3034 char *sqlite3DbStrDup(sqlite3*,const char*); | 3209 char *sqlite3DbStrDup(sqlite3*,const char*); |
3035 char *sqlite3DbStrNDup(sqlite3*,const char*, u64); | 3210 char *sqlite3DbStrNDup(sqlite3*,const char*, u64); |
3036 void *sqlite3Realloc(void*, u64); | 3211 void *sqlite3Realloc(void*, u64); |
3037 void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64); | 3212 void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64); |
3038 void *sqlite3DbRealloc(sqlite3 *, void *, u64); | 3213 void *sqlite3DbRealloc(sqlite3 *, void *, u64); |
3039 void sqlite3DbFree(sqlite3*, void*); | 3214 void sqlite3DbFree(sqlite3*, void*); |
3040 int sqlite3MallocSize(void*); | 3215 int sqlite3MallocSize(void*); |
3041 int sqlite3DbMallocSize(sqlite3*, void*); | 3216 int sqlite3DbMallocSize(sqlite3*, void*); |
3042 void *sqlite3ScratchMalloc(int); | 3217 void *sqlite3ScratchMalloc(int); |
3043 void sqlite3ScratchFree(void*); | 3218 void sqlite3ScratchFree(void*); |
3044 void *sqlite3PageMalloc(int); | 3219 void *sqlite3PageMalloc(int); |
3045 void sqlite3PageFree(void*); | 3220 void sqlite3PageFree(void*); |
3046 void sqlite3MemSetDefault(void); | 3221 void sqlite3MemSetDefault(void); |
| 3222 #ifndef SQLITE_OMIT_BUILTIN_TEST |
3047 void sqlite3BenignMallocHooks(void (*)(void), void (*)(void)); | 3223 void sqlite3BenignMallocHooks(void (*)(void), void (*)(void)); |
| 3224 #endif |
3048 int sqlite3HeapNearlyFull(void); | 3225 int sqlite3HeapNearlyFull(void); |
3049 | 3226 |
3050 /* | 3227 /* |
3051 ** On systems with ample stack space and that support alloca(), make | 3228 ** On systems with ample stack space and that support alloca(), make |
3052 ** use of alloca() to obtain space for large automatic objects. By default, | 3229 ** use of alloca() to obtain space for large automatic objects. By default, |
3053 ** obtain space from malloc(). | 3230 ** obtain space from malloc(). |
3054 ** | 3231 ** |
3055 ** The alloca() routine never returns NULL. This will cause code paths | 3232 ** The alloca() routine never returns NULL. This will cause code paths |
3056 ** that deal with sqlite3StackAlloc() failures to be unreachable. | 3233 ** that deal with sqlite3StackAlloc() failures to be unreachable. |
3057 */ | 3234 */ |
(...skipping 15 matching lines...) Expand all Loading... |
3073 #endif | 3250 #endif |
3074 | 3251 |
3075 | 3252 |
3076 #ifndef SQLITE_MUTEX_OMIT | 3253 #ifndef SQLITE_MUTEX_OMIT |
3077 sqlite3_mutex_methods const *sqlite3DefaultMutex(void); | 3254 sqlite3_mutex_methods const *sqlite3DefaultMutex(void); |
3078 sqlite3_mutex_methods const *sqlite3NoopMutex(void); | 3255 sqlite3_mutex_methods const *sqlite3NoopMutex(void); |
3079 sqlite3_mutex *sqlite3MutexAlloc(int); | 3256 sqlite3_mutex *sqlite3MutexAlloc(int); |
3080 int sqlite3MutexInit(void); | 3257 int sqlite3MutexInit(void); |
3081 int sqlite3MutexEnd(void); | 3258 int sqlite3MutexEnd(void); |
3082 #endif | 3259 #endif |
| 3260 #if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP) |
| 3261 void sqlite3MemoryBarrier(void); |
| 3262 #else |
| 3263 # define sqlite3MemoryBarrier() |
| 3264 #endif |
3083 | 3265 |
3084 int sqlite3StatusValue(int); | 3266 sqlite3_int64 sqlite3StatusValue(int); |
3085 void sqlite3StatusAdd(int, int); | 3267 void sqlite3StatusUp(int, int); |
3086 void sqlite3StatusSet(int, int); | 3268 void sqlite3StatusDown(int, int); |
| 3269 void sqlite3StatusHighwater(int, int); |
| 3270 |
| 3271 /* Access to mutexes used by sqlite3_status() */ |
| 3272 sqlite3_mutex *sqlite3Pcache1Mutex(void); |
| 3273 sqlite3_mutex *sqlite3MallocMutex(void); |
3087 | 3274 |
3088 #ifndef SQLITE_OMIT_FLOATING_POINT | 3275 #ifndef SQLITE_OMIT_FLOATING_POINT |
3089 int sqlite3IsNaN(double); | 3276 int sqlite3IsNaN(double); |
3090 #else | 3277 #else |
3091 # define sqlite3IsNaN(X) 0 | 3278 # define sqlite3IsNaN(X) 0 |
3092 #endif | 3279 #endif |
3093 | 3280 |
3094 /* | 3281 /* |
3095 ** An instance of the following structure holds information about SQL | 3282 ** An instance of the following structure holds information about SQL |
3096 ** functions arguments that are the parameters to the printf() function. | 3283 ** functions arguments that are the parameters to the printf() function. |
3097 */ | 3284 */ |
3098 struct PrintfArguments { | 3285 struct PrintfArguments { |
3099 int nArg; /* Total number of arguments */ | 3286 int nArg; /* Total number of arguments */ |
3100 int nUsed; /* Number of arguments used so far */ | 3287 int nUsed; /* Number of arguments used so far */ |
3101 sqlite3_value **apArg; /* The argument values */ | 3288 sqlite3_value **apArg; /* The argument values */ |
3102 }; | 3289 }; |
3103 | 3290 |
3104 #define SQLITE_PRINTF_INTERNAL 0x01 | 3291 #define SQLITE_PRINTF_INTERNAL 0x01 |
3105 #define SQLITE_PRINTF_SQLFUNC 0x02 | 3292 #define SQLITE_PRINTF_SQLFUNC 0x02 |
3106 void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list); | 3293 void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list); |
3107 void sqlite3XPrintf(StrAccum*, u32, const char*, ...); | 3294 void sqlite3XPrintf(StrAccum*, u32, const char*, ...); |
3108 char *sqlite3MPrintf(sqlite3*,const char*, ...); | 3295 char *sqlite3MPrintf(sqlite3*,const char*, ...); |
3109 char *sqlite3VMPrintf(sqlite3*,const char*, va_list); | 3296 char *sqlite3VMPrintf(sqlite3*,const char*, va_list); |
3110 char *sqlite3MAppendf(sqlite3*,char*,const char*,...); | 3297 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE) |
3111 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) | |
3112 void sqlite3DebugPrintf(const char*, ...); | 3298 void sqlite3DebugPrintf(const char*, ...); |
3113 #endif | 3299 #endif |
3114 #if defined(SQLITE_TEST) | 3300 #if defined(SQLITE_TEST) |
3115 void *sqlite3TestTextToPtr(const char*); | 3301 void *sqlite3TestTextToPtr(const char*); |
3116 #endif | 3302 #endif |
3117 | 3303 |
3118 #if defined(SQLITE_DEBUG) | 3304 #if defined(SQLITE_DEBUG) |
3119 TreeView *sqlite3TreeViewPush(TreeView*,u8); | |
3120 void sqlite3TreeViewPop(TreeView*); | |
3121 void sqlite3TreeViewLine(TreeView*, const char*, ...); | |
3122 void sqlite3TreeViewItem(TreeView*, const char*, u8); | |
3123 void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); | 3305 void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); |
3124 void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); | 3306 void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); |
3125 void sqlite3TreeViewSelect(TreeView*, const Select*, u8); | 3307 void sqlite3TreeViewSelect(TreeView*, const Select*, u8); |
| 3308 void sqlite3TreeViewWith(TreeView*, const With*, u8); |
3126 #endif | 3309 #endif |
3127 | 3310 |
3128 | 3311 |
3129 void sqlite3SetString(char **, sqlite3*, const char*, ...); | 3312 void sqlite3SetString(char **, sqlite3*, const char*); |
3130 void sqlite3ErrorMsg(Parse*, const char*, ...); | 3313 void sqlite3ErrorMsg(Parse*, const char*, ...); |
3131 int sqlite3Dequote(char*); | 3314 int sqlite3Dequote(char*); |
3132 int sqlite3KeywordCode(const unsigned char*, int); | 3315 int sqlite3KeywordCode(const unsigned char*, int); |
3133 int sqlite3RunParser(Parse*, const char*, char **); | 3316 int sqlite3RunParser(Parse*, const char*, char **); |
3134 void sqlite3FinishCoding(Parse*); | 3317 void sqlite3FinishCoding(Parse*); |
3135 int sqlite3GetTempReg(Parse*); | 3318 int sqlite3GetTempReg(Parse*); |
3136 void sqlite3ReleaseTempReg(Parse*,int); | 3319 void sqlite3ReleaseTempReg(Parse*,int); |
3137 int sqlite3GetTempRange(Parse*,int); | 3320 int sqlite3GetTempRange(Parse*,int); |
3138 void sqlite3ReleaseTempRange(Parse*,int,int); | 3321 void sqlite3ReleaseTempRange(Parse*,int,int); |
3139 void sqlite3ClearTempRegCache(Parse*); | 3322 void sqlite3ClearTempRegCache(Parse*); |
3140 Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); | 3323 Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); |
3141 Expr *sqlite3Expr(sqlite3*,int,const char*); | 3324 Expr *sqlite3Expr(sqlite3*,int,const char*); |
3142 void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); | 3325 void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); |
3143 Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); | 3326 Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); |
3144 Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); | 3327 Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); |
3145 Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); | 3328 Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); |
3146 void sqlite3ExprAssignVarNumber(Parse*, Expr*); | 3329 void sqlite3ExprAssignVarNumber(Parse*, Expr*); |
3147 void sqlite3ExprDelete(sqlite3*, Expr*); | 3330 void sqlite3ExprDelete(sqlite3*, Expr*); |
3148 ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); | 3331 ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 3332 void sqlite3ExprListSetSortOrder(ExprList*,int); |
3149 void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); | 3333 void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
3150 void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*); | 3334 void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*); |
3151 void sqlite3ExprListDelete(sqlite3*, ExprList*); | 3335 void sqlite3ExprListDelete(sqlite3*, ExprList*); |
| 3336 u32 sqlite3ExprListFlags(const ExprList*); |
3152 int sqlite3Init(sqlite3*, char**); | 3337 int sqlite3Init(sqlite3*, char**); |
3153 int sqlite3InitCallback(void*, int, char**, char**); | 3338 int sqlite3InitCallback(void*, int, char**, char**); |
3154 void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); | 3339 void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); |
3155 void sqlite3ResetAllSchemasOfConnection(sqlite3*); | 3340 void sqlite3ResetAllSchemasOfConnection(sqlite3*); |
3156 void sqlite3ResetOneSchema(sqlite3*,int); | 3341 void sqlite3ResetOneSchema(sqlite3*,int); |
3157 void sqlite3CollapseDatabaseArray(sqlite3*); | 3342 void sqlite3CollapseDatabaseArray(sqlite3*); |
3158 void sqlite3BeginParse(Parse*,int); | 3343 void sqlite3BeginParse(Parse*,int); |
3159 void sqlite3CommitInternalChanges(sqlite3*); | 3344 void sqlite3CommitInternalChanges(sqlite3*); |
| 3345 void sqlite3DeleteColumnNames(sqlite3*,Table*); |
| 3346 int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
3160 Table *sqlite3ResultSetOfSelect(Parse*,Select*); | 3347 Table *sqlite3ResultSetOfSelect(Parse*,Select*); |
3161 void sqlite3OpenMasterTable(Parse *, int); | 3348 void sqlite3OpenMasterTable(Parse *, int); |
3162 Index *sqlite3PrimaryKeyIndex(Table*); | 3349 Index *sqlite3PrimaryKeyIndex(Table*); |
3163 i16 sqlite3ColumnOfIndex(Index*, i16); | 3350 i16 sqlite3ColumnOfIndex(Index*, i16); |
3164 void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); | 3351 void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); |
| 3352 #if SQLITE_ENABLE_HIDDEN_COLUMNS |
| 3353 void sqlite3ColumnPropertiesFromName(Table*, Column*); |
| 3354 #else |
| 3355 # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ |
| 3356 #endif |
3165 void sqlite3AddColumn(Parse*,Token*); | 3357 void sqlite3AddColumn(Parse*,Token*); |
3166 void sqlite3AddNotNull(Parse*, int); | 3358 void sqlite3AddNotNull(Parse*, int); |
3167 void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); | 3359 void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); |
3168 void sqlite3AddCheckConstraint(Parse*, Expr*); | 3360 void sqlite3AddCheckConstraint(Parse*, Expr*); |
3169 void sqlite3AddColumnType(Parse*,Token*); | 3361 void sqlite3AddColumnType(Parse*,Token*); |
3170 void sqlite3AddDefaultValue(Parse*,ExprSpan*); | 3362 void sqlite3AddDefaultValue(Parse*,ExprSpan*); |
3171 void sqlite3AddCollateType(Parse*, Token*); | 3363 void sqlite3AddCollateType(Parse*, Token*); |
3172 void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); | 3364 void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); |
3173 int sqlite3ParseUri(const char*,const char*,unsigned int*, | 3365 int sqlite3ParseUri(const char*,const char*,unsigned int*, |
3174 sqlite3_vfs**,char**,char **); | 3366 sqlite3_vfs**,char**,char **); |
3175 Btree *sqlite3DbNameToBtree(sqlite3*,const char*); | 3367 Btree *sqlite3DbNameToBtree(sqlite3*,const char*); |
3176 int sqlite3CodeOnce(Parse *); | 3368 int sqlite3CodeOnce(Parse *); |
3177 | 3369 |
3178 #ifdef SQLITE_OMIT_BUILTIN_TEST | 3370 #ifdef SQLITE_OMIT_BUILTIN_TEST |
3179 # define sqlite3FaultSim(X) SQLITE_OK | 3371 # define sqlite3FaultSim(X) SQLITE_OK |
3180 #else | 3372 #else |
3181 int sqlite3FaultSim(int); | 3373 int sqlite3FaultSim(int); |
3182 #endif | 3374 #endif |
3183 | 3375 |
3184 Bitvec *sqlite3BitvecCreate(u32); | 3376 Bitvec *sqlite3BitvecCreate(u32); |
3185 int sqlite3BitvecTest(Bitvec*, u32); | 3377 int sqlite3BitvecTest(Bitvec*, u32); |
| 3378 int sqlite3BitvecTestNotNull(Bitvec*, u32); |
3186 int sqlite3BitvecSet(Bitvec*, u32); | 3379 int sqlite3BitvecSet(Bitvec*, u32); |
3187 void sqlite3BitvecClear(Bitvec*, u32, void*); | 3380 void sqlite3BitvecClear(Bitvec*, u32, void*); |
3188 void sqlite3BitvecDestroy(Bitvec*); | 3381 void sqlite3BitvecDestroy(Bitvec*); |
3189 u32 sqlite3BitvecSize(Bitvec*); | 3382 u32 sqlite3BitvecSize(Bitvec*); |
| 3383 #ifndef SQLITE_OMIT_BUILTIN_TEST |
3190 int sqlite3BitvecBuiltinTest(int,int*); | 3384 int sqlite3BitvecBuiltinTest(int,int*); |
| 3385 #endif |
3191 | 3386 |
3192 RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); | 3387 RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); |
3193 void sqlite3RowSetClear(RowSet*); | 3388 void sqlite3RowSetClear(RowSet*); |
3194 void sqlite3RowSetInsert(RowSet*, i64); | 3389 void sqlite3RowSetInsert(RowSet*, i64); |
3195 int sqlite3RowSetTest(RowSet*, int iBatch, i64); | 3390 int sqlite3RowSetTest(RowSet*, int iBatch, i64); |
3196 int sqlite3RowSetNext(RowSet*, i64*); | 3391 int sqlite3RowSetNext(RowSet*, i64*); |
3197 | 3392 |
3198 void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); | 3393 void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int); |
3199 | 3394 |
3200 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) | 3395 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
3201 int sqlite3ViewGetColumnNames(Parse*,Table*); | 3396 int sqlite3ViewGetColumnNames(Parse*,Table*); |
3202 #else | 3397 #else |
3203 # define sqlite3ViewGetColumnNames(A,B) 0 | 3398 # define sqlite3ViewGetColumnNames(A,B) 0 |
3204 #endif | 3399 #endif |
3205 | 3400 |
3206 #if SQLITE_MAX_ATTACHED>30 | 3401 #if SQLITE_MAX_ATTACHED>30 |
3207 int sqlite3DbMaskAllZero(yDbMask); | 3402 int sqlite3DbMaskAllZero(yDbMask); |
3208 #endif | 3403 #endif |
3209 void sqlite3DropTable(Parse*, SrcList*, int, int); | 3404 void sqlite3DropTable(Parse*, SrcList*, int, int); |
3210 void sqlite3CodeDropTable(Parse*, Table*, int, int); | 3405 void sqlite3CodeDropTable(Parse*, Table*, int, int); |
3211 void sqlite3DeleteTable(sqlite3*, Table*); | 3406 void sqlite3DeleteTable(sqlite3*, Table*); |
3212 #ifndef SQLITE_OMIT_AUTOINCREMENT | 3407 #ifndef SQLITE_OMIT_AUTOINCREMENT |
3213 void sqlite3AutoincrementBegin(Parse *pParse); | 3408 void sqlite3AutoincrementBegin(Parse *pParse); |
3214 void sqlite3AutoincrementEnd(Parse *pParse); | 3409 void sqlite3AutoincrementEnd(Parse *pParse); |
3215 #else | 3410 #else |
3216 # define sqlite3AutoincrementBegin(X) | 3411 # define sqlite3AutoincrementBegin(X) |
3217 # define sqlite3AutoincrementEnd(X) | 3412 # define sqlite3AutoincrementEnd(X) |
3218 #endif | 3413 #endif |
3219 void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int); | 3414 void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int); |
3220 void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); | 3415 void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); |
3221 IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*); | 3416 IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*); |
3222 int sqlite3IdListIndex(IdList*,const char*); | 3417 int sqlite3IdListIndex(IdList*,const char*); |
3223 SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); | 3418 SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); |
3224 SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); | 3419 SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); |
3225 SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, | 3420 SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, |
3226 Token*, Select*, Expr*, IdList*); | 3421 Token*, Select*, Expr*, IdList*); |
3227 void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); | 3422 void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); |
| 3423 void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*); |
3228 int sqlite3IndexedByLookup(Parse *, struct SrcList_item *); | 3424 int sqlite3IndexedByLookup(Parse *, struct SrcList_item *); |
3229 void sqlite3SrcListShiftJoinType(SrcList*); | 3425 void sqlite3SrcListShiftJoinType(SrcList*); |
3230 void sqlite3SrcListAssignCursors(Parse*, SrcList*); | 3426 void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
3231 void sqlite3IdListDelete(sqlite3*, IdList*); | 3427 void sqlite3IdListDelete(sqlite3*, IdList*); |
3232 void sqlite3SrcListDelete(sqlite3*, SrcList*); | 3428 void sqlite3SrcListDelete(sqlite3*, SrcList*); |
3233 Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); | 3429 Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); |
3234 Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, | 3430 Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
3235 Expr*, int, int); | 3431 Expr*, int, int); |
3236 void sqlite3DropIndex(Parse*, SrcList*, int); | 3432 void sqlite3DropIndex(Parse*, SrcList*, int); |
3237 int sqlite3Select(Parse*, Select*, SelectDest*); | 3433 int sqlite3Select(Parse*, Select*, SelectDest*); |
(...skipping 10 matching lines...) Expand all Loading... |
3248 void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); | 3444 void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); |
3249 WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int); | 3445 WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int); |
3250 void sqlite3WhereEnd(WhereInfo*); | 3446 void sqlite3WhereEnd(WhereInfo*); |
3251 u64 sqlite3WhereOutputRowCount(WhereInfo*); | 3447 u64 sqlite3WhereOutputRowCount(WhereInfo*); |
3252 int sqlite3WhereIsDistinct(WhereInfo*); | 3448 int sqlite3WhereIsDistinct(WhereInfo*); |
3253 int sqlite3WhereIsOrdered(WhereInfo*); | 3449 int sqlite3WhereIsOrdered(WhereInfo*); |
3254 int sqlite3WhereIsSorted(WhereInfo*); | 3450 int sqlite3WhereIsSorted(WhereInfo*); |
3255 int sqlite3WhereContinueLabel(WhereInfo*); | 3451 int sqlite3WhereContinueLabel(WhereInfo*); |
3256 int sqlite3WhereBreakLabel(WhereInfo*); | 3452 int sqlite3WhereBreakLabel(WhereInfo*); |
3257 int sqlite3WhereOkOnePass(WhereInfo*, int*); | 3453 int sqlite3WhereOkOnePass(WhereInfo*, int*); |
| 3454 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */ |
| 3455 #define ONEPASS_SINGLE 1 /* ONEPASS valid for a single row update */ |
| 3456 #define ONEPASS_MULTI 2 /* ONEPASS is valid for multiple rows */ |
| 3457 void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); |
3258 int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); | 3458 int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 3459 void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int); |
3259 void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); | 3460 void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
3260 void sqlite3ExprCodeMove(Parse*, int, int, int); | 3461 void sqlite3ExprCodeMove(Parse*, int, int, int); |
3261 void sqlite3ExprCacheStore(Parse*, int, int, int); | 3462 void sqlite3ExprCacheStore(Parse*, int, int, int); |
3262 void sqlite3ExprCachePush(Parse*); | 3463 void sqlite3ExprCachePush(Parse*); |
3263 void sqlite3ExprCachePop(Parse*); | 3464 void sqlite3ExprCachePop(Parse*); |
3264 void sqlite3ExprCacheRemove(Parse*, int, int); | 3465 void sqlite3ExprCacheRemove(Parse*, int, int); |
3265 void sqlite3ExprCacheClear(Parse*); | 3466 void sqlite3ExprCacheClear(Parse*); |
3266 void sqlite3ExprCacheAffinityChange(Parse*, int, int); | 3467 void sqlite3ExprCacheAffinityChange(Parse*, int, int); |
3267 void sqlite3ExprCode(Parse*, Expr*, int); | 3468 void sqlite3ExprCode(Parse*, Expr*, int); |
| 3469 void sqlite3ExprCodeCopy(Parse*, Expr*, int); |
3268 void sqlite3ExprCodeFactorable(Parse*, Expr*, int); | 3470 void sqlite3ExprCodeFactorable(Parse*, Expr*, int); |
3269 void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8); | 3471 void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8); |
3270 int sqlite3ExprCodeTemp(Parse*, Expr*, int*); | 3472 int sqlite3ExprCodeTemp(Parse*, Expr*, int*); |
3271 int sqlite3ExprCodeTarget(Parse*, Expr*, int); | 3473 int sqlite3ExprCodeTarget(Parse*, Expr*, int); |
3272 void sqlite3ExprCodeAndCache(Parse*, Expr*, int); | 3474 void sqlite3ExprCodeAndCache(Parse*, Expr*, int); |
3273 int sqlite3ExprCodeExprList(Parse*, ExprList*, int, u8); | 3475 int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8); |
3274 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */ | 3476 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */ |
3275 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */ | 3477 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */ |
| 3478 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */ |
3276 void sqlite3ExprIfTrue(Parse*, Expr*, int, int); | 3479 void sqlite3ExprIfTrue(Parse*, Expr*, int, int); |
3277 void sqlite3ExprIfFalse(Parse*, Expr*, int, int); | 3480 void sqlite3ExprIfFalse(Parse*, Expr*, int, int); |
| 3481 void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int); |
3278 Table *sqlite3FindTable(sqlite3*,const char*, const char*); | 3482 Table *sqlite3FindTable(sqlite3*,const char*, const char*); |
3279 Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*); | 3483 Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*); |
3280 Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *); | 3484 Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *); |
3281 Index *sqlite3FindIndex(sqlite3*,const char*, const char*); | 3485 Index *sqlite3FindIndex(sqlite3*,const char*, const char*); |
3282 void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); | 3486 void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
3283 void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); | 3487 void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
3284 void sqlite3Vacuum(Parse*); | 3488 void sqlite3Vacuum(Parse*); |
3285 int sqlite3RunVacuum(char**, sqlite3*); | 3489 int sqlite3RunVacuum(char**, sqlite3*); |
3286 char *sqlite3NameFromToken(sqlite3*, Token*); | 3490 char *sqlite3NameFromToken(sqlite3*, Token*); |
3287 int sqlite3ExprCompare(Expr*, Expr*, int); | 3491 int sqlite3ExprCompare(Expr*, Expr*, int); |
3288 int sqlite3ExprListCompare(ExprList*, ExprList*, int); | 3492 int sqlite3ExprListCompare(ExprList*, ExprList*, int); |
3289 int sqlite3ExprImpliesExpr(Expr*, Expr*, int); | 3493 int sqlite3ExprImpliesExpr(Expr*, Expr*, int); |
3290 void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); | 3494 void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
3291 void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); | 3495 void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
3292 int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); | 3496 int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); |
3293 Vdbe *sqlite3GetVdbe(Parse*); | 3497 Vdbe *sqlite3GetVdbe(Parse*); |
| 3498 #ifndef SQLITE_OMIT_BUILTIN_TEST |
3294 void sqlite3PrngSaveState(void); | 3499 void sqlite3PrngSaveState(void); |
3295 void sqlite3PrngRestoreState(void); | 3500 void sqlite3PrngRestoreState(void); |
| 3501 #endif |
3296 void sqlite3RollbackAll(sqlite3*,int); | 3502 void sqlite3RollbackAll(sqlite3*,int); |
3297 void sqlite3CodeVerifySchema(Parse*, int); | 3503 void sqlite3CodeVerifySchema(Parse*, int); |
3298 void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb); | 3504 void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb); |
3299 void sqlite3BeginTransaction(Parse*, int); | 3505 void sqlite3BeginTransaction(Parse*, int); |
3300 void sqlite3CommitTransaction(Parse*); | 3506 void sqlite3CommitTransaction(Parse*); |
3301 void sqlite3RollbackTransaction(Parse*); | 3507 void sqlite3RollbackTransaction(Parse*); |
3302 void sqlite3Savepoint(Parse*, int, Token*); | 3508 void sqlite3Savepoint(Parse*, int, Token*); |
3303 void sqlite3CloseSavepoints(sqlite3 *); | 3509 void sqlite3CloseSavepoints(sqlite3 *); |
3304 void sqlite3LeaveMutexAndCloseZombie(sqlite3*); | 3510 void sqlite3LeaveMutexAndCloseZombie(sqlite3*); |
3305 int sqlite3ExprIsConstant(Expr*); | 3511 int sqlite3ExprIsConstant(Expr*); |
3306 int sqlite3ExprIsConstantNotJoin(Expr*); | 3512 int sqlite3ExprIsConstantNotJoin(Expr*); |
3307 int sqlite3ExprIsConstantOrFunction(Expr*, u8); | 3513 int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 3514 int sqlite3ExprIsTableConstant(Expr*,int); |
| 3515 #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 3516 int sqlite3ExprContainsSubquery(Expr*); |
| 3517 #endif |
3308 int sqlite3ExprIsInteger(Expr*, int*); | 3518 int sqlite3ExprIsInteger(Expr*, int*); |
3309 int sqlite3ExprCanBeNull(const Expr*); | 3519 int sqlite3ExprCanBeNull(const Expr*); |
3310 int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); | 3520 int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
3311 int sqlite3IsRowid(const char*); | 3521 int sqlite3IsRowid(const char*); |
3312 void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8); | 3522 void sqlite3GenerateRowDelete( |
3313 void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*); | 3523 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 3524 void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
3314 int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); | 3525 int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); |
3315 void sqlite3ResolvePartIdxLabel(Parse*,int); | 3526 void sqlite3ResolvePartIdxLabel(Parse*,int); |
3316 void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, | 3527 void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, |
3317 u8,u8,int,int*); | 3528 u8,u8,int,int*); |
3318 void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int); | 3529 void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int); |
3319 int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, u8*, int*, int*); | 3530 int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*); |
3320 void sqlite3BeginWriteOperation(Parse*, int, int); | 3531 void sqlite3BeginWriteOperation(Parse*, int, int); |
3321 void sqlite3MultiWrite(Parse*); | 3532 void sqlite3MultiWrite(Parse*); |
3322 void sqlite3MayAbort(Parse*); | 3533 void sqlite3MayAbort(Parse*); |
3323 void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8); | 3534 void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8); |
3324 void sqlite3UniqueConstraint(Parse*, int, Index*); | 3535 void sqlite3UniqueConstraint(Parse*, int, Index*); |
3325 void sqlite3RowidConstraint(Parse*, int, Table*); | 3536 void sqlite3RowidConstraint(Parse*, int, Table*); |
3326 Expr *sqlite3ExprDup(sqlite3*,Expr*,int); | 3537 Expr *sqlite3ExprDup(sqlite3*,Expr*,int); |
3327 ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); | 3538 ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); |
3328 SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); | 3539 SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); |
3329 IdList *sqlite3IdListDup(sqlite3*,IdList*); | 3540 IdList *sqlite3IdListDup(sqlite3*,IdList*); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3361 void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*); | 3572 void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*); |
3362 TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*); | 3573 TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*); |
3363 TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, | 3574 TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, |
3364 Select*,u8); | 3575 Select*,u8); |
3365 TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); | 3576 TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); |
3366 TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*); | 3577 TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*); |
3367 void sqlite3DeleteTrigger(sqlite3*, Trigger*); | 3578 void sqlite3DeleteTrigger(sqlite3*, Trigger*); |
3368 void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); | 3579 void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); |
3369 u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); | 3580 u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); |
3370 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) | 3581 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) |
| 3582 # define sqlite3IsToplevel(p) ((p)->pToplevel==0) |
3371 #else | 3583 #else |
3372 # define sqlite3TriggersExist(B,C,D,E,F) 0 | 3584 # define sqlite3TriggersExist(B,C,D,E,F) 0 |
3373 # define sqlite3DeleteTrigger(A,B) | 3585 # define sqlite3DeleteTrigger(A,B) |
3374 # define sqlite3DropTriggerPtr(A,B) | 3586 # define sqlite3DropTriggerPtr(A,B) |
3375 # define sqlite3UnlinkAndDeleteTrigger(A,B,C) | 3587 # define sqlite3UnlinkAndDeleteTrigger(A,B,C) |
3376 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) | 3588 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) |
3377 # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F) | 3589 # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F) |
3378 # define sqlite3TriggerList(X, Y) 0 | 3590 # define sqlite3TriggerList(X, Y) 0 |
3379 # define sqlite3ParseToplevel(p) p | 3591 # define sqlite3ParseToplevel(p) p |
| 3592 # define sqlite3IsToplevel(p) 1 |
3380 # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0 | 3593 # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0 |
3381 #endif | 3594 #endif |
3382 | 3595 |
3383 int sqlite3JoinType(Parse*, Token*, Token*, Token*); | 3596 int sqlite3JoinType(Parse*, Token*, Token*, Token*); |
3384 void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); | 3597 void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
3385 void sqlite3DeferForeignKey(Parse*, int); | 3598 void sqlite3DeferForeignKey(Parse*, int); |
3386 #ifndef SQLITE_OMIT_AUTHORIZATION | 3599 #ifndef SQLITE_OMIT_AUTHORIZATION |
3387 void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*); | 3600 void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*); |
3388 int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*); | 3601 int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*); |
3389 void sqlite3AuthContextPush(Parse*, AuthContext*, const char*); | 3602 void sqlite3AuthContextPush(Parse*, AuthContext*, const char*); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3433 */ | 3646 */ |
3434 #define getVarint32(A,B) \ | 3647 #define getVarint32(A,B) \ |
3435 (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B))) | 3648 (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B))) |
3436 #define putVarint32(A,B) \ | 3649 #define putVarint32(A,B) \ |
3437 (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\ | 3650 (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\ |
3438 sqlite3PutVarint((A),(B))) | 3651 sqlite3PutVarint((A),(B))) |
3439 #define getVarint sqlite3GetVarint | 3652 #define getVarint sqlite3GetVarint |
3440 #define putVarint sqlite3PutVarint | 3653 #define putVarint sqlite3PutVarint |
3441 | 3654 |
3442 | 3655 |
3443 const char *sqlite3IndexAffinityStr(Vdbe *, Index *); | 3656 const char *sqlite3IndexAffinityStr(sqlite3*, Index*); |
3444 void sqlite3TableAffinity(Vdbe*, Table*, int); | 3657 void sqlite3TableAffinity(Vdbe*, Table*, int); |
3445 char sqlite3CompareAffinity(Expr *pExpr, char aff2); | 3658 char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
3446 int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); | 3659 int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
3447 char sqlite3ExprAffinity(Expr *pExpr); | 3660 char sqlite3ExprAffinity(Expr *pExpr); |
3448 int sqlite3Atoi64(const char*, i64*, int, u8); | 3661 int sqlite3Atoi64(const char*, i64*, int, u8); |
3449 int sqlite3DecOrHexToI64(const char*, i64*); | 3662 int sqlite3DecOrHexToI64(const char*, i64*); |
3450 void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); | 3663 void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); |
3451 void sqlite3Error(sqlite3*,int); | 3664 void sqlite3Error(sqlite3*,int); |
3452 void *sqlite3HexToBlob(sqlite3*, const char *z, int n); | 3665 void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
3453 u8 sqlite3HexToInt(int h); | 3666 u8 sqlite3HexToInt(int h); |
3454 int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); | 3667 int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
3455 | 3668 |
3456 #if defined(SQLITE_TEST) | 3669 #if defined(SQLITE_NEED_ERR_NAME) |
3457 const char *sqlite3ErrName(int); | 3670 const char *sqlite3ErrName(int); |
3458 #endif | 3671 #endif |
3459 | 3672 |
3460 const char *sqlite3ErrStr(int); | 3673 const char *sqlite3ErrStr(int); |
3461 int sqlite3ReadSchema(Parse *pParse); | 3674 int sqlite3ReadSchema(Parse *pParse); |
3462 CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); | 3675 CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); |
3463 CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); | 3676 CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); |
3464 CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr); | 3677 CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr); |
3465 Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int); | 3678 Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int); |
3466 Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*); | 3679 Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*); |
(...skipping 17 matching lines...) Expand all Loading... |
3484 void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, | 3697 void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, |
3485 void(*)(void*)); | 3698 void(*)(void*)); |
3486 void sqlite3ValueSetNull(sqlite3_value*); | 3699 void sqlite3ValueSetNull(sqlite3_value*); |
3487 void sqlite3ValueFree(sqlite3_value*); | 3700 void sqlite3ValueFree(sqlite3_value*); |
3488 sqlite3_value *sqlite3ValueNew(sqlite3 *); | 3701 sqlite3_value *sqlite3ValueNew(sqlite3 *); |
3489 char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); | 3702 char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
3490 int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); | 3703 int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); |
3491 void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); | 3704 void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
3492 #ifndef SQLITE_AMALGAMATION | 3705 #ifndef SQLITE_AMALGAMATION |
3493 extern const unsigned char sqlite3OpcodeProperty[]; | 3706 extern const unsigned char sqlite3OpcodeProperty[]; |
| 3707 extern const char sqlite3StrBINARY[]; |
3494 extern const unsigned char sqlite3UpperToLower[]; | 3708 extern const unsigned char sqlite3UpperToLower[]; |
3495 extern const unsigned char sqlite3CtypeMap[]; | 3709 extern const unsigned char sqlite3CtypeMap[]; |
3496 extern const Token sqlite3IntTokens[]; | 3710 extern const Token sqlite3IntTokens[]; |
3497 extern SQLITE_WSD struct Sqlite3Config sqlite3Config; | 3711 extern SQLITE_WSD struct Sqlite3Config sqlite3Config; |
3498 extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; | 3712 extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; |
3499 #ifndef SQLITE_OMIT_WSD | 3713 #ifndef SQLITE_OMIT_WSD |
3500 extern int sqlite3PendingByte; | 3714 extern int sqlite3PendingByte; |
3501 #endif | 3715 #endif |
3502 #endif | 3716 #endif |
3503 void sqlite3RootPageMoved(sqlite3*, int, int, int); | 3717 void sqlite3RootPageMoved(sqlite3*, int, int, int); |
3504 void sqlite3Reindex(Parse*, Token*, Token*); | 3718 void sqlite3Reindex(Parse*, Token*, Token*); |
3505 void sqlite3AlterFunctions(void); | 3719 void sqlite3AlterFunctions(void); |
3506 void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); | 3720 void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); |
3507 int sqlite3GetToken(const unsigned char *, int *); | 3721 int sqlite3GetToken(const unsigned char *, int *); |
3508 void sqlite3NestedParse(Parse*, const char*, ...); | 3722 void sqlite3NestedParse(Parse*, const char*, ...); |
3509 void sqlite3ExpirePreparedStatements(sqlite3*); | 3723 void sqlite3ExpirePreparedStatements(sqlite3*); |
3510 int sqlite3CodeSubselect(Parse *, Expr *, int, int); | 3724 int sqlite3CodeSubselect(Parse *, Expr *, int, int); |
3511 void sqlite3SelectPrep(Parse*, Select*, NameContext*); | 3725 void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 3726 void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
3512 int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); | 3727 int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); |
3513 int sqlite3ResolveExprNames(NameContext*, Expr*); | 3728 int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 3729 int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
3514 void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); | 3730 void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); |
3515 void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); | 3731 void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); |
3516 int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); | 3732 int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); |
3517 void sqlite3ColumnDefault(Vdbe *, Table *, int, int); | 3733 void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
3518 void sqlite3AlterFinishAddColumn(Parse *, Token *); | 3734 void sqlite3AlterFinishAddColumn(Parse *, Token *); |
3519 void sqlite3AlterBeginAddColumn(Parse *, SrcList *); | 3735 void sqlite3AlterBeginAddColumn(Parse *, SrcList *); |
3520 CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); | 3736 CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); |
3521 char sqlite3AffinityType(const char*, u8*); | 3737 char sqlite3AffinityType(const char*, u8*); |
3522 void sqlite3Analyze(Parse*, Token*, Token*); | 3738 void sqlite3Analyze(Parse*, Token*, Token*); |
3523 int sqlite3InvokeBusyHandler(BusyHandler*); | 3739 int sqlite3InvokeBusyHandler(BusyHandler*); |
(...skipping 16 matching lines...) Expand all Loading... |
3540 int sqlite3KeyInfoIsWriteable(KeyInfo*); | 3756 int sqlite3KeyInfoIsWriteable(KeyInfo*); |
3541 #endif | 3757 #endif |
3542 int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, | 3758 int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, |
3543 void (*)(sqlite3_context*,int,sqlite3_value **), | 3759 void (*)(sqlite3_context*,int,sqlite3_value **), |
3544 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*), | 3760 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*), |
3545 FuncDestructor *pDestructor | 3761 FuncDestructor *pDestructor |
3546 ); | 3762 ); |
3547 int sqlite3ApiExit(sqlite3 *db, int); | 3763 int sqlite3ApiExit(sqlite3 *db, int); |
3548 int sqlite3OpenTempDatabase(Parse *); | 3764 int sqlite3OpenTempDatabase(Parse *); |
3549 | 3765 |
3550 void sqlite3StrAccumInit(StrAccum*, char*, int, int); | 3766 void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
3551 void sqlite3StrAccumAppend(StrAccum*,const char*,int); | 3767 void sqlite3StrAccumAppend(StrAccum*,const char*,int); |
3552 void sqlite3StrAccumAppendAll(StrAccum*,const char*); | 3768 void sqlite3StrAccumAppendAll(StrAccum*,const char*); |
3553 void sqlite3AppendChar(StrAccum*,int,char); | 3769 void sqlite3AppendChar(StrAccum*,int,char); |
3554 char *sqlite3StrAccumFinish(StrAccum*); | 3770 char *sqlite3StrAccumFinish(StrAccum*); |
3555 void sqlite3StrAccumReset(StrAccum*); | 3771 void sqlite3StrAccumReset(StrAccum*); |
3556 void sqlite3SelectDestInit(SelectDest*,int,int); | 3772 void sqlite3SelectDestInit(SelectDest*,int,int); |
3557 Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); | 3773 Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); |
3558 | 3774 |
3559 void sqlite3BackupRestart(sqlite3_backup *); | 3775 void sqlite3BackupRestart(sqlite3_backup *); |
3560 void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *); | 3776 void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 int sqlite3VtabRollback(sqlite3 *db); | 3828 int sqlite3VtabRollback(sqlite3 *db); |
3613 int sqlite3VtabCommit(sqlite3 *db); | 3829 int sqlite3VtabCommit(sqlite3 *db); |
3614 void sqlite3VtabLock(VTable *); | 3830 void sqlite3VtabLock(VTable *); |
3615 void sqlite3VtabUnlock(VTable *); | 3831 void sqlite3VtabUnlock(VTable *); |
3616 void sqlite3VtabUnlockList(sqlite3*); | 3832 void sqlite3VtabUnlockList(sqlite3*); |
3617 int sqlite3VtabSavepoint(sqlite3 *, int, int); | 3833 int sqlite3VtabSavepoint(sqlite3 *, int, int); |
3618 void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*); | 3834 void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*); |
3619 VTable *sqlite3GetVTable(sqlite3*, Table*); | 3835 VTable *sqlite3GetVTable(sqlite3*, Table*); |
3620 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) | 3836 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) |
3621 #endif | 3837 #endif |
| 3838 int sqlite3VtabEponymousTableInit(Parse*,Module*); |
| 3839 void sqlite3VtabEponymousTableClear(sqlite3*,Module*); |
3622 void sqlite3VtabMakeWritable(Parse*,Table*); | 3840 void sqlite3VtabMakeWritable(Parse*,Table*); |
3623 void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int); | 3841 void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int); |
3624 void sqlite3VtabFinishParse(Parse*, Token*); | 3842 void sqlite3VtabFinishParse(Parse*, Token*); |
3625 void sqlite3VtabArgInit(Parse*); | 3843 void sqlite3VtabArgInit(Parse*); |
3626 void sqlite3VtabArgExtend(Parse*, Token*); | 3844 void sqlite3VtabArgExtend(Parse*, Token*); |
3627 int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **); | 3845 int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **); |
3628 int sqlite3VtabCallConnect(Parse*, Table*); | 3846 int sqlite3VtabCallConnect(Parse*, Table*); |
3629 int sqlite3VtabCallDestroy(sqlite3*, int, const char *); | 3847 int sqlite3VtabCallDestroy(sqlite3*, int, const char *); |
3630 int sqlite3VtabBegin(sqlite3 *, VTable *); | 3848 int sqlite3VtabBegin(sqlite3 *, VTable *); |
3631 FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*); | 3849 FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3724 int sqlite3JournalExists(sqlite3_file *p); | 3942 int sqlite3JournalExists(sqlite3_file *p); |
3725 #else | 3943 #else |
3726 #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) | 3944 #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) |
3727 #define sqlite3JournalExists(p) 1 | 3945 #define sqlite3JournalExists(p) 1 |
3728 #endif | 3946 #endif |
3729 | 3947 |
3730 void sqlite3MemJournalOpen(sqlite3_file *); | 3948 void sqlite3MemJournalOpen(sqlite3_file *); |
3731 int sqlite3MemJournalSize(void); | 3949 int sqlite3MemJournalSize(void); |
3732 int sqlite3IsMemJournal(sqlite3_file *); | 3950 int sqlite3IsMemJournal(sqlite3_file *); |
3733 | 3951 |
| 3952 void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p); |
3734 #if SQLITE_MAX_EXPR_DEPTH>0 | 3953 #if SQLITE_MAX_EXPR_DEPTH>0 |
3735 void sqlite3ExprSetHeight(Parse *pParse, Expr *p); | |
3736 int sqlite3SelectExprHeight(Select *); | 3954 int sqlite3SelectExprHeight(Select *); |
3737 int sqlite3ExprCheckHeight(Parse*, int); | 3955 int sqlite3ExprCheckHeight(Parse*, int); |
3738 #else | 3956 #else |
3739 #define sqlite3ExprSetHeight(x,y) | |
3740 #define sqlite3SelectExprHeight(x) 0 | 3957 #define sqlite3SelectExprHeight(x) 0 |
3741 #define sqlite3ExprCheckHeight(x,y) | 3958 #define sqlite3ExprCheckHeight(x,y) |
3742 #endif | 3959 #endif |
3743 | 3960 |
3744 u32 sqlite3Get4byte(const u8*); | 3961 u32 sqlite3Get4byte(const u8*); |
3745 void sqlite3Put4byte(u8*, u32); | 3962 void sqlite3Put4byte(u8*, u32); |
3746 | 3963 |
3747 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY | 3964 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
3748 void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *); | 3965 void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *); |
3749 void sqlite3ConnectionUnlocked(sqlite3 *db); | 3966 void sqlite3ConnectionUnlocked(sqlite3 *db); |
3750 void sqlite3ConnectionClosed(sqlite3 *db); | 3967 void sqlite3ConnectionClosed(sqlite3 *db); |
3751 #else | 3968 #else |
3752 #define sqlite3ConnectionBlocked(x,y) | 3969 #define sqlite3ConnectionBlocked(x,y) |
3753 #define sqlite3ConnectionUnlocked(x) | 3970 #define sqlite3ConnectionUnlocked(x) |
3754 #define sqlite3ConnectionClosed(x) | 3971 #define sqlite3ConnectionClosed(x) |
3755 #endif | 3972 #endif |
3756 | 3973 |
3757 #ifdef SQLITE_DEBUG | 3974 #ifdef SQLITE_DEBUG |
3758 void sqlite3ParserTrace(FILE*, char *); | 3975 void sqlite3ParserTrace(FILE*, char *); |
3759 #endif | 3976 #endif |
3760 | 3977 |
3761 /* | 3978 /* |
3762 ** If the SQLITE_ENABLE IOTRACE exists then the global variable | 3979 ** If the SQLITE_ENABLE IOTRACE exists then the global variable |
3763 ** sqlite3IoTrace is a pointer to a printf-like routine used to | 3980 ** sqlite3IoTrace is a pointer to a printf-like routine used to |
3764 ** print I/O tracing messages. | 3981 ** print I/O tracing messages. |
3765 */ | 3982 */ |
3766 #ifdef SQLITE_ENABLE_IOTRACE | 3983 #ifdef SQLITE_ENABLE_IOTRACE |
3767 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } | 3984 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } |
3768 void sqlite3VdbeIOTraceSql(Vdbe*); | 3985 void sqlite3VdbeIOTraceSql(Vdbe*); |
3769 SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); | 3986 SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...); |
3770 #else | 3987 #else |
3771 # define IOTRACE(A) | 3988 # define IOTRACE(A) |
3772 # define sqlite3VdbeIOTraceSql(X) | 3989 # define sqlite3VdbeIOTraceSql(X) |
3773 #endif | 3990 #endif |
3774 | 3991 |
3775 /* | 3992 /* |
3776 ** These routines are available for the mem2.c debugging memory allocator | 3993 ** These routines are available for the mem2.c debugging memory allocator |
3777 ** only. They are used to verify that different "types" of memory | 3994 ** only. They are used to verify that different "types" of memory |
3778 ** allocations are properly tracked by the system. | 3995 ** allocations are properly tracked by the system. |
3779 ** | 3996 ** |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3815 #define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ | 4032 #define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ |
3816 | 4033 |
3817 /* | 4034 /* |
3818 ** Threading interface | 4035 ** Threading interface |
3819 */ | 4036 */ |
3820 #if SQLITE_MAX_WORKER_THREADS>0 | 4037 #if SQLITE_MAX_WORKER_THREADS>0 |
3821 int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*); | 4038 int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*); |
3822 int sqlite3ThreadJoin(SQLiteThread*, void**); | 4039 int sqlite3ThreadJoin(SQLiteThread*, void**); |
3823 #endif | 4040 #endif |
3824 | 4041 |
| 4042 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST) |
| 4043 int sqlite3DbstatRegister(sqlite3*); |
| 4044 #endif |
| 4045 |
3825 #endif /* _SQLITEINT_H_ */ | 4046 #endif /* _SQLITEINT_H_ */ |
OLD | NEW |