SQLite

Check-in [230a4ff2c8]
Login

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

Overview
Comment:Fix the code generator to a void a VDBE stack overflow on 3-way joins. Ticket #519. (CVS 1129)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 230a4ff2c8a3927533baf5b22edc9f25490d5443
User & Date: drh 2003-12-10 01:31:21.000
Context
2003-12-10
03:13
Fix a bulk-memory initialization problem in the expression list logic. (CVS 1130) (check-in: d654995440 user: drh tags: trunk)
01:31
Fix the code generator to a void a VDBE stack overflow on 3-way joins. Ticket #519. (CVS 1129) (check-in: 230a4ff2c8 user: drh tags: trunk)
2003-12-07
00:24
Make the VACUUM command run out of the VDBE like all other commands. (Ticket #464). Make the VACUUM command work even if there are VIEWs in the SQLITE_MASTER table that come before tables they reference. (Ticket #515) (CVS 1128) (check-in: 614cbbafa1 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
**
** 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.244 2003/12/07 00:24:35 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*







|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
**
** 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.245 2003/12/10 01:31:21 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
541
542
543
544
545
546
547

548
549
550
551
552
553
554
  if( sqlite_malloc_failed ) goto no_mem;
  if( p->popStack ){
    sqliteVdbePopStack(p, p->popStack);
    p->popStack = 0;
  }
  for(pc=p->pc; rc==SQLITE_OK; pc++){
    assert( pc>=0 && pc<p->nOp );

#ifdef VDBE_PROFILE
    origPc = pc;
    start = hwtime();
#endif
    pOp = &p->aOp[pc];

    /* Only allow tracing if NDEBUG is not defined.







>







541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
  if( sqlite_malloc_failed ) goto no_mem;
  if( p->popStack ){
    sqliteVdbePopStack(p, p->popStack);
    p->popStack = 0;
  }
  for(pc=p->pc; rc==SQLITE_OK; pc++){
    assert( pc>=0 && pc<p->nOp );
    assert( p->tos<=pc );
#ifdef VDBE_PROFILE
    origPc = pc;
    start = hwtime();
#endif
    pOp = &p->aOp[pc];

    /* Only allow tracing if NDEBUG is not defined.
Changes to src/where.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.
**
** $Id: where.c,v 1.84 2003/12/06 21:43:56 drh Exp $
*/
#include "sqliteInt.h"

/*
** The query generator uses an array of instances of this structure to
** help it analyze the subexpressions of the WHERE clause.  Each WHERE
** clause subexpression is separated from the others by an AND operator.







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.
**
** $Id: where.c,v 1.85 2003/12/10 01:31:21 drh Exp $
*/
#include "sqliteInt.h"

/*
** The query generator uses an array of instances of this structure to
** help it analyze the subexpressions of the WHERE clause.  Each WHERE
** clause subexpression is separated from the others by an AND operator.
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
        if( aExpr[k].idxLeft==iCur ){
          sqliteExprCode(pParse, aExpr[k].p->pRight);
        }else{
          sqliteExprCode(pParse, aExpr[k].p->pLeft);
        }
        /* sqliteVdbeAddOp(v, OP_MustBeInt, 0, 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 ){
          testOp = OP_Ge;
        }else{
          testOp = OP_Gt;
        }
        aExpr[k].p = 0;
      }







|







868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
        if( aExpr[k].idxLeft==iCur ){
          sqliteExprCode(pParse, aExpr[k].p->pRight);
        }else{
          sqliteExprCode(pParse, aExpr[k].p->pLeft);
        }
        /* sqliteVdbeAddOp(v, OP_MustBeInt, 0, sqliteVdbeCurrentAddr(v)+1); */
        pLevel->iMem = pParse->nMem++;
        sqliteVdbeAddOp(v, OP_MemStore, pLevel->iMem, 1);
        if( aExpr[k].p->op==TK_LT || aExpr[k].p->op==TK_GT ){
          testOp = OP_Ge;
        }else{
          testOp = OP_Gt;
        }
        aExpr[k].p = 0;
      }
Changes to test/misc2.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: misc2.test,v 1.9 2003/09/12 02:08:16 drh Exp $

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

# Test for ticket #360
#
do_test misc2-1.1 {







|







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: misc2.test,v 1.10 2003/12/10 01:31:21 drh Exp $

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

# Test for ticket #360
#
do_test misc2-1.1 {
183
184
185
186
187
188
189












































# Ticket #453.  If the SQL ended with "-", the tokenizer was calling that
# an incomplete token, which caused problem.  The solution was to just call
# it a minus sign.
#
do_test misc2-8.1 {
  catchsql {-}
} {1 {near "-": syntax error}}



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Ticket #453.  If the SQL ended with "-", the tokenizer was calling that
# an incomplete token, which caused problem.  The solution was to just call
# it a minus sign.
#
do_test misc2-8.1 {
  catchsql {-}
} {1 {near "-": syntax error}}

# Ticket #513.  Make sure the VDBE stack does not grow on a 3-way join.
#
do_test misc2-9.1 {
  execsql {
    BEGIN;
    CREATE TABLE counts(n INTEGER PRIMARY KEY);
    INSERT INTO counts VALUES(0);
    INSERT INTO counts VALUES(1);
    INSERT INTO counts SELECT n+2 FROM counts;
    INSERT INTO counts SELECT n+4 FROM counts;
    INSERT INTO counts SELECT n+8 FROM counts;
    COMMIT;

    CREATE TEMP TABLE x AS
    SELECT dim1.n, dim2.n, dim3.n
    FROM counts AS dim1, counts AS dim2, counts AS dim3
    WHERE dim1.n<10 AND dim2.n<10 AND dim3.n<10;

    SELECT count(*) FROM x;
  }
} {1000}
do_test misc2-9.2 {
  execsql {
    DROP TABLE x;
    CREATE TEMP TABLE x AS
    SELECT dim1.n, dim2.n, dim3.n
    FROM counts AS dim1, counts AS dim2, counts AS dim3
    WHERE dim1.n>=6 AND dim2.n>=6 AND dim3.n>=6;

    SELECT count(*) FROM x;
  }
} {1000}
do_test misc2-9.3 {
  execsql {
    DROP TABLE x;
    CREATE TEMP TABLE x AS
    SELECT dim1.n, dim2.n, dim3.n, dim4.n
    FROM counts AS dim1, counts AS dim2, counts AS dim3, counts AS dim4
    WHERE dim1.n<5 AND dim2.n<5 AND dim3.n<5 AND dim4.n<5;

    SELECT count(*) FROM x;
  }
} [expr 5*5*5*5]