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

Improved robustness following OOM in the constant propagation optimization.

dbsqlfuzz 001a20255c0df7495c21df62a20ea5b51e22c390.

FossilOrigin-Name: 8658a64d414db6900b55281f5e67180ea74b82627199b927634a727ed28030c2
This commit is contained in:
drh
2021-06-10 14:36:23 +00:00
parent d622855e34
commit 75016050f3
3 changed files with 12 additions and 7 deletions

View File

@@ -4415,6 +4415,7 @@ static int flattenSubquery(
typedef struct WhereConst WhereConst;
struct WhereConst {
Parse *pParse; /* Parsing context */
u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
int nConst; /* Number for COLUMN=CONSTANT terms */
int nChng; /* Number of times a constant is propagated */
int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
@@ -4514,6 +4515,7 @@ static int propagateConstantExprRewriteOne(
int bIgnoreAffBlob
){
int i;
if( pConst->pOomFault[0] ) return WRC_Prune;
if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
testcase( ExprHasProperty(pExpr, EP_FixedCol) );
@@ -4534,6 +4536,7 @@ static int propagateConstantExprRewriteOne(
ExprSetProperty(pExpr, EP_FixedCol);
assert( pExpr->pLeft==0 );
pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
if( pConst->pParse->db->mallocFailed ) return WRC_Prune;
break;
}
return WRC_Prune;
@@ -4566,6 +4569,7 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
|| pExpr->op==TK_IS
){
propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
if( pConst->pOomFault[0] ) return WRC_Prune;
if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
}
@@ -4633,6 +4637,7 @@ static int propagateConstants(
Walker w;
int nChng = 0;
x.pParse = pParse;
x.pOomFault = &pParse->db->mallocFailed;
do{
x.nConst = 0;
x.nChng = 0;