mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
When generating the name of a view (or common table expression) because the
SQL does not specify a name, avoid the names "true" and "false" which might be confused for the boolean literals of the same name, leading to an inconsistent abstract syntax tree. FossilOrigin-Name: ff9492d3ff733c222ea67f23d478df1547641b5e2e6dd870b0b29e25c13f3739
This commit is contained in:
21
src/expr.c
21
src/expr.c
@@ -1848,19 +1848,34 @@ int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
|
||||
return WRC_Abort;
|
||||
}
|
||||
|
||||
/*
|
||||
** Check the input string to see if it is "true" or "false" (in any case).
|
||||
**
|
||||
** If the string is.... Return
|
||||
** "true" EP_IsTrue
|
||||
** "false" EP_IsFalse
|
||||
** anything else 0
|
||||
*/
|
||||
u32 sqlite3IsTrueOrFalse(const char *zIn){
|
||||
if( sqlite3StrICmp(zIn, "true")==0 ) return EP_IsTrue;
|
||||
if( sqlite3StrICmp(zIn, "false")==0 ) return EP_IsFalse;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** If the input expression is an ID with the name "true" or "false"
|
||||
** then convert it into an TK_TRUEFALSE term. Return non-zero if
|
||||
** the conversion happened, and zero if the expression is unaltered.
|
||||
*/
|
||||
int sqlite3ExprIdToTrueFalse(Expr *pExpr){
|
||||
u32 v;
|
||||
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
|
||||
if( !ExprHasProperty(pExpr, EP_Quoted)
|
||||
&& (sqlite3StrICmp(pExpr->u.zToken, "true")==0
|
||||
|| sqlite3StrICmp(pExpr->u.zToken, "false")==0)
|
||||
&& (v = sqlite3IsTrueOrFalse(pExpr->u.zToken))!=0
|
||||
){
|
||||
pExpr->op = TK_TRUEFALSE;
|
||||
ExprSetProperty(pExpr, pExpr->u.zToken[4]==0 ? EP_IsTrue : EP_IsFalse);
|
||||
ExprSetProperty(pExpr, v);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user