diff options
author | drh <drh@noemail.net> | 2019-06-11 10:43:56 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-06-11 10:43:56 +0000 |
commit | 8e34e4061b534130bc7495c102120371c8738d95 (patch) | |
tree | 54e870823fd3bfd69c70ba1071e4ff484a99e702 /src | |
parent | b854b767330306ae20b235186af8e75f3c368900 (diff) | |
download | sqlite-8e34e4061b534130bc7495c102120371c8738d95.tar.gz sqlite-8e34e4061b534130bc7495c102120371c8738d95.zip |
Add the new sqlite3ExprUnmapAndDelete() function and use it in place of
separate calls to sqlite3RenameExprUnmap() and sqlite3ExprDelete().
FossilOrigin-Name: 36ea13e0a851a749c9ef292377ecd82dbd4797d38df907b362487fa234c98ca5
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 25 | ||||
-rw-r--r-- | src/parse.y | 2 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 |
3 files changed, 17 insertions, 11 deletions
diff --git a/src/expr.c b/src/expr.c index 057cbd6b7..4e8251bd8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -895,12 +895,8 @@ Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){ }else if( pRight==0 ){ return pLeft; }else if( ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight) ){ - if( IN_RENAME_OBJECT ){ - sqlite3RenameExprUnmap(pParse, pLeft); - sqlite3RenameExprUnmap(pParse, pRight); - } - sqlite3ExprDelete(db, pLeft); - sqlite3ExprDelete(db, pRight); + sqlite3ExprUnmapAndDelete(pParse, pLeft); + sqlite3ExprUnmapAndDelete(pParse, pRight); return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0); }else{ return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); @@ -1060,6 +1056,18 @@ void sqlite3ExprDelete(sqlite3 *db, Expr *p){ if( p ) sqlite3ExprDeleteNN(db, p); } +/* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the +** expression. +*/ +void sqlite3ExprUnmapAndDelete(Parse *pParse, Expr *p){ + if( p ){ + if( IN_RENAME_OBJECT ){ + sqlite3RenameExprUnmap(pParse, p); + } + sqlite3ExprDeleteNN(pParse->db, p); + } +} + /* ** Return the number of bytes allocated for the expression structure ** passed as the first argument. This is always one of EXPR_FULLSIZE, @@ -1642,10 +1650,7 @@ ExprList *sqlite3ExprListAppendVector( } vector_append_error: - if( IN_RENAME_OBJECT ){ - sqlite3RenameExprUnmap(pParse, pExpr); - } - sqlite3ExprDelete(db, pExpr); + sqlite3ExprUnmapAndDelete(pParse, pExpr); sqlite3IdListDelete(db, pColumns); return pList; } diff --git a/src/parse.y b/src/parse.y index f02f2074c..fc5bff16d 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1173,7 +1173,7 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { ** simplify to constants 0 (false) and 1 (true), respectively, ** regardless of the value of expr1. */ - sqlite3ExprDelete(pParse->db, A); + sqlite3ExprUnmapAndDelete(pParse, A); A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1); }else if( Y->nExpr==1 ){ /* Expressions of the form: diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 542200795..5c711f952 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3871,6 +3871,7 @@ Expr *sqlite3ExprSimplifiedAndOr(Expr*); Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); void sqlite3ExprDelete(sqlite3*, Expr*); +void sqlite3ExprUnmapAndDelete(Parse*, Expr*); ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); void sqlite3ExprListSetSortOrder(ExprList*,int); |