Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Ensure that tables names are dequoted exactly once by the trigger logic. Cherrypick [59e92bd9521f1e8] and [9d887b92f8086961e]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | branch-3.7.11 |
Files: | files | file ages | folders |
SHA1: |
9e3f64a4f4182ad80e82edb53095ed50 |
User & Date: | drh 2015-05-21 02:20:47.492 |
Context
2015-05-21
| ||
02:24 | Silently ignore any attempt to add a prefix index for prefixes zero bytes in size to an fts3/4 table. Or any prefix index size so large that it overflows a 32-bit signed integer. Cherrypick [ad4b19d2ac0889a] (check-in: 000197cc4e user: drh tags: branch-3.7.11) | |
02:20 | Ensure that tables names are dequoted exactly once by the trigger logic. Cherrypick [59e92bd9521f1e8] and [9d887b92f8086961e]. (check-in: 9e3f64a4f4 user: drh tags: branch-3.7.11) | |
02:07 | When parsing the schema, ignore any SQL that does not begin with "CREATE". Cherrypick of [d3c00d61581c] with additional changes. (check-in: 09784f376b user: drh tags: branch-3.7.11) | |
2015-04-21
| ||
16:38 | Ensure that tables names are dequoted exactly once by the trigger logic. (check-in: 9d887b92f8 user: dan tags: trunk) | |
03:13 | Fix some identifier name de-quoting issues in the foreign key and trigger logic. (check-in: 59e92bd952 user: drh tags: trunk) | |
Changes
Changes to src/fkey.c.
︙ | |||
1014 1015 1016 1017 1018 1019 1020 | 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 | - - + + - + - - + + - - + + - - + + | /* Create the expression "OLD.zToCol = zFromCol". It is important ** that the "OLD.zToCol" term is on the LHS of the = operator, so ** that the affinity and collation sequence associated with the ** parent table are used for the comparison. */ pEq = sqlite3PExpr(pParse, TK_EQ, sqlite3PExpr(pParse, TK_DOT, |
︙ | |||
1092 1093 1094 1095 1096 1097 1098 | 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | - + - + - - + | /* Disable lookaside memory allocation */ enableLookaside = db->lookaside.bEnabled; db->lookaside.bEnabled = 0; pTrigger = (Trigger *)sqlite3DbMallocZero(db, sizeof(Trigger) + /* struct Trigger */ sizeof(TriggerStep) + /* Single step in trigger program */ |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
2337 2338 2339 2340 2341 2342 2343 | 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 | - + - + - + - - + + | * "SELECT" statement. The meanings of the other members is determined by the * value of "op" as follows: * * (op == TK_INSERT) * orconf -> stores the ON CONFLICT algorithm * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then * this stores a pointer to the SELECT statement. Otherwise NULL. |
︙ |
Changes to src/trigger.c.
︙ | |||
369 370 371 372 373 374 375 | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | - + + - + - | static TriggerStep *triggerStepAllocate( sqlite3 *db, /* Database connection */ u8 op, /* Trigger opcode */ Token *pName /* The target name */ ){ TriggerStep *pTriggerStep; |
︙ | |||
663 664 665 666 667 668 669 | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | - + + - + - - + + - - + | if( pMask ){ *pMask = mask; } return (mask ? pList : 0); } /* |
︙ |
Changes to test/fkey1.test.
︙ | |||
113 114 115 116 117 118 119 120 121 | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ); PRAGMA foreign_key_list(t9); } } [concat \ {0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \ {0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \ ] # Stress the dequoting logic. The first test is not so bad. do_execsql_test fkey1-4.0 { PRAGMA foreign_keys=ON; CREATE TABLE "xx1"("xx2" TEXT PRIMARY KEY, "xx3" TEXT); INSERT INTO "xx1"("xx2","xx3") VALUES('abc','def'); CREATE TABLE "xx4"("xx5" TEXT REFERENCES "xx1" ON DELETE CASCADE); INSERT INTO "xx4"("xx5") VALUES('abc'); INSERT INTO "xx1"("xx2","xx3") VALUES('uvw','xyz'); SELECT 1, "xx5" FROM "xx4"; DELETE FROM "xx1"; SELECT 2, "xx5" FROM "xx4"; } {1 abc} # This case is identical to the previous except the "xx" in each name # is changed to a single escaped double-quote character. do_execsql_test fkey1-4.1 { PRAGMA foreign_keys=ON; CREATE TABLE """1"("""2" TEXT PRIMARY KEY, """3" TEXT); INSERT INTO """1"("""2","""3") VALUES('abc','def'); CREATE TABLE """4"("""5" TEXT REFERENCES """1" ON DELETE CASCADE); INSERT INTO """4"("""5") VALUES('abc'); INSERT INTO """1"("""2","""3") VALUES('uvw','xyz'); SELECT 1, """5" FROM """4"; DELETE FROM """1"; SELECT 2, """5" FROM """4"; } {1 abc} do_execsql_test fkey1-4.2 { PRAGMA table_info="""1"; } {0 {"2} TEXT 0 {} 1 1 {"3} TEXT 0 {} 0} finish_test |
Changes to test/triggerC.test.
︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | + | # May you share freely, never taking more than you give. # #*********************************************************************** # set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix triggerC ifcapable {!trigger} { finish_test return } #------------------------------------------------------------------------- # Test organization: |
︙ | |||
946 947 948 949 950 951 952 953 954 | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | END; } {} do_catchsql_test triggerC-13.2 { UPDATE t12 SET a=a+1, b=b+1; } {1 {too many levels of trigger recursion}} #------------------------------------------------------------------------- # Check that table names used by trigger programs are dequoted exactly # once. # do_execsql_test 15.1.1 { PRAGMA recursive_triggers = 1; CREATE TABLE node( id int not null primary key, pid int not null default 0 references node, key varchar not null, path varchar default '', unique(pid, key) ); CREATE TRIGGER node_delete_referencing AFTER DELETE ON "node" BEGIN DELETE FROM "node" WHERE pid = old."id"; END; } do_execsql_test 15.1.2 { INSERT INTO node(id, pid, key) VALUES(9, 0, 'test'); INSERT INTO node(id, pid, key) VALUES(90, 9, 'test1'); INSERT INTO node(id, pid, key) VALUES(900, 90, 'test2'); DELETE FROM node WHERE id=9; SELECT * FROM node; } do_execsql_test 15.2.1 { CREATE TABLE x1 (x); CREATE TABLE x2 (a, b); CREATE TABLE '"x2"'(a, b); INSERT INTO x2 VALUES(1, 2); INSERT INTO x2 VALUES(3, 4); INSERT INTO '"x2"' SELECT * FROM x2; CREATE TRIGGER x1ai AFTER INSERT ON x1 BEGIN INSERT INTO """x2""" VALUES('x', 'y'); DELETE FROM """x2""" WHERE a=1; UPDATE """x2""" SET b = 11 WHERE a = 3; END; INSERT INTO x1 VALUES('go!'); } do_execsql_test 15.2.2 { SELECT * FROM x2; } {1 2 3 4} do_execsql_test 15.2.3 { SELECT * FROM """x2"""; } {3 11 x y} finish_test |