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

Simplifications and clarification to update callback handling in the

OP_Delete and OP_Insert opcodes.

FossilOrigin-Name: 47887ef89ed60ddb869d65e0957c1c4b2115f169
This commit is contained in:
drh
2016-03-30 15:30:07 +00:00
parent 9fc4caf64c
commit c556f3c33f
4 changed files with 17 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
C Increase\sthe\sversion\snumber\sto\s3.13.0\son\saccount\sof\sthe\snew\ssession\sextension. C Simplifications\sand\sclarification\sto\supdate\scallback\shandling\sin\sthe\nOP_Delete\sand\sOP_Insert\sopcodes.
D 2016-03-30T14:26:36.915 D 2016-03-30T15:30:07.231
F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449 F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e6ee58b849c116d5554024f524cbf61f064f6f01 F Makefile.msc e6ee58b849c116d5554024f524cbf61f064f6f01
@@ -378,7 +378,7 @@ F src/shell.c cd3f82fdc5c895b817a375b7ab8319cb41f447ce
F src/sqlite.h.in a1d7a367997f80c7075303aaf73e5fc46261c11c F src/sqlite.h.in a1d7a367997f80c7075303aaf73e5fc46261c11c
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2
F src/sqliteInt.h 410bd07098423b887874d9d2ff9ed6f8e3284839 F src/sqliteInt.h 594bf31a7a0cc788688ca947e562576e23bd7904
F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
@@ -439,7 +439,7 @@ F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
F src/util.c 8873d696c9ccc4206058c402e09e101f1b81561a F src/util.c 8873d696c9ccc4206058c402e09e101f1b81561a
F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52
F src/vdbe.c 04e0606bc0505924036a974759703af6a3664904 F src/vdbe.c 0f0e4a6255f9a5272857a818314d081db26bcd90
F src/vdbe.h c16ba943d407baa1c7085eefea73a063fc631863 F src/vdbe.h c16ba943d407baa1c7085eefea73a063fc631863
F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd
F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c
@@ -1480,7 +1480,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 9cdf813c6aaaddc01d2d4e04636c83fcda04d971 P e9bcd5acb9ab7b3d55c96519ca10f51f35e24cd9
R 7a69958e274665351e7e782b27ccbb0b R 7d699e46158684aaeb0674ba8ed1262b
U drh U drh
Z fc241d926edbc77d507e66ad4423e83d Z 8edbe6879cd34861bc153d7b5712adb5

View File

@@ -1 +1 @@
e9bcd5acb9ab7b3d55c96519ca10f51f35e24cd9 47887ef89ed60ddb869d65e0957c1c4b2115f169

View File

@@ -2927,9 +2927,6 @@ struct AuthContext {
/* /*
** Bitfield flags for P5 value in various opcodes. ** Bitfield flags for P5 value in various opcodes.
**
** Note that the values for ISNOOP and LENGTHARG are the same. But as
** those bits are never used on the same opcode, the overlap is harmless.
*/ */
#define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */ #define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
/* Also used in P2 (not P5) of OP_Delete */ /* Also used in P2 (not P5) of OP_Delete */
@@ -2938,7 +2935,9 @@ struct AuthContext {
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
#define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */ #define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */
#endif
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */

View File

@@ -4317,6 +4317,7 @@ case OP_InsertInt: {
assert( pC->iDb>=0 ); assert( pC->iDb>=0 );
zDb = db->aDb[pC->iDb].zName; zDb = db->aDb[pC->iDb].zName;
pTab = pOp->p4.pTab; pTab = pOp->p4.pTab;
assert( HasRowid(pTab) );
op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT); op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
}else{ }else{
pTab = 0; /* Not needed. Silence a comiler warning. */ pTab = 0; /* Not needed. Silence a comiler warning. */
@@ -4328,7 +4329,6 @@ case OP_InsertInt: {
if( db->xPreUpdateCallback if( db->xPreUpdateCallback
&& pOp->p4type==P4_TABLE && pOp->p4type==P4_TABLE
&& !(pOp->p5 & OPFLAG_ISUPDATE) && !(pOp->p5 & OPFLAG_ISUPDATE)
&& HasRowid(pTab)
){ ){
sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2); sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
} }
@@ -4357,7 +4357,7 @@ case OP_InsertInt: {
/* Invoke the update-hook if required. */ /* Invoke the update-hook if required. */
if( rc ) goto abort_due_to_error; if( rc ) goto abort_due_to_error;
if( db->xUpdateCallback && op && HasRowid(pTab) ){ if( db->xUpdateCallback && op ){
db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey); db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
} }
break; break;
@@ -4428,11 +4428,12 @@ case OP_Delete: {
** of p4.pTab. Finally, if p5 is true, indicating that this cursor was ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was
** last moved with OP_Next or OP_Prev, not Seek or NotFound, set ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set
** VdbeCursor.movetoTarget to the current rowid. */ ** VdbeCursor.movetoTarget to the current rowid. */
if( pOp->p4.pTab && HAS_UPDATE_HOOK(db) ){ if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
assert( pC->iDb>=0 ); assert( pC->iDb>=0 );
assert( pOp->p4.pTab!=0 );
zDb = db->aDb[pC->iDb].zName; zDb = db->aDb[pC->iDb].zName;
pTab = pOp->p4.pTab; pTab = pOp->p4.pTab;
if( pOp->p5 && pC->isTable ){ if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget); sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
} }
}else{ }else{
@@ -4450,9 +4451,8 @@ case OP_Delete: {
pOp->p3 pOp->p3
); );
} }
#endif
if( opflags & OPFLAG_ISNOOP ) break; if( opflags & OPFLAG_ISNOOP ) break;
#endif
/* Only flags that can be set are SAVEPOISTION and AUXDELETE */ /* Only flags that can be set are SAVEPOISTION and AUXDELETE */
assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 ); assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 );
@@ -4480,7 +4480,7 @@ case OP_Delete: {
/* Invoke the update-hook if required. */ /* Invoke the update-hook if required. */
if( opflags & OPFLAG_NCHANGE ){ if( opflags & OPFLAG_NCHANGE ){
p->nChange++; p->nChange++;
if( rc==SQLITE_OK && db->xUpdateCallback && HasRowid(pTab) ){ if( db->xUpdateCallback && HasRowid(pTab) ){
db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName, db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,
pC->movetoTarget); pC->movetoTarget);
assert( pC->iDb>=0 ); assert( pC->iDb>=0 );