Run the column cache in a new context when generating code for trigger

programs.  Fix for ticket [efc02f9779].

FossilOrigin-Name: dee1b8eb402f47c6d5ee60aac28f8e3dcf98167f
This commit is contained in:
drh 2009-08-24 01:35:25 +00:00
parent 08da86a68e
commit e408edac16
5 changed files with 50 additions and 131 deletions

View File

@ -1,121 +0,0 @@
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%

View File

@ -1,5 +1,8 @@
C When\sa\sdatabase\sfile\sis\sopened,\stry\sto\sfind\san\sunused\sfile\sdescriptor\sto\sreuse.\s\sThis\schange\saffects\sunix\s(and\sother\ssystems\sthat\suse\sos_unix.c)\sonly.\sFix\sfor\scvstrac\sticket\s[http://www.sqlite.org/cvstrac/tktview?tn=4018|#4018].
D 2009-08-21T17:18:03
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Run\sthe\scolumn\scache\sin\sa\snew\scontext\swhen\sgenerating\scode\sfor\strigger\nprograms.\s\sFix\sfor\sticket\s[efc02f9779].
D 2009-08-24T01:35:25
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -22,7 +25,6 @@ F configure 486c870218ec915bd8edfece7109b6c864e82a5a
F configure.ac 14740970ddb674d92a9f5da89083dff1179014ff
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
F ext/README.txt 913a7bd3f4837ab14d7e063304181787658b14e1
F ext/async/README.txt 0c541f418b14b415212264cbaaf51c924ec62e5b
F ext/async/sqlite3async.c ec97d85cdb56dda9312cce39dd3cd9d62a747ec6
@ -200,7 +202,7 @@ F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4
F src/test_thread.c b8a1ab7ca1a632f18e8a361880d5d65eeea08eac
F src/test_wsd.c 3ae5101de6cbfda2720152ab659ea84079719241
F src/tokenize.c af8a56e6a50c5042fc305bfa796275e9bf26ff2b
F src/trigger.c 9bc5278d509d81ff0f9b52f0ce7239563d188e32
F src/trigger.c 545f3b8354001577a82c44fc6c4beac598b45b86
F src/update.c 4da327f706c0d0dfedf4d92154b1b5688bdea0ac
F src/utf.c 3ca2c9461b8e942c68da28bfccd448663f536a6f
F src/util.c efb5f8e533d4beef545cf765cab5f7920b4c75f9
@ -621,7 +623,7 @@ F test/tkt2942.test c5c87d179799ca6d1fbe83c815510b87cd5ec7ce
F test/tkt3080.test 1bca7579260920a66b4dd7e196e807c0f25ff804
F test/tkt3093.test fbdbc5b4969244ad11f540759003e361fcaf391f
F test/tkt3121.test 536df66a02838c26a12fe98639354ca1290ca68b
F test/tkt3201.test 607d433ad2c1f6a8cb1af55aaca427f63c83191b
F test/tkt3201.test 7aac9921c187de4baad138060802a96956c7fe5d
F test/tkt3292.test 962465a0984a3b8c757efe59c2c59144871ee1dd
F test/tkt3298.test 20fd8773b825cb602e033aa04f8602e1ebdcd93c
F test/tkt3334.test ea13a53cb176e90571a76c86605b14a09efe366d
@ -748,7 +750,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
P 75f596a04a74eb3a538c7be5b41756c970a21a1b
R a2800e2c5932867798528426b058f0c9
U dan
Z 0551703c5a252ef4437a61cdae64c5ea
P 9b4d9ab62d687289837b13b07885e72cc3abe8a9
R 8c0a86d1dda3ad47818cafa2a01a76cc
U drh
Z a8886aa9c2f39a29c2eeac74183b7a19
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFKke5hoxKgR168RlERAlsiAJ99uio4dN8iQWmrdPv34d66O3Nb/wCdEt6E
0TzPUVqtgGFOj3LSxkTm7fQ=
=7r/8
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
9b4d9ab62d687289837b13b07885e72cc3abe8a9
dee1b8eb402f47c6d5ee60aac28f8e3dcf98167f

View File

@ -856,7 +856,9 @@ int sqlite3CodeRowTrigger(
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;

View File

@ -70,5 +70,34 @@ 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