/ Check-in [e6d5fee8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ensure that the BtShared.nPage value is reset correctly on a SAVEPOINT ROLLBACK.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e6d5fee8cdbdce8515957e8288e4d1e7b06f417fd3f9deeeb636fbf5b995af51
User & Date: drh 2019-05-10 14:34:18
Context
2019-05-10
17:50
Fix harmless compiler warnings in the CLI. check-in: 2846bc04 user: drh tags: trunk
16:16
Fix some harmless compiler warnings. Closed-Leaf check-in: ca068d82 user: mistachkin tags: warnings
14:34
Ensure that the BtShared.nPage value is reset correctly on a SAVEPOINT ROLLBACK. check-in: e6d5fee8 user: drh tags: trunk
14:26
Treat integer values in window definition ORDER BY clauses as constants, not as references to another expression. check-in: 7e4809ea user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  4148   4148         }
  4149   4149         btreeReleaseAllCursorPages(p);
  4150   4150       }
  4151   4151       sqlite3BtreeLeave(pBtree);
  4152   4152     }
  4153   4153     return rc;
  4154   4154   }
         4155  +
         4156  +/*
         4157  +** Set the pBt->nPage field correctly, according to the current
         4158  +** state of the database.  Assume pBt->pPage1 is valid.
         4159  +*/
         4160  +static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){
         4161  +  int nPage = get4byte(&pPage1->aData[28]);
         4162  +  testcase( nPage==0 );
         4163  +  if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
         4164  +  testcase( pBt->nPage!=nPage );
         4165  +  pBt->nPage = nPage;
         4166  +}
  4155   4167   
  4156   4168   /*
  4157   4169   ** Rollback the transaction in progress.
  4158   4170   **
  4159   4171   ** If tripCode is not SQLITE_OK then cursors will be invalidated (tripped).
  4160   4172   ** Only write cursors are tripped if writeOnly is true but all cursors are
  4161   4173   ** tripped if writeOnly is false.  Any attempt to use
................................................................................
  4194   4206         rc = rc2;
  4195   4207       }
  4196   4208   
  4197   4209       /* The rollback may have destroyed the pPage1->aData value.  So
  4198   4210       ** call btreeGetPage() on page 1 again to make
  4199   4211       ** sure pPage1->aData is set correctly. */
  4200   4212       if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){
  4201         -      int nPage = get4byte(28+(u8*)pPage1->aData);
  4202         -      testcase( nPage==0 );
  4203         -      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
  4204         -      testcase( pBt->nPage!=nPage );
  4205         -      pBt->nPage = nPage;
         4213  +      btreeSetNPage(pBt, pPage1);
  4206   4214         releasePageOne(pPage1);
  4207   4215       }
  4208   4216       assert( countValidCursors(pBt, 1)==0 );
  4209   4217       pBt->inTransaction = TRANS_READ;
  4210   4218       btreeClearHasContent(pBt);
  4211   4219     }
  4212   4220   
................................................................................
  4278   4286         rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
  4279   4287       }
  4280   4288       if( rc==SQLITE_OK ){
  4281   4289         if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){
  4282   4290           pBt->nPage = 0;
  4283   4291         }
  4284   4292         rc = newDatabase(pBt);
  4285         -      pBt->nPage = get4byte(28 + pBt->pPage1->aData);
         4293  +      btreeSetNPage(pBt, pBt->pPage1);
  4286   4294   
  4287   4295         /* pBt->nPage might be zero if the database was corrupt when 
  4288   4296         ** the transaction was started. Otherwise, it must be at least 1.  */
  4289   4297         assert( CORRUPT_DB || pBt->nPage>0 );
  4290   4298       }
  4291   4299       sqlite3BtreeLeave(p);
  4292   4300     }

Changes to test/fuzzdata8.db.

cannot compute difference between binary files