/ Check-in [7c0f638e]
Login

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

Overview
Comment:Deallocate a temp register allocated by codeEqualityTerm() in where.c. If it is not deallocated, its value may be reused by the column-cache mechanism. However, by the time it is used, the value may have been clobbered by a sub-routine that also uses the same temp register. Fix for #3357. (CVS 5679)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7c0f638ef3d7ff9156f07d6fb01448453ffcf5ac
User & Date: danielk1977 2008-09-06 14:19:11
Context
2008-09-08
08:08
Add header file sqliteicu.h to the ICU extension. This is analogous to the rtree.h and fts3.h headers used by other extensions to declare their entry points. Fix for ticket #3361. (CVS 5680) check-in: 79364b96 user: danielk1977 tags: trunk
2008-09-06
14:19
Deallocate a temp register allocated by codeEqualityTerm() in where.c. If it is not deallocated, its value may be reused by the column-cache mechanism. However, by the time it is used, the value may have been clobbered by a sub-routine that also uses the same temp register. Fix for #3357. (CVS 5679) check-in: 7c0f638e user: danielk1977 tags: trunk
2008-09-05
05:29
Change pcache.test so that it works if sqlite is configured to create auto-vacuum databases by default. (CVS 5678) check-in: 55e67756 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
2419
2420
2421
2422
2423
2424
2425

2426
2427
2428
2429
2430
2431
2432
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is responsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.321 2008/08/25 12:08:22 drh Exp $
*/
#include "sqliteInt.h"

/*
** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
*/
#define BMS  (sizeof(Bitmask)*8)
................................................................................
      assert( pTerm->pExpr!=0 );
      assert( pTerm->leftCursor==iCur );
      assert( omitTable==0 );
      r1 = codeEqualityTerm(pParse, pTerm, pLevel, 0);
      nxt = pLevel->nxt;
      sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, nxt);
      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, nxt, r1);

      VdbeComment((v, "pk"));
      pLevel->op = OP_Noop;
    }else if( pLevel->flags & WHERE_ROWID_RANGE ){
      /* Case 2:  We have an inequality comparison against the ROWID field.
      */
      int testOp = OP_Noop;
      int start;







|







 







>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is responsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.322 2008/09/06 14:19:11 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
*/
#define BMS  (sizeof(Bitmask)*8)
................................................................................
      assert( pTerm->pExpr!=0 );
      assert( pTerm->leftCursor==iCur );
      assert( omitTable==0 );
      r1 = codeEqualityTerm(pParse, pTerm, pLevel, 0);
      nxt = pLevel->nxt;
      sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, nxt);
      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, nxt, r1);
      sqlite3ReleaseTempReg(pParse, r1);
      VdbeComment((v, "pk"));
      pLevel->op = OP_Noop;
    }else if( pLevel->flags & WHERE_ROWID_RANGE ){
      /* Case 2:  We have an inequality comparison against the ROWID field.
      */
      int testOp = OP_Noop;
      int start;

Added test/tkt3357.test.



































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 2008 September 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the fix for ticket #3357.
#
# $Id: tkt3357.test,v 1.1 2008/09/06 14:19:11 danielk1977 Exp $

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

do_test tkt3357-1.1 {
  execsql {
    create table a(id integer primary key, b_id integer, myvalue varchar);
    create table b(id integer primary key, bvalue varchar);
    insert into a(b_id, myvalue) values(1,'Test');
    insert into a(b_id, myvalue) values(1,'Test2');
    insert into a(b_id, myvalue) values(1,'Test3');
    insert into b(bvalue) values('btest');
  }
} {}

do_test tkt3357-1.2 {
  execsql {
    SELECT cc.id, cc.b_id, cc.myvalue, dd.bvalue 
    FROM (
      SELECT DISTINCT a.id, a.b_id, a.myvalue FROM a
      INNER JOIN b ON a.b_id = b.id WHERE b.bvalue = 'btest'
    ) cc
    LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  }
} {1 1 Test btest 2 1 Test2 btest 3 1 Test3 btest}

do_test tkt3357-1.3 {
  execsql {
    SELECT cc.id, cc.b_id, cc.myvalue
    FROM (
      SELECT a.id, a.b_id, a.myvalue 
      FROM a, b WHERE a.b_id = b.id
    ) cc
    LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  }
} {1 1 Test 2 1 Test2 3 1 Test3}

do_test tkt3357-1.4 {
  execsql {
    SELECT cc.id, cc.b_id, cc.myvalue
    FROM (
      SELECT DISTINCT a.id, a.b_id, a.myvalue 
      FROM a, b WHERE a.b_id = b.id
    ) cc
    LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  }
} {1 1 Test 2 1 Test2 3 1 Test3}

finish_test