diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 10 | ||||
-rw-r--r-- | src/sqliteInt.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c index 0796c8dba..10db73964 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.405 2008/12/05 15:24:17 drh Exp $ +** $Id: expr.c,v 1.406 2008/12/08 13:42:36 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1725,10 +1725,14 @@ void sqlite3ExprHardCopy(Parse *pParse, int iReg, int nReg){ static int codeAlias(Parse *pParse, int iAlias, Expr *pExpr, int target){ sqlite3 *db = pParse->db; int iReg; - if( pParse->aAlias==0 ){ - pParse->aAlias = sqlite3DbMallocZero(db, + if( pParse->nAliasAlloc<pParse->nAlias ){ + pParse->aAlias = sqlite3DbReallocOrFree(db, pParse->aAlias, sizeof(pParse->aAlias[0])*pParse->nAlias ); + testcase( db->mallocFailed && pParse->nAliasAlloc>0 ); if( db->mallocFailed ) return 0; + memset(&pParse->aAlias[pParse->nAliasAlloc], 0, + (pParse->nAlias-pParse->nAliasAlloc)*sizeof(pParse->aAlias[0])); + pParse->nAliasAlloc = pParse->nAlias; } assert( iAlias>0 && iAlias<=pParse->nAlias ); iReg = pParse->aAlias[iAlias-1]; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5758aa407..adf051033 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.802 2008/12/05 17:17:08 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.803 2008/12/08 13:42:36 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1752,6 +1752,7 @@ struct Parse { int nVarExprAlloc; /* Number of allocated slots in apVarExpr[] */ Expr **apVarExpr; /* Pointers to :aaa and $aaaa wildcard expressions */ int nAlias; /* Number of aliased result set columns */ + int nAliasAlloc; /* Number of allocated slots for aAlias[] */ int *aAlias; /* Register used to hold aliased result */ u8 explain; /* True if the EXPLAIN flag is found on the query */ Token sErrToken; /* The token at which the error occurred */ |