SQLite

Check-in [dee1b8eb40]
Login

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

Overview
Comment:Run the column cache in a new context when generating code for trigger programs. Fix for ticket [efc02f9779].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dee1b8eb402f47c6d5ee60aac28f8e3dcf98167f
User & Date: drh 2009-08-24 01:35:25.000
References
2009-09-17
00:47 Fixed ticket [e25d9ea771]: Cascading delete trigger fails. plus 4 other changes (artifact: df2f80f30b user: drh)
2009-09-14
22:28 Ticket [a696379c1f] Access violation error trying to insert into triggered view status still Open with 1 other change (artifact: 3e27afc20e user: drh)
2009-08-25
12:11
Merge together the os_unix.c fix of [aa6acfa8ca] and the trigger fix of [dee1b8eb40]. (check-in: 1e2c6e134e user: drh tags: trunk)
2009-08-24
01:37 Fixed ticket [efc02f9779]: Trigger creation order affects query correctness plus 2 other changes (artifact: b60050895a user: drh)
Context
2009-08-28
18:53
Changes to support recursive triggers. (check-in: 9b9c192115 user: dan tags: trunk)
2009-08-24
19:37
Update the version number to 3.6.18, even though the actual release of that version is still a few weeks away. (check-in: c0ea4e9a7d user: drh tags: trunk)
01:35
Run the column cache in a new context when generating code for trigger programs. Fix for ticket [efc02f9779]. (check-in: dee1b8eb40 user: drh tags: trunk)
2009-08-21
17:18
When a database file is opened, try to find an unused file descriptor to reuse. This change affects unix (and other systems that use os_unix.c) only. Fix for cvstrac ticket #4018. (check-in: 9b4d9ab62d user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Deleted doc/report1.txt.
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
69
70
71
72
73
74
75
76
77
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
An SQLite (version 1.0) database was used in a large military application
where the database contained 105 tables and indices.  The following is
a breakdown on the sizes of keys and data within these tables and indices:

Entries:      967089
Size:         45896104
Avg Size:     48
Key Size:     11112265
Avg Key Size: 12
Max Key Size: 99

    0..8            263    0%
    9..12          5560    0%
   13..16         71394    7%
   17..24        180717   26%
   25..32        215442   48%
   33..40        151118   64%
   41..48         77479   72%
   49..56         13983   74%
   57..64         14481   75%
   65..80         41342   79%
   81..96        127098   92%
   97..112        38054   96%
  113..128        14197   98%
  129..144         8208   99%
  145..160         3326   99%
  161..176         1242   99%
  177..192          604   99%
  193..208          222   99%
  209..224          213   99%
  225..240          132   99%
  241..256           58   99%
  257..288          515   99%
  289..320           64   99%
  321..352           39   99%
  353..384           44   99%
  385..416           25   99%
  417..448           24   99%
  449..480           26   99%
  481..512           27   99%
  513..1024         470   99%
 1025..2048         396   99%
 2049..4096         187   99%
 4097..8192          78   99%
 8193..16384         35   99%
16385..32768         17   99%
32769..65536          6   99%
65537..65541          3  100%

If the indices are omitted, the statistics for the 49 tables
become the following:

Entries:      451103
Size:         30930282
Avg Size:     69
Key Size:     1804412
Avg Key Size: 4
Max Key Size: 4

    0..24            89    0%
   25..32          9417    2%
   33..40        119162   28%
   41..48         68710   43%
   49..56          9539   45%
   57..64         12435   48%
   65..80         38650   57%
   81..96        126877   85%
   97..112        38030   93%
  113..128        14183   96%
  129..144         7668   98%
  145..160         3302   99%
  161..176         1238   99%
  177..192          597   99%
  193..208          217   99%
  209..224          211   99%
  225..240          130   99%
  241..256           57   99%
  257..288          100   99%
  289..320           62   99%
  321..352           34   99%
  353..384           43   99%
  385..416           24   99%
  417..448           24   99%
  449..480           25   99%
  481..512           27   99%
  513..1024         153   99%
 1025..2048          92   99%
 2049..4096           7  100%

The 56 indices have these statistics:

Entries:      512422
Size:         14879828
Avg Size:     30
Key Size:     9253204
Avg Key Size: 19
Max Key Size: 99

    0..8            246    0%
    9..12          5486    1%
   13..16         70717   14%
   17..24        178246   49%
   25..32        205722   89%
   33..40         31951   96%
   41..48          8768   97%
   49..56          4444   98%
   57..64          2046   99%
   65..80          2691   99%
   81..96           202   99%
   97..112           11   99%
  113..144          527   99%
  145..160           20   99%
  161..288          406   99%
  289..1024         316   99%
 1025..2048         304   99%
 2049..4096         180   99%
 4097..8192          78   99%
 8193..16384         35   99%
16385..32768         17   99%
32769..65536          6   99%
65537..65541          3  100%
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































Changes to src/trigger.c.
852
853
854
855
856
857
858

859

860
861
862
863
864
865
866
        pParse->trigStack = trigStackEntry.pNext;
        sqlite3ExprDelete(db, whenExpr);
        return 1;
      }
      sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, SQLITE_JUMPIFNULL);
      sqlite3ExprDelete(db, whenExpr);


      codeTriggerProgram(pParse, p->step_list, orconf); 


      /* Pop the entry off the trigger stack */
      pParse->trigStack = trigStackEntry.pNext;
      sqlite3AuthContextPop(&sContext);

      sqlite3VdbeResolveLabel(pParse->pVdbe, endTrigger);
    }







>

>







852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
        pParse->trigStack = trigStackEntry.pNext;
        sqlite3ExprDelete(db, whenExpr);
        return 1;
      }
      sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, SQLITE_JUMPIFNULL);
      sqlite3ExprDelete(db, whenExpr);

      sqlite3ExprCachePush(pParse);
      codeTriggerProgram(pParse, p->step_list, orconf); 
      sqlite3ExprCachePop(pParse, 1);

      /* Pop the entry off the trigger stack */
      pParse->trigStack = trigStackEntry.pNext;
      sqlite3AuthContextPop(&sContext);

      sqlite3VdbeResolveLabel(pParse->pVdbe, endTrigger);
    }
Changes to test/tkt3201.test.
65
66
67
68
69
70
71





























72
73
74
  }
  execsql { SELECT a, b, c, d FROM t1, t3 }
} {1 one 2 two}

do_test tkt3201-7 {
  execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }
} {1 one 2 two}































finish_test







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



65
66
67
68
69
70
71
72
73
74
75
76
77
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
  }
  execsql { SELECT a, b, c, d FROM t1, t3 }
} {1 one 2 two}

do_test tkt3201-7 {
  execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }
} {1 one 2 two}

# Ticket [efc02f977919]
#
do_test tkt3201-4.0 {
  db eval {
   CREATE TABLE t4(x);
   CREATE TABLE t4_log(x);
   CREATE TRIGGER r4_1 AFTER INSERT ON t4 WHEN new.x=1 BEGIN
     INSERT INTO t4_log(x) VALUES(new.x);
   END;
   CREATE TRIGGER r4_2 AFTER INSERT ON t4 WHEN new.x=2 BEGIN
     INSERT INTO t4_log(x) VALUES(new.x);
   END;
   CREATE TRIGGER r4_3 AFTER INSERT ON t4 WHEN new.x=3 BEGIN
     INSERT INTO t4_log(x) VALUES(new.x);
   END;
   CREATE TRIGGER r4_4 AFTER INSERT ON t4 WHEN new.x=4 BEGIN
     INSERT INTO t4_log(x) VALUES(new.x);
   END;
   INSERT INTO t4 VALUES(1);
   INSERT INTO t4 VALUES(2);
   INSERT INTO t4 VALUES(3);
   INSERT INTO t4 VALUES(4);
   SELECT * FROM t4_log;
  }
} {1 2 3 4}





finish_test