1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Record within the Token structure itself whether or not the token has

been dequoted.  This steals one bit from the length of a token and
thus limits the size of tokens to 1GiB. (CVS 6589)

FossilOrigin-Name: 12bcb03d9b9e1a31c1a3c67cbb4263cc0af2f3d0
This commit is contained in:
drh
2009-05-01 21:13:36 +00:00
parent d51397a614
commit 24fb627afa
14 changed files with 76 additions and 110 deletions

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.510 2009/04/24 15:46:22 drh Exp $
** $Id: select.c,v 1.511 2009/05/01 21:13:37 drh Exp $
*/
#include "sqliteInt.h"
@@ -193,42 +193,7 @@ static void setToken(Token *p, const char *z){
p->z = (u8*)z;
p->n = z ? sqlite3Strlen30(z) : 0;
p->dyn = 0;
}
/*
** Set the token to the double-quoted and escaped version of the string pointed
** to by z. For example;
**
** {a"bc} -> {"a""bc"}
*/
static void setQuotedToken(Parse *pParse, Token *p, const char *z){
/* Check if the string appears to be quoted using "..." or `...`
** or [...] or '...' or if the string contains any " characters.
** If it does, then record a version of the string with the special
** characters escaped.
*/
const char *z2 = z;
if( *z2!='[' && *z2!='`' && *z2!='\'' ){
while( *z2 ){
if( *z2=='"' ) break;
z2++;
}
}
if( *z2 ){
/* String contains " characters - copy and quote the string. */
p->z = (u8 *)sqlite3MPrintf(pParse->db, "\"%w\"", z);
if( p->z ){
p->n = sqlite3Strlen30((char *)p->z);
p->dyn = 1;
}
}else{
/* String contains no " characters - copy the pointer. */
p->z = (u8*)z;
p->n = (int)(z2 - z);
p->dyn = 0;
}
p->quoted = 0;
}
/*
@@ -3228,12 +3193,12 @@ static int selectExpander(Walker *pWalker, Select *p){
}
pRight = sqlite3PExpr(pParse, TK_ID, 0, 0, 0);
if( pRight==0 ) break;
setQuotedToken(pParse, &pRight->token, zName);
setToken(&pRight->token, zName);
if( longNames || pTabList->nSrc>1 ){
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, 0);
pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
if( pExpr==0 ) break;
setQuotedToken(pParse, &pLeft->token, zTabName);
setToken(&pLeft->token, zTabName);
setToken(&pExpr->span,
sqlite3MPrintf(db, "%s.%s", zTabName, zName));
pExpr->span.dyn = 1;