]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix some incorrect comments and typos in comments. Add testcase() macros
authordrh <drh@noemail.net>
Thu, 6 Mar 2014 01:56:33 +0000 (01:56 +0000)
committerdrh <drh@noemail.net>
Thu, 6 Mar 2014 01:56:33 +0000 (01:56 +0000)
to some of the new record comparison code.

FossilOrigin-Name: b83cfe899d84fe9d61540e9984321ca30401638c

manifest
manifest.uuid
src/btree.c
src/insert.c
src/vdbe.c
src/vdbeaux.c

index 9ebba2561837e899c7ecf5194df53a46c5ec12a2..0317e45b49e9095d39fdd1bc6004cb03dad6550c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Better\sloadable\sextension\shandling\sin\sthe\sWin32\sVFS\swhen\scompiled\sfor\sCygwin.
-D 2014-03-06T00:30:27.980
+C Fix\ssome\sincorrect\scomments\sand\stypos\sin\scomments.\s\sAdd\stestcase()\smacros\nto\ssome\sof\sthe\snew\srecord\scomparison\scode.
+D 2014-03-06T01:56:33.418
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -163,7 +163,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c ad795be588e394a0921796f87cc27717359738cc
+F src/btree.c 4d28fb15543f0e071b1780b2af8cd2ee489de32d
 F src/btree.h 9e0f97c01b972f779eb7655cfb4f8727fd6dc26f
 F src/btreeInt.h 0be66063468a520e4d66b80c7a1dc26d04ee6ea4
 F src/build.c 0d50ef95aad63f4c4fc47f3fa2670d4557c45db0
@@ -180,7 +180,7 @@ F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486
 F src/hash.c d139319967164f139c8d1bb8a11b14db9c4ba3cd
 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
-F src/insert.c d3d1164299faa53b5347f8ff676d3787537fa9e5
+F src/insert.c d8bb30535c8c0785876025a4a07f9074640a15d1
 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
@@ -277,11 +277,11 @@ F src/update.c 5b3e74a03b3811e586b4f2b4cbd7c49f01c93115
 F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c
 F src/util.c c46c90459ef9bdc0c6c73803cf4c55425b4771cf
 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
-F src/vdbe.c 8c6fc7bb9f2218c0e43f24d847e596effa8671e2
+F src/vdbe.c b2ca9b8e3a47a3bcecdb2b551279a2ba750a19e5
 F src/vdbe.h d189f92468a17a6f04daeec9df3b767f50557b21
 F src/vdbeInt.h e54fc4f289fce48e81b3371128446033d097733b
 F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4
-F src/vdbeaux.c 43bee29ac866f7ce6af90c4f084bb22c160b8b70
+F src/vdbeaux.c e45e3f9daf38c5be3fd39e9aacc1c9066af57a06
 F src/vdbeblob.c d939997de046b8fcc607cfee4248f3d33dbcca50
 F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447
 F src/vdbesort.c 46801acb342e5e4c07ba1777fe58880c143abb59
@@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 170e0585202eec6882e9513eba05e6d5767bfc5b 854d410ad3a2bb3af5465d933ac9535fe3f22bfe
-R dbc36dfda03a0ba225e8ff052c2c6fea
-U mistachkin
-Z 97b3517e69e758ff54d2564329fd6e38
+P 29b0a4f158785449b6f3da6fcceeb63442c9711c
+R 6ebc5b98243298bdc1108377764c8e0d
+U drh
+Z 431ba6c46f093bf18085ee790e19125c
index 41cd05f2ef60ac8ece69bf2010f9a4a27640c385..d5463c1070119eb91d453be9e5fc6d46743cc15b 100644 (file)
@@ -1 +1 @@
-29b0a4f158785449b6f3da6fcceeb63442c9711c
\ No newline at end of file
+b83cfe899d84fe9d61540e9984321ca30401638c
\ No newline at end of file
index eebf6f1e89dc2a8510c801b3e33e08be9b291605..29ead1c67a0ceb4c366d057a0099bd1857483e86 100644 (file)
@@ -4576,7 +4576,7 @@ int sqlite3BtreeMovetoUnpacked(
          || pIdxKey->default_rc==-1
     );
   }else{
-    xRecordCompare = 0; /* Not actually used.  Avoids a compiler warning. */
+    xRecordCompare = 0; /* All keys are integers */
   }
 
   rc = moveToRoot(pCur);
index 1d29da30923c008a7da4b0cf96673acab5c6b787..abdf1ada952a14868146ae66b4276ce9a3cb7fab 100644 (file)
@@ -101,13 +101,13 @@ const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
 ** Compute the affinity string for table pTab, if it has not already been
 ** computed.  As an optimization, omit trailing SQLITE_AFF_NONE affinities.
 **
-** If the affinity exists (if it is no entirely SQLITE_AFF_NONE values and
+** If the affinity exists (if it is no entirely SQLITE_AFF_NONE values) and
 ** if iReg>0 then code an OP_Affinity opcode that will set the affinities
 ** for register iReg and following.  Or if affinities exists and iReg==0,
 ** then just set the P4 operand of the previous opcode (which should  be
 ** an OP_MakeRecord) to the affinity string.
 **
-** A column affinity string has one character column:
+** A column affinity string has one character per column:
 **
 **  Character      Column affinity
 **  ------------------------------
@@ -148,10 +148,9 @@ void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
 
 /*
 ** Return non-zero if the table pTab in database iDb or any of its indices
-** have been opened at any point in the VDBE program beginning at location
-** iStartAddr throught the end of the program.  This is used to see if 
+** have been opened at any point in the VDBE program. This is used to see if 
 ** a statement of the form  "INSERT INTO <iDb, pTab> SELECT ..." can 
-** run without using temporary table for the results of the SELECT. 
+** run without using temporary table for the results of the SELECT. 
 */
 static int readsTable(Parse *p, int iDb, Table *pTab){
   Vdbe *v = sqlite3GetVdbe(p);
index b9d49e362096d5aace390a54e498c3cd75e0cbc5..4c36e12090e55fd9ecf10441192251afd4835fd4 100644 (file)
@@ -28,7 +28,7 @@
 ** pointer to the string or blob, not the content.  If the original
 ** is changed while the copy is still in use, the string or blob might
 ** be changed out from under the copy.  This macro verifies that nothing
-** like that every happens.
+** like that ever happens.
 */
 #ifdef SQLITE_DEBUG
 # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
@@ -2166,8 +2166,8 @@ case OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */
 **
 ** Check if OP_Once flag P1 is set. If so, jump to instruction P2. Otherwise,
 ** set the flag and fall through to the next instruction.  In other words,
-** this opcode causes all following up codes up through P2 (but not including
-** P2) to run just once and skipped on subsequent times through the loop.
+** this opcode causes all following opcodes up through P2 (but not including
+** P2) to run just once and to be skipped on subsequent times through the loop.
 */
 case OP_Once: {             /* jump */
   assert( pOp->p1<p->nOnceFlag );
index 00ec9015880a2a8b90e49f488e995c887f7e4f6f..a641a72ec8e40b4c534eb59bbfc704795893aea6 100644 (file)
@@ -1234,6 +1234,10 @@ static void releaseMemArray(Mem *p, int N){
       ** with no indexes using a single prepared INSERT statement, bind() 
       ** and reset(). Inserts are grouped into a transaction.
       */
+      testcase( p->flags & MEM_Agg );
+      testcase( p->flags & MEM_Dyn );
+      testcase( p->flags & MEM_Frame );
+      testcase( p->flags & MEM_RowSet );
       if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){
         sqlite3VdbeMemRelease(p);
       }else if( p->zMalloc ){
@@ -2962,27 +2966,32 @@ u32 sqlite3VdbeSerialGet(
     case 1: { /* 1-byte signed integer */
       pMem->u.i = ONE_BYTE_INT(buf);
       pMem->flags = MEM_Int;
+      testcase( pMem->u.i<0 );
       return 1;
     }
     case 2: { /* 2-byte signed integer */
       pMem->u.i = TWO_BYTE_INT(buf);
       pMem->flags = MEM_Int;
+      testcase( pMem->u.i<0 );
       return 2;
     }
     case 3: { /* 3-byte signed integer */
       pMem->u.i = THREE_BYTE_INT(buf);
       pMem->flags = MEM_Int;
+      testcase( pMem->u.i<0 );
       return 3;
     }
     case 4: { /* 4-byte signed integer */
       y = FOUR_BYTE_UINT(buf);
       pMem->u.i = (i64)*(int*)&y;
       pMem->flags = MEM_Int;
+      testcase( pMem->u.i<0 );
       return 4;
     }
     case 5: { /* 6-byte signed integer */
       pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
       pMem->flags = MEM_Int;
+      testcase( pMem->u.i<0 );
       return 6;
     }
     case 6:   /* 8-byte signed integer */
@@ -3005,6 +3014,7 @@ u32 sqlite3VdbeSerialGet(
       if( serial_type==6 ){
         pMem->u.i = *(i64*)&x;
         pMem->flags = MEM_Int;
+        testcase( pMem->u.i<0 );
       }else{
         assert( sizeof(x)==8 && sizeof(pMem->r)==8 );
         swapMixedEndianFloat(x);
@@ -3350,20 +3360,26 @@ static i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){
   switch( serial_type ){
     case 0:
     case 1:
+      testcase( aKey[0]&0x80 );
       return ONE_BYTE_INT(aKey);
     case 2:
+      testcase( aKey[0]&0x80 );
       return TWO_BYTE_INT(aKey);
     case 3:
+      testcase( aKey[0]&0x80 );
       return THREE_BYTE_INT(aKey);
     case 4: {
+      testcase( aKey[0]&0x80 );
       y = FOUR_BYTE_UINT(aKey);
       return (i64)*(int*)&y;
     }
     case 5: {
+      testcase( aKey[0]&0x80 );
       return FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);
     }
     case 6: {
       u64 x = FOUR_BYTE_UINT(aKey);
+      testcase( aKey[0]&0x80 );
       x = (x<<32) | FOUR_BYTE_UINT(aKey+4);
       return (i64)*(i64*)&x;
     }
@@ -3431,6 +3447,7 @@ int sqlite3VdbeRecordCompare(
     /* RHS is an integer */
     if( pRhs->flags & MEM_Int ){
       serial_type = aKey1[idx1];
+      testcase( serial_type==12 );
       if( serial_type>=12 ){
         rc = +1;
       }else if( serial_type==0 ){
@@ -3481,12 +3498,15 @@ int sqlite3VdbeRecordCompare(
     /* RHS is a string */
     else if( pRhs->flags & MEM_Str ){
       getVarint32(&aKey1[idx1], serial_type);
+      testcase( serial_type==12 );
       if( serial_type<12 ){
         rc = -1;
       }else if( !(serial_type & 0x01) ){
         rc = +1;
       }else{
         mem1.n = (serial_type - 12) / 2;
+        testcase( (d1+mem1.n)==(unsigned)nKey1 );
+        testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
         if( (d1+mem1.n) > (unsigned)nKey1 ){
           rc = 1;                /* Corruption */
         }else if( pKeyInfo->aColl[i] ){
@@ -3506,10 +3526,13 @@ int sqlite3VdbeRecordCompare(
     /* RHS is a blob */
     else if( pRhs->flags & MEM_Blob ){
       getVarint32(&aKey1[idx1], serial_type);
+      testcase( serial_type==12 );
       if( serial_type<12 || (serial_type & 0x01) ){
         rc = -1;
       }else{
         int nStr = (serial_type - 12) / 2;
+        testcase( (d1+nStr)==(unsigned)nKey1 );
+        testcase( (d1+nStr+1)==(unsigned)nKey1 );
         if( (d1+nStr) > (unsigned)nKey1 ){
           rc = 1;                /* Corruption */
         }else{
@@ -3583,29 +3606,35 @@ static int vdbeRecordCompareInt(
   switch( serial_type ){
     case 1: { /* 1-byte signed integer */
       lhs = ONE_BYTE_INT(aKey);
+      testcase( lhs<0 );
       break;
     }
     case 2: { /* 2-byte signed integer */
       lhs = TWO_BYTE_INT(aKey);
+      testcase( lhs<0 );
       break;
     }
     case 3: { /* 3-byte signed integer */
       lhs = THREE_BYTE_INT(aKey);
+      testcase( lhs<0 );
       break;
     }
     case 4: { /* 4-byte signed integer */
       y = FOUR_BYTE_UINT(aKey);
       lhs = (i64)*(int*)&y;
+      testcase( lhs<0 );
       break;
     }
     case 5: { /* 6-byte signed integer */
       lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);
+      testcase( lhs<0 );
       break;
     }
     case 6: { /* 8-byte signed integer */
       x = FOUR_BYTE_UINT(aKey);
       x = (x<<32) | FOUR_BYTE_UINT(aKey+4);
       lhs = *(i64*)&x;
+      testcase( lhs<0 );
       break;
     }
     case 8: 
@@ -3742,9 +3771,11 @@ RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){
     if( (flags & MEM_Int) ){
       return vdbeRecordCompareInt;
     }
-    if( (flags & (MEM_Int|MEM_Real|MEM_Null|MEM_Blob))==0 
-        && p->pKeyInfo->aColl[0]==0 
-    ){
+    testcase( flags & MEM_Real );
+    testcase( flags & MEM_Null );
+    testcase( flags & MEM_Blob );
+    if( (flags & (MEM_Real|MEM_Null|MEM_Blob))==0 && p->pKeyInfo->aColl[0]==0 ){
+      assert( flags & MEM_Str );
       return vdbeRecordCompareString;
     }
   }