drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1 | /* |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 2 | ** 2001 September 15 |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 3 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 6 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 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. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** An tokenizer for SQL |
| 13 | ** |
| 14 | ** This file contains C code that splits an SQL input string up into |
| 15 | ** individual tokens and sends those tokens one-by-one over to the |
| 16 | ** parser for analysis. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 17 | */ |
| 18 | #include "sqliteInt.h" |
drh | dcc581c | 2000-05-30 13:44:19 +0000 | [diff] [blame] | 19 | #include <stdlib.h> |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 20 | |
| 21 | /* |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 22 | ** The charMap() macro maps alphabetic characters into their |
| 23 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| 24 | ** an upper-to-lower case map. On EBCDIC machines we also need |
| 25 | ** to adjust the encoding. Only alphabetic characters and underscores |
| 26 | ** need to be translated. |
| 27 | */ |
| 28 | #ifdef SQLITE_ASCII |
| 29 | # define charMap(X) sqlite3UpperToLower[(unsigned char)X] |
| 30 | #endif |
| 31 | #ifdef SQLITE_EBCDIC |
| 32 | # define charMap(X) ebcdicToAscii[(unsigned char)X] |
| 33 | const unsigned char ebcdicToAscii[] = { |
| 34 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
| 35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ |
| 36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ |
| 37 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ |
| 38 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ |
| 39 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ |
| 40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ |
| 41 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ |
| 42 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ |
| 43 | 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ |
| 44 | 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ |
| 45 | 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ |
| 46 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ |
| 47 | 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ |
| 48 | 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ |
| 49 | 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ |
| 50 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ |
| 51 | }; |
| 52 | #endif |
| 53 | |
| 54 | /* |
drh | 52fb6d7 | 2004-11-03 03:59:57 +0000 | [diff] [blame] | 55 | ** The sqlite3KeywordCode function looks up an identifier to determine if |
| 56 | ** it is a keyword. If it is a keyword, the token code of that keyword is |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 57 | ** returned. If the input is not a keyword, TK_ID is returned. |
drh | 2090a0e | 2004-10-07 19:03:01 +0000 | [diff] [blame] | 58 | ** |
| 59 | ** The implementation of this routine was generated by a program, |
drh | 73b211a | 2005-01-18 04:00:42 +0000 | [diff] [blame] | 60 | ** mkkeywordhash.h, located in the tool subdirectory of the distribution. |
drh | 52fb6d7 | 2004-11-03 03:59:57 +0000 | [diff] [blame] | 61 | ** The output of the mkkeywordhash.c program is written into a file |
drh | 73b211a | 2005-01-18 04:00:42 +0000 | [diff] [blame] | 62 | ** named keywordhash.h and then included into this source file by |
drh | 52fb6d7 | 2004-11-03 03:59:57 +0000 | [diff] [blame] | 63 | ** the #include below. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 64 | */ |
drh | 73b211a | 2005-01-18 04:00:42 +0000 | [diff] [blame] | 65 | #include "keywordhash.h" |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 66 | |
drh | 40f20f7 | 2004-10-23 05:10:18 +0000 | [diff] [blame] | 67 | |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 68 | /* |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 69 | ** If X is a character that can be used in an identifier then |
| 70 | ** IdChar(X) will be true. Otherwise it is false. |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 71 | ** |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 72 | ** For ASCII, any character with the high-order bit set is |
| 73 | ** allowed in an identifier. For 7-bit characters, |
| 74 | ** sqlite3IsIdChar[X] must be 1. |
| 75 | ** |
| 76 | ** For EBCDIC, the rules are more complex but have the same |
| 77 | ** end result. |
drh | a0d1f66 | 2005-01-11 17:59:47 +0000 | [diff] [blame] | 78 | ** |
| 79 | ** Ticket #1066. the SQL standard does not allow '$' in the |
peter.d.reid | 60ec914 | 2014-09-06 16:39:46 +0000 | [diff] [blame] | 80 | ** middle of identifiers. But many SQL implementations do. |
drh | a0d1f66 | 2005-01-11 17:59:47 +0000 | [diff] [blame] | 81 | ** SQLite will allow '$' in identifiers for compatibility. |
| 82 | ** But the feature is undocumented. |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 83 | */ |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 84 | #ifdef SQLITE_ASCII |
drh | af2b572 | 2009-11-16 15:11:51 +0000 | [diff] [blame] | 85 | #define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 86 | #endif |
| 87 | #ifdef SQLITE_EBCDIC |
drh | 46c99e0 | 2007-08-27 23:26:59 +0000 | [diff] [blame] | 88 | const char sqlite3IsEbcdicIdChar[] = { |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 89 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ |
| 90 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ |
| 91 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ |
| 92 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ |
| 93 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ |
| 94 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ |
| 95 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ |
| 96 | 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ |
| 97 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ |
| 98 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ |
| 99 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ |
| 100 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ |
| 101 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ |
| 102 | }; |
drh | 46c99e0 | 2007-08-27 23:26:59 +0000 | [diff] [blame] | 103 | #define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 104 | #endif |
drh | f5ed7ad | 2015-06-15 14:43:25 +0000 | [diff] [blame] | 105 | |
| 106 | /* Make the IdChar function accessible from ctime.c */ |
| 107 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
drh | 97348b3 | 2014-09-25 02:44:29 +0000 | [diff] [blame] | 108 | int sqlite3IsIdChar(u8 c){ return IdChar(c); } |
drh | f5ed7ad | 2015-06-15 14:43:25 +0000 | [diff] [blame] | 109 | #endif |
drh | 9b8f447 | 2006-04-04 01:54:55 +0000 | [diff] [blame] | 110 | |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 111 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 112 | /* |
drh | 61b487d | 2003-09-12 02:08:14 +0000 | [diff] [blame] | 113 | ** Return the length of the token that begins at z[0]. |
| 114 | ** Store the token type in *tokenType before returning. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 115 | */ |
drh | 35b5a33 | 2008-04-05 18:41:42 +0000 | [diff] [blame] | 116 | int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 117 | int i, c; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 118 | switch( *z ){ |
drh | 30cab80 | 2000-08-09 17:17:25 +0000 | [diff] [blame] | 119 | case ' ': case '\t': case '\n': case '\f': case '\r': { |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 120 | testcase( z[0]==' ' ); |
| 121 | testcase( z[0]=='\t' ); |
| 122 | testcase( z[0]=='\n' ); |
| 123 | testcase( z[0]=='\f' ); |
| 124 | testcase( z[0]=='\r' ); |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 125 | for(i=1; sqlite3Isspace(z[i]); i++){} |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 126 | *tokenType = TK_SPACE; |
| 127 | return i; |
| 128 | } |
| 129 | case '-': { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 130 | if( z[1]=='-' ){ |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 131 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
drh | d3479b9 | 2009-12-14 17:42:12 +0000 | [diff] [blame] | 132 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 133 | return i; |
| 134 | } |
| 135 | *tokenType = TK_MINUS; |
| 136 | return 1; |
| 137 | } |
| 138 | case '(': { |
drh | dab3518 | 2003-09-27 13:39:38 +0000 | [diff] [blame] | 139 | *tokenType = TK_LP; |
| 140 | return 1; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 141 | } |
| 142 | case ')': { |
| 143 | *tokenType = TK_RP; |
| 144 | return 1; |
| 145 | } |
| 146 | case ';': { |
| 147 | *tokenType = TK_SEMI; |
| 148 | return 1; |
| 149 | } |
| 150 | case '+': { |
| 151 | *tokenType = TK_PLUS; |
| 152 | return 1; |
| 153 | } |
| 154 | case '*': { |
| 155 | *tokenType = TK_STAR; |
| 156 | return 1; |
| 157 | } |
| 158 | case '/': { |
drh | 66105a8 | 2002-08-27 14:28:29 +0000 | [diff] [blame] | 159 | if( z[1]!='*' || z[2]==0 ){ |
| 160 | *tokenType = TK_SLASH; |
| 161 | return 1; |
| 162 | } |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 163 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 164 | if( c ) i++; |
drh | d3479b9 | 2009-12-14 17:42:12 +0000 | [diff] [blame] | 165 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
drh | 66105a8 | 2002-08-27 14:28:29 +0000 | [diff] [blame] | 166 | return i; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 167 | } |
drh | bf4133c | 2001-10-13 02:59:08 +0000 | [diff] [blame] | 168 | case '%': { |
| 169 | *tokenType = TK_REM; |
| 170 | return 1; |
| 171 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 172 | case '=': { |
| 173 | *tokenType = TK_EQ; |
| 174 | return 1 + (z[1]=='='); |
| 175 | } |
| 176 | case '<': { |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 177 | if( (c=z[1])=='=' ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 178 | *tokenType = TK_LE; |
| 179 | return 2; |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 180 | }else if( c=='>' ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 181 | *tokenType = TK_NE; |
| 182 | return 2; |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 183 | }else if( c=='<' ){ |
drh | bf4133c | 2001-10-13 02:59:08 +0000 | [diff] [blame] | 184 | *tokenType = TK_LSHIFT; |
| 185 | return 2; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 186 | }else{ |
| 187 | *tokenType = TK_LT; |
| 188 | return 1; |
| 189 | } |
| 190 | } |
| 191 | case '>': { |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 192 | if( (c=z[1])=='=' ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 193 | *tokenType = TK_GE; |
| 194 | return 2; |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 195 | }else if( c=='>' ){ |
drh | bf4133c | 2001-10-13 02:59:08 +0000 | [diff] [blame] | 196 | *tokenType = TK_RSHIFT; |
| 197 | return 2; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 198 | }else{ |
| 199 | *tokenType = TK_GT; |
| 200 | return 1; |
| 201 | } |
| 202 | } |
| 203 | case '!': { |
| 204 | if( z[1]!='=' ){ |
| 205 | *tokenType = TK_ILLEGAL; |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 206 | return 2; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 207 | }else{ |
| 208 | *tokenType = TK_NE; |
| 209 | return 2; |
| 210 | } |
| 211 | } |
drh | 0040077 | 2000-06-16 20:51:26 +0000 | [diff] [blame] | 212 | case '|': { |
| 213 | if( z[1]!='|' ){ |
drh | bf4133c | 2001-10-13 02:59:08 +0000 | [diff] [blame] | 214 | *tokenType = TK_BITOR; |
drh | 0040077 | 2000-06-16 20:51:26 +0000 | [diff] [blame] | 215 | return 1; |
| 216 | }else{ |
| 217 | *tokenType = TK_CONCAT; |
| 218 | return 2; |
| 219 | } |
| 220 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 221 | case ',': { |
| 222 | *tokenType = TK_COMMA; |
| 223 | return 1; |
| 224 | } |
drh | bf4133c | 2001-10-13 02:59:08 +0000 | [diff] [blame] | 225 | case '&': { |
| 226 | *tokenType = TK_BITAND; |
| 227 | return 1; |
| 228 | } |
| 229 | case '~': { |
| 230 | *tokenType = TK_BITNOT; |
| 231 | return 1; |
| 232 | } |
drh | 3d94662 | 2005-08-13 18:15:42 +0000 | [diff] [blame] | 233 | case '`': |
| 234 | case '\'': |
| 235 | case '"': { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 236 | int delim = z[0]; |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 237 | testcase( delim=='`' ); |
| 238 | testcase( delim=='\'' ); |
| 239 | testcase( delim=='"' ); |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 240 | for(i=1; (c=z[i])!=0; i++){ |
| 241 | if( c==delim ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 242 | if( z[i+1]==delim ){ |
| 243 | i++; |
| 244 | }else{ |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | } |
drh | a33cb5f | 2008-08-07 13:05:34 +0000 | [diff] [blame] | 249 | if( c=='\'' ){ |
drh | eef8b55 | 2005-10-23 11:29:40 +0000 | [diff] [blame] | 250 | *tokenType = TK_STRING; |
| 251 | return i+1; |
drh | a33cb5f | 2008-08-07 13:05:34 +0000 | [diff] [blame] | 252 | }else if( c!=0 ){ |
| 253 | *tokenType = TK_ID; |
| 254 | return i+1; |
drh | eef8b55 | 2005-10-23 11:29:40 +0000 | [diff] [blame] | 255 | }else{ |
| 256 | *tokenType = TK_ILLEGAL; |
| 257 | return i; |
| 258 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 259 | } |
| 260 | case '.': { |
drh | 7681618 | 2005-08-23 11:31:26 +0000 | [diff] [blame] | 261 | #ifndef SQLITE_OMIT_FLOATING_POINT |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 262 | if( !sqlite3Isdigit(z[1]) ) |
drh | 7681618 | 2005-08-23 11:31:26 +0000 | [diff] [blame] | 263 | #endif |
| 264 | { |
| 265 | *tokenType = TK_DOT; |
| 266 | return 1; |
| 267 | } |
| 268 | /* If the next character is a digit, this is a floating point |
| 269 | ** number that begins with ".". Fall thru into the next case */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 270 | } |
| 271 | case '0': case '1': case '2': case '3': case '4': |
| 272 | case '5': case '6': case '7': case '8': case '9': { |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 273 | testcase( z[0]=='0' ); testcase( z[0]=='1' ); testcase( z[0]=='2' ); |
| 274 | testcase( z[0]=='3' ); testcase( z[0]=='4' ); testcase( z[0]=='5' ); |
| 275 | testcase( z[0]=='6' ); testcase( z[0]=='7' ); testcase( z[0]=='8' ); |
| 276 | testcase( z[0]=='9' ); |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 277 | *tokenType = TK_INTEGER; |
drh | 28e048c | 2014-07-23 01:26:51 +0000 | [diff] [blame] | 278 | #ifndef SQLITE_OMIT_HEX_INTEGER |
| 279 | if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ |
| 280 | for(i=3; sqlite3Isxdigit(z[i]); i++){} |
| 281 | return i; |
| 282 | } |
| 283 | #endif |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 284 | for(i=0; sqlite3Isdigit(z[i]); i++){} |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 285 | #ifndef SQLITE_OMIT_FLOATING_POINT |
drh | 7681618 | 2005-08-23 11:31:26 +0000 | [diff] [blame] | 286 | if( z[i]=='.' ){ |
| 287 | i++; |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 288 | while( sqlite3Isdigit(z[i]) ){ i++; } |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 289 | *tokenType = TK_FLOAT; |
| 290 | } |
| 291 | if( (z[i]=='e' || z[i]=='E') && |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 292 | ( sqlite3Isdigit(z[i+1]) |
| 293 | || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2])) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 294 | ) |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 295 | ){ |
| 296 | i += 2; |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 297 | while( sqlite3Isdigit(z[i]) ){ i++; } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 298 | *tokenType = TK_FLOAT; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 299 | } |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 300 | #endif |
drh | 67dd901 | 2006-08-12 12:33:14 +0000 | [diff] [blame] | 301 | while( IdChar(z[i]) ){ |
| 302 | *tokenType = TK_ILLEGAL; |
| 303 | i++; |
| 304 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 305 | return i; |
| 306 | } |
drh | 2f4392f | 2002-02-14 21:42:51 +0000 | [diff] [blame] | 307 | case '[': { |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 308 | for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){} |
drh | 4b2f936 | 2008-01-22 23:37:09 +0000 | [diff] [blame] | 309 | *tokenType = c==']' ? TK_ID : TK_ILLEGAL; |
drh | 2f4392f | 2002-02-14 21:42:51 +0000 | [diff] [blame] | 310 | return i; |
| 311 | } |
drh | 7c972de | 2003-09-06 22:18:07 +0000 | [diff] [blame] | 312 | case '?': { |
drh | 5045789 | 2003-09-06 01:10:47 +0000 | [diff] [blame] | 313 | *tokenType = TK_VARIABLE; |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 314 | for(i=1; sqlite3Isdigit(z[i]); i++){} |
drh | fa6bc00 | 2004-09-07 16:19:52 +0000 | [diff] [blame] | 315 | return i; |
drh | 5045789 | 2003-09-06 01:10:47 +0000 | [diff] [blame] | 316 | } |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 317 | #ifndef SQLITE_OMIT_TCL_VARIABLE |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 318 | case '$': |
| 319 | #endif |
drh | 0b2a5ee | 2006-02-09 22:24:41 +0000 | [diff] [blame] | 320 | case '@': /* For compatibility with MS SQL Server */ |
drh | f59b12f | 2014-01-11 03:54:05 +0000 | [diff] [blame] | 321 | case '#': |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 322 | case ':': { |
| 323 | int n = 0; |
drh | f59b12f | 2014-01-11 03:54:05 +0000 | [diff] [blame] | 324 | testcase( z[0]=='$' ); testcase( z[0]=='@' ); |
| 325 | testcase( z[0]==':' ); testcase( z[0]=='#' ); |
drh | 9d74b4c | 2004-08-24 15:23:34 +0000 | [diff] [blame] | 326 | *tokenType = TK_VARIABLE; |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 327 | for(i=1; (c=z[i])!=0; i++){ |
| 328 | if( IdChar(c) ){ |
| 329 | n++; |
| 330 | #ifndef SQLITE_OMIT_TCL_VARIABLE |
| 331 | }else if( c=='(' && n>0 ){ |
| 332 | do{ |
| 333 | i++; |
danielk1977 | 78ca0e7 | 2009-01-20 16:53:39 +0000 | [diff] [blame] | 334 | }while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' ); |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 335 | if( c==')' ){ |
drh | 895d747 | 2004-08-20 16:02:39 +0000 | [diff] [blame] | 336 | i++; |
| 337 | }else{ |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 338 | *tokenType = TK_ILLEGAL; |
drh | 895d747 | 2004-08-20 16:02:39 +0000 | [diff] [blame] | 339 | } |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 340 | break; |
| 341 | }else if( c==':' && z[i+1]==':' ){ |
| 342 | i++; |
| 343 | #endif |
| 344 | }else{ |
| 345 | break; |
drh | 895d747 | 2004-08-20 16:02:39 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
drh | 288d37f | 2005-06-22 08:48:06 +0000 | [diff] [blame] | 348 | if( n==0 ) *tokenType = TK_ILLEGAL; |
drh | 895d747 | 2004-08-20 16:02:39 +0000 | [diff] [blame] | 349 | return i; |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 350 | } |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 351 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
danielk1977 | c572ef7 | 2004-05-27 09:28:41 +0000 | [diff] [blame] | 352 | case 'x': case 'X': { |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 353 | testcase( z[0]=='x' ); testcase( z[0]=='X' ); |
drh | 4b2f936 | 2008-01-22 23:37:09 +0000 | [diff] [blame] | 354 | if( z[1]=='\'' ){ |
danielk1977 | 3fd0a73 | 2004-05-27 13:35:19 +0000 | [diff] [blame] | 355 | *tokenType = TK_BLOB; |
drh | 3a61a5a | 2011-06-03 21:34:45 +0000 | [diff] [blame] | 356 | for(i=2; sqlite3Isxdigit(z[i]); i++){} |
| 357 | if( z[i]!='\'' || i%2 ){ |
| 358 | *tokenType = TK_ILLEGAL; |
| 359 | while( z[i] && z[i]!='\'' ){ i++; } |
danielk1977 | c572ef7 | 2004-05-27 09:28:41 +0000 | [diff] [blame] | 360 | } |
drh | 3a61a5a | 2011-06-03 21:34:45 +0000 | [diff] [blame] | 361 | if( z[i] ) i++; |
danielk1977 | c572ef7 | 2004-05-27 09:28:41 +0000 | [diff] [blame] | 362 | return i; |
| 363 | } |
| 364 | /* Otherwise fall through to the next case */ |
| 365 | } |
drh | b7f9164 | 2004-10-31 02:22:47 +0000 | [diff] [blame] | 366 | #endif |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 367 | default: { |
drh | 9a087a9 | 2007-05-15 14:34:32 +0000 | [diff] [blame] | 368 | if( !IdChar(*z) ){ |
drh | 98808ba | 2001-10-18 12:34:46 +0000 | [diff] [blame] | 369 | break; |
| 370 | } |
drh | aa756b0 | 2004-09-25 15:25:26 +0000 | [diff] [blame] | 371 | for(i=1; IdChar(z[i]); i++){} |
danielk1977 | c60e9b8 | 2005-01-31 12:42:29 +0000 | [diff] [blame] | 372 | *tokenType = keywordCode((char*)z, i); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 373 | return i; |
| 374 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 375 | } |
| 376 | *tokenType = TK_ILLEGAL; |
| 377 | return 1; |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 | ** Run the parser on the given SQL string. The parser structure is |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 382 | ** passed in. An SQLITE_ status code is returned. If an error occurs |
drh | fb45d8c | 2008-07-08 00:06:49 +0000 | [diff] [blame] | 383 | ** then an and attempt is made to write an error message into |
| 384 | ** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that |
| 385 | ** error message. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 386 | */ |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 387 | int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ |
drh | d9da78a | 2009-03-24 15:08:09 +0000 | [diff] [blame] | 388 | int nErr = 0; /* Number of errors encountered */ |
| 389 | int i; /* Loop counter */ |
| 390 | void *pEngine; /* The LEMON-generated LALR(1) parser */ |
| 391 | int tokenType; /* type of the next token */ |
| 392 | int lastTokenParsed = -1; /* type of the previous token */ |
shane | b08a67a | 2009-03-31 03:41:56 +0000 | [diff] [blame] | 393 | u8 enableLookaside; /* Saved value of db->lookaside.bEnabled */ |
drh | d9da78a | 2009-03-24 15:08:09 +0000 | [diff] [blame] | 394 | sqlite3 *db = pParse->db; /* The database connection */ |
| 395 | int mxSqlLen; /* Max length of an SQL string */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 396 | |
drh | 96c707a | 2015-02-13 16:36:14 +0000 | [diff] [blame] | 397 | assert( zSql!=0 ); |
drh | d9da78a | 2009-03-24 15:08:09 +0000 | [diff] [blame] | 398 | mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
drh | 4f7d3a5 | 2013-06-27 23:54:02 +0000 | [diff] [blame] | 399 | if( db->nVdbeActive==0 ){ |
drh | 15ca1df | 2006-07-26 13:43:30 +0000 | [diff] [blame] | 400 | db->u1.isInterrupted = 0; |
| 401 | } |
drh | 4c50439 | 2000-10-16 22:06:40 +0000 | [diff] [blame] | 402 | pParse->rc = SQLITE_OK; |
drh | e7f3f3e | 2009-07-03 22:54:36 +0000 | [diff] [blame] | 403 | pParse->zTail = zSql; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 404 | i = 0; |
drh | fb45d8c | 2008-07-08 00:06:49 +0000 | [diff] [blame] | 405 | assert( pzErrMsg!=0 ); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 406 | /* sqlite3ParserTrace(stdout, "parser: "); */ |
drh | fb046e7 | 2014-09-12 04:28:33 +0000 | [diff] [blame] | 407 | pEngine = sqlite3ParserAlloc(sqlite3Malloc); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 408 | if( pEngine==0 ){ |
drh | f3a65f7 | 2007-08-22 20:18:21 +0000 | [diff] [blame] | 409 | db->mallocFailed = 1; |
drh | defc997 | 2005-06-06 14:45:42 +0000 | [diff] [blame] | 410 | return SQLITE_NOMEM; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 411 | } |
drh | fa6bc00 | 2004-09-07 16:19:52 +0000 | [diff] [blame] | 412 | assert( pParse->pNewTable==0 ); |
| 413 | assert( pParse->pNewTrigger==0 ); |
| 414 | assert( pParse->nVar==0 ); |
drh | 124c0b4 | 2011-06-01 18:15:55 +0000 | [diff] [blame] | 415 | assert( pParse->nzVar==0 ); |
| 416 | assert( pParse->azVar==0 ); |
drh | d9da78a | 2009-03-24 15:08:09 +0000 | [diff] [blame] | 417 | enableLookaside = db->lookaside.bEnabled; |
| 418 | if( db->lookaside.pStart ) db->lookaside.bEnabled = 1; |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 419 | while( !db->mallocFailed && zSql[i]!=0 ){ |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 420 | assert( i>=0 ); |
drh | b7916a7 | 2009-05-27 10:31:29 +0000 | [diff] [blame] | 421 | pParse->sLastToken.z = &zSql[i]; |
drh | 35b5a33 | 2008-04-05 18:41:42 +0000 | [diff] [blame] | 422 | pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 423 | i += pParse->sLastToken.n; |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 424 | if( i>mxSqlLen ){ |
drh | e5c941b | 2007-05-08 13:58:26 +0000 | [diff] [blame] | 425 | pParse->rc = SQLITE_TOOBIG; |
| 426 | break; |
| 427 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 428 | switch( tokenType ){ |
drh | 200a81d | 2008-08-08 14:19:41 +0000 | [diff] [blame] | 429 | case TK_SPACE: { |
drh | 881feaa | 2006-07-26 01:39:30 +0000 | [diff] [blame] | 430 | if( db->u1.isInterrupted ){ |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 431 | sqlite3ErrorMsg(pParse, "interrupt"); |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 432 | pParse->rc = SQLITE_INTERRUPT; |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 433 | goto abort_parse; |
| 434 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 435 | break; |
| 436 | } |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 437 | case TK_ILLEGAL: { |
drh | 347bdc3 | 2015-04-15 07:57:27 +0000 | [diff] [blame] | 438 | sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", |
drh | fb45d8c | 2008-07-08 00:06:49 +0000 | [diff] [blame] | 439 | &pParse->sLastToken); |
drh | caec2f1 | 2003-01-07 02:47:47 +0000 | [diff] [blame] | 440 | goto abort_parse; |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 441 | } |
drh | 326dce7 | 2003-01-29 14:06:07 +0000 | [diff] [blame] | 442 | case TK_SEMI: { |
| 443 | pParse->zTail = &zSql[i]; |
| 444 | /* Fall thru into the default case */ |
| 445 | } |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 446 | default: { |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 447 | sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse); |
drh | b86ccfb | 2003-01-28 23:13:10 +0000 | [diff] [blame] | 448 | lastTokenParsed = tokenType; |
| 449 | if( pParse->rc!=SQLITE_OK ){ |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 450 | goto abort_parse; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 451 | } |
| 452 | break; |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 453 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 454 | } |
| 455 | } |
drh | 32eb7b4 | 2003-01-07 01:44:37 +0000 | [diff] [blame] | 456 | abort_parse: |
drh | 0be0cf6 | 2015-04-15 08:37:42 +0000 | [diff] [blame] | 457 | assert( nErr==0 ); |
drh | e726622 | 2015-05-29 17:51:16 +0000 | [diff] [blame] | 458 | if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ |
| 459 | assert( zSql[i]==0 ); |
drh | b86ccfb | 2003-01-28 23:13:10 +0000 | [diff] [blame] | 460 | if( lastTokenParsed!=TK_SEMI ){ |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 461 | sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 462 | pParse->zTail = &zSql[i]; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 463 | } |
drh | 9a9705d | 2015-04-25 00:32:30 +0000 | [diff] [blame] | 464 | if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ |
| 465 | sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); |
| 466 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 467 | } |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 468 | #ifdef YYTRACKMAXSTACKDEPTH |
drh | af89fe6 | 2015-03-23 17:25:18 +0000 | [diff] [blame] | 469 | sqlite3_mutex_enter(sqlite3MallocMutex()); |
drh | b02392e | 2015-10-15 15:28:56 +0000 | [diff] [blame^] | 470 | sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK, |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 471 | sqlite3ParserStackPeak(pEngine) |
| 472 | ); |
drh | af89fe6 | 2015-03-23 17:25:18 +0000 | [diff] [blame] | 473 | sqlite3_mutex_leave(sqlite3MallocMutex()); |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 474 | #endif /* YYDEBUG */ |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 475 | sqlite3ParserFree(pEngine, sqlite3_free); |
drh | d9da78a | 2009-03-24 15:08:09 +0000 | [diff] [blame] | 476 | db->lookaside.bEnabled = enableLookaside; |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 477 | if( db->mallocFailed ){ |
drh | 71c697e | 2004-08-08 23:39:19 +0000 | [diff] [blame] | 478 | pParse->rc = SQLITE_NOMEM; |
| 479 | } |
drh | b86ccfb | 2003-01-28 23:13:10 +0000 | [diff] [blame] | 480 | if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){ |
drh | 22c17b8 | 2015-05-15 04:13:15 +0000 | [diff] [blame] | 481 | pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc)); |
drh | b86ccfb | 2003-01-28 23:13:10 +0000 | [diff] [blame] | 482 | } |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 483 | assert( pzErrMsg!=0 ); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 484 | if( pParse->zErrMsg ){ |
drh | 19f81f6 | 2009-06-09 18:01:37 +0000 | [diff] [blame] | 485 | *pzErrMsg = pParse->zErrMsg; |
drh | 413c3d3 | 2010-02-23 20:11:56 +0000 | [diff] [blame] | 486 | sqlite3_log(pParse->rc, "%s", *pzErrMsg); |
drh | b86ccfb | 2003-01-28 23:13:10 +0000 | [diff] [blame] | 487 | pParse->zErrMsg = 0; |
drh | 4b2f936 | 2008-01-22 23:37:09 +0000 | [diff] [blame] | 488 | nErr++; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 489 | } |
drh | 2958a4e | 2004-11-12 03:56:15 +0000 | [diff] [blame] | 490 | if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){ |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 491 | sqlite3VdbeDelete(pParse->pVdbe); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 492 | pParse->pVdbe = 0; |
| 493 | } |
danielk1977 | c00da10 | 2006-01-07 13:21:04 +0000 | [diff] [blame] | 494 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 495 | if( pParse->nested==0 ){ |
drh | 633e6d5 | 2008-07-28 19:34:53 +0000 | [diff] [blame] | 496 | sqlite3DbFree(db, pParse->aTableLock); |
danielk1977 | c00da10 | 2006-01-07 13:21:04 +0000 | [diff] [blame] | 497 | pParse->aTableLock = 0; |
| 498 | pParse->nTableLock = 0; |
| 499 | } |
| 500 | #endif |
drh | 4f3dd15 | 2008-04-28 18:46:43 +0000 | [diff] [blame] | 501 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
drh | b975598 | 2010-07-24 16:34:37 +0000 | [diff] [blame] | 502 | sqlite3_free(pParse->apVtabLock); |
drh | 4f3dd15 | 2008-04-28 18:46:43 +0000 | [diff] [blame] | 503 | #endif |
danielk1977 | 7e6ebfb | 2006-06-12 11:24:37 +0000 | [diff] [blame] | 504 | |
danielk1977 | 7e6ebfb | 2006-06-12 11:24:37 +0000 | [diff] [blame] | 505 | if( !IN_DECLARE_VTAB ){ |
| 506 | /* If the pParse->declareVtab flag is set, do not delete any table |
| 507 | ** structure built up in pParse->pNewTable. The calling code (see vtab.c) |
| 508 | ** will take responsibility for freeing the Table structure. |
| 509 | */ |
dan | 1feeaed | 2010-07-23 15:41:47 +0000 | [diff] [blame] | 510 | sqlite3DeleteTable(db, pParse->pNewTable); |
danielk1977 | 7e6ebfb | 2006-06-12 11:24:37 +0000 | [diff] [blame] | 511 | } |
| 512 | |
dan | b290f11 | 2014-01-17 14:59:27 +0000 | [diff] [blame] | 513 | if( pParse->bFreeWith ) sqlite3WithDelete(db, pParse->pWith); |
drh | 633e6d5 | 2008-07-28 19:34:53 +0000 | [diff] [blame] | 514 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
drh | 124c0b4 | 2011-06-01 18:15:55 +0000 | [diff] [blame] | 515 | for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]); |
| 516 | sqlite3DbFree(db, pParse->azVar); |
drh | 0b9f50d | 2009-06-23 20:28:53 +0000 | [diff] [blame] | 517 | while( pParse->pAinc ){ |
| 518 | AutoincInfo *p = pParse->pAinc; |
| 519 | pParse->pAinc = p->pNext; |
| 520 | sqlite3DbFree(db, p); |
| 521 | } |
drh | 588a9a1 | 2008-09-01 15:52:10 +0000 | [diff] [blame] | 522 | while( pParse->pZombieTab ){ |
| 523 | Table *p = pParse->pZombieTab; |
| 524 | pParse->pZombieTab = p->pNextZombie; |
dan | 1feeaed | 2010-07-23 15:41:47 +0000 | [diff] [blame] | 525 | sqlite3DeleteTable(db, p); |
drh | 588a9a1 | 2008-09-01 15:52:10 +0000 | [diff] [blame] | 526 | } |
drh | f3151f0 | 2015-04-16 20:27:09 +0000 | [diff] [blame] | 527 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 528 | return nErr; |
| 529 | } |