1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix the truncate optimization so that PRAGMA count_changes and changes()

return correct values even for a WITHOUT ROWID table.
[forum:/forumpost/07dedbf9a1|Forum post 07dedbf9a1].

FossilOrigin-Name: 820ae3b117c2d8c117c0c5a4e440a7d06886772516c7fc0a84606388f91be195
This commit is contained in:
drh
2021-06-03 18:51:51 +00:00
parent 6468990e7b
commit a6df0e693f
7 changed files with 34 additions and 27 deletions

View File

@@ -9494,8 +9494,8 @@ static int clearDatabasePage(
if( !pPage->leaf ){
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
if( rc ) goto cleardatabasepage_out;
}else if( pnChange ){
assert( pPage->intKey || CORRUPT_DB );
}
if( pnChange ){
testcase( !pPage->intKey );
*pnChange += pPage->nCell;
}
@@ -9520,9 +9520,8 @@ cleardatabasepage_out:
** read cursors on the table. Open write cursors are moved to the
** root of the table.
**
** If pnChange is not NULL, then table iTable must be an intkey table. The
** integer value pointed to by pnChange is incremented by the number of
** entries in the table.
** If pnChange is not NULL, then the integer value pointed to by pnChange
** is incremented by the number of entries in the table.
*/
int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
int rc;