]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix for ticket #124: Fix a stack VDBE overflow problem on joins on an
authordrh <drh@noemail.net>
Wed, 31 Jul 2002 19:50:26 +0000 (19:50 +0000)
committerdrh <drh@noemail.net>
Wed, 31 Jul 2002 19:50:26 +0000 (19:50 +0000)
INTEGER PRIMARY KEY. (CVS 700)

FossilOrigin-Name: fe329e078fa209faf62e08599a00c7efa75b8501

manifest
manifest.uuid
src/vdbe.c
src/where.c
test/join.test

index a980bd8c2c5be5c250b5e2e17528a2976556aced..329fad7d7e7740d45999f75eb5ed0d4f25859552 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s2.6.2\s(CVS\s699)
-D 2002-07-31T00:38:07
+C Fix\sfor\sticket\s#124:\sFix\sa\sstack\sVDBE\soverflow\sproblem\son\sjoins\son\san\nINTEGER\sPRIMARY\sKEY.\s(CVS\s700)
+D 2002-07-31T19:50:27
 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
 F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -52,9 +52,9 @@ F src/tokenize.c b5500e193a82b5b9888fbf947efd90d3b4858178
 F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4
 F src/update.c f07e6ed2c517c92871e54d3f5886d1cf56121b11
 F src/util.c 7a99e754c44dd220e881122e30581c08b6d6adef
-F src/vdbe.c b35ea5d6af6c4649d6cda171d326352ff616875d
+F src/vdbe.c aa647946d08e54b71bfff9049ad31135b7af4a8e
 F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2
-F src/where.c 6a43aa6c80eab12221eeca754cba852a9ecd1e13
+F src/where.c 0fde349514717a55ff6a27ed2c6e914ce98a1512
 F test/all.test f296d27fff6aca72348af15092154f879d1fc7d4
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
 F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1
@@ -71,7 +71,7 @@ F test/insert.test a122afb86911e77c181d912348866a5b1a61eeab
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
 F test/intpkey.test 69a6a9b41e541f27a2ffcd20264fb35adc3c2680
 F test/ioerr.test 57d9bffaca18b34f9e976f786eadc2591d6efc6a
-F test/join.test 75561ec0e5fdde381a3e31317ebe4d6d9474bb71
+F test/join.test 90a620f2a2d015e5139d5a4cde0eeb4cf62523bf
 F test/limit.test 49b44e027a002c0ba336d723b448f07e05b04466
 F test/lock.test f1b55dc61632e99d241643cc8e7c03774f09f623
 F test/main.test c66b564554b770ee7fdbf6a66c0cd90329bc2c85
@@ -143,7 +143,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 4f196de07d258dc44b6fd20d776120e2aadd3224
-R 6fc4add27e1daff3e73e47693ab2e9a0
+P 223a2150ac1fa34d4bd01dd32b5fed9e90aa38d4
+R 44456872a0d4b203d2c6dd56f3b04dc6
 U drh
-Z 57e7cf48960b18de6fc8c07074fa6766
+Z 7dedae30cba3306a28c1b36217d2dbe0
index 36967b976f31a00d4aa70112116c17a9b6d9d4c6..2315116b25bb05dc90eea7efcc69e6b172137a52 100644 (file)
@@ -1 +1 @@
-223a2150ac1fa34d4bd01dd32b5fed9e90aa38d4
\ No newline at end of file
+fe329e078fa209faf62e08599a00c7efa75b8501
\ No newline at end of file
index cc4b6f7421563c0bf2aa351ca34f508afeb18745..9697e4d24d25064a3ad97bcde06bc9d9c4d16ec0 100644 (file)
@@ -30,7 +30,7 @@
 ** But other routines are also provided to help in building up
 ** a program instruction by instruction.
 **
-** $Id: vdbe.c,v 1.166 2002/07/30 17:20:40 drh Exp $
+** $Id: vdbe.c,v 1.167 2002/07/31 19:50:27 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1976,12 +1976,16 @@ case OP_AddImm: {
   break;
 }
 
-/* Opcode: MustBeInt  * P2 *
+/* Opcode: MustBeInt P1 P2 *
 ** 
 ** Force the top of the stack to be an integer.  If the top of the
 ** stack is not an integer and cannot be converted into an integer
 ** with out data loss, then jump immediately to P2, or if P2==0
 ** raise an SQLITE_MISMATCH exception.
+**
+** If the top of the stack is not an integer and P2 is not zero and
+** P1 is 1, then the stack is popped.  In all other cases, the depth
+** of the stack is unchanged.
 */
 case OP_MustBeInt: {
   int tos = p->tos;
@@ -2012,6 +2016,7 @@ mismatch:
     rc = SQLITE_MISMATCH;
     goto abort_due_to_error;
   }else{
+    if( pOp->p1 ) POPSTACK;
     pc = pOp->p2 - 1;
   }
   break;
index f4ff6c2d41ae66936fd0ce612fd8dd133da5a0ee..bb5102c1c44ef827a47ff28b5cdd0e8a6cd8acf6 100644 (file)
@@ -13,7 +13,7 @@
 ** the WHERE clause of SQL statements.  Also found here are subroutines
 ** to generate VDBE code to evaluate expressions.
 **
-** $Id: where.c,v 1.58 2002/06/28 12:18:47 drh Exp $
+** $Id: where.c,v 1.59 2002/07/31 19:50:28 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -690,7 +690,7 @@ WhereInfo *sqliteWhereBegin(
       }
       aExpr[k].p = 0;
       cont = pLevel->cont = sqliteVdbeMakeLabel(v);
-      sqliteVdbeAddOp(v, OP_MustBeInt, 0, brk);
+      sqliteVdbeAddOp(v, OP_MustBeInt, 1, brk);
       haveKey = 0;
       sqliteVdbeAddOp(v, OP_NotExists, base+idx, brk);
       pLevel->op = OP_Noop;
@@ -787,7 +787,7 @@ WhereInfo *sqliteWhereBegin(
         }else{
           sqliteExprCode(pParse, aExpr[k].p->pLeft);
         }
-        sqliteVdbeAddOp(v, OP_MustBeInt, 0, brk);
+        sqliteVdbeAddOp(v, OP_MustBeInt, 1, brk);
         if( aExpr[k].p->op==TK_LT || aExpr[k].p->op==TK_GT ){
           sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
         }
@@ -806,7 +806,7 @@ WhereInfo *sqliteWhereBegin(
         }else{
           sqliteExprCode(pParse, aExpr[k].p->pLeft);
         }
-        sqliteVdbeAddOp(v, OP_MustBeInt, 0, sqliteVdbeCurrentAddr(v)+1);
+        sqliteVdbeAddOp(v, OP_MustBeInt, 1, sqliteVdbeCurrentAddr(v)+1);
         pLevel->iMem = pParse->nMem++;
         sqliteVdbeAddOp(v, OP_MemStore, pLevel->iMem, 0);
         if( aExpr[k].p->op==TK_LT || aExpr[k].p->op==TK_GT ){
index ee91d5f4c9fa3305d6b9169922577bdf8ce23b82..9607e90e3ecff2b10dafe9db33bf98d34925a0f7 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for joins, including outer joins.
 #
-# $Id: join.test,v 1.4 2002/07/01 12:27:09 drh Exp $
+# $Id: join.test,v 1.5 2002/07/31 19:50:28 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -221,5 +221,67 @@ do_test join-3.7 {
   }
 } {1 {unknown or unsupported join type: LEFT BOGUS}}
 
+do_test join-4.1 {
+  execsql {
+    BEGIN;
+    CREATE TABLE t5(a INTEGER PRIMARY KEY);
+    CREATE TABLE t6(a INTEGER);
+    INSERT INTO t6 VALUES(NULL);
+    INSERT INTO t6 VALUES(NULL);
+    INSERT INTO t6 SELECT * FROM t6;
+    INSERT INTO t6 SELECT * FROM t6;
+    INSERT INTO t6 SELECT * FROM t6;
+    INSERT INTO t6 SELECT * FROM t6;
+    INSERT INTO t6 SELECT * FROM t6;
+    INSERT INTO t6 SELECT * FROM t6;
+    COMMIT;
+  }
+  execsql {
+    SELECT * FROM t6 NATURAL JOIN t5;
+  }
+} {}
+do_test join-4.2 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+  }
+} {}
+do_test join-4.3 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+  }
+} {}
+do_test join-4.4 {
+  execsql {
+    UPDATE t6 SET a='xyz';
+    SELECT * FROM t6 NATURAL JOIN t5;
+  }
+} {}
+do_test join-4.6 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+  }
+} {}
+do_test join-4.7 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+  }
+} {}
+do_test join-4.8 {
+  execsql {
+    UPDATE t6 SET a=1;
+    SELECT * FROM t6 NATURAL JOIN t5;
+  }
+} {}
+do_test join-4.9 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+  }
+} {}
+do_test join-4.10 {
+  execsql {
+    SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+  }
+} {}
+
 
 finish_test