SQLite

Check-in [29145746f3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a bug in the OP_MemStore operator of the VDBE. A realloc() might occur but pointer to the old buffer were not being moved over to the new buffer. (CVS 752)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 29145746f34438bd830c763872c5e82572150357
User & Date: drh 2002-09-17 03:20:46.000
Context
2002-09-21
15:57
Make sure memory malloced() for structures is aligned on an even byte boundry. Solaris segfaults otherwise. (CVS 753) (check-in: 14ebe30bf5 user: drh tags: trunk)
2002-09-17
03:20
Fix a bug in the OP_MemStore operator of the VDBE. A realloc() might occur but pointer to the old buffer were not being moved over to the new buffer. (CVS 752) (check-in: 29145746f3 user: drh tags: trunk)
2002-09-16
11:44
Modify the sqlite_encode_binary() routine to return the strlen() of the encoded string. Also fix a bug that occurs when attempting to encode a zero-length buffer. (CVS 751) (check-in: f12c3a25ba user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** 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 $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following
** array of string constants which are the names of all VDBE opcodes.







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** 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.179 2002/09/17 03:20:46 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following
** array of string constants which are the names of all VDBE opcodes.
4755
4756
4757
4758
4759
4760
4761








4762
4763
4764
4765
4766
4767
4768
  VERIFY( if( tos<0 ) goto not_enough_stack; )
  if( i>=p->nMem ){
    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;








    p->aMem = aMem;
    if( nOld<p->nMem ){
      memset(&p->aMem[nOld], 0, sizeof(p->aMem[0])*(p->nMem-nOld));
    }
  }
  pMem = &p->aMem[i];
  if( pMem->s.flags & STK_Dyn ){







>
>
>
>
>
>
>
>







4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
  VERIFY( if( tos<0 ) goto not_enough_stack; )
  if( i>=p->nMem ){
    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; j<nOld; j++){
        if( aMem[j].z==p->aMem[j].s.z ){
          aMem[j].z = aMem[j].s.z;
        }
      }
    }
    p->aMem = aMem;
    if( nOld<p->nMem ){
      memset(&p->aMem[nOld], 0, sizeof(p->aMem[0])*(p->nMem-nOld));
    }
  }
  pMem = &p->aMem[i];
  if( pMem->s.flags & STK_Dyn ){
Changes to test/misc1.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# 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 $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test the creation and use of tables that have a large number
# of columns.
#







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# 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.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
# of columns.
#
394
395
396
397
398
399
400




401





























402



403
} {1 4 4}
do_test misc1-12.13 {
  execsql {
    SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1;
  }
} {1 2 2 3 4 2}







































finish_test







>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
} {1 4 4}
do_test misc1-12.13 {
  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