]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
An alternative way of fixing the key comparison bug of alt1-tkt-f97c4637
authordrh <drh@noemail.net>
Mon, 19 Jan 2015 19:21:36 +0000 (19:21 +0000)
committerdrh <drh@noemail.net>
Mon, 19 Jan 2015 19:21:36 +0000 (19:21 +0000)
ticket [f97c4637102a3ae72b].

FossilOrigin-Name: e41376cf0804a0ca1b9033661ef6e94e37ad865e

manifest
manifest.uuid
src/vdbeaux.c

index 136cb71f94a17113994c82f4612c0e438093c489..86730755d37e3757bbbdea577f20edf19cd79332 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\sthe\scommand-line\sshell\swith\sthe\sability\sto\sset\sthe\nSQLITE_TESTCTRL_NEVER_CORRUPT\sflag\susing:\s".testctrl\snever_corrupt\s1".
-D 2015-01-19T15:05:54.471
+C An\salternative\sway\sof\sfixing\sthe\skey\scomparison\sbug\sof\nticket\s[f97c4637102a3ae72b].
+D 2015-01-19T19:21:36.662
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -296,7 +296,7 @@ F src/vdbe.c ddfc977981cd6324668aa6b114045eb1c677421a
 F src/vdbe.h 6fc69d9c5e146302c56e163cb4b31d1ee64a18c3
 F src/vdbeInt.h 9bb69ff2447c34b6ccc58b34ec35b615f86ead78
 F src/vdbeapi.c 4bc511a46b9839392ae0e90844a71dc96d9dbd71
-F src/vdbeaux.c 07ef87c6d4b5abdf13ff33babb10205702fdab0a
+F src/vdbeaux.c a27240f5d800317c49ed06600c44402895999ee7
 F src/vdbeblob.c 4af4bfb71f6df7778397b4a0ebc1879793276778
 F src/vdbemem.c 31d8eabb0cd78bfeab4e5124c7363c3e9e54db9f
 F src/vdbesort.c 6d64c5448b64851b99931ede980addc3af70d5e2
@@ -1236,7 +1236,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 10321910990195878c0af1e94b34ae0cdc0cb31b
-R 1842536563f5d094d57991d4a5161858
+P 824328f9833d01fc155a9d0265ef41d338cf1ffb
+R 851e412f0bb1f167975796b44f8ba55a
+T *branch * alt1-tkt-f97c4637
+T *sym-alt1-tkt-f97c4637 *
+T -sym-trunk *
 U drh
-Z b40ce48cd42cd2dd2358d0667c50be5c
+Z 89b67a6e4c6f42fba90e007874b16e43
index a042232dda36b1bd4d3df51f24568bb976c9f9e1..cdfef467e50e2836a0c15c8ffed5b94d1caab804 100644 (file)
@@ -1 +1 @@
-824328f9833d01fc155a9d0265ef41d338cf1ffb
\ No newline at end of file
+e41376cf0804a0ca1b9033661ef6e94e37ad865e
\ No newline at end of file
index 03c229c994a0bd08f621411933a234f4bc956bb4..dce7bf20a5ae3b8b74146401bc421f4df14fe634 100644 (file)
@@ -3760,7 +3760,9 @@ static int vdbeRecordCompareInt(
   i64 v = pPKey2->aMem[0].u.i;
   i64 lhs;
 
-  assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );
+  if( ((const u8*)pKey1)[0]>=64 ){
+    return vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
+  }
   switch( serial_type ){
     case 1: { /* 1-byte signed integer */
       lhs = ONE_BYTE_INT(aKey);
@@ -3847,6 +3849,9 @@ static int vdbeRecordCompareString(
   int serial_type;
   int res;
 
+  if( aKey1[0]>=64 ){
+    return vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
+  }
   getVarint32(&aKey1[1], serial_type);
   if( serial_type<12 ){
     res = pPKey2->r1;      /* (pKey1/nKey1) is a number or a null */
@@ -3898,40 +3903,24 @@ static int vdbeRecordCompareString(
 ** as the only argument.
 */
 RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){
-  /* varintRecordCompareInt() and varintRecordCompareString() both assume
-  ** that the size-of-header varint that occurs at the start of each record
-  ** fits in a single byte (i.e. is 127 or less). varintRecordCompareInt()
-  ** also assumes that it is safe to overread a buffer by at least the 
-  ** maximum possible legal header size plus 8 bytes. Because there is
-  ** guaranteed to be at least 74 (but not 136) bytes of padding following each
-  ** buffer passed to varintRecordCompareInt() this makes it convenient to
-  ** limit the size of the header to 64 bytes in cases where the first field
-  ** is an integer.
-  **
-  ** The easiest way to enforce this limit is to consider only records with
-  ** 13 fields or less. If the first field is an integer, the maximum legal
-  ** header size is (12*5 + 1 + 1) bytes.  */
-  if( (p->pKeyInfo->nField + p->pKeyInfo->nXField)<=13 ){
-    int flags = p->aMem[0].flags;
-    if( p->pKeyInfo->aSortOrder[0] ){
-      p->r1 = 1;
-      p->r2 = -1;
-    }else{
-      p->r1 = -1;
-      p->r2 = 1;
-    }
-    if( (flags & MEM_Int) ){
-      return vdbeRecordCompareInt;
-    }
-    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;
-    }
+  int flags = p->aMem[0].flags;
+  if( p->pKeyInfo->aSortOrder[0] ){
+    p->r1 = 1;
+    p->r2 = -1;
+  }else{
+    p->r1 = -1;
+    p->r2 = 1;
+  }
+  if( (flags & MEM_Int) ){
+    return vdbeRecordCompareInt;
+  }
+  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;
   }
-
   return sqlite3VdbeRecordCompare;
 }