Index: src/vdbe.c ================================================================== --- src/vdbe.c +++ src/vdbe.c @@ -34,11 +34,11 @@ ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** 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.178 2002/09/14 13:47:32 drh Exp $ +** $Id: vdbe.c,v 1.179 2002/09/17 03:20:46 drh Exp $ */ #include "sqliteInt.h" #include /* @@ -4757,10 +4757,18 @@ int nOld = p->nMem; Mem *aMem; p->nMem = i + 5; aMem = sqliteRealloc(p->aMem, p->nMem*sizeof(p->aMem[0])); if( aMem==0 ) goto no_mem; + if( aMem!=p->aMem ){ + int j; + for(j=0; jaMem[j].s.z ){ + aMem[j].z = aMem[j].s.z; + } + } + } p->aMem = aMem; if( nOldnMem ){ memset(&p->aMem[nOld], 0, sizeof(p->aMem[0])*(p->nMem-nOld)); } } Index: test/misc1.test ================================================================== --- test/misc1.test +++ test/misc1.test @@ -11,11 +11,11 @@ # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc1.test,v 1.14 2002/08/18 22:41:22 drh Exp $ +# $Id: misc1.test,v 1.15 2002/09/17 03:20:46 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test the creation and use of tables that have a large number @@ -396,8 +396,44 @@ execsql { SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1; } } {1 2 2 3 4 2} - +# There was a problem with realloc() in the OP_MemStore operation of +# the VDBE. A buffer was being reallocated but some pointers into +# the old copy of the buffer were not being moved over to the new copy. +# The following code tests for the problem. +# +do_test misc1-13.1 { + execsql { + CREATE TABLE t9(x,y); + INSERT INTO t9 VALUES('one',1); + INSERT INTO t9 VALUES('two',2); + INSERT INTO t9 VALUES('three',3); + INSERT INTO t9 VALUES('four',4); + INSERT INTO t9 VALUES('five',5); + INSERT INTO t9 VALUES('six',6); + INSERT INTO t9 VALUES('seven',7); + INSERT INTO t9 VALUES('eight',8); + INSERT INTO t9 VALUES('nine',9); + INSERT INTO t9 VALUES('ten',10); + INSERT INTO t9 VALUES('eleven',11); + SELECT y FROM t9 + WHERE x=(SELECT x FROM t9 WHERE y=1) + OR x=(SELECT x FROM t9 WHERE y=2) + OR x=(SELECT x FROM t9 WHERE y=3) + OR x=(SELECT x FROM t9 WHERE y=4) + OR x=(SELECT x FROM t9 WHERE y=5) + OR x=(SELECT x FROM t9 WHERE y=6) + OR x=(SELECT x FROM t9 WHERE y=7) + OR x=(SELECT x FROM t9 WHERE y=8) + OR x=(SELECT x FROM t9 WHERE y=9) + OR x=(SELECT x FROM t9 WHERE y=10) + OR x=(SELECT x FROM t9 WHERE y=11) + OR x=(SELECT x FROM t9 WHERE y=12) + OR x=(SELECT x FROM t9 WHERE y=13) + OR x=(SELECT x FROM t9 WHERE y=14) + ; + } +} {1 2 3 4 5 6 7 8 9 10 11} finish_test