mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Make sqlite3_count_changes() and total_changes() work with "DELETE FROM <table-name>". (CVS 5844)
FossilOrigin-Name: e68e4282adb9003aa297d033aeb5d9cadee215cd
This commit is contained in:
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
|||||||
C Remove\ssome\sif()\sconditions\sthat\sare\salways\strue\sfrom\sdelete.c.\s(CVS\s5843)
|
C Make\ssqlite3_count_changes()\sand\stotal_changes()\swork\swith\s"DELETE\sFROM\s<table-name>".\s(CVS\s5844)
|
||||||
D 2008-10-27T08:24:38
|
D 2008-10-27T13:59:34
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 3fe17eccd87d385b5adc9766828716cfdd154d6b
|
F Makefile.in 3fe17eccd87d385b5adc9766828716cfdd154d6b
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -99,14 +99,14 @@ F src/attach.c db3f4a60538733c1e4dcb9d0217a6e0d6ccd615b
|
|||||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||||
F src/btmutex.c 3a90096c3080b9057dc570b8e16e46511e1c788a
|
F src/btmutex.c 3a90096c3080b9057dc570b8e16e46511e1c788a
|
||||||
F src/btree.c 3e686f899659df8d79f2587d0f34f51fdf6a6276
|
F src/btree.c 5d72b67ee20afba92e95827fc9fc599d917f7f68
|
||||||
F src/btree.h 903682f2a88da37435f103da00cb915d63bc8015
|
F src/btree.h 179c3ea813780df78a289a8f5130db18e6d4616e
|
||||||
F src/btreeInt.h e38e9b2b285f40f5bc0a6664f630d4a141622f16
|
F src/btreeInt.h e38e9b2b285f40f5bc0a6664f630d4a141622f16
|
||||||
F src/build.c d6d55f97abcb6f17ac3e9e7a1dd8c0db67db34fd
|
F src/build.c d6d55f97abcb6f17ac3e9e7a1dd8c0db67db34fd
|
||||||
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
|
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
|
||||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||||
F src/date.c 6f4277fa56d8c1b8e70c0bde838c9e99609f5ec0
|
F src/date.c 6f4277fa56d8c1b8e70c0bde838c9e99609f5ec0
|
||||||
F src/delete.c 8bb079e098c0d154f0469062ddbc8237d1cc0b55
|
F src/delete.c b0b7c499ccf28c1857905c9cf42f4ddc49bf7331
|
||||||
F src/expr.c 2b1945314fdc661fb04306cb86bd8516cfd12d4a
|
F src/expr.c 2b1945314fdc661fb04306cb86bd8516cfd12d4a
|
||||||
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
||||||
F src/func.c 8431b40a7843d1024145684d303c55b4ee087bbe
|
F src/func.c 8431b40a7843d1024145684d303c55b4ee087bbe
|
||||||
@ -160,7 +160,7 @@ F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
|
|||||||
F src/tclsqlite.c 96049bd454f1547abff0a57c45f0dfa57701e076
|
F src/tclsqlite.c 96049bd454f1547abff0a57c45f0dfa57701e076
|
||||||
F src/test1.c a7310348961945e656c096e5f91d4d87dee6b61d
|
F src/test1.c a7310348961945e656c096e5f91d4d87dee6b61d
|
||||||
F src/test2.c 897528183edf2839c2a3c991d415905db56f1240
|
F src/test2.c 897528183edf2839c2a3c991d415905db56f1240
|
||||||
F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b
|
F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
|
||||||
F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
|
F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
|
||||||
F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
|
F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
|
||||||
F src/test6.c 0a0304a69cfa4962a429d084c6d451ff9e4fb572
|
F src/test6.c 0a0304a69cfa4962a429d084c6d451ff9e4fb572
|
||||||
@ -191,7 +191,7 @@ F src/update.c ed233298db6dd23d340e449e4b4a81b9306da6aa
|
|||||||
F src/utf.c c63e6f69082f85c19ab88d62dedaf91d71ac1a50
|
F src/utf.c c63e6f69082f85c19ab88d62dedaf91d71ac1a50
|
||||||
F src/util.c afe659ccc05d1f8af9e8631dabfec3ee3a7144af
|
F src/util.c afe659ccc05d1f8af9e8631dabfec3ee3a7144af
|
||||||
F src/vacuum.c fd77433d0c26d3ff1eb96eab017a1787ac5aa642
|
F src/vacuum.c fd77433d0c26d3ff1eb96eab017a1787ac5aa642
|
||||||
F src/vdbe.c b78adf571b9abac4092c641bec148832e8f26f34
|
F src/vdbe.c be81532805ee6fc1fe7bd2e1c82cf4a09b7b3061
|
||||||
F src/vdbe.h 41c99aaad9167c1b5431993db446de74b2f71fc3
|
F src/vdbe.h 41c99aaad9167c1b5431993db446de74b2f71fc3
|
||||||
F src/vdbeInt.h a20f479ec3bf41c61b0c2bd5176a9bad6b2a07ef
|
F src/vdbeInt.h a20f479ec3bf41c61b0c2bd5176a9bad6b2a07ef
|
||||||
F src/vdbeapi.c 6798c70cf176d23594ec557db88190ca8c7fa860
|
F src/vdbeapi.c 6798c70cf176d23594ec557db88190ca8c7fa860
|
||||||
@ -396,7 +396,7 @@ F test/join5.test 86675fc2919269aa923c84dd00ee4249b97990fe
|
|||||||
F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19
|
F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19
|
||||||
F test/jrnlmode.test c2e8212a6f6d32f8fd8f869b93553154eaf2244c
|
F test/jrnlmode.test c2e8212a6f6d32f8fd8f869b93553154eaf2244c
|
||||||
F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51
|
F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51
|
||||||
F test/laststmtchanges.test 18ead86c8a87ade949a1d5658f6dc4bb111d1b02
|
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
|
||||||
F test/like.test fef924922828d5a2a5bff80b9bdd9ff57a1ca500
|
F test/like.test fef924922828d5a2a5bff80b9bdd9ff57a1ca500
|
||||||
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
|
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
|
||||||
F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e
|
F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e
|
||||||
@ -651,7 +651,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 3224ea59812d0f3b5685bd92751054b81e3b681e
|
P 297ad90dd3a69002e6e4175e9e3938b3a627574d
|
||||||
R ba54cbfc3be9ecc00ba76b8e1609779a
|
R a6b93c46cddb9e42feecabc035375dbb
|
||||||
U danielk1977
|
U danielk1977
|
||||||
Z ccda3a5856c2017497ad6a21acb2893e
|
Z 98ec3e2e89a662c96092f7315cee2195
|
||||||
|
@ -1 +1 @@
|
|||||||
297ad90dd3a69002e6e4175e9e3938b3a627574d
|
e68e4282adb9003aa297d033aeb5d9cadee215cd
|
22
src/btree.c
22
src/btree.c
@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btree.c,v 1.525 2008/10/08 17:58:49 danielk1977 Exp $
|
** $Id: btree.c,v 1.526 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** See the header comment on "btreeInt.h" for additional information.
|
** See the header comment on "btreeInt.h" for additional information.
|
||||||
@ -6187,7 +6187,8 @@ static int clearDatabasePage(
|
|||||||
BtShared *pBt, /* The BTree that contains the table */
|
BtShared *pBt, /* The BTree that contains the table */
|
||||||
Pgno pgno, /* Page number to clear */
|
Pgno pgno, /* Page number to clear */
|
||||||
MemPage *pParent, /* Parent page. NULL for the root */
|
MemPage *pParent, /* Parent page. NULL for the root */
|
||||||
int freePageFlag /* Deallocate page if true */
|
int freePageFlag, /* Deallocate page if true */
|
||||||
|
int *pnChange
|
||||||
){
|
){
|
||||||
MemPage *pPage = 0;
|
MemPage *pPage = 0;
|
||||||
int rc;
|
int rc;
|
||||||
@ -6204,15 +6205,18 @@ static int clearDatabasePage(
|
|||||||
for(i=0; i<pPage->nCell; i++){
|
for(i=0; i<pPage->nCell; i++){
|
||||||
pCell = findCell(pPage, i);
|
pCell = findCell(pPage, i);
|
||||||
if( !pPage->leaf ){
|
if( !pPage->leaf ){
|
||||||
rc = clearDatabasePage(pBt, get4byte(pCell), pPage, 1);
|
rc = clearDatabasePage(pBt, get4byte(pCell), pPage, 1, pnChange);
|
||||||
if( rc ) goto cleardatabasepage_out;
|
if( rc ) goto cleardatabasepage_out;
|
||||||
}
|
}
|
||||||
rc = clearCell(pPage, pCell);
|
rc = clearCell(pPage, pCell);
|
||||||
if( rc ) goto cleardatabasepage_out;
|
if( rc ) goto cleardatabasepage_out;
|
||||||
}
|
}
|
||||||
if( !pPage->leaf ){
|
if( !pPage->leaf ){
|
||||||
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[8]), pPage, 1);
|
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[8]), pPage, 1, pnChange);
|
||||||
if( rc ) goto cleardatabasepage_out;
|
if( rc ) goto cleardatabasepage_out;
|
||||||
|
}else if( pnChange ){
|
||||||
|
assert( pPage->intKey );
|
||||||
|
*pnChange += pPage->nCell;
|
||||||
}
|
}
|
||||||
if( freePageFlag ){
|
if( freePageFlag ){
|
||||||
rc = freePage(pPage);
|
rc = freePage(pPage);
|
||||||
@ -6233,8 +6237,12 @@ cleardatabasepage_out:
|
|||||||
** This routine will fail with SQLITE_LOCKED if there are any open
|
** This routine will fail with SQLITE_LOCKED if there are any open
|
||||||
** read cursors on the table. Open write cursors are moved to the
|
** read cursors on the table. Open write cursors are moved to the
|
||||||
** root of the table.
|
** 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.
|
||||||
*/
|
*/
|
||||||
int sqlite3BtreeClearTable(Btree *p, int iTable){
|
int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
|
||||||
int rc;
|
int rc;
|
||||||
BtShared *pBt = p->pBt;
|
BtShared *pBt = p->pBt;
|
||||||
sqlite3BtreeEnter(p);
|
sqlite3BtreeEnter(p);
|
||||||
@ -6246,7 +6254,7 @@ int sqlite3BtreeClearTable(Btree *p, int iTable){
|
|||||||
}else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){
|
}else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
}else{
|
}else{
|
||||||
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, 0);
|
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, 0, pnChange);
|
||||||
}
|
}
|
||||||
sqlite3BtreeLeave(p);
|
sqlite3BtreeLeave(p);
|
||||||
return rc;
|
return rc;
|
||||||
@ -6294,7 +6302,7 @@ static int btreeDropTable(Btree *p, int iTable, int *piMoved){
|
|||||||
|
|
||||||
rc = sqlite3BtreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
|
rc = sqlite3BtreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
rc = sqlite3BtreeClearTable(p, iTable);
|
rc = sqlite3BtreeClearTable(p, iTable, 0);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
releasePage(pPage);
|
releasePage(pPage);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** subsystem. See comments in the source code for a detailed description
|
** subsystem. See comments in the source code for a detailed description
|
||||||
** of what each interface routine does.
|
** of what each interface routine does.
|
||||||
**
|
**
|
||||||
** @(#) $Id: btree.h,v 1.104 2008/10/08 17:58:49 danielk1977 Exp $
|
** @(#) $Id: btree.h,v 1.105 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _BTREE_H_
|
#ifndef _BTREE_H_
|
||||||
#define _BTREE_H_
|
#define _BTREE_H_
|
||||||
@ -117,7 +117,7 @@ int sqlite3BtreeIncrVacuum(Btree *);
|
|||||||
#define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */
|
#define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */
|
||||||
|
|
||||||
int sqlite3BtreeDropTable(Btree*, int, int*);
|
int sqlite3BtreeDropTable(Btree*, int, int*);
|
||||||
int sqlite3BtreeClearTable(Btree*, int);
|
int sqlite3BtreeClearTable(Btree*, int, int*);
|
||||||
int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
|
int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
|
||||||
int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
|
int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
|
||||||
void sqlite3BtreeTripAllCursors(Btree*, int);
|
void sqlite3BtreeTripAllCursors(Btree*, int);
|
||||||
|
16
src/delete.c
16
src/delete.c
@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** in order to generate code for DELETE FROM statements.
|
** in order to generate code for DELETE FROM statements.
|
||||||
**
|
**
|
||||||
** $Id: delete.c,v 1.183 2008/10/27 08:24:38 danielk1977 Exp $
|
** $Id: delete.c,v 1.184 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ void sqlite3DeleteFrom(
|
|||||||
int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */
|
int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */
|
||||||
NameContext sNC; /* Name context to resolve expressions in */
|
NameContext sNC; /* Name context to resolve expressions in */
|
||||||
int iDb; /* Database number */
|
int iDb; /* Database number */
|
||||||
int memCnt = 0; /* Memory cell used for change counting */
|
int memCnt = -1; /* Memory cell used for change counting */
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_TRIGGER
|
#ifndef SQLITE_OMIT_TRIGGER
|
||||||
int isView; /* True if attempting to delete from a view */
|
int isView; /* True if attempting to delete from a view */
|
||||||
@ -372,17 +372,7 @@ void sqlite3DeleteFrom(
|
|||||||
*/
|
*/
|
||||||
if( pWhere==0 && !triggers_exist && !IsVirtual(pTab) ){
|
if( pWhere==0 && !triggers_exist && !IsVirtual(pTab) ){
|
||||||
assert( !isView );
|
assert( !isView );
|
||||||
if( db->flags & SQLITE_CountRows ){
|
sqlite3VdbeAddOp3(v, OP_Clear, pTab->tnum, iDb, memCnt);
|
||||||
/* If counting rows deleted, just count the total number of
|
|
||||||
** entries in the table. */
|
|
||||||
int addr2;
|
|
||||||
sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
|
|
||||||
sqlite3VdbeAddOp2(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);
|
|
||||||
addr2 = sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
|
|
||||||
sqlite3VdbeAddOp2(v, OP_Next, iCur, addr2);
|
|
||||||
sqlite3VdbeAddOp1(v, OP_Close, iCur);
|
|
||||||
}
|
|
||||||
sqlite3VdbeAddOp2(v, OP_Clear, pTab->tnum, iDb);
|
|
||||||
if( !pParse->nested ){
|
if( !pParse->nested ){
|
||||||
sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
|
sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test3.c,v 1.101 2008/08/13 19:11:48 drh Exp $
|
** $Id: test3.c,v 1.102 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "btreeInt.h"
|
#include "btreeInt.h"
|
||||||
@ -389,7 +389,7 @@ static int btree_clear_table(
|
|||||||
pBt = sqlite3TestTextToPtr(argv[1]);
|
pBt = sqlite3TestTextToPtr(argv[1]);
|
||||||
if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
|
if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
|
||||||
sqlite3BtreeEnter(pBt);
|
sqlite3BtreeEnter(pBt);
|
||||||
rc = sqlite3BtreeClearTable(pBt, iTable);
|
rc = sqlite3BtreeClearTable(pBt, iTable, 0);
|
||||||
sqlite3BtreeLeave(pBt);
|
sqlite3BtreeLeave(pBt);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||||
|
21
src/vdbe.c
21
src/vdbe.c
@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.782 2008/10/08 17:58:49 danielk1977 Exp $
|
** $Id: vdbe.c,v 1.783 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -4042,7 +4042,7 @@ case OP_Destroy: { /* out2-prerelease */
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Opcode: Clear P1 P2 *
|
/* Opcode: Clear P1 P2 P3
|
||||||
**
|
**
|
||||||
** Delete all contents of the database table or index whose root page
|
** Delete all contents of the database table or index whose root page
|
||||||
** in the database file is given by P1. But, unlike Destroy, do not
|
** in the database file is given by P1. But, unlike Destroy, do not
|
||||||
@ -4052,11 +4052,26 @@ case OP_Destroy: { /* out2-prerelease */
|
|||||||
** P2==1 then the table to be clear is in the auxiliary database file
|
** P2==1 then the table to be clear is in the auxiliary database file
|
||||||
** that is used to store tables create using CREATE TEMPORARY TABLE.
|
** that is used to store tables create using CREATE TEMPORARY TABLE.
|
||||||
**
|
**
|
||||||
|
** If the P3 value is non-zero, then the table refered to must be an
|
||||||
|
** intkey table (an SQL table, not an index). In this case the row change
|
||||||
|
** count is incremented by the number of rows in the table being cleared.
|
||||||
|
** If P3 is greater than zero, then the value stored in register P3 is
|
||||||
|
** also incremented by the number of rows in the table being cleared.
|
||||||
|
**
|
||||||
** See also: Destroy
|
** See also: Destroy
|
||||||
*/
|
*/
|
||||||
case OP_Clear: {
|
case OP_Clear: {
|
||||||
|
int nChange = 0;
|
||||||
assert( (p->btreeMask & (1<<pOp->p2))!=0 );
|
assert( (p->btreeMask & (1<<pOp->p2))!=0 );
|
||||||
rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, pOp->p1);
|
rc = sqlite3BtreeClearTable(
|
||||||
|
db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0)
|
||||||
|
);
|
||||||
|
if( pOp->p3 ){
|
||||||
|
p->nChange += nChange;
|
||||||
|
if( pOp->p3>0 ){
|
||||||
|
p->aMem[pOp->p3].u.i += nChange;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#
|
||||||
# The author disclaims copyright to this source code. In place of
|
# The author disclaims copyright to this source code. In place of
|
||||||
# a legal notice, here is a blessing:
|
# a legal notice, here is a blessing:
|
||||||
#
|
#
|
||||||
@ -19,6 +20,7 @@
|
|||||||
# Note 3: changes() is not changed by a change to a view (since everything
|
# Note 3: changes() is not changed by a change to a view (since everything
|
||||||
# is done within instead of trigger context).
|
# is done within instead of trigger context).
|
||||||
#
|
#
|
||||||
|
# $Id: laststmtchanges.test,v 1.7 2008/10/27 13:59:34 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -278,4 +280,52 @@ do_test laststmtchanges-5.5 {
|
|||||||
|
|
||||||
} ;# ifcapable view
|
} ;# ifcapable view
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# 6.x - Test "DELETE FROM <table>" in the absence of triggers
|
||||||
|
#
|
||||||
|
do_test laststmtchanges-6.1 {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE t3(a, b, c);
|
||||||
|
INSERT INTO t3 VALUES(1, 2, 3);
|
||||||
|
INSERT INTO t3 VALUES(4, 5, 6);
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
do_test laststmtchanges-6.2 {
|
||||||
|
execsql {
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM t3;
|
||||||
|
SELECT changes();
|
||||||
|
}
|
||||||
|
} {2}
|
||||||
|
do_test laststmtchanges-6.3 {
|
||||||
|
execsql {
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM t3 WHERE a IS NOT NULL;
|
||||||
|
SELECT changes();
|
||||||
|
}
|
||||||
|
} {2}
|
||||||
|
do_test laststmtchanges-6.4 {
|
||||||
|
execsql {
|
||||||
|
ROLLBACK;
|
||||||
|
CREATE INDEX t3_i1 ON t3(a);
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM t3;
|
||||||
|
SELECT changes();
|
||||||
|
}
|
||||||
|
} {2}
|
||||||
|
do_test laststmtchanges-6.5 {
|
||||||
|
execsql { ROLLBACK }
|
||||||
|
set nTotalChange [execsql {SELECT total_changes()}]
|
||||||
|
expr 0
|
||||||
|
} {0}
|
||||||
|
do_test laststmtchanges-6.6 {
|
||||||
|
execsql {
|
||||||
|
SELECT total_changes();
|
||||||
|
DELETE FROM t3;
|
||||||
|
SELECT total_changes();
|
||||||
|
}
|
||||||
|
} [list $nTotalChange [expr $nTotalChange+2]]
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user