SQLite

Check-in [2d5f37c99a]
Login

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

Overview
Comment:Ensure the VerifyCookie sub-routine has been run before the database is accessed in an obscure case. Fix for ticket [d6b36be38].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2d5f37c99a9e5377409697f5392a1ca55970964e
User & Date: dan 2012-12-07 19:28:26.162
Context
2012-12-08
21:51
Refactor collating-sequence handling as a fix for ticket [71e333e7d2e642]. The Expr.pColl field is removed from the Expr object. The COLLATE operator now becomes a separate instance of Expr in the expression tree. The code generator looks up the correct collating function as needed, rather than referring to Expr.pColl. (check-in: 8542e6180d user: drh tags: trunk)
06:46
Merge updates from trunk. (check-in: e65db42c9f user: mistachkin tags: configReadOnly)
2012-12-07
19:28
Ensure the VerifyCookie sub-routine has been run before the database is accessed in an obscure case. Fix for ticket [d6b36be38]. (check-in: 2d5f37c99a user: dan tags: trunk)
10:55
Do not run test file malloc3.test as part of the inmemory_journal permutation. Explanation is in a comment at the top of malloc3.test. (check-in: df1827b19e user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
3946
3947
3948
3949
3950
3951
3952









3953
3954
3955
3956
3957
3958
3959
      /* Implement a co-routine that will return a single row of the result
      ** set on each invocation.
      */
      int addrTop;
      int addrEof;
      pItem->regReturn = ++pParse->nMem;
      addrEof = ++pParse->nMem;









      sqlite3VdbeAddOp0(v, OP_Goto);
      addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);
      sqlite3VdbeChangeP5(v, 1);
      VdbeComment((v, "coroutine for %s", pItem->pTab->zName));
      pItem->addrFillSub = addrTop;
      sqlite3VdbeAddOp2(v, OP_Integer, 0, addrEof);
      sqlite3VdbeChangeP5(v, 1);







>
>
>
>
>
>
>
>
>







3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
      /* Implement a co-routine that will return a single row of the result
      ** set on each invocation.
      */
      int addrTop;
      int addrEof;
      pItem->regReturn = ++pParse->nMem;
      addrEof = ++pParse->nMem;
      /* Before coding the OP_Goto to jump to the start of the main routine,
      ** ensure that the jump to the verify-schema routine has already
      ** been coded. Otherwise, the verify-schema would likely be coded as 
      ** part of the co-routine. If the main routine then accessed the 
      ** database before invoking the co-routine for the first time (for 
      ** example to initialize a LIMIT register from a sub-select), it would 
      ** be doing so without having verified the schema version and obtained 
      ** the required db locks. See ticket d6b36be38.  */
      sqlite3CodeVerifySchema(pParse, -1);
      sqlite3VdbeAddOp0(v, OP_Goto);
      addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);
      sqlite3VdbeChangeP5(v, 1);
      VdbeComment((v, "coroutine for %s", pItem->pTab->zName));
      pItem->addrFillSub = addrTop;
      sqlite3VdbeAddOp2(v, OP_Integer, 0, addrEof);
      sqlite3VdbeChangeP5(v, 1);
Changes to test/subquery2.test.
11
12
13
14
15
16
17

18
19
20
21
22
23
24
# This file implements regression tests for SQLite library.  The
# focus of this script is testing correlated subqueries
#
#

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


ifcapable !subquery {
  finish_test
  return
}

do_test subquery2-1.1 {







>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This file implements regression tests for SQLite library.  The
# focus of this script is testing correlated subqueries
#
#

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

ifcapable !subquery {
  finish_test
  return
}

do_test subquery2-1.1 {
77
78
79
80
81
82
83




















84
85
86
do_test subquery2-1.22 {
  execsql {
    SELECT a FROM t1
     WHERE b=(SELECT x+1 FROM 
                 (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))
  }
} {1 3 5 7}






















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
do_test subquery2-1.22 {
  execsql {
    SELECT a FROM t1
     WHERE b=(SELECT x+1 FROM 
                 (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))
  }
} {1 3 5 7}

#-------------------------------------------------------------------------
# Test that ticket d6b36be38a has been fixed.
do_execsql_test 2.1 {
  CREATE TABLE t4(a, b);
  CREATE TABLE t5(a, b);
  INSERT INTO t5 VALUES(3, 5);

  INSERT INTO t4 VALUES(1, 1);
  INSERT INTO t4 VALUES(2, 3);
  INSERT INTO t4 VALUES(3, 6);
  INSERT INTO t4 VALUES(4, 10);
  INSERT INTO t4 VALUES(5, 15);
}

do_execsql_test 2.2 {
  SELECT * 
  FROM (SELECT * FROM t4 ORDER BY a LIMIT -1 OFFSET 1) 
  LIMIT (SELECT a FROM t5)
} {2 3   3 6   4 10}


finish_test