From: drh Date: Sat, 7 Jan 2017 14:26:28 +0000 (+0000) Subject: Critical fix to the previous check-in so that it works when there are X-Git-Tag: version-3.17.0~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cef5b1c812cf5739251039d7d5d0e1223fe0caf;p=thirdparty%2Fsqlite.git Critical fix to the previous check-in so that it works when there are BEFORE triggers that move the cursor before the OP_Delete has a chance to be applied. FossilOrigin-Name: db2c0960ffb3b396b20e0441d3edb812254c82bc --- diff --git a/manifest b/manifest index c1d7de4c1b..769b92f991 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\san\sunnecessary\sbtree\sseek\swhile\sdeleting\san\sindex\sentry\sdue\sto\sa\sconflict\non\sa\sREPLACE\soperation. -D 2017-01-07T03:26:50.193 +C Critical\sfix\sto\sthe\sprevious\scheck-in\sso\sthat\sit\sworks\swhen\sthere\sare\nBEFORE\striggers\sthat\smove\sthe\scursor\sbefore\sthe\sOP_Delete\shas\sa\schance\sto\nbe\sapplied. +D 2017-01-07T14:26:28.809 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -340,7 +340,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d -F src/delete.c 1a443cedfff0420959416a09f55119973f803593 +F src/delete.c 4220f4feee7fddefc1e73e5ade1ed82ffe8dc92a F src/expr.c f06f41e5e5daca10fb090e70a2502dcc0dbc992b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae @@ -350,7 +350,7 @@ F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c ad2a0b2757a23b6f9297ee414eeab22b52fbde75 +F src/insert.c 3b7fbb149ef249269bfbedabbe8fd706ef9a2317 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0 @@ -1543,7 +1543,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d577dda0a7fbfacda57e8cad2bc4651d2a05d813 -R 9a736b4439c4e25faa8492f344a490a5 +P f0495c5133d0dc04d63521136d6b9ca440792cdf +R 21f1a5c5760681e8d66bbbeed4342953 U drh -Z c755348d5a4bd2ab8fd825f60cd77850 +Z 06625003bcd408124313c9f36986c7f6 diff --git a/manifest.uuid b/manifest.uuid index c1cc73a62a..ce6b8d600a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0495c5133d0dc04d63521136d6b9ca440792cdf \ No newline at end of file +db2c0960ffb3b396b20e0441d3edb812254c82bc \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index 5a75e606e2..db00803996 100644 --- a/src/delete.c +++ b/src/delete.c @@ -519,10 +519,7 @@ void sqlite3DeleteFrom( #endif { int count = (pParse->nested==0); /* True to count changes */ - int iIdxNoSeek = -1; - if( bComplex==0 && aiCurOnePass[1]!=iDataCur ){ - iIdxNoSeek = aiCurOnePass[1]; - } + int iIdxNoSeek = bComplex ? -1 : aiCurOnePass[1]; sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, iKey, nKey, count, OE_Default, eOnePass, iIdxNoSeek); } @@ -604,15 +601,15 @@ delete_from_cleanup: ** ** If eMode is ONEPASS_MULTI, then this call is being made as part ** of a ONEPASS delete that affects multiple rows. In this case, if -** iIdxNoSeek is a valid cursor number (>=0), then its position should -** be preserved following the delete operation. Or, if iIdxNoSeek is not -** a valid cursor number, the position of iDataCur should be preserved -** instead. +** iIdxNoSeek is a valid cursor number (>=0) and is not the same as +** iDataCur, then its position should be preserved following the delete +** operation. Or, if iIdxNoSeek is not a valid cursor number, the +** position of iDataCur should be preserved instead. ** ** iIdxNoSeek: -** If iIdxNoSeek is a valid cursor number (>=0), then it identifies an -** index cursor (from within array of cursors starting at iIdxCur) that -** already points to the index entry to be deleted. +** If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur, +** then it identifies an index cursor (from within array of cursors +** starting at iIdxCur) that already points to the index entry to be deleted. */ void sqlite3GenerateRowDelete( Parse *pParse, /* Parsing context */ @@ -683,7 +680,7 @@ void sqlite3GenerateRowDelete( /* If any BEFORE triggers were coded, then seek the cursor to the ** row to be deleted again. It may be that the BEFORE triggers moved - ** the cursor or of already deleted the row that the cursor was + ** the cursor or already deleted the row that the cursor was ** pointing to. */ if( addrStart