| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 ** 2008 June 13 | |
| 3 ** | |
| 4 ** The author disclaims copyright to this source code. In place of | |
| 5 ** a legal notice, here is a blessing: | |
| 6 ** | |
| 7 ** May you do good and not evil. | |
| 8 ** May you find forgiveness for yourself and forgive others. | |
| 9 ** May you share freely, never taking more than you give. | |
| 10 ** | |
| 11 ************************************************************************* | |
| 12 ** | |
| 13 ** This file contains definitions of global variables and contants. | |
| 14 */ | |
| 15 #include "sqliteInt.h" | |
| 16 | |
| 17 | |
| 18 /* An array to map all upper-case characters into their corresponding | |
| 19 ** lower-case character. | |
| 20 ** | |
| 21 ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not | |
| 22 ** handle case conversions for the UTF character set since the tables | |
| 23 ** involved are nearly as big or bigger than SQLite itself. | |
| 24 */ | |
| 25 const unsigned char sqlite3UpperToLower[] = { | |
| 26 #ifdef SQLITE_ASCII | |
| 27 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, | |
| 28 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, | |
| 29 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | |
| 30 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, | |
| 31 104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, | |
| 32 122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, | |
| 33 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, | |
| 34 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, | |
| 35 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, | |
| 36 162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, | |
| 37 180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, | |
| 38 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, | |
| 39 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, | |
| 40 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, | |
| 41 252,253,254,255 | |
| 42 #endif | |
| 43 #ifdef SQLITE_EBCDIC | |
| 44 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ | |
| 45 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ | |
| 46 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ | |
| 47 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ | |
| 48 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ | |
| 49 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ | |
| 50 96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ | |
| 51 112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ | |
| 52 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ | |
| 53 144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ | |
| 54 160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ | |
| 55 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ | |
| 56 192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ | |
| 57 208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ | |
| 58 224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ | |
| 59 239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ | |
| 60 #endif | |
| 61 }; | |
| 62 | |
| 63 /* | |
| 64 ** The following 256 byte lookup table is used to support SQLites built-in | |
| 65 ** equivalents to the following standard library functions: | |
| 66 ** | |
| 67 ** isspace() 0x01 | |
| 68 ** isalpha() 0x02 | |
| 69 ** isdigit() 0x04 | |
| 70 ** isalnum() 0x06 | |
| 71 ** isxdigit() 0x08 | |
| 72 ** toupper() 0x20 | |
| 73 ** | |
| 74 ** Bit 0x20 is set if the mapped character requires translation to upper | |
| 75 ** case. i.e. if the character is a lower-case ASCII character. | |
| 76 ** If x is a lower-case ASCII character, then its upper-case equivalent | |
| 77 ** is (x - 0x20). Therefore toupper() can be implemented as: | |
| 78 ** | |
| 79 ** (x & ~(map[x]&0x20)) | |
| 80 ** | |
| 81 ** Standard function tolower() is implemented using the sqlite3UpperToLower[] | |
| 82 ** array. tolower() is used more often than toupper() by SQLite. | |
| 83 ** | |
| 84 ** SQLite's versions are identical to the standard versions assuming a | |
| 85 ** locale of "C". They are implemented as macros in sqliteInt.h. | |
| 86 */ | |
| 87 #ifdef SQLITE_ASCII | |
| 88 const unsigned char sqlite3CtypeMap[256] = { | |
| 89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ | |
| 90 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ | |
| 91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10..17 ........ */ | |
| 92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 18..1f ........ */ | |
| 93 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 20..27 !"#$%&' */ | |
| 94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 28..2f ()*+,-./ */ | |
| 95 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 30..37 01234567 */ | |
| 96 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 38..3f 89:;<=>? */ | |
| 97 | |
| 98 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02, /* 40..47 @ABCDEFG */ | |
| 99 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 48..4f HIJKLMNO */ | |
| 100 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 50..57 PQRSTUVW */ | |
| 101 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* 58..5f XYZ[\]^_ */ | |
| 102 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22, /* 60..67 `abcdefg */ | |
| 103 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, /* 68..6f hijklmno */ | |
| 104 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, /* 70..77 pqrstuvw */ | |
| 105 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, /* 78..7f xyz{|}~. */ | |
| 106 | |
| 107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 80..87 ........ */ | |
| 108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 88..8f ........ */ | |
| 109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 90..97 ........ */ | |
| 110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 98..9f ........ */ | |
| 111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a0..a7 ........ */ | |
| 112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a8..af ........ */ | |
| 113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b0..b7 ........ */ | |
| 114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b8..bf ........ */ | |
| 115 | |
| 116 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c0..c7 ........ */ | |
| 117 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c8..cf ........ */ | |
| 118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d0..d7 ........ */ | |
| 119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d8..df ........ */ | |
| 120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e0..e7 ........ */ | |
| 121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e8..ef ........ */ | |
| 122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f0..f7 ........ */ | |
| 123 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* f8..ff ........ */ | |
| 124 }; | |
| 125 #endif | |
| 126 | |
| 127 | |
| 128 | |
| 129 /* | |
| 130 ** The following singleton contains the global configuration for | |
| 131 ** the SQLite library. | |
| 132 */ | |
| 133 SQLITE_WSD struct Sqlite3Config sqlite3Config = { | |
| 134 SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ | |
| 135 1, /* bCoreMutex */ | |
| 136 SQLITE_THREADSAFE==1, /* bFullMutex */ | |
| 137 0x7ffffffe, /* mxStrlen */ | |
| 138 100, /* szLookaside */ | |
| 139 500, /* nLookaside */ | |
| 140 {0,0,0,0,0,0,0,0}, /* m */ | |
| 141 {0,0,0,0,0,0,0,0,0}, /* mutex */ | |
| 142 {0,0,0,0,0,0,0,0,0,0,0}, /* pcache */ | |
| 143 (void*)0, /* pHeap */ | |
| 144 0, /* nHeap */ | |
| 145 0, 0, /* mnHeap, mxHeap */ | |
| 146 (void*)0, /* pScratch */ | |
| 147 0, /* szScratch */ | |
| 148 0, /* nScratch */ | |
| 149 (void*)0, /* pPage */ | |
| 150 0, /* szPage */ | |
| 151 0, /* nPage */ | |
| 152 0, /* mxParserStack */ | |
| 153 0, /* sharedCacheEnabled */ | |
| 154 /* All the rest should always be initialized to zero */ | |
| 155 0, /* isInit */ | |
| 156 0, /* inProgress */ | |
| 157 0, /* isMutexInit */ | |
| 158 0, /* isMallocInit */ | |
| 159 0, /* isPCacheInit */ | |
| 160 0, /* pInitMutex */ | |
| 161 0, /* nRefInitMutex */ | |
| 162 }; | |
| 163 | |
| 164 | |
| 165 /* | |
| 166 ** Hash table for global functions - functions common to all | |
| 167 ** database connections. After initialization, this table is | |
| 168 ** read-only. | |
| 169 */ | |
| 170 SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; | |
| 171 | |
| 172 /* | |
| 173 ** The value of the "pending" byte must be 0x40000000 (1 byte past the | |
| 174 ** 1-gibabyte boundary) in a compatible database. SQLite never uses | |
| 175 ** the database page that contains the pending byte. It never attempts | |
| 176 ** to read or write that page. The pending byte page is set assign | |
| 177 ** for use by the VFS layers as space for managing file locks. | |
| 178 ** | |
| 179 ** During testing, it is often desirable to move the pending byte to | |
| 180 ** a different position in the file. This allows code that has to | |
| 181 ** deal with the pending byte to run on files that are much smaller | |
| 182 ** than 1 GiB. The sqlite3_test_control() interface can be used to | |
| 183 ** move the pending byte. | |
| 184 ** | |
| 185 ** IMPORTANT: Changing the pending byte to any value other than | |
| 186 ** 0x40000000 results in an incompatible database file format! | |
| 187 ** Changing the pending byte during operating results in undefined | |
| 188 ** and dileterious behavior. | |
| 189 */ | |
| 190 int sqlite3PendingByte = 0x40000000; | |
| OLD | NEW |