Index: third_party/sqlite/src/src/tokenize.c |
diff --git a/third_party/sqlite/src/src/tokenize.c b/third_party/sqlite/src/src/tokenize.c |
index c624efdcc7c7947ba73304c2b8c12fb333960bce..5bb91554606c1830639e352d2be453fd4b235585 100644 |
--- a/third_party/sqlite/src/src/tokenize.c |
+++ b/third_party/sqlite/src/src/tokenize.c |
@@ -77,7 +77,7 @@ const unsigned char ebcdicToAscii[] = { |
** end result. |
** |
** Ticket #1066. the SQL standard does not allow '$' in the |
-** middle of identfiers. But many SQL implementations do. |
+** middle of identifiers. But many SQL implementations do. |
** SQLite will allow '$' in identifiers for compatibility. |
** But the feature is undocumented. |
*/ |
@@ -102,6 +102,7 @@ const char sqlite3IsEbcdicIdChar[] = { |
}; |
#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) |
#endif |
+int sqlite3IsIdChar(u8 c){ return IdChar(c); } |
/* |
@@ -123,7 +124,6 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
} |
case '-': { |
if( z[1]=='-' ){ |
- /* IMP: R-15891-05542 -- syntax diagram for comments */ |
for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
return i; |
@@ -156,7 +156,6 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
*tokenType = TK_SLASH; |
return 1; |
} |
- /* IMP: R-15891-05542 -- syntax diagram for comments */ |
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
if( c ) i++; |
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
@@ -272,6 +271,12 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
testcase( z[0]=='6' ); testcase( z[0]=='7' ); testcase( z[0]=='8' ); |
testcase( z[0]=='9' ); |
*tokenType = TK_INTEGER; |
+#ifndef SQLITE_OMIT_HEX_INTEGER |
+ if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ |
+ for(i=3; sqlite3Isxdigit(z[i]); i++){} |
+ return i; |
+ } |
+#endif |
for(i=0; sqlite3Isdigit(z[i]); i++){} |
#ifndef SQLITE_OMIT_FLOATING_POINT |
if( z[i]=='.' ){ |
@@ -305,24 +310,15 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
for(i=1; sqlite3Isdigit(z[i]); i++){} |
return i; |
} |
- case '#': { |
- for(i=1; sqlite3Isdigit(z[i]); i++){} |
- if( i>1 ){ |
- /* Parameters of the form #NNN (where NNN is a number) are used |
- ** internally by sqlite3NestedParse. */ |
- *tokenType = TK_REGISTER; |
- return i; |
- } |
- /* Fall through into the next case if the '#' is not followed by |
- ** a digit. Try to match #AAAA where AAAA is a parameter name. */ |
- } |
#ifndef SQLITE_OMIT_TCL_VARIABLE |
case '$': |
#endif |
case '@': /* For compatibility with MS SQL Server */ |
+ case '#': |
case ':': { |
int n = 0; |
- testcase( z[0]=='$' ); testcase( z[0]=='@' ); testcase( z[0]==':' ); |
+ testcase( z[0]=='$' ); testcase( z[0]=='@' ); |
+ testcase( z[0]==':' ); testcase( z[0]=='#' ); |
*tokenType = TK_VARIABLE; |
for(i=1; (c=z[i])!=0; i++){ |
if( IdChar(c) ){ |
@@ -353,13 +349,12 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
testcase( z[0]=='x' ); testcase( z[0]=='X' ); |
if( z[1]=='\'' ){ |
*tokenType = TK_BLOB; |
- for(i=2; (c=z[i])!=0 && c!='\''; i++){ |
- if( !sqlite3Isxdigit(c) ){ |
- *tokenType = TK_ILLEGAL; |
- } |
+ for(i=2; sqlite3Isxdigit(z[i]); i++){} |
+ if( z[i]!='\'' || i%2 ){ |
+ *tokenType = TK_ILLEGAL; |
+ while( z[i] && z[i]!='\'' ){ i++; } |
} |
- if( i%2 || !c ) *tokenType = TK_ILLEGAL; |
- if( c ) i++; |
+ if( z[i] ) i++; |
return i; |
} |
/* Otherwise fall through to the next case */ |
@@ -397,14 +392,14 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ |
mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
- if( db->activeVdbeCnt==0 ){ |
+ if( db->nVdbeActive==0 ){ |
db->u1.isInterrupted = 0; |
} |
pParse->rc = SQLITE_OK; |
pParse->zTail = zSql; |
i = 0; |
assert( pzErrMsg!=0 ); |
- pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc); |
+ pEngine = sqlite3ParserAlloc(sqlite3Malloc); |
if( pEngine==0 ){ |
db->mallocFailed = 1; |
return SQLITE_NOMEM; |
@@ -412,9 +407,8 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ |
assert( pParse->pNewTable==0 ); |
assert( pParse->pNewTrigger==0 ); |
assert( pParse->nVar==0 ); |
- assert( pParse->nVarExpr==0 ); |
- assert( pParse->nVarExprAlloc==0 ); |
- assert( pParse->apVarExpr==0 ); |
+ assert( pParse->nzVar==0 ); |
+ assert( pParse->azVar==0 ); |
enableLookaside = db->lookaside.bEnabled; |
if( db->lookaside.pStart ) db->lookaside.bEnabled = 1; |
while( !db->mallocFailed && zSql[i]!=0 ){ |
@@ -507,9 +501,10 @@ abort_parse: |
sqlite3DeleteTable(db, pParse->pNewTable); |
} |
+ if( pParse->bFreeWith ) sqlite3WithDelete(db, pParse->pWith); |
sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
- sqlite3DbFree(db, pParse->apVarExpr); |
- sqlite3DbFree(db, pParse->aAlias); |
+ for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]); |
+ sqlite3DbFree(db, pParse->azVar); |
while( pParse->pAinc ){ |
AutoincInfo *p = pParse->pAinc; |
pParse->pAinc = p->pNext; |