xref: /sqlite-3.40.0/src/global.c (revision 705d7be6)
140257ffdSdrh /*
240257ffdSdrh ** 2008 June 13
340257ffdSdrh **
440257ffdSdrh ** The author disclaims copyright to this source code.  In place of
540257ffdSdrh ** a legal notice, here is a blessing:
640257ffdSdrh **
740257ffdSdrh **    May you do good and not evil.
840257ffdSdrh **    May you find forgiveness for yourself and forgive others.
940257ffdSdrh **    May you share freely, never taking more than you give.
1040257ffdSdrh **
1140257ffdSdrh *************************************************************************
1240257ffdSdrh **
1360ec914cSpeter.d.reid ** This file contains definitions of global variables and constants.
1440257ffdSdrh */
1540257ffdSdrh #include "sqliteInt.h"
1640257ffdSdrh 
1740257ffdSdrh /* An array to map all upper-case characters into their corresponding
1840257ffdSdrh ** lower-case character.
1940257ffdSdrh **
2040257ffdSdrh ** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not
2140257ffdSdrh ** handle case conversions for the UTF character set since the tables
2240257ffdSdrh ** involved are nearly as big or bigger than SQLite itself.
2340257ffdSdrh */
2440257ffdSdrh const unsigned char sqlite3UpperToLower[] = {
2540257ffdSdrh #ifdef SQLITE_ASCII
2640257ffdSdrh       0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
2740257ffdSdrh      18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
2840257ffdSdrh      36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
2940257ffdSdrh      54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,
3040257ffdSdrh     104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,
3140257ffdSdrh     122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,
3240257ffdSdrh     108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
3340257ffdSdrh     126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
3440257ffdSdrh     144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
3540257ffdSdrh     162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
3640257ffdSdrh     180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,
3740257ffdSdrh     198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
3840257ffdSdrh     216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,
3940257ffdSdrh     234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
401af3fd56Sdrh     252,253,254,255,
4140257ffdSdrh #endif
4240257ffdSdrh #ifdef SQLITE_EBCDIC
4340257ffdSdrh       0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */
4440257ffdSdrh      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */
4540257ffdSdrh      32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */
4640257ffdSdrh      48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
4740257ffdSdrh      64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
4840257ffdSdrh      80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
49db222adfSdrh      96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */
50db222adfSdrh     112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */
5140257ffdSdrh     128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
52db222adfSdrh     144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */
5340257ffdSdrh     160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
5440257ffdSdrh     176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
5540257ffdSdrh     192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
5640257ffdSdrh     208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
57db222adfSdrh     224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */
58db222adfSdrh     240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */
5940257ffdSdrh #endif
601af3fd56Sdrh /* All of the upper-to-lower conversion data is above.  The following
611af3fd56Sdrh ** 18 integers are completely unrelated.  They are appended to the
621af3fd56Sdrh ** sqlite3UpperToLower[] array to avoid UBSAN warnings.  Here's what is
631af3fd56Sdrh ** going on:
641af3fd56Sdrh **
651af3fd56Sdrh ** The SQL comparison operators (<>, =, >, <=, <, and >=) are implemented
661af3fd56Sdrh ** by invoking sqlite3MemCompare(A,B) which compares values A and B and
671af3fd56Sdrh ** returns negative, zero, or positive if A is less then, equal to, or
681af3fd56Sdrh ** greater than B, respectively.  Then the true false results is found by
691af3fd56Sdrh ** consulting sqlite3aLTb[opcode], sqlite3aEQb[opcode], or
701af3fd56Sdrh ** sqlite3aGTb[opcode] depending on whether the result of compare(A,B)
711af3fd56Sdrh ** is negative, zero, or positive, where opcode is the specific opcode.
721af3fd56Sdrh ** The only works because the comparison opcodes are consecutive and in
731af3fd56Sdrh ** this order: NE EQ GT LE LT GE.  Various assert()s throughout the code
741af3fd56Sdrh ** ensure that is the case.
751af3fd56Sdrh **
761af3fd56Sdrh ** These elements must be appended to another array.  Otherwise the
771af3fd56Sdrh ** index (here shown as [256-OP_Ne]) would be out-of-bounds and thus
781af3fd56Sdrh ** be undefined behavior.  That's goofy, but the C-standards people thought
791af3fd56Sdrh ** it was a good idea, so here we are.
801af3fd56Sdrh */
811af3fd56Sdrh /* NE  EQ  GT  LE  LT  GE  */
821af3fd56Sdrh    1,  0,  0,  1,  1,  0,  /* aLTb[]: Use when compare(A,B) less than zero */
831af3fd56Sdrh    0,  1,  0,  1,  0,  1,  /* aEQb[]: Use when compare(A,B) equals zero */
841af3fd56Sdrh    1,  0,  1,  0,  0,  1   /* aGTb[]: Use when compare(A,B) greater than zero*/
8540257ffdSdrh };
861af3fd56Sdrh const unsigned char *sqlite3aLTb = &sqlite3UpperToLower[256-OP_Ne];
871af3fd56Sdrh const unsigned char *sqlite3aEQb = &sqlite3UpperToLower[256+6-OP_Ne];
881af3fd56Sdrh const unsigned char *sqlite3aGTb = &sqlite3UpperToLower[256+12-OP_Ne];
8940257ffdSdrh 
9040257ffdSdrh /*
9178ca0e7eSdanielk1977 ** The following 256 byte lookup table is used to support SQLites built-in
9278ca0e7eSdanielk1977 ** equivalents to the following standard library functions:
9378ca0e7eSdanielk1977 **
9478ca0e7eSdanielk1977 **   isspace()                        0x01
95dc86e2b2Sdrh **   isalpha()                        0x02
9678ca0e7eSdanielk1977 **   isdigit()                        0x04
97dc86e2b2Sdrh **   isalnum()                        0x06
9878ca0e7eSdanielk1977 **   isxdigit()                       0x08
9978ca0e7eSdanielk1977 **   toupper()                        0x20
100af2b5720Sdrh **   SQLite identifier character      0x40
101244b9d6eSdrh **   Quote character                  0x80
10278ca0e7eSdanielk1977 **
10378ca0e7eSdanielk1977 ** Bit 0x20 is set if the mapped character requires translation to upper
104dc86e2b2Sdrh ** case. i.e. if the character is a lower-case ASCII character.
10578ca0e7eSdanielk1977 ** If x is a lower-case ASCII character, then its upper-case equivalent
10678ca0e7eSdanielk1977 ** is (x - 0x20). Therefore toupper() can be implemented as:
10778ca0e7eSdanielk1977 **
10878ca0e7eSdanielk1977 **   (x & ~(map[x]&0x20))
10978ca0e7eSdanielk1977 **
11022fa36dcSdrh ** The equivalent of tolower() is implemented using the sqlite3UpperToLower[]
11178ca0e7eSdanielk1977 ** array. tolower() is used more often than toupper() by SQLite.
11278ca0e7eSdanielk1977 **
11322fa36dcSdrh ** Bit 0x40 is set if the character is non-alphanumeric and can be used in an
114af2b5720Sdrh ** SQLite identifier.  Identifiers are alphanumerics, "_", "$", and any
115af2b5720Sdrh ** non-ASCII UTF character. Hence the test for whether or not a character is
116af2b5720Sdrh ** part of an identifier is 0x46.
11778ca0e7eSdanielk1977 */
11878ca0e7eSdanielk1977 const unsigned char sqlite3CtypeMap[256] = {
11978ca0e7eSdanielk1977   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 00..07    ........ */
12078ca0e7eSdanielk1977   0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */
12178ca0e7eSdanielk1977   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */
12278ca0e7eSdanielk1977   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */
123244b9d6eSdrh   0x01, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x80,  /* 20..27     !"#$%&' */
12478ca0e7eSdanielk1977   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */
125dc86e2b2Sdrh   0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */
126dc86e2b2Sdrh   0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */
12778ca0e7eSdanielk1977 
12878ca0e7eSdanielk1977   0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */
12978ca0e7eSdanielk1977   0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */
13078ca0e7eSdanielk1977   0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */
131244b9d6eSdrh   0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\]^_ */
132244b9d6eSdrh   0x80, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */
13378ca0e7eSdanielk1977   0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */
13478ca0e7eSdanielk1977   0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */
13578ca0e7eSdanielk1977   0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */
13678ca0e7eSdanielk1977 
137af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */
138af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */
139af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */
140af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */
141af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */
142af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */
143af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */
144af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */
14578ca0e7eSdanielk1977 
146af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */
147af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */
148af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */
149af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */
150af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */
151af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */
152af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */
153af2b5720Sdrh   0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */
15478ca0e7eSdanielk1977 };
15578ca0e7eSdanielk1977 
15600729cbaSdrh /* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards
15700729cbaSdrh ** compatibility for legacy applications, the URI filename capability is
15800729cbaSdrh ** disabled by default.
15900729cbaSdrh **
16000729cbaSdrh ** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled
16100729cbaSdrh ** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.
1624d9f188fSdrh **
1634d9f188fSdrh ** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally
1644d9f188fSdrh ** disabled. The default value may be changed by compiling with the
1654d9f188fSdrh ** SQLITE_USE_URI symbol defined.
16600729cbaSdrh */
167cd74b611Sdan #ifndef SQLITE_USE_URI
168cd74b611Sdan # define SQLITE_USE_URI 0
169cd74b611Sdan #endif
17078ca0e7eSdanielk1977 
1714d9f188fSdrh /* EVIDENCE-OF: R-38720-18127 The default setting is determined by the
1724d9f188fSdrh ** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if
1734d9f188fSdrh ** that compile-time option is omitted.
1744d9f188fSdrh */
175c164cc99Sdrh #if !defined(SQLITE_ALLOW_COVERING_INDEX_SCAN)
176de9a7b8aSdrh # define SQLITE_ALLOW_COVERING_INDEX_SCAN 1
177c164cc99Sdrh #else
178c164cc99Sdrh # if !SQLITE_ALLOW_COVERING_INDEX_SCAN
179c164cc99Sdrh #   error "Compile-time disabling of covering index scan using the\
180c164cc99Sdrh  -DSQLITE_ALLOW_COVERING_INDEX_SCAN=0 option is deprecated.\
181c164cc99Sdrh  Contact SQLite developers if this is a problem for you, and\
182c164cc99Sdrh  delete this #error macro to continue with your build."
183c164cc99Sdrh # endif
184de9a7b8aSdrh #endif
185de9a7b8aSdrh 
1863bd1791dSdrh /* The minimum PMA size is set to this value multiplied by the database
1873bd1791dSdrh ** page size in bytes.
1883bd1791dSdrh */
1893bd1791dSdrh #ifndef SQLITE_SORTER_PMASZ
1903bd1791dSdrh # define SQLITE_SORTER_PMASZ 250
1913bd1791dSdrh #endif
1923bd1791dSdrh 
1938c71a98cSdrh /* Statement journals spill to disk when their size exceeds the following
19422fa36dcSdrh ** threshold (in bytes). 0 means that statement journals are created and
1958c71a98cSdrh ** written to disk immediately (the default behavior for SQLite versions
1968c71a98cSdrh ** before 3.12.0).  -1 means always keep the entire statement journal in
1978c71a98cSdrh ** memory.  (The statement journal is also always held entirely in memory
1988c71a98cSdrh ** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this
1998c71a98cSdrh ** setting.)
2008c71a98cSdrh */
2018c71a98cSdrh #ifndef SQLITE_STMTJRNL_SPILL
2028c71a98cSdrh # define SQLITE_STMTJRNL_SPILL (64*1024)
2038c71a98cSdrh #endif
2048c71a98cSdrh 
20578ca0e7eSdanielk1977 /*
20656d65cd7Sdrh ** The default lookaside-configuration, the format "SZ,N".  SZ is the
20756d65cd7Sdrh ** number of bytes in each lookaside slot (should be a multiple of 8)
20856d65cd7Sdrh ** and N is the number of slots.  The lookaside-configuration can be
20956d65cd7Sdrh ** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)
21056d65cd7Sdrh ** or at run-time for an individual database connection using
21156d65cd7Sdrh ** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);
212d335bc40Sdrh **
213cf014f6cSdrh ** With the two-size-lookaside enhancement, less lookaside is required.
214cf014f6cSdrh ** The default configuration of 1200,40 actually provides 30 1200-byte slots
215cf014f6cSdrh ** and 93 128-byte slots, which is more lookaside than is available
216cf014f6cSdrh ** using the older 1200,100 configuration without two-size-lookaside.
21756d65cd7Sdrh */
21856d65cd7Sdrh #ifndef SQLITE_DEFAULT_LOOKASIDE
219cf014f6cSdrh # ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE
220d335bc40Sdrh #   define SQLITE_DEFAULT_LOOKASIDE 1200,100  /* 120KB of memory */
221d335bc40Sdrh # else
222d335bc40Sdrh #   define SQLITE_DEFAULT_LOOKASIDE 1200,40   /* 48KB of memory */
223d335bc40Sdrh # endif
22456d65cd7Sdrh #endif
22556d65cd7Sdrh 
22656d65cd7Sdrh 
22723a88595Sdrh /* The default maximum size of an in-memory database created using
22823a88595Sdrh ** sqlite3_deserialize()
22923a88595Sdrh */
23023a88595Sdrh #ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE
23123a88595Sdrh # define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824
23223a88595Sdrh #endif
23323a88595Sdrh 
23456d65cd7Sdrh /*
23540257ffdSdrh ** The following singleton contains the global configuration for
23640257ffdSdrh ** the SQLite library.
23740257ffdSdrh */
238075c23afSdanielk1977 SQLITE_WSD struct Sqlite3Config sqlite3Config = {
2390a732f59Sdanielk1977    SQLITE_DEFAULT_MEMSTATUS,  /* bMemstat */
240633e6d57Sdrh    1,                         /* bCoreMutex */
2410a732f59Sdanielk1977    SQLITE_THREADSAFE==1,      /* bFullMutex */
242cd74b611Sdan    SQLITE_USE_URI,            /* bOpenUri */
243de9a7b8aSdrh    SQLITE_ALLOW_COVERING_INDEX_SCAN,   /* bUseCis */
244b2a0f75cSdrh    0,                         /* bSmallMalloc */
24530842990Sdrh    1,                         /* bExtraSchemaChecks */
246633e6d57Sdrh    0x7ffffffe,                /* mxStrlen */
24709fe6143Sdrh    0,                         /* neverCorrupt */
24856d65cd7Sdrh    SQLITE_DEFAULT_LOOKASIDE,  /* szLookaside, nLookaside */
2498c71a98cSdrh    SQLITE_STMTJRNL_SPILL,     /* nStmtSpill */
2501875f7a3Sdrh    {0,0,0,0,0,0,0,0},         /* m */
2511875f7a3Sdrh    {0,0,0,0,0,0,0,0,0},       /* mutex */
25213e0ea99Sdrh    {0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */
2531875f7a3Sdrh    (void*)0,                  /* pHeap */
2541875f7a3Sdrh    0,                         /* nHeap */
2551875f7a3Sdrh    0, 0,                      /* mnHeap, mxHeap */
2569b4c59faSdrh    SQLITE_DEFAULT_MMAP_SIZE,  /* szMmap */
2579b4c59faSdrh    SQLITE_MAX_MMAP_SIZE,      /* mxMmap */
2581875f7a3Sdrh    (void*)0,                  /* pPage */
2591875f7a3Sdrh    0,                         /* szPage */
2604297c7c4Sdrh    SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */
2611875f7a3Sdrh    0,                         /* mxParserStack */
2621875f7a3Sdrh    0,                         /* sharedCacheEnabled */
2633bd1791dSdrh    SQLITE_SORTER_PMASZ,       /* szPma */
2649ac06509Sdrh    /* All the rest should always be initialized to zero */
2651875f7a3Sdrh    0,                         /* isInit */
2661875f7a3Sdrh    0,                         /* inProgress */
267e1ab2193Sdan    0,                         /* isMutexInit */
2681875f7a3Sdrh    0,                         /* isMallocInit */
269e1ab2193Sdan    0,                         /* isPCacheInit */
2701875f7a3Sdrh    0,                         /* nRefInitMutex */
271c007f61bSdrh    0,                         /* pInitMutex */
2723f280701Sdrh    0,                         /* xLog */
2733f280701Sdrh    0,                         /* pLogArg */
274ac455939Sdan #ifdef SQLITE_ENABLE_SQLLOG
275ac455939Sdan    0,                         /* xSqllog */
276c007f61bSdrh    0,                         /* pSqllogArg */
277ac455939Sdan #endif
278c007f61bSdrh #ifdef SQLITE_VDBE_COVERAGE
279c007f61bSdrh    0,                         /* xVdbeBranch */
280c007f61bSdrh    0,                         /* pVbeBranchArg */
281c007f61bSdrh #endif
2828d889afcSdrh #ifndef SQLITE_OMIT_DESERIALIZE
28323a88595Sdrh    SQLITE_MEMDB_DEFAULT_MAXSIZE,   /* mxMemdbSize */
28423a88595Sdrh #endif
285d12602a9Sdrh #ifndef SQLITE_UNTESTABLE
286c007f61bSdrh    0,                         /* xTestCallback */
287c007f61bSdrh #endif
2889e5eb9c8Sdrh    0,                         /* bLocaltimeFault */
289d7e185ceSdrh    0,                         /* xAltLocaltime */
2902e3a5a81Sdan    0x7ffffffe,                /* iOnceResetThreshold */
29123a88595Sdrh    SQLITE_DEFAULT_SORTERREF_SIZE,   /* szSorterRef */
292ade54d68Sdrh    0,                         /* iPrngSeed */
293e684ac6fSdrh #ifdef SQLITE_DEBUG
294e684ac6fSdrh    {0,0,0,0,0,0}              /* aTune */
295e684ac6fSdrh #endif
296633e6d57Sdrh };
29770a8ca3cSdrh 
29870a8ca3cSdrh /*
29970a8ca3cSdrh ** Hash table for global functions - functions common to all
30070a8ca3cSdrh ** database connections.  After initialization, this table is
30170a8ca3cSdrh ** read-only.
30270a8ca3cSdrh */
30380738d9cSdrh FuncDefHash sqlite3BuiltinFunctions;
304c7a3bb94Sdrh 
305dcf10a1aSdrh #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
3069fdd66e3Sdrh /*
3079fdd66e3Sdrh ** Counter used for coverage testing.  Does not come into play for
3089fdd66e3Sdrh ** release builds.
309dcf10a1aSdrh **
310dcf10a1aSdrh ** Access to this global variable is not mutex protected.  This might
311dcf10a1aSdrh ** result in TSAN warnings.  But as the variable does not exist in
312dcf10a1aSdrh ** release builds, that should not be a concern.
3139fdd66e3Sdrh */
3149fdd66e3Sdrh unsigned int sqlite3CoverageCounter;
315dcf10a1aSdrh #endif /* SQLITE_COVERAGE_TEST || SQLITE_DEBUG */
3169fdd66e3Sdrh 
31735043cc3Sdrh #ifdef VDBE_PROFILE
31835043cc3Sdrh /*
31935043cc3Sdrh ** The following performance counter can be used in place of
32035043cc3Sdrh ** sqlite3Hwtime() for profiling.  This is a no-op on standard builds.
32135043cc3Sdrh */
32235043cc3Sdrh sqlite3_uint64 sqlite3NProfileCnt = 0;
32335043cc3Sdrh #endif
324094430ebSdrh 
325094430ebSdrh /*
326c7a3bb94Sdrh ** The value of the "pending" byte must be 0x40000000 (1 byte past the
327c7a3bb94Sdrh ** 1-gibabyte boundary) in a compatible database.  SQLite never uses
328c7a3bb94Sdrh ** the database page that contains the pending byte.  It never attempts
32922fa36dcSdrh ** to read or write that page.  The pending byte page is set aside
330c7a3bb94Sdrh ** for use by the VFS layers as space for managing file locks.
331c7a3bb94Sdrh **
332c7a3bb94Sdrh ** During testing, it is often desirable to move the pending byte to
333c7a3bb94Sdrh ** a different position in the file.  This allows code that has to
334c7a3bb94Sdrh ** deal with the pending byte to run on files that are much smaller
335c7a3bb94Sdrh ** than 1 GiB.  The sqlite3_test_control() interface can be used to
336c7a3bb94Sdrh ** move the pending byte.
337c7a3bb94Sdrh **
338c7a3bb94Sdrh ** IMPORTANT:  Changing the pending byte to any value other than
339c7a3bb94Sdrh ** 0x40000000 results in an incompatible database file format!
34086a11b8aSdrh ** Changing the pending byte during operation will result in undefined
34186a11b8aSdrh ** and incorrect behavior.
342c7a3bb94Sdrh */
343f83dc1efSdrh #ifndef SQLITE_OMIT_WSD
344c7a3bb94Sdrh int sqlite3PendingByte = 0x40000000;
345f83dc1efSdrh #endif
346a6c2ed91Sdrh 
3479216de8aSdrh /*
348c0622a4dSdrh ** Tracing flags set by SQLITE_TESTCTRL_TRACEFLAGS.
3499216de8aSdrh */
350*5e431beaSdrh u32 sqlite3TreeTrace = 0;
351c0622a4dSdrh u32 sqlite3WhereTrace = 0;
3529216de8aSdrh 
353a6c2ed91Sdrh #include "opcodes.h"
354a6c2ed91Sdrh /*
355a6c2ed91Sdrh ** Properties of opcodes.  The OPFLG_INITIALIZER macro is
356a6c2ed91Sdrh ** created by mkopcodeh.awk during compilation.  Data is obtained
357a6c2ed91Sdrh ** from the comments following the "case OP_xxxx:" statements in
358a6c2ed91Sdrh ** the vdbe.c file.
359a6c2ed91Sdrh */
360a6c2ed91Sdrh const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
361f19aa5faSdrh 
362f19aa5faSdrh /*
363f19aa5faSdrh ** Name of the default collating sequence
364f19aa5faSdrh */
365f19aa5faSdrh const char sqlite3StrBINARY[] = "BINARY";
366c2df4d6aSdrh 
367c2df4d6aSdrh /*
368c2df4d6aSdrh ** Standard typenames.  These names must match the COLTYPE_* definitions.
369c2df4d6aSdrh ** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
37071c770fbSdrh **
37171c770fbSdrh **    sqlite3StdType[]            The actual names of the datatypes.
37271c770fbSdrh **
37371c770fbSdrh **    sqlite3StdTypeLen[]         The length (in bytes) of each entry
37471c770fbSdrh **                                in sqlite3StdType[].
37571c770fbSdrh **
37671c770fbSdrh **    sqlite3StdTypeAffinity[]    The affinity associated with each entry
37771c770fbSdrh **                                in sqlite3StdType[].
378c2df4d6aSdrh */
379b9fd0101Sdrh const unsigned char sqlite3StdTypeLen[] = { 3, 4, 3, 7, 4, 4 };
380c2df4d6aSdrh const char sqlite3StdTypeAffinity[] = {
381b9fd0101Sdrh   SQLITE_AFF_NUMERIC,
382c2df4d6aSdrh   SQLITE_AFF_BLOB,
383c2df4d6aSdrh   SQLITE_AFF_INTEGER,
384c2df4d6aSdrh   SQLITE_AFF_INTEGER,
385c2df4d6aSdrh   SQLITE_AFF_REAL,
386c2df4d6aSdrh   SQLITE_AFF_TEXT
387c2df4d6aSdrh };
388c2df4d6aSdrh const char *sqlite3StdType[] = {
389b9fd0101Sdrh   "ANY",
390c2df4d6aSdrh   "BLOB",
391c2df4d6aSdrh   "INT",
392c2df4d6aSdrh   "INTEGER",
393c2df4d6aSdrh   "REAL",
394c2df4d6aSdrh   "TEXT"
395c2df4d6aSdrh };
396