]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure KeyInfo objects on multi-column indices of WITHOUT ROWID tables
authordrh <drh@noemail.net>
Wed, 30 Oct 2013 15:52:32 +0000 (15:52 +0000)
committerdrh <drh@noemail.net>
Wed, 30 Oct 2013 15:52:32 +0000 (15:52 +0000)
have the correct nField and nXField values.  Also, add the
SQLITE_ENABLE_MODULE_COMMENT compile-time option and the VdbeModuleComment()
macro and use it to label entry and exit points of some key routines.

FossilOrigin-Name: 6d9af6065fc0da8337aee2297a8da7511eecccf1

manifest
manifest.uuid
src/build.c
src/delete.c
src/insert.c
src/vdbe.h
src/vdbeaux.c

index 6795db92d3460e7ad7e5cf407896e23c60445d23..7e83d2e7ba10e3082223f6fea84ae9f25d75f5f9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sthe\sP4\scolumn\sof\sthe\sEXPLAIN\slisting,\sabbreviate\s"keyinfo"\sas\sjust\s"k"\sand\n"BINARY"\sas\sjust\s"B".
-D 2013-10-30T13:46:01.883
+C Make\ssure\sKeyInfo\sobjects\son\smulti-column\sindices\sof\sWITHOUT\sROWID\stables\nhave\sthe\scorrect\snField\sand\snXField\svalues.\s\sAlso,\sadd\sthe\nSQLITE_ENABLE_MODULE_COMMENT\scompile-time\soption\sand\sthe\sVdbeModuleComment()\nmacro\sand\suse\sit\sto\slabel\sentry\sand\sexit\spoints\sof\ssome\skey\sroutines.
+D 2013-10-30T15:52:32.018
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -168,12 +168,12 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
 F src/btree.c 509722ce305471b626d3401c0631a808fd33237b
 F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf
 F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
-F src/build.c 4d62e99fa36db1793cc1bed63e6775defdf8c587
+F src/build.c 9d33b8691f44e05129aeb11217a415824bd0cf56
 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2
 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
 F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c
 F src/date.c 593c744b2623971e45affd0bde347631bdfa4625
-F src/delete.c 8b9aa9c935fdd48a7a8ac0eff22c03cb29f12e96
+F src/delete.c d4917b7b977636f38b9c03040d8bb5f1457f9457
 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 42e8dc617c4db4683b4b2aac4d40dabf0333bef2
+F src/insert.c f8eea9f2303c90a4bfc62bb298dac45b7cc7cd11
 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
@@ -280,10 +280,10 @@ F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
 F src/util.c 2fa6c821d28bbdbeec1b2a7b091a281c9ef8f918
 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
 F src/vdbe.c 3c98b77343f8a1f4624b86795bf29cfd008b0e4a
-F src/vdbe.h 6bdee35c54d57fd52733d4c542781820009311dc
+F src/vdbe.h c18a2dd91c838601b867a214e43c5f66d5d001ba
 F src/vdbeInt.h 42dcff74dbeb2b071e569b53f885fc9c2e4b4cb0
 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
-F src/vdbeaux.c 517c110b99979b2e86c59ccbaa9edc34df3582a0
+F src/vdbeaux.c 347cfece32afdbac935000fd6ea2b58930a99e8a
 F src/vdbeblob.c ef973d8d9f8170015343dd8824f795da675caa87
 F src/vdbemem.c 6087553f2c61c06c8e1ab3959a60e174d6240c98
 F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
@@ -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 2fcac056074f0a23884ab5425003a7ca1d35c2a8
-R fc2ecfc95d81ab6a95e55c9cb9ad5def
+P 72d45eb79b5d0505050cff57a00d725948b2a0c0
+R 52fcbe874e2522b4dc7ef0c1b4c145a0
 U drh
-Z 47249c1e0f7df9709137d158fda9b808
+Z 3d4390b53d26d2b8ae9a915e21b79a8b
index b85da12a409534e4e85dd53498f9bd341d6ac88e..88593d7affa248e4c2345ae86d53fc73a19fd1e7 100644 (file)
@@ -1 +1 @@
-72d45eb79b5d0505050cff57a00d725948b2a0c0
\ No newline at end of file
+6d9af6065fc0da8337aee2297a8da7511eecccf1
\ No newline at end of file
index 1a85396ca9f349b76bf6bcc4b898a7670f51100c..c0113a5a3434012356fd25b6830aa6b1a138f22d 100644 (file)
@@ -2935,6 +2935,7 @@ Index *sqlite3CreateIndex(
   pIndex->uniqNotNull = onError!=OE_None;
   pIndex->autoIndex = (u8)(pName==0);
   pIndex->pSchema = db->aDb[iDb].pSchema;
+  pIndex->nKeyCol = pList->nExpr;
   if( pPIWhere ){
     sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
     pIndex->pPartIdxWhere = pPIWhere;
index 35d06aafe817ddc4efc83a0db2b908a3f7a9c536..b8e3d256ca1301ee49b7db7b3aab3283cd6f3e46 100644 (file)
@@ -549,6 +549,8 @@ void sqlite3GenerateRowDelete(
 
   /* Vdbe is guaranteed to have been allocated by this stage. */
   assert( v );
+  VdbeModuleComment((v, "BEGIN: GenerateRowDelete(%d,%d,%d)",
+                         iCur, iPk, (int)nPk));
 
   /* Seek cursor iCur to the row to delete. If this row no longer exists 
   ** (this can happen if a trigger program has already deleted it), do
@@ -623,6 +625,7 @@ void sqlite3GenerateRowDelete(
   ** trigger programs were invoked. Or if a trigger program throws a 
   ** RAISE(IGNORE) exception.  */
   sqlite3VdbeResolveLabel(v, iLabel);
+  VdbeModuleComment((v, "END: GenerateRowDelete()"));
 }
 
 /*
index e665509f519e73a72933c795131be9edc311de18..b79a729d8367bb7b9b9537624f681919c222323d 100644 (file)
@@ -1271,6 +1271,8 @@ void sqlite3GenerateConstraintChecks(
   assert( pTab->pSelect==0 );  /* This table is not a VIEW */
   nCol = pTab->nCol;
   regData = regRowid + 1;
+  VdbeModuleComment((v, "BEGIN: GenerateConstraintChecks(%d,%d,%d)",
+                     baseCur, regRowid, pkChng));
 
   /* For WITHOUT ROWID tables, we'll need to know the Index and the cursor
   ** number for the PRIMARY KEY index */
@@ -1587,6 +1589,7 @@ void sqlite3GenerateConstraintChecks(
   if( pbMayReplace ){
     *pbMayReplace = seenReplace;
   }
+  VdbeModuleComment((v, "END: GenerateConstraintChecks()"));
 }
 
 /*
index 966ea752648bbe32eee6d193a149d33a271e5688..9a870ba4c1c5732bd6f440c6c5d02ebe5df4a141 100644 (file)
@@ -218,15 +218,27 @@ UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
 void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
 #endif
 
-
+/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
+** each VDBE opcode.
+**
+** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op
+** comments in VDBE programs that show key decision points in the code
+** generator.
+*/
 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
   void sqlite3VdbeComment(Vdbe*, const char*, ...);
 # define VdbeComment(X)  sqlite3VdbeComment X
   void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);
 # define VdbeNoopComment(X)  sqlite3VdbeNoopComment X
+# ifdef SQLITE_ENABLE_MODULE_COMMENTS
+#   define VdbeModuleComment(X)  sqlite3VdbeNoopComment X
+# else
+#   define VdbeModuleComment(X)
+# endif
 #else
 # define VdbeComment(X)
 # define VdbeNoopComment(X)
+# define VdbeModuleComment(X)
 #endif
 
 #endif
index f64112359d938bb03c6c17b054e52877e3bf65f3..91288c886706bb8f63715812acc14c55c2ffdb92 100644 (file)
@@ -3116,7 +3116,7 @@ int sqlite3VdbeRecordCompare(
   
   idx1 = getVarint32(aKey1, szHdr1);
   d1 = szHdr1;
-  assert( pKeyInfo->nField+1>=pPKey2->nField );
+  assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField );
   assert( pKeyInfo->aSortOrder!=0 );
   while( idx1<szHdr1 && i<pPKey2->nField ){
     u32 serial_type1;