diff options
author | drh <drh@noemail.net> | 2020-06-08 11:34:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-06-08 11:34:40 +0000 |
commit | e6463a717a15ec0c7958e1bda45bd08da28188ab (patch) | |
tree | 2c9346ec7fee7e74498eda401732203ad25e0e70 /src/sqliteInt.h | |
parent | a0365c487c1267af6d3ab101399c6fa35f5184a3 (diff) | |
parent | 2f82acc036c5f286fda6ef815bfc3469acd402e2 (diff) | |
download | sqlite-e6463a717a15ec0c7958e1bda45bd08da28188ab.tar.gz sqlite-e6463a717a15ec0c7958e1bda45bd08da28188ab.zip |
When an Expr object is changed and that Expr is referenced by an AggInfo, then
also update the AggInfo. Also, persist all AggInfo objects until the Parse
object is destroyed. This is a new fix for ticket [c8d3b9f0a750a529] that
avoids the follow-on problems identified by tickets
[0899cf62f597d7e7], [1f6f353b684fc708], [e5504e987e419fb0], and
[f7d890858f361402].
FossilOrigin-Name: 6e6b3729e0549de028f6c5bf494b2d69d621c81b61a1dc0a329d3950039342fb
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r-- | src/sqliteInt.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e37ed673a..0b71ef42b 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2506,11 +2506,11 @@ struct AggInfo { ExprList *pGroupBy; /* The group by clause */ struct AggInfo_col { /* For each column used in source tables */ Table *pTab; /* Source table */ + Expr *pExpr; /* The original expression */ int iTable; /* Cursor number of the source table */ - int iColumn; /* Column number within the source table */ - int iSorterColumn; /* Column number in the sorting index */ int iMem; /* Memory location that acts as accumulator */ - Expr *pExpr; /* The original expression */ + i16 iColumn; /* Column number within the source table */ + i16 iSorterColumn; /* Column number in the sorting index */ } *aCol; int nColumn; /* Number of used entries in aCol[] */ int nAccumulator; /* Number of columns that show through to the output. @@ -2523,9 +2523,18 @@ struct AggInfo { int iDistinct; /* Ephemeral table used to enforce DISTINCT */ } *aFunc; int nFunc; /* Number of entries in aFunc[] */ +#ifdef SQLITE_DEBUG + int iAggMagic; /* Magic number when valid */ +#endif + AggInfo *pNext; /* Next in list of them all */ }; /* +** Value for AggInfo.iAggMagic when the structure is valid +*/ +#define AggInfoMagic 0x2059e99e + +/* ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater ** than 32767 we have to make it 32-bit. 16-bit is preferred because @@ -3321,6 +3330,7 @@ struct Parse { Parse *pToplevel; /* Parse structure for main program (or NULL) */ Table *pTriggerTab; /* Table triggers are being coded for */ Parse *pParentParse; /* Parent parser if this parser is nested */ + AggInfo *pAggList; /* List of all AggInfo objects */ int addrCrTab; /* Address of OP_CreateBtree opcode on CREATE TABLE */ u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ u32 oldmask; /* Mask of old.* columns referenced */ @@ -4287,6 +4297,7 @@ int sqlite3ExprCompareSkip(Expr*, Expr*, int); int sqlite3ExprListCompare(ExprList*, ExprList*, int); int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int); int sqlite3ExprImpliesNonNullRow(Expr*,int); +void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |