mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Get the "DEFAULT true" and "DEFAULT false" phrases working correctly in
CREATE TABLE. FossilOrigin-Name: 8002f87d96b3f885cd208e7d204907a33ba60c4057ce2338b71e2de41215b0e5
This commit is contained in:
28
src/expr.c
28
src/expr.c
@@ -1123,7 +1123,7 @@ static int dupedExprStructSize(Expr *p, int flags){
|
||||
assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
|
||||
assert( EXPR_FULLSIZE<=0xfff );
|
||||
assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
|
||||
if( 0==flags || p->op==TK_SELECT_COLUMN ){
|
||||
if( 0==flags || p->op==TK_SELECT_COLUMN || p->op==TK_TRUEFALSE ){
|
||||
nSize = EXPR_FULLSIZE;
|
||||
}else{
|
||||
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
|
||||
@@ -1732,6 +1732,26 @@ int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
|
||||
return WRC_Abort;
|
||||
}
|
||||
|
||||
/*
|
||||
** If the input expression is an ID with the name "true" or "false"
|
||||
** then convert it into an appropriate TK_TRUEFALSE term. Return true
|
||||
** if a conversion occurred, and false if the expression is unaltered.
|
||||
*/
|
||||
int sqlite3ExprIdToTrueFalse(Expr *pExpr){
|
||||
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
|
||||
if( sqlite3StrICmp(pExpr->u.zToken, "true")==0
|
||||
|| sqlite3StrICmp(pExpr->u.zToken, "false")==0
|
||||
){
|
||||
pExpr->op = TK_TRUEFALSE;
|
||||
pExpr->iTable = pExpr->u.zToken[4]==0;
|
||||
pExpr->pTab = 0;
|
||||
ExprSetProperty(pExpr, EP_NoReduce);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** These routines are Walker callbacks used to check expressions to
|
||||
** see if they are "constant" for some definition of constant. The
|
||||
@@ -1779,6 +1799,12 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
|
||||
return WRC_Abort;
|
||||
}
|
||||
case TK_ID:
|
||||
/* Convert "true" or "false" in a DEFAULT clause into the
|
||||
** appropriate TK_TRUEFALSE operator */
|
||||
if( pWalker->eCode>=4 && sqlite3ExprIdToTrueFalse(pExpr) ){
|
||||
return WRC_Prune;
|
||||
}
|
||||
/* Fall thru */
|
||||
case TK_COLUMN:
|
||||
case TK_AGG_FUNCTION:
|
||||
case TK_AGG_COLUMN:
|
||||
|
||||
Reference in New Issue
Block a user