]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved comments. Add assert()s to verify that the AggInfo structure
authordrh <>
Fri, 25 Nov 2022 13:08:20 +0000 (13:08 +0000)
committerdrh <>
Fri, 25 Nov 2022 13:08:20 +0000 (13:08 +0000)
is unchanged after registers have been assigned.

FossilOrigin-Name: 5200b84195ee1ccaa387f7032eae3d463724c48cb53ba0251bbc79e927dd9752

manifest
manifest.uuid
src/expr.c
src/select.c
src/sqliteInt.h

index b0b68942588c967e5400983d58114a145e343460..77a2dfc4d6dafabad9ab9b8c0320ffaa163c7e04 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Correctly\sdeal\swith\sIF-NULL-ROW\soperators\swhen\sdealing\swith\nindexed\sexpressions\sin\saggregates.
-D 2022-11-24T23:35:27.975
+C Improved\scomments.\s\sAdd\sassert()s\sto\sverify\sthat\sthe\sAggInfo\sstructure\nis\sunchanged\safter\sregisters\shave\sbeen\sassigned.
+D 2022-11-25T13:08:20.992
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -591,7 +591,7 @@ F src/date.c 94ce83b4cd848a387680a5f920c9018c16655db778c4d36525af0a0f34679ac5
 F src/dbpage.c f1a87f4ebcf22284e0aaf0697862f4ccfc120dcd6db3d8dfa3b049b2580c01d8
 F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
 F src/delete.c 86573edae75e3d3e9a8b590d87db8e47222103029df4f3e11fa56044459b514e
-F src/expr.c af9e80644a53ba437851659ba753e8e049e32c40cd584eece3796357fab52e9e
+F src/expr.c 9e7fadc664b938c18f006be0d4f6669888f9302756ee204420c7eccaed5435a6
 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
 F src/fkey.c 722f20779f5342a787922deded3628d8c74b5249cab04098cf17ee2f2aaff002
 F src/func.c 7e86074afc4dc702691a29b7801f6dcc191db092b52e8bbe69dcd2f7be52194d
@@ -641,12 +641,12 @@ F src/printf.c e99ee9741e79ae3873458146f59644276657340385ade4e76a5f5d1c25793764
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633
 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
-F src/select.c c1cf437e18022df196bfe6e1f34a5fc1e871706665a0588863df5082d2e26563
+F src/select.c 6168029423615a01de361024c56261f2f39d85adcd6da06137010f7ceea759b4
 F src/shell.c.in 09cb15d7421c475f2d308f6a4312d8d690916ea5cb62ea1618f2f4ce5703af35
 F src/sqlite.h.in 100fc660c2f19961b8ed8437b9d53d687de2f8eb2b96437ec6da216adcb643ca
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h c4b9fa7a7e2bcdf850cfeb4b8a91d5ec47b7a00033bc996fd2ee96cbf2741f5f
-F src/sqliteInt.h f4917d663170308601d794cdff7b8cf9704c4bafe03d7e926a156be835e29f29
+F src/sqliteInt.h 5dd5d3d47f40b6a12be4a5fc131673bfe00c00373ed266ff4c4ec05d1991e69f
 F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
@@ -2060,8 +2060,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 5fc23863e4a6388884ce061cd69546757b4c39d731bbb58a8121b92fd5144f7b
-R 9699b80135f783c01dc948dbd9568fdf
+P 939cb47025354e2df047de7654c0b06f791957cfe4e904abe8892207cea90215
+R 85b4d1494a033b09f8257ada7ad96c3c
 U drh
-Z b4118428f98b75714904c3dd7e4b5c40
+Z f7018e8b2be8d601c79b6c13f2f54a26
 # Remove this line to create a well-formed Fossil manifest.
index 5c7c74dae16da6a48568eec098fd277ae54cbbc5..07bc523f18a01f7e7234d83428d7d6de86e1c26c 100644 (file)
@@ -1 +1 @@
-939cb47025354e2df047de7654c0b06f791957cfe4e904abe8892207cea90215
\ No newline at end of file
+5200b84195ee1ccaa387f7032eae3d463724c48cb53ba0251bbc79e927dd9752
\ No newline at end of file
index d7f8cfa9173987e61eec3055ac16f750309f2b08..d30ae97668b1ce4d5a198897a41f89285bae09e3 100644 (file)
@@ -6265,6 +6265,7 @@ static void findOrCreateAggInfoColumn(
   struct AggInfo_col *pCol;
   int k;
 
+  assert( pAggInfo->iFirstReg==0 );
   pCol = pAggInfo->aCol;
   for(k=0; k<pAggInfo->nColumn; k++, pCol++){
     if( pCol->iTable==pExpr->iTable
@@ -6328,6 +6329,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
   AggInfo *pAggInfo = pNC->uNC.pAggInfo;
 
   assert( pNC->ncFlags & NC_UAggInfo );
+  assert( pAggInfo->iFirstReg==0 );
   switch( pExpr->op ){
     default: {
       IndexedExpr *pIEpr;
index 2e6ad456146c9e6256eb601bd78f9bbdedc30a46..e76198772d79f2a1c881b053fe947085782298d6 100644 (file)
@@ -6253,6 +6253,7 @@ static void analyzeAggFuncArgs(
 ){
   int i;
   assert( pAggInfo!=0 );
+  assert( pAggInfo->iFirstReg==0 );
   pNC->ncFlags |= NC_InAggFunc;
   for(i=0; i<pAggInfo->nFunc; i++){
     Expr *pExpr = pAggInfo->aFunc[i].pFExpr;
@@ -6281,6 +6282,7 @@ static void optimizeAggregateUseOfIndexedExpr(
   AggInfo *pAggInfo,      /* The aggregate info */
   NameContext *pNC        /* Name context used to resolve agg-func args */
 ){
+  assert( pAggInfo->iFirstReg==0 );
   pAggInfo->nColumn = pAggInfo->nAccumulator;
   if( ALWAYS(pAggInfo->nSortingColumn>0) ){
     if( pAggInfo->nColumn==0 ){
@@ -6348,6 +6350,18 @@ static void aggregateConvertIndexedExprRefToColumn(AggInfo *pAggInfo){
 ** Allocate a block of registers so that there is one register for each
 ** pAggInfo->aCol[] and pAggInfo->aFunc[] entry in pAggInfo.  The first
 ** register in this block is stored in pAggInfo->iFirstReg.
+**
+** This routine may only be called once for each AggInfo object.  Prior
+** to calling this routine:
+**
+**     *  The aCol[] and aFunc[] arrays may be modified
+**     *  The AggInfoColumnReg() and AggInfoFuncReg() macros may not be used
+**
+** After clling this routine:
+**
+**     *  The aCol[] and aFunc[] arrays are fixed
+**     *  The AggInfoColumnReg() and AggInfoFuncReg() macros may be used
+**
 */
 static void assignAggregateRegisters(Parse *pParse, AggInfo *pAggInfo){
   assert( pAggInfo!=0 );
@@ -6369,6 +6383,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
   int i;
   struct AggInfo_func *pFunc;
   int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
+  assert( pAggInfo->iFirstReg>0 );
   assert( pParse->db->pParse==pParse );
   assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
   if( nReg==0 ) return;
@@ -6436,6 +6451,7 @@ static void updateAccumulator(
   struct AggInfo_func *pF;
   struct AggInfo_col *pC;
 
+  assert( pAggInfo->iFirstReg>0 );
   pAggInfo->directMode = 1;
   for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){
     int nArg;
index 3ecdb35feeb38136b45b08c3d59b229e5d42e454..db65082bbc559479cc0aacf1af819117fd2da8a5 100644 (file)
@@ -2766,10 +2766,15 @@ struct AggInfo {
 };
 
 /*
-** Macros to compute aCol[] and aFunc[] register numbers:
+** Macros to compute aCol[] and aFunc[] register numbers.
+**
+** These macros should not be used prior to the call to 
+** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg.
+** The assert()s that are part of this macro verify that constraint.
 */
-#define AggInfoColumnReg(A,I)  ((A)->iFirstReg+(I))
-#define AggInfoFuncReg(A,I)    ((A)->iFirstReg+(A)->nColumn+(I))
+#define AggInfoColumnReg(A,I)  (assert((A)->iFirstReg),(A)->iFirstReg+(I))
+#define AggInfoFuncReg(A,I)    \
+                      (assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I))
 
 /*
 ** The datatype ynVar is a signed integer, either 16-bit or 32-bit.