From: drh Date: Thu, 24 Oct 2013 19:48:39 +0000 (+0000) Subject: Update the interface to the sqlite3GenerateRowDelete() utility so that it is X-Git-Tag: version-3.8.2~137^2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ecb31b6304d432b9afdeec1a297ed8902b41dfe1;p=thirdparty%2Fsqlite.git Update the interface to the sqlite3GenerateRowDelete() utility so that it is able to handle WITHOUT ROWID tables. The implementation still needs to be completed. FossilOrigin-Name: 85daf5174679630474b3bccf3d662d5d56bf00d5 --- diff --git a/manifest b/manifest index 41b9154edf..a44ff79d39 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Delete\sPRIMARY\sKEY\sindex\sentries\slast.\s\sOnly\sconstruct\sthe\sunique\sprefix\sof\nan\sindex\skey\swhen\sdeleting\sentries\sfrom\san\sindex. -D 2013-10-24T14:16:10.049 +C Update\sthe\sinterface\sto\sthe\ssqlite3GenerateRowDelete()\sutility\sso\sthat\sit\sis\nable\sto\shandle\sWITHOUT\sROWID\stables.\s\sThe\simplementation\sstill\sneeds\sto\sbe\s\ncompleted. +D 2013-10-24T19:48:39.042 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,7 @@ F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 -F src/delete.c 18bd99db316cf8f7ab2e779f9eea2fdc0d281960 +F src/delete.c 3a750695133bf8646124b07cf8a51222110885a6 F src/expr.c 3180b6332072b263f845592e72e92971af562ab0 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 628f81177299660a86e40359b3689b81f517e125 @@ -182,7 +182,7 @@ F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c c028df48f0564b43831ce8a14d1e14ac07b6729c +F src/insert.c a188b1abcc80cb835a1a9b76e78190d1516d22bc F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b @@ -223,7 +223,7 @@ F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb F src/sqlite.h.in 547a44dd4ff4d975e92a645ea2d609e543a83d0f F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 62dee86c51c7b2dc73b0f2cbdfa332a4b79f9bcf +F src/sqliteInt.h a0834a450cd990eadcb18b790557abfe6dc52270 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1127,7 +1127,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 53bb070c851db02c9d900cb041ab441895ddbfb7 -R 51fe8599e5a3fd933943a52c99bda7fd +P 0e56ba69f0fcd12a5166c32f6e4eacdcc29fba04 +R 23965d1fb428e8ef205e9927049056c2 U drh -Z 341cc48c3c0ebe6f2ca7c21fb7db25ce +Z 7e96dccb2394803edfe091e61702bf27 diff --git a/manifest.uuid b/manifest.uuid index 1e374fcb35..6c09c1517a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e56ba69f0fcd12a5166c32f6e4eacdcc29fba04 \ No newline at end of file +85daf5174679630474b3bccf3d662d5d56bf00d5 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index b16cdab567..b80db6f6b2 100644 --- a/src/delete.c +++ b/src/delete.c @@ -409,8 +409,8 @@ void sqlite3DeleteFrom( #endif { int count = (pParse->nested==0); /* True to count changes */ - sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, - pTrigger, OE_Default); + sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iCur, iRowid, 0, + count, OE_Default); } /* End of the delete loop */ @@ -468,13 +468,17 @@ delete_from_cleanup: ** These are the requirements: ** ** 1. A read/write cursor pointing to pTab, the table containing the row -** to be deleted, must be opened as cursor number iCur. +** to be deleted, must be opened as cursor number iCur (except for +** WITHOUT ROWID tables which do not have a main table). ** ** 2. Read/write cursors for all indices of pTab must be open as ** cursor number iCur+i for the i-th index. ** -** 3. The record number of the row to be deleted must be stored in -** memory cell iRowid. +** 3. The primary key for the row to be deleted must be stored in a +** sequence of memory cells starting at iPk. If nPk==0 then the +** primary key is a rowid an uses just one memory cell. If nPk>0 +** then a WITHOUT ROWID table is being used and there are nPk elements +** of the primary key. ** ** This routine generates code to remove both the table record and all ** index entries that point to that record. @@ -482,11 +486,12 @@ delete_from_cleanup: void sqlite3GenerateRowDelete( Parse *pParse, /* Parsing context */ Table *pTab, /* Table containing the row to be deleted */ - int iCur, /* Cursor number for the table */ - int iRowid, /* Memory cell that contains the rowid to delete */ - int count, /* If non-zero, increment the row change counter */ Trigger *pTrigger, /* List of triggers to (potentially) fire */ - int onconf /* Default ON CONFLICT policy for triggers */ + int iCur, /* Cursor number for the table */ + int iPk, /* First memory cell containing the PRIMARY KEY */ + i16 nPk, /* Number of PRIMARY KEY memory cells */ + u8 count, /* If non-zero, increment the row change counter */ + u8 onconf /* Default ON CONFLICT policy for triggers */ ){ Vdbe *v = pParse->pVdbe; /* Vdbe */ int iOld = 0; /* First register in OLD.* array */ @@ -499,7 +504,7 @@ void sqlite3GenerateRowDelete( ** (this can happen if a trigger program has already deleted it), do ** not attempt to delete it or fire any DELETE triggers. */ iLabel = sqlite3VdbeMakeLabel(v); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iPk); /* If there are any triggers to fire, allocate a range of registers to ** use for the old.* references in the triggers. */ @@ -518,7 +523,7 @@ void sqlite3GenerateRowDelete( /* Populate the OLD.* pseudo-table register array. These values will be ** used by any BEFORE and AFTER triggers that exist. */ - sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld); + sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); for(iCol=0; iColnCol; iCol++){ if( mask==0xffffffff || mask&(1<pIndex ){ sqlite3MultiWrite(pParse); @@ -1491,7 +1491,7 @@ void sqlite3GenerateConstraintChecks( pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); } sqlite3GenerateRowDelete( - pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace + pParse, pTab, pTrigger, baseCur, regR, 0, 0, OE_Replace ); seenReplace = 1; break; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index fec5f230b8..99730e4d2a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2914,7 +2914,7 @@ int sqlite3ExprCanBeNull(const Expr*); void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); int sqlite3IsRowid(const char*); -void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); +void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,i16,u8,u8); void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*); int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*); void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,