/ Check-in [a1b1f6cd]
Login

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

Overview
Comment:Reset the column cache before coding each step of a trigger program. Candidate fix for #3554. (CVS 6065)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a1b1f6cd7d2c060bd75ce39347e1220b872806ed
User & Date: danielk1977 2008-12-26 07:56:39
Context
2008-12-27
15:23
Fix a problem with savepoint and incremental-vacuum. (CVS 6066) check-in: 08352f9e user: danielk1977 tags: trunk
2008-12-26
07:56
Reset the column cache before coding each step of a trigger program. Candidate fix for #3554. (CVS 6065) check-in: a1b1f6cd user: danielk1977 tags: trunk
2008-12-24
11:25
Fix a virtual table related assert() that can fail following a malloc failure. (CVS 6064) check-in: c6fd3b8f user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/trigger.c.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
668
669
670
671
672
673
674

675
676
677
678
679
680
681
**    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.
**
*************************************************************************
**
**
** $Id: trigger.c,v 1.132 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"

#ifndef SQLITE_OMIT_TRIGGER
/*
** Delete a linked list of TriggerStep structures.
*/
................................................................................
  sqlite3 *db = pParse->db;

  assert( pTriggerStep!=0 );
  assert( v!=0 );
  sqlite3VdbeAddOp2(v, OP_ContextPush, 0, 0);
  VdbeComment((v, "begin trigger %s", pStepList->pTrig->name));
  while( pTriggerStep ){

    orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;
    pParse->trigStack->orconf = orconf;
    switch( pTriggerStep->op ){
      case TK_SELECT: {
        Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect);
        if( ss ){
          SelectDest dest;







|







 







>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
**    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.
**
*************************************************************************
**
**
** $Id: trigger.c,v 1.133 2008/12/26 07:56:39 danielk1977 Exp $
*/
#include "sqliteInt.h"

#ifndef SQLITE_OMIT_TRIGGER
/*
** Delete a linked list of TriggerStep structures.
*/
................................................................................
  sqlite3 *db = pParse->db;

  assert( pTriggerStep!=0 );
  assert( v!=0 );
  sqlite3VdbeAddOp2(v, OP_ContextPush, 0, 0);
  VdbeComment((v, "begin trigger %s", pStepList->pTrig->name));
  while( pTriggerStep ){
    sqlite3ExprClearColumnCache(pParse, -1);
    orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;
    pParse->trigStack->orconf = orconf;
    switch( pTriggerStep->op ){
      case TK_SELECT: {
        Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect);
        if( ss ){
          SelectDest dest;

Added test/tkt3554.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
66
67
68
# 2008 December 24
#
# 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.
#
# This file implements tests to verify that ticket #3554 has been
# fixed.  
#
# $Id: tkt3554.test,v 1.1 2008/12/26 07:56:39 danielk1977 Exp $

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

ifcapable !trigger {
  finish_test
  return
}

do_test tkt3544-1.1 {
  execsql {
    CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) );
  
    CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN
      UPDATE test SET t1 = new.t1 
        WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;
  
      UPDATE test SET t2 = new.t2 
        WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;
  
      SELECT RAISE(IGNORE) WHERE EXISTS (
        SELECT obj FROM test 
        WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2
      );
    END;
  }
} {}

do_test tkt3544-1.2 {
  execsql {
    INSERT INTO test VALUES('a', 10000, 11000);
    SELECT * FROM test;
  }
} {a 10000 11000}


do_test tkt3544-1.3 {
  execsql {
    INSERT INTO test VALUES('a', 9000, 10500);
  }
  execsql { SELECT * FROM test }
} {a 9000 11000}

do_test tkt3544-1.4 {
  execsql {
    INSERT INTO test VALUES('a', 10000, 12000);
  }
  execsql { SELECT * FROM test }
} {a 9000 12000}

finish_test