xref: /sqlite-3.40.0/src/tokenize.c (revision c00da105)
175897234Sdrh /*
2b19a2bc6Sdrh ** 2001 September 15
375897234Sdrh **
4b19a2bc6Sdrh ** The author disclaims copyright to this source code.  In place of
5b19a2bc6Sdrh ** a legal notice, here is a blessing:
675897234Sdrh **
7b19a2bc6Sdrh **    May you do good and not evil.
8b19a2bc6Sdrh **    May you find forgiveness for yourself and forgive others.
9b19a2bc6Sdrh **    May you share freely, never taking more than you give.
1075897234Sdrh **
1175897234Sdrh *************************************************************************
1275897234Sdrh ** An tokenizer for SQL
1375897234Sdrh **
1475897234Sdrh ** This file contains C code that splits an SQL input string up into
1575897234Sdrh ** individual tokens and sends those tokens one-by-one over to the
1675897234Sdrh ** parser for analysis.
1775897234Sdrh **
18*c00da105Sdanielk1977 ** $Id: tokenize.c,v 1.111 2006/01/07 13:21:04 danielk1977 Exp $
1975897234Sdrh */
2075897234Sdrh #include "sqliteInt.h"
21ad75e987Sdrh #include "os.h"
2275897234Sdrh #include <ctype.h>
23dcc581ccSdrh #include <stdlib.h>
2475897234Sdrh 
2575897234Sdrh /*
2652fb6d71Sdrh ** The sqlite3KeywordCode function looks up an identifier to determine if
2752fb6d71Sdrh ** it is a keyword.  If it is a keyword, the token code of that keyword is
2875897234Sdrh ** returned.  If the input is not a keyword, TK_ID is returned.
292090a0edSdrh **
302090a0edSdrh ** The implementation of this routine was generated by a program,
3173b211abSdrh ** mkkeywordhash.h, located in the tool subdirectory of the distribution.
3252fb6d71Sdrh ** The output of the mkkeywordhash.c program is written into a file
3373b211abSdrh ** named keywordhash.h and then included into this source file by
3452fb6d71Sdrh ** the #include below.
3575897234Sdrh */
3673b211abSdrh #include "keywordhash.h"
3775897234Sdrh 
3840f20f7dSdrh 
3998808babSdrh /*
40ba21256fSdrh ** If X is a character that can be used in an identifier and
41a2b902d6Sdrh ** X&0x80==0 then sqlite3IsIdChar[X] will be 1.  If X&0x80==0x80 then
42ba21256fSdrh ** X is always an identifier character.  (Hence all UTF-8
43a2b902d6Sdrh ** characters can be part of an identifier).  sqlite3IsIdChar[X] will
44ba21256fSdrh ** be 0 for every character in the lower 128 ASCII characters
45ba21256fSdrh ** that cannot be used as part of an identifier.
4698808babSdrh **
4798808babSdrh ** In this implementation, an identifier can be a string of
4898808babSdrh ** alphabetic characters, digits, and "_" plus any character
4998808babSdrh ** with the high-order bit set.  The latter rule means that
5098808babSdrh ** any sequence of UTF-8 characters or characters taken from
5198808babSdrh ** an extended ISO8859 character set can form an identifier.
52a0d1f663Sdrh **
53a0d1f663Sdrh ** Ticket #1066.  the SQL standard does not allow '$' in the
54a0d1f663Sdrh ** middle of identfiers.  But many SQL implementations do.
55a0d1f663Sdrh ** SQLite will allow '$' in identifiers for compatibility.
56a0d1f663Sdrh ** But the feature is undocumented.
5798808babSdrh */
58a2b902d6Sdrh const char sqlite3IsIdChar[] = {
5998808babSdrh /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
60a0d1f663Sdrh     0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */
6198808babSdrh     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */
6298808babSdrh     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */
6398808babSdrh     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */
6498808babSdrh     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */
6598808babSdrh     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */
6698808babSdrh };
6798808babSdrh 
68a2b902d6Sdrh #define IdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsIdChar[c-0x20]))
6998808babSdrh 
7075897234Sdrh /*
7161b487d0Sdrh ** Return the length of the token that begins at z[0].
7261b487d0Sdrh ** Store the token type in *tokenType before returning.
7375897234Sdrh */
74c60e9b82Sdanielk1977 static int getToken(const unsigned char *z, int *tokenType){
75aa756b09Sdrh   int i, c;
7675897234Sdrh   switch( *z ){
7730cab809Sdrh     case ' ': case '\t': case '\n': case '\f': case '\r': {
7832eb7b47Sdrh       for(i=1; isspace(z[i]); i++){}
7975897234Sdrh       *tokenType = TK_SPACE;
8075897234Sdrh       return i;
8175897234Sdrh     }
8275897234Sdrh     case '-': {
8375897234Sdrh       if( z[1]=='-' ){
84aa756b09Sdrh         for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
8575897234Sdrh         *tokenType = TK_COMMENT;
8675897234Sdrh         return i;
8775897234Sdrh       }
8875897234Sdrh       *tokenType = TK_MINUS;
8975897234Sdrh       return 1;
9075897234Sdrh     }
9175897234Sdrh     case '(': {
9275897234Sdrh       *tokenType = TK_LP;
9375897234Sdrh       return 1;
9475897234Sdrh     }
9575897234Sdrh     case ')': {
9675897234Sdrh       *tokenType = TK_RP;
9775897234Sdrh       return 1;
9875897234Sdrh     }
9975897234Sdrh     case ';': {
10075897234Sdrh       *tokenType = TK_SEMI;
10175897234Sdrh       return 1;
10275897234Sdrh     }
10375897234Sdrh     case '+': {
10475897234Sdrh       *tokenType = TK_PLUS;
10575897234Sdrh       return 1;
10675897234Sdrh     }
10775897234Sdrh     case '*': {
10875897234Sdrh       *tokenType = TK_STAR;
10975897234Sdrh       return 1;
11075897234Sdrh     }
11175897234Sdrh     case '/': {
11266105a8eSdrh       if( z[1]!='*' || z[2]==0 ){
11375897234Sdrh         *tokenType = TK_SLASH;
11475897234Sdrh         return 1;
11575897234Sdrh       }
116aa756b09Sdrh       for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
117aa756b09Sdrh       if( c ) i++;
11866105a8eSdrh       *tokenType = TK_COMMENT;
11966105a8eSdrh       return i;
12066105a8eSdrh     }
121bf4133cbSdrh     case '%': {
122bf4133cbSdrh       *tokenType = TK_REM;
123bf4133cbSdrh       return 1;
124bf4133cbSdrh     }
12575897234Sdrh     case '=': {
12675897234Sdrh       *tokenType = TK_EQ;
12775897234Sdrh       return 1 + (z[1]=='=');
12875897234Sdrh     }
12975897234Sdrh     case '<': {
130aa756b09Sdrh       if( (c=z[1])=='=' ){
13175897234Sdrh         *tokenType = TK_LE;
13275897234Sdrh         return 2;
133aa756b09Sdrh       }else if( c=='>' ){
13475897234Sdrh         *tokenType = TK_NE;
13575897234Sdrh         return 2;
136aa756b09Sdrh       }else if( c=='<' ){
137bf4133cbSdrh         *tokenType = TK_LSHIFT;
138bf4133cbSdrh         return 2;
13975897234Sdrh       }else{
14075897234Sdrh         *tokenType = TK_LT;
14175897234Sdrh         return 1;
14275897234Sdrh       }
14375897234Sdrh     }
14475897234Sdrh     case '>': {
145aa756b09Sdrh       if( (c=z[1])=='=' ){
14675897234Sdrh         *tokenType = TK_GE;
14775897234Sdrh         return 2;
148aa756b09Sdrh       }else if( c=='>' ){
149bf4133cbSdrh         *tokenType = TK_RSHIFT;
150bf4133cbSdrh         return 2;
15175897234Sdrh       }else{
15275897234Sdrh         *tokenType = TK_GT;
15375897234Sdrh         return 1;
15475897234Sdrh       }
15575897234Sdrh     }
15675897234Sdrh     case '!': {
15775897234Sdrh       if( z[1]!='=' ){
15875897234Sdrh         *tokenType = TK_ILLEGAL;
159c837e709Sdrh         return 2;
16075897234Sdrh       }else{
16175897234Sdrh         *tokenType = TK_NE;
16275897234Sdrh         return 2;
16375897234Sdrh       }
16475897234Sdrh     }
1650040077dSdrh     case '|': {
1660040077dSdrh       if( z[1]!='|' ){
167bf4133cbSdrh         *tokenType = TK_BITOR;
1680040077dSdrh         return 1;
1690040077dSdrh       }else{
1700040077dSdrh         *tokenType = TK_CONCAT;
1710040077dSdrh         return 2;
1720040077dSdrh       }
1730040077dSdrh     }
17475897234Sdrh     case ',': {
17575897234Sdrh       *tokenType = TK_COMMA;
17675897234Sdrh       return 1;
17775897234Sdrh     }
178bf4133cbSdrh     case '&': {
179bf4133cbSdrh       *tokenType = TK_BITAND;
180bf4133cbSdrh       return 1;
181bf4133cbSdrh     }
182bf4133cbSdrh     case '~': {
183bf4133cbSdrh       *tokenType = TK_BITNOT;
184bf4133cbSdrh       return 1;
185bf4133cbSdrh     }
1863d94662aSdrh     case '`':
1873d94662aSdrh     case '\'':
1883d94662aSdrh     case '"': {
18975897234Sdrh       int delim = z[0];
190aa756b09Sdrh       for(i=1; (c=z[i])!=0; i++){
191aa756b09Sdrh         if( c==delim ){
19275897234Sdrh           if( z[i+1]==delim ){
19375897234Sdrh             i++;
19475897234Sdrh           }else{
19575897234Sdrh             break;
19675897234Sdrh           }
19775897234Sdrh         }
19875897234Sdrh       }
199eef8b558Sdrh       if( c ){
20075897234Sdrh         *tokenType = TK_STRING;
201eef8b558Sdrh         return i+1;
202eef8b558Sdrh       }else{
203eef8b558Sdrh         *tokenType = TK_ILLEGAL;
20475897234Sdrh         return i;
20575897234Sdrh       }
206eef8b558Sdrh     }
20775897234Sdrh     case '.': {
2087681618cSdrh #ifndef SQLITE_OMIT_FLOATING_POINT
2097681618cSdrh       if( !isdigit(z[1]) )
2107681618cSdrh #endif
2117681618cSdrh       {
21275897234Sdrh         *tokenType = TK_DOT;
21375897234Sdrh         return 1;
21475897234Sdrh       }
2157681618cSdrh       /* If the next character is a digit, this is a floating point
2167681618cSdrh       ** number that begins with ".".  Fall thru into the next case */
2177681618cSdrh     }
21875897234Sdrh     case '0': case '1': case '2': case '3': case '4':
21975897234Sdrh     case '5': case '6': case '7': case '8': case '9': {
220c837e709Sdrh       *tokenType = TK_INTEGER;
2217681618cSdrh       for(i=0; isdigit(z[i]); i++){}
222b7f9164eSdrh #ifndef SQLITE_OMIT_FLOATING_POINT
2237681618cSdrh       if( z[i]=='.' ){
2247681618cSdrh         i++;
22532eb7b47Sdrh         while( isdigit(z[i]) ){ i++; }
226c837e709Sdrh         *tokenType = TK_FLOAT;
227c837e709Sdrh       }
22875897234Sdrh       if( (z[i]=='e' || z[i]=='E') &&
22975897234Sdrh            ( isdigit(z[i+1])
23075897234Sdrh             || ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2]))
23175897234Sdrh            )
23275897234Sdrh       ){
23375897234Sdrh         i += 2;
23432eb7b47Sdrh         while( isdigit(z[i]) ){ i++; }
23575897234Sdrh         *tokenType = TK_FLOAT;
23675897234Sdrh       }
237b7f9164eSdrh #endif
23875897234Sdrh       return i;
23975897234Sdrh     }
2402f4392ffSdrh     case '[': {
241aa756b09Sdrh       for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}
2422f4392ffSdrh       *tokenType = TK_ID;
2432f4392ffSdrh       return i;
2442f4392ffSdrh     }
2457c972decSdrh     case '?': {
24650457896Sdrh       *tokenType = TK_VARIABLE;
247fa6bc000Sdrh       for(i=1; isdigit(z[i]); i++){}
248fa6bc000Sdrh       return i;
24950457896Sdrh     }
250288d37f1Sdrh     case '#': {
251288d37f1Sdrh       for(i=1; isdigit(z[i]); i++){}
252288d37f1Sdrh       if( i>1 ){
253288d37f1Sdrh         /* Parameters of the form #NNN (where NNN is a number) are used
254288d37f1Sdrh         ** internally by sqlite3NestedParse.  */
255288d37f1Sdrh         *tokenType = TK_REGISTER;
256895d7472Sdrh         return i;
257895d7472Sdrh       }
258288d37f1Sdrh       /* Fall through into the next case if the '#' is not followed by
259288d37f1Sdrh       ** a digit. Try to match #AAAA where AAAA is a parameter name. */
260288d37f1Sdrh     }
261b7f9164eSdrh #ifndef SQLITE_OMIT_TCL_VARIABLE
262288d37f1Sdrh     case '$':
263288d37f1Sdrh #endif
264288d37f1Sdrh     case ':': {
265895d7472Sdrh       int n = 0;
266288d37f1Sdrh       *tokenType = TK_VARIABLE;
267895d7472Sdrh       for(i=1; (c=z[i])!=0; i++){
268288d37f1Sdrh         if( IdChar(c) ){
269895d7472Sdrh           n++;
270288d37f1Sdrh #ifndef SQLITE_OMIT_TCL_VARIABLE
271895d7472Sdrh         }else if( c=='(' && n>0 ){
272895d7472Sdrh           do{
273895d7472Sdrh             i++;
274895d7472Sdrh           }while( (c=z[i])!=0 && !isspace(c) && c!=')' );
275895d7472Sdrh           if( c==')' ){
276895d7472Sdrh             i++;
277895d7472Sdrh           }else{
278895d7472Sdrh             *tokenType = TK_ILLEGAL;
279895d7472Sdrh           }
280895d7472Sdrh           break;
281895d7472Sdrh         }else if( c==':' && z[i+1]==':' ){
282895d7472Sdrh           i++;
283288d37f1Sdrh #endif
284895d7472Sdrh         }else{
285895d7472Sdrh           break;
286895d7472Sdrh         }
287895d7472Sdrh       }
2889d74b4c5Sdrh       if( n==0 ) *tokenType = TK_ILLEGAL;
289895d7472Sdrh       return i;
290895d7472Sdrh     }
291b7f9164eSdrh #ifndef SQLITE_OMIT_BLOB_LITERAL
292c572ef7fSdanielk1977     case 'x': case 'X': {
293aa756b09Sdrh       if( (c=z[1])=='\'' || c=='"' ){
294aa756b09Sdrh         int delim = c;
2953fd0a736Sdanielk1977         *tokenType = TK_BLOB;
296aa756b09Sdrh         for(i=2; (c=z[i])!=0; i++){
297aa756b09Sdrh           if( c==delim ){
2983fd0a736Sdanielk1977             if( i%2 ) *tokenType = TK_ILLEGAL;
299c572ef7fSdanielk1977             break;
300c572ef7fSdanielk1977           }
301aa756b09Sdrh           if( !isxdigit(c) ){
3023fd0a736Sdanielk1977             *tokenType = TK_ILLEGAL;
3033fd0a736Sdanielk1977             return i;
3043fd0a736Sdanielk1977           }
305c572ef7fSdanielk1977         }
306aa756b09Sdrh         if( c ) i++;
307c572ef7fSdanielk1977         return i;
308c572ef7fSdanielk1977       }
309c572ef7fSdanielk1977       /* Otherwise fall through to the next case */
310c572ef7fSdanielk1977     }
311b7f9164eSdrh #endif
31298808babSdrh     default: {
313aa756b09Sdrh       if( !IdChar(*z) ){
31498808babSdrh         break;
31598808babSdrh       }
316aa756b09Sdrh       for(i=1; IdChar(z[i]); i++){}
317c60e9b82Sdanielk1977       *tokenType = keywordCode((char*)z, i);
31875897234Sdrh       return i;
31975897234Sdrh     }
32075897234Sdrh   }
32175897234Sdrh   *tokenType = TK_ILLEGAL;
32275897234Sdrh   return 1;
32375897234Sdrh }
324c60e9b82Sdanielk1977 int sqlite3GetToken(const unsigned char *z, int *tokenType){
325c60e9b82Sdanielk1977   return getToken(z, tokenType);
326c60e9b82Sdanielk1977 }
32775897234Sdrh 
32875897234Sdrh /*
32975897234Sdrh ** Run the parser on the given SQL string.  The parser structure is
330b19a2bc6Sdrh ** passed in.  An SQLITE_ status code is returned.  If an error occurs
331b19a2bc6Sdrh ** and pzErrMsg!=NULL then an error message might be written into
332b19a2bc6Sdrh ** memory obtained from malloc() and *pzErrMsg made to point to that
333b19a2bc6Sdrh ** error message.  Or maybe not.
33475897234Sdrh */
3354adee20fSdanielk1977 int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
33675897234Sdrh   int nErr = 0;
33775897234Sdrh   int i;
33875897234Sdrh   void *pEngine;
339b86ccfb2Sdrh   int tokenType;
340b86ccfb2Sdrh   int lastTokenParsed = -1;
3419bb575fdSdrh   sqlite3 *db = pParse->db;
3424adee20fSdanielk1977   extern void *sqlite3ParserAlloc(void*(*)(int));
3434adee20fSdanielk1977   extern void sqlite3ParserFree(void*, void(*)(void*));
3444adee20fSdanielk1977   extern int sqlite3Parser(void*, int, Token, Parse*);
34575897234Sdrh 
3466d4abfbeSdrh   db->flags &= ~SQLITE_Interrupt;
3474c504391Sdrh   pParse->rc = SQLITE_OK;
34875897234Sdrh   i = 0;
349132d8d6aSdrh   pEngine = sqlite3ParserAlloc((void*(*)(int))sqlite3MallocX);
35075897234Sdrh   if( pEngine==0 ){
351defc9972Sdrh     return SQLITE_NOMEM;
35275897234Sdrh   }
353fa6bc000Sdrh   assert( pParse->sLastToken.dyn==0 );
354fa6bc000Sdrh   assert( pParse->pNewTable==0 );
355fa6bc000Sdrh   assert( pParse->pNewTrigger==0 );
356fa6bc000Sdrh   assert( pParse->nVar==0 );
357fa6bc000Sdrh   assert( pParse->nVarExpr==0 );
358fa6bc000Sdrh   assert( pParse->nVarExprAlloc==0 );
359fa6bc000Sdrh   assert( pParse->apVarExpr==0 );
3603f7d4e49Sdrh   pParse->zTail = pParse->zSql = zSql;
361261919ccSdanielk1977   while( sqlite3Tsd()->mallocFailed==0 && zSql[i]!=0 ){
36232eb7b47Sdrh     assert( i>=0 );
3632646da7eSdrh     pParse->sLastToken.z = (u8*)&zSql[i];
36432eb7b47Sdrh     assert( pParse->sLastToken.dyn==0 );
365c60e9b82Sdanielk1977     pParse->sLastToken.n = getToken((unsigned char*)&zSql[i],&tokenType);
36675897234Sdrh     i += pParse->sLastToken.n;
36775897234Sdrh     switch( tokenType ){
36875897234Sdrh       case TK_SPACE:
36975897234Sdrh       case TK_COMMENT: {
37032eb7b47Sdrh         if( (db->flags & SQLITE_Interrupt)!=0 ){
37132eb7b47Sdrh           pParse->rc = SQLITE_INTERRUPT;
3724adee20fSdanielk1977           sqlite3SetString(pzErrMsg, "interrupt", (char*)0);
37332eb7b47Sdrh           goto abort_parse;
37432eb7b47Sdrh         }
37575897234Sdrh         break;
37675897234Sdrh       }
37732eb7b47Sdrh       case TK_ILLEGAL: {
378ae29ffbeSdrh         if( pzErrMsg ){
379ae29ffbeSdrh           sqliteFree(*pzErrMsg);
380ae29ffbeSdrh           *pzErrMsg = sqlite3MPrintf("unrecognized token: \"%T\"",
381ae29ffbeSdrh                           &pParse->sLastToken);
382ae29ffbeSdrh         }
38375897234Sdrh         nErr++;
384caec2f12Sdrh         goto abort_parse;
38532eb7b47Sdrh       }
386326dce74Sdrh       case TK_SEMI: {
387326dce74Sdrh         pParse->zTail = &zSql[i];
388326dce74Sdrh         /* Fall thru into the default case */
389326dce74Sdrh       }
39032eb7b47Sdrh       default: {
3914adee20fSdanielk1977         sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
392b86ccfb2Sdrh         lastTokenParsed = tokenType;
393b86ccfb2Sdrh         if( pParse->rc!=SQLITE_OK ){
39432eb7b47Sdrh           goto abort_parse;
39575897234Sdrh         }
39675897234Sdrh         break;
39775897234Sdrh       }
39875897234Sdrh     }
39932eb7b47Sdrh   }
40032eb7b47Sdrh abort_parse:
401b86ccfb2Sdrh   if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){
402b86ccfb2Sdrh     if( lastTokenParsed!=TK_SEMI ){
4034adee20fSdanielk1977       sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
404326dce74Sdrh       pParse->zTail = &zSql[i];
40575897234Sdrh     }
4064adee20fSdanielk1977     sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
40775897234Sdrh   }
408132d8d6aSdrh   sqlite3ParserFree(pEngine, sqlite3FreeX);
409261919ccSdanielk1977   if( sqlite3Tsd()->mallocFailed ){
41071c697efSdrh     pParse->rc = SQLITE_NOMEM;
41171c697efSdrh   }
412b86ccfb2Sdrh   if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
413261919ccSdanielk1977     sqlite3SetString(&pParse->zErrMsg, sqlite3ErrStr(pParse->rc), (char*)0);
414b86ccfb2Sdrh   }
41575897234Sdrh   if( pParse->zErrMsg ){
416b86ccfb2Sdrh     if( pzErrMsg && *pzErrMsg==0 ){
41775897234Sdrh       *pzErrMsg = pParse->zErrMsg;
41875897234Sdrh     }else{
41975897234Sdrh       sqliteFree(pParse->zErrMsg);
42075897234Sdrh     }
421b86ccfb2Sdrh     pParse->zErrMsg = 0;
42275897234Sdrh     if( !nErr ) nErr++;
42375897234Sdrh   }
4242958a4e6Sdrh   if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
4254adee20fSdanielk1977     sqlite3VdbeDelete(pParse->pVdbe);
42675897234Sdrh     pParse->pVdbe = 0;
42775897234Sdrh   }
428*c00da105Sdanielk1977 #ifndef SQLITE_OMIT_SHARED_CACHE
429*c00da105Sdanielk1977   if( pParse->nested==0 ){
430*c00da105Sdanielk1977     sqliteFree(pParse->aTableLock);
431*c00da105Sdanielk1977     pParse->aTableLock = 0;
432*c00da105Sdanielk1977     pParse->nTableLock = 0;
433*c00da105Sdanielk1977   }
434*c00da105Sdanielk1977 #endif
4354adee20fSdanielk1977   sqlite3DeleteTable(pParse->db, pParse->pNewTable);
4364adee20fSdanielk1977   sqlite3DeleteTrigger(pParse->pNewTrigger);
437fa6bc000Sdrh   sqliteFree(pParse->apVarExpr);
438b86ccfb2Sdrh   if( nErr>0 && (pParse->rc==SQLITE_OK || pParse->rc==SQLITE_DONE) ){
4394c504391Sdrh     pParse->rc = SQLITE_ERROR;
4404c504391Sdrh   }
44175897234Sdrh   return nErr;
44275897234Sdrh }
443