diff options
author | dan <dan@noemail.net> | 2018-06-04 08:28:18 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2018-06-04 08:28:18 +0000 |
commit | 2b1287cf4443e040662a16667bb024f948e51c17 (patch) | |
tree | 10151f634a4b704038fdabb24a6b813990d61cb8 /src/resolve.c | |
parent | f1abe3680e04cc0f5c9eed7a9e6b47093a490beb (diff) | |
parent | eb7df46e3203bb1fe1cfbd1c42c3af1a26a6ce6d (diff) | |
download | sqlite-2b1287cf4443e040662a16667bb024f948e51c17.tar.gz sqlite-2b1287cf4443e040662a16667bb024f948e51c17.zip |
Merge latest trunk changes into this branch.
FossilOrigin-Name: 83d6416a868fac81a78c9507185a48d00920e4322276245e285946f760915f4a
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/resolve.c b/src/resolve.c index 84baf01ab..47f22a971 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -75,29 +75,31 @@ static void resolveAlias( assert( pOrig!=0 ); db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); - if( pDup==0 ) return; - if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery); - if( pExpr->op==TK_COLLATE ){ - pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); - } - ExprSetProperty(pDup, EP_Alias); - - /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This - ** prevents ExprDelete() from deleting the Expr structure itself, - ** allowing it to be repopulated by the memcpy() on the following line. - ** The pExpr->u.zToken might point into memory that will be freed by the - ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to - ** make a copy of the token before doing the sqlite3DbFree(). - */ - ExprSetProperty(pExpr, EP_Static); - sqlite3ExprDelete(db, pExpr); - memcpy(pExpr, pDup, sizeof(*pExpr)); - if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){ - assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 ); - pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); - pExpr->flags |= EP_MemToken; + if( pDup!=0 ){ + if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery); + if( pExpr->op==TK_COLLATE ){ + pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); + } + ExprSetProperty(pDup, EP_Alias); + + /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This + ** prevents ExprDelete() from deleting the Expr structure itself, + ** allowing it to be repopulated by the memcpy() on the following line. + ** The pExpr->u.zToken might point into memory that will be freed by the + ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to + ** make a copy of the token before doing the sqlite3DbFree(). + */ + ExprSetProperty(pExpr, EP_Static); + sqlite3ExprDelete(db, pExpr); + memcpy(pExpr, pDup, sizeof(*pExpr)); + if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){ + assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 ); + pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); + pExpr->flags |= EP_MemToken; + } + sqlite3DbFree(db, pDup); } - sqlite3DbFree(db, pDup); + ExprSetProperty(pExpr, EP_Alias); } @@ -349,6 +351,7 @@ static int lookupName( testcase( iCol==(-1) ); pExpr->iTable = pNC->uNC.pUpsert->regData + iCol; eNewExprOp = TK_REGISTER; + ExprSetProperty(pExpr, EP_Alias); }else #endif /* SQLITE_OMIT_UPSERT */ { |