]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure the IN operator works with zeroblobs. Ticket #3965.
authordrh <drh@noemail.net>
Tue, 14 Jul 2009 02:33:02 +0000 (02:33 +0000)
committerdrh <drh@noemail.net>
Tue, 14 Jul 2009 02:33:02 +0000 (02:33 +0000)
Other simplifications associated with structural testing. (CVS 6890)

FossilOrigin-Name: 25dd342283046aaf66a679348ef1c7364c616402

manifest
manifest.uuid
src/vdbe.c
src/vdbeaux.c
test/zeroblob.test

index 15b7f833e6f0866a7f369571fe1d273e05430c1f..55841b11fcf71fabad12e68b42b6db5fdfb1f8a0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sthe\sSQLITE_CommitBusy\sflag.\s\sThis\swas\san\sattempt\sto\sblock\srecursion\non\sthe\ssqlite3_commit_hook()\sinterface.\s\sBut\ssuch\srecursion\sis\sexplicitly\ndisallowed,\sso\sthe\sflag\sis\spointless.\s(CVS\s6889)
-D 2009-07-13T15:52:38
+C Make\ssure\sthe\sIN\soperator\sworks\swith\szeroblobs.\sTicket\s#3965.\nOther\ssimplifications\sassociated\swith\sstructural\stesting.\s(CVS\s6890)
+D 2009-07-14T02:33:02
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -204,11 +204,11 @@ F src/update.c a1bbe774bce495d62dce3df3f42a5f04c1de173a
 F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff
 F src/util.c 861d5b5c58be4921f0a254489ea94cb15f550ef8
 F src/vacuum.c 3fe0eebea6d2311c1c2ab2962887d11f7a4dcfb0
-F src/vdbe.c 4f702761ce1829192e191de461671e214a778386
+F src/vdbe.c f76edc03ffef53ccbf9e38ecc73a65d29eb5b1bd
 F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
 F src/vdbeInt.h 831c254a6eef237ef4664c8381a0137586567007
 F src/vdbeapi.c 0ab8ada7260b32031ca97f338caecf0812460624
-F src/vdbeaux.c a032d0eceee52b6d8334eca50e7ad56740894ddd
+F src/vdbeaux.c 17b354bc801098c0c39d6bee6efe629447fa5d68
 F src/vdbeblob.c a3f3e0e877fc64ea50165eec2855f5ada4477611
 F src/vdbemem.c 1618f685d19b4bcc96e40b3c478487bafd2ae246
 F src/vtab.c 00902f289521041712fb0293d0bf8688c7af8e48
@@ -715,7 +715,7 @@ F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
 F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623
 F test/whereA.test 1d1674254614147c866ab9b59af6582f454a858c
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
-F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
+F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 9f800e11391a108d7aa57f5a96d9a58711129132
-R f8d0ae220937cd02626c27ace66322f8
+P 1c2bfc43a4fd5b779a3b5b5b8ca5b41cb7250b5a
+R 5b29579da257bf626ba86a77cdfd950e
 U drh
-Z fc143e85c113c8856af7ddc393d5518c
+Z f2dc33c5921003d4457094dd4509cc09
index d471c17e54e0eb81fb499bf11cc25257a543b0ae..2dddf591dfbda7e543ed56460bd042c0dfea0bb4 100644 (file)
@@ -1 +1 @@
-1c2bfc43a4fd5b779a3b5b5b8ca5b41cb7250b5a
\ No newline at end of file
+25dd342283046aaf66a679348ef1c7364c616402
\ No newline at end of file
index 9d380d1b4451fad482d5349308704d79f43d1ba9..47094e163d74cf4fab98fc6ff7b85d9c39678009 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.870 2009/07/07 15:47:12 danielk1977 Exp $
+** $Id: vdbe.c,v 1.871 2009/07/14 02:33:02 drh Exp $
 */
 #include "sqliteInt.h"
 #include "vdbeInt.h"
@@ -3349,6 +3349,7 @@ case OP_Found: {        /* jump, in3 */
 
     assert( pC->isTable==0 );
     assert( pIn3->flags & MEM_Blob );
+    ExpandBlob(pIn3);
     pIdxKey = sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z,
                                       aTempRec, sizeof(aTempRec));
     if( pIdxKey==0 ){
@@ -3951,12 +3952,12 @@ case OP_Rowid: {                 /* out2-prerelease */
     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
   }else{
+    assert( pC->pCursor!=0 );
     rc = sqlite3VdbeCursorMoveto(pC);
     if( rc ) goto abort_due_to_error;
     if( pC->rowidIsValid ){
       v = pC->lastRowid;
     }else{
-      assert( pC->pCursor!=0 );
       sqlite3BtreeKeySize(pC->pCursor, &v);
     }
   }
index 9e98db2459c6da0f572981ab1e3e1de723c7a649..d31fb3e552c56b19f168c5b98b66f82a198ead30 100644 (file)
@@ -14,7 +14,7 @@
 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
 ** But that file was getting too big so this subroutines were split out.
 **
-** $Id: vdbeaux.c,v 1.471 2009/07/13 15:52:38 drh Exp $
+** $Id: vdbeaux.c,v 1.472 2009/07/14 02:33:02 drh Exp $
 */
 #include "sqliteInt.h"
 #include "vdbeInt.h"
@@ -1614,12 +1614,7 @@ int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){
   sqlite3 *const db = p->db;
   int rc = SQLITE_OK;
 
-  /* If p->iStatement is greater than zero, then this Vdbe opened a 
-  ** statement transaction that should be closed here. The only exception
-  ** is that an IO error may have occured, causing an emergency rollback.
-  ** In this case (db->nStatement==0), and there is nothing to do.
-  */
-  if( db->nStatement && p->iStatement ){
+  if( p->iStatement ){
     int i;
     const int iSavepoint = p->iStatement-1;
 
@@ -1810,7 +1805,7 @@ int sqlite3VdbeHalt(Vdbe *p){
     /* If this was an INSERT, UPDATE or DELETE and no statement transaction
     ** has been rolled back, update the database connection change-counter. 
     */
-    if( p->changeCntOn && p->pc>=0 ){
+    if( p->changeCntOn ){
       if( eStatementOp!=SAVEPOINT_ROLLBACK ){
         sqlite3VdbeSetChanges(db, p->nChange);
       }else{
@@ -2052,7 +2047,7 @@ int sqlite3VdbeCursorMoveto(VdbeCursor *p){
 #endif
     p->deferredMoveto = 0;
     p->cacheStatus = CACHE_STALE;
-  }else if( p->pCursor ){
+  }else if( ALWAYS(p->pCursor) ){
     int hasMoved;
     int rc = sqlite3BtreeCursorHasMoved(p->pCursor, &hasMoved);
     if( rc ) return rc;
@@ -2453,9 +2448,12 @@ void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord *p){
   assert( p!=0 );
   assert( p->flags & UNPACKED_NEED_DESTROY );
   for(i=0, pMem=p->aMem; i<p->nField; i++, pMem++){
-    if( pMem->zMalloc ){
-      sqlite3VdbeMemRelease(pMem);
-    }
+    /* The unpacked record is always constructed by the
+    ** sqlite3VdbeUnpackRecord() function above, which makes all
+    ** strings and blobs static.  And none of the elements are
+    ** ever transformed, so there is never anything to delete.
+    */
+    if( NEVER(pMem->zMalloc) ) sqlite3VdbeMemRelease(pMem);
   }
   if( p->flags & UNPACKED_NEED_FREE ){
     sqlite3DbFree(p->pKeyInfo->db, p);
index 79723d4b1ee63b364966edf894b97c50e7e92547..f4a195083696a4e3227e1dc6076e1a944115a175 100644 (file)
@@ -13,7 +13,7 @@
 # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
 # and the built-in zeroblob() SQL function.
 #
-# $Id: zeroblob.test,v 1.13 2008/06/13 18:24:28 drh Exp $
+# $Id: zeroblob.test,v 1.14 2009/07/14 02:33:02 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -227,4 +227,33 @@ do_test zeroblob-8.1 {
 } {8}
 
 
+# Ticket #3965
+# zeroblobs on either size of an IN operator
+#
+do_test zeroblob-9.1 {
+  db eval {SELECT x'0000' IN (x'000000')}
+} {0}
+do_test zeroblob-9.2 {
+  db eval {SELECT x'0000' IN (x'0000')}
+} {1}
+do_test zeroblob-9.3 {
+  db eval {SELECT zeroblob(2) IN (x'000000')}
+} {0}
+do_test zeroblob-9.4 {
+  db eval {SELECT zeroblob(2) IN (x'0000')}
+} {1}
+do_test zeroblob-9.5 {
+  db eval {SELECT x'0000' IN (zeroblob(3))}
+} {0}
+do_test zeroblob-9.6 {
+  db eval {SELECT x'0000' IN (zeroblob(2))}
+} {1}
+do_test zeroblob-9.7 {
+  db eval {SELECT zeroblob(2) IN (zeroblob(3))}
+} {0}
+do_test zeroblob-9.8 {
+  db eval {SELECT zeroblob(2) IN (zeroblob(2))}
+} {1}
+
+
 finish_test