3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #*************************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the ALTER TABLE statement.
14 # $Id: alter.test,v 1.32 2009/03/24 15:08:10 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
21 ifcapable !altertable {
26 #----------------------------------------------------------------------
29 # alter-1.1.* - alter-1.7.*: Basic tests of ALTER TABLE, including tables
30 # with implicit and explicit indices. These tests came from an earlier
31 # fork of SQLite that also supported ALTER TABLE.
32 # alter-1.8.*: Tests for ALTER TABLE when the table resides in an
34 # alter-1.9.*: Tests for ALTER TABLE when their is whitespace between the
35 # table name and left parenthesis token. i.e:
36 # "CREATE TABLE abc (a, b, c);"
37 # alter-2.*: Test error conditions and messages.
38 # alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them.
39 # alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields.
41 # alter-12.*: Test ALTER TABLE on views.
44 # Create some tables to rename. Be sure to include some TEMP tables
45 # and some tables with odd names.
53 execsql [subst -nocommands {
55 INSERT INTO t1 VALUES(1,2);
56 CREATE TABLE [t1'x1](c UNIQUE, b PRIMARY KEY);
57 INSERT INTO [t1'x1] VALUES(3,4);
58 CREATE INDEX t1i1 ON T1(B);
59 CREATE INDEX t1i2 ON t1(a,b);
60 CREATE INDEX i3 ON [t1'x1](b,c);
61 CREATE $::temp TABLE "temp table"(e,f,g UNIQUE);
62 CREATE INDEX i2 ON [temp table](f);
63 INSERT INTO [temp table] VALUES(5,6,7);
66 SELECT 't1', * FROM t1;
67 SELECT 't1''x1', * FROM "t1'x1";
68 SELECT * FROM [temp table];
70 } {t1 1 2 t1'x1 3 4 5 6 7}
73 CREATE $::temp TABLE objlist(type, name, tbl_name);
74 INSERT INTO objlist SELECT type, name, tbl_name
75 FROM sqlite_master WHERE NAME!='objlist';
79 INSERT INTO objlist SELECT type, name, tbl_name
80 FROM temp.sqlite_master WHERE NAME!='objlist';
85 SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
93 index {sqlite_autoindex_t1'x1_1} t1'x1 \
94 index {sqlite_autoindex_t1'x1_2} t1'x1 \
95 table {temp table} {temp table} \
96 index i2 {temp table} \
97 index {sqlite_autoindex_temp table_1} {temp table} \
102 integrity_check alter-1.3.0
105 ALTER TABLE [T1] RENAME to [-t1-];
106 ALTER TABLE "t1'x1" RENAME TO T2;
107 ALTER TABLE [temp table] RENAME to TempTab;
110 integrity_check alter-1.3.1
113 SELECT 't1', * FROM [-t1-];
114 SELECT 't2', * FROM t2;
115 SELECT * FROM temptab;
117 } {t1 1 2 t2 3 4 5 6 7}
121 INSERT INTO objlist SELECT type, name, tbl_name
122 FROM sqlite_master WHERE NAME!='objlist';
125 INSERT INTO objlist SELECT type, name, tbl_name
126 FROM sqlite_temp_master WHERE NAME!='objlist';
129 SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
137 index {sqlite_autoindex_T2_1} T2 \
138 index {sqlite_autoindex_T2_2} T2 \
139 table {TempTab} {TempTab} \
141 index {sqlite_autoindex_TempTab_1} {TempTab} \
144 # Make sure the changes persist after restarting the database.
145 # (The TEMP table will not persist, of course.)
151 set DB [sqlite3_connection_pointer db]
153 CREATE TEMP TABLE objlist(type, name, tbl_name);
154 INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_master;
156 SELECT type, name, tbl_name FROM temp.sqlite_master
157 WHERE NAME!='objlist';
158 SELECT type, name, tbl_name FROM objlist
159 ORDER BY tbl_name, type desc, name;
167 index {sqlite_autoindex_T2_1} T2 \
168 index {sqlite_autoindex_T2_2} T2 \
176 # Create bogus application-defined functions for functions used
177 # internally by ALTER TABLE, to ensure that ALTER TABLE falls back
178 # to the built-in functions.
180 proc failing_app_func {args} {error "bad function"}
181 do_test alter-1.7-prep {
182 db func substr failing_app_func
183 db func like failing_app_func
184 db func sqlite_rename_table failing_app_func
185 db func sqlite_rename_trigger failing_app_func
186 db func sqlite_rename_parent failing_app_func
187 catchsql {SELECT substr(name,1,3) FROM sqlite_master}
190 # Make sure the ALTER TABLE statements work with the
195 ALTER TABLE [-t1-] RENAME to [*t1*];
196 ALTER TABLE T2 RENAME TO [<t2>];
200 INSERT INTO objlist SELECT type, name, tbl_name
201 FROM sqlite_master WHERE NAME!='objlist';
204 INSERT INTO objlist SELECT type, name, tbl_name
205 FROM sqlite_temp_master WHERE NAME!='objlist';
208 SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
216 index {sqlite_autoindex_<t2>_1} <t2> \
217 index {sqlite_autoindex_<t2>_2} <t2> \
220 # Check that ALTER TABLE works on attached databases.
223 do_test alter-1.8.1 {
225 forcedelete test2.db-journal
227 ATTACH 'test2.db' AS aux;
230 do_test alter-1.8.2 {
232 CREATE TABLE t4(a PRIMARY KEY, b, c);
233 CREATE TABLE aux.t4(a PRIMARY KEY, b, c);
234 CREATE INDEX i4 ON t4(b);
235 CREATE INDEX aux.i4 ON t4(b);
238 do_test alter-1.8.3 {
240 INSERT INTO t4 VALUES('main', 'main', 'main');
241 INSERT INTO aux.t4 VALUES('aux', 'aux', 'aux');
242 SELECT * FROM t4 WHERE a = 'main';
245 do_test alter-1.8.4 {
247 ALTER TABLE t4 RENAME TO t5;
248 SELECT * FROM t4 WHERE a = 'aux';
251 do_test alter-1.8.5 {
256 do_test alter-1.8.6 {
258 SELECT * FROM t5 WHERE b = 'main';
261 do_test alter-1.8.7 {
263 ALTER TABLE aux.t4 RENAME TO t5;
264 SELECT * FROM aux.t5 WHERE b = 'aux';
269 do_test alter-1.9.1 {
271 CREATE TABLE tbl1 (a, b, c);
272 INSERT INTO tbl1 VALUES(1, 2, 3);
275 do_test alter-1.9.2 {
280 do_test alter-1.9.3 {
282 ALTER TABLE tbl1 RENAME TO tbl2;
286 do_test alter-1.9.4 {
292 # Test error messages
296 ALTER TABLE none RENAME TO hi;
298 } {1 {no such table: none}}
301 CREATE TABLE t3(p,q,r);
304 ALTER TABLE [<t2>] RENAME TO t3;
306 } {1 {there is already another table or index with this name: t3}}
309 ALTER TABLE [<t2>] RENAME TO i3;
311 } {1 {there is already another table or index with this name: i3}}
314 ALTER TABLE SqLiTe_master RENAME TO master;
316 } {1 {table sqlite_master may not be altered}}
319 ALTER TABLE t3 RENAME TO sqlite_t3;
321 } {1 {object name reserved for internal use: sqlite_t3}}
324 ALTER TABLE t3 ADD COLUMN (ALTER TABLE t3 ADD COLUMN);
326 } {1 {near "(": syntax error}}
328 # If this compilation does not include triggers, omit the alter-3.* tests.
331 #-----------------------------------------------------------------------
332 # Tests alter-3.* test ALTER TABLE on tables that have triggers.
334 # alter-3.1.*: ALTER TABLE with triggers.
335 # alter-3.2.*: Test that the ON keyword cannot be used as a database,
336 # table or column name unquoted. This is done because part of the
337 # ALTER TABLE code (specifically the implementation of SQL function
338 # "sqlite_alter_trigger") will break in this case.
339 # alter-3.3.*: ALTER TABLE with TEMP triggers (todo).
342 # An SQL user-function for triggers to fire, so that we know they
344 proc trigfunc {args} {
347 db func trigfunc trigfunc
349 do_test alter-3.1.0 {
351 CREATE TABLE t6(a, b, c);
352 -- Different case for the table name in the trigger.
353 CREATE TRIGGER trig1 AFTER INSERT ON T6 BEGIN
354 SELECT trigfunc('trig1', new.a, new.b, new.c);
358 do_test alter-3.1.1 {
360 INSERT INTO t6 VALUES(1, 2, 3);
364 do_test alter-3.1.2 {
366 ALTER TABLE t6 RENAME TO t7;
367 INSERT INTO t7 VALUES(4, 5, 6);
371 do_test alter-3.1.3 {
376 do_test alter-3.1.4 {
378 CREATE TRIGGER trig2 AFTER INSERT ON main.t7 BEGIN
379 SELECT trigfunc('trig2', new.a, new.b, new.c);
381 INSERT INTO t7 VALUES(1, 2, 3);
385 do_test alter-3.1.5 {
387 ALTER TABLE t7 RENAME TO t8;
388 INSERT INTO t8 VALUES(4, 5, 6);
392 do_test alter-3.1.6 {
397 do_test alter-3.1.7 {
399 CREATE TRIGGER trig3 AFTER INSERT ON main.'t8'BEGIN
400 SELECT trigfunc('trig3', new.a, new.b, new.c);
402 INSERT INTO t8 VALUES(1, 2, 3);
406 do_test alter-3.1.8 {
408 ALTER TABLE t8 RENAME TO t9;
409 INSERT INTO t9 VALUES(4, 5, 6);
414 # Make sure "ON" cannot be used as a database, table or column name without
415 # quoting. Otherwise the sqlite_alter_trigger() function might not work.
417 forcedelete test3.db-journal
419 do_test alter-3.2.1 {
421 ATTACH 'test3.db' AS ON;
423 } {1 {near "ON": syntax error}}
424 do_test alter-3.2.2 {
426 ATTACH 'test3.db' AS 'ON';
429 do_test alter-3.2.3 {
431 CREATE TABLE ON.t1(a, b, c);
433 } {1 {near "ON": syntax error}}
434 do_test alter-3.2.4 {
436 CREATE TABLE 'ON'.t1(a, b, c);
439 do_test alter-3.2.4 {
441 CREATE TABLE 'ON'.ON(a, b, c);
443 } {1 {near "ON": syntax error}}
444 do_test alter-3.2.5 {
446 CREATE TABLE 'ON'.'ON'(a, b, c);
450 do_test alter-3.2.6 {
452 CREATE TABLE t10(a, ON, c);
454 } {1 {near "ON": syntax error}}
455 do_test alter-3.2.7 {
457 CREATE TABLE t10(a, 'ON', c);
460 do_test alter-3.2.8 {
462 CREATE TRIGGER trig4 AFTER INSERT ON ON BEGIN SELECT 1; END;
464 } {1 {near "ON": syntax error}}
466 do_test alter-3.2.9 {
468 CREATE TRIGGER 'on'.trig4 AFTER INSERT ON 'ON' BEGIN SELECT 1; END;
472 do_test alter-3.2.10 {
478 do_test alter-3.3.1 {
480 CREATE TABLE tbl1(a, b, c);
481 CREATE $::temp TRIGGER trig1 AFTER INSERT ON tbl1 BEGIN
482 SELECT trigfunc('trig1', new.a, new.b, new.c);
486 do_test alter-3.3.2 {
488 INSERT INTO tbl1 VALUES('a', 'b', 'c');
492 do_test alter-3.3.3 {
494 ALTER TABLE tbl1 RENAME TO tbl2;
495 INSERT INTO tbl2 VALUES('d', 'e', 'f');
499 do_test alter-3.3.4 {
501 CREATE $::temp TRIGGER trig2 AFTER UPDATE ON tbl2 BEGIN
502 SELECT trigfunc('trig2', new.a, new.b, new.c);
506 do_test alter-3.3.5 {
508 ALTER TABLE tbl2 RENAME TO tbl3;
509 INSERT INTO tbl3 VALUES('g', 'h', 'i');
513 do_test alter-3.3.6 {
515 UPDATE tbl3 SET a = 'G' where a = 'g';
519 do_test alter-3.3.7 {
525 do_test alter-3.3.8 {
527 SELECT * FROM temp.sqlite_master WHERE type = 'trigger';
532 } ;# ifcapable trigger
534 # If the build does not include AUTOINCREMENT fields, omit alter-4.*.
539 CREATE TABLE tbl1(a INTEGER PRIMARY KEY AUTOINCREMENT);
540 INSERT INTO tbl1 VALUES(10);
545 INSERT INTO tbl1 VALUES(NULL);
551 ALTER TABLE tbl1 RENAME TO tbl2;
553 INSERT INTO tbl2 VALUES(NULL);
563 } ;# ifcapable autoinc
565 # Test that it is Ok to execute an ALTER TABLE immediately after
566 # opening a database.
569 CREATE TABLE tbl1(a, b, c);
570 INSERT INTO tbl1 VALUES('x', 'y', 'z');
576 ALTER TABLE tbl1 RENAME TO tbl2;
584 foreach tblname [execsql {
585 SELECT name FROM sqlite_master
586 WHERE type='table' AND name NOT GLOB 'sqlite*'
588 execsql "DROP TABLE \"$tblname\""
591 set ::tbl_name "abc\uABCDdef"
593 string length $::tbl_name
597 CREATE TABLE ${tbl_name}(a, b, c);
599 set ::oid [execsql {SELECT max(oid) FROM sqlite_master}]
601 SELECT sql FROM sqlite_master WHERE oid = $::oid;
603 } "{CREATE TABLE ${::tbl_name}(a, b, c)}"
605 SELECT * FROM ${::tbl_name}
607 set ::tbl_name2 "abcXdef"
610 ALTER TABLE $::tbl_name RENAME TO $::tbl_name2
613 SELECT sql FROM sqlite_master WHERE oid = $::oid
615 } "{CREATE TABLE \"${::tbl_name2}\"(a, b, c)}"
618 ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name
621 SELECT sql FROM sqlite_master WHERE oid = $::oid
623 } "{CREATE TABLE \"${::tbl_name}\"(a, b, c)}"
624 set ::col_name ghi\1234\jkl
627 ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR
630 SELECT sql FROM sqlite_master WHERE oid = $::oid
632 } "{CREATE TABLE \"${::tbl_name}\"(a, b, c, $::col_name VARCHAR)}"
633 set ::col_name2 B\3421\A
638 ALTER TABLE $::tbl_name ADD COLUMN $::col_name2
641 SELECT sql FROM sqlite_master WHERE oid = $::oid
643 } "{CREATE TABLE \"${::tbl_name}\"(a, b, c, $::col_name VARCHAR, $::col_name2)}"
646 INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5);
647 SELECT $::col_name, $::col_name2 FROM $::tbl_name;
651 # Ticket #1665: Make sure ALTER TABLE ADD COLUMN works on a table
652 # that includes a COLLATE clause.
654 do_realnum_test alter-7.1 {
656 CREATE TABLE t1(a TEXT COLLATE BINARY);
657 ALTER TABLE t1 ADD COLUMN b INTEGER COLLATE NOCASE;
658 INSERT INTO t1 VALUES(1,'-2');
659 INSERT INTO t1 VALUES(5.4e-08,'5.4e-08');
660 SELECT typeof(a), a, typeof(b), b FROM t1;
662 } {text 1 integer -2 text 5.4e-08 real 5.4e-08}
664 # Make sure that when a column is added by ALTER TABLE ADD COLUMN and has
665 # a default value that the default value is used by aggregate functions.
669 CREATE TABLE t2(a INTEGER);
670 INSERT INTO t2 VALUES(1);
671 INSERT INTO t2 VALUES(1);
672 INSERT INTO t2 VALUES(2);
673 ALTER TABLE t2 ADD COLUMN b INTEGER DEFAULT 9;
674 SELECT sum(b) FROM t2;
679 SELECT a, sum(b) FROM t2 GROUP BY a;
683 #--------------------------------------------------------------------------
684 # alter-9.X - Special test: Make sure the sqlite_rename_trigger() and
685 # rename_table() functions do not crash when handed bad input.
689 execsql {SELECT SQLITE_RENAME_TRIGGER(0,0)}
694 SELECT SQLITE_RENAME_TABLE(0,0);
695 SELECT SQLITE_RENAME_TABLE(10,20);
696 SELECT SQLITE_RENAME_TABLE('foo', 'foo');
700 #------------------------------------------------------------------------
701 # alter-10.X - Make sure ALTER TABLE works with multi-byte UTF-8 characters
705 execsql "CREATE TABLE xyz(x UNIQUE)"
706 execsql "ALTER TABLE xyz RENAME TO xyz\u1234abc"
707 execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}
708 } [list xyz\u1234abc]
710 execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}
711 } [list sqlite_autoindex_xyz\u1234abc_1]
713 execsql "ALTER TABLE xyz\u1234abc RENAME TO xyzabc"
714 execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}
717 execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}
718 } [list sqlite_autoindex_xyzabc_1]
721 sqlite3_exec db {CREATE TABLE t11(%c6%c6)}
723 ALTER TABLE t11 ADD COLUMN abc;
726 ALTER TABLE t11 ADD COLUMN abc;
728 } {1 {duplicate column name: abc}}
729 set isutf16 [regexp 16 [db one {PRAGMA encoding}]]
732 execsql {INSERT INTO t11 VALUES(1,2)}
733 sqlite3_exec db {SELECT %c6%c6 AS xyz, abc FROM t11}
737 sqlite3_exec db {CREATE TABLE t11b("%81%82%83" text)}
739 ALTER TABLE t11b ADD COLUMN abc;
742 ALTER TABLE t11b ADD COLUMN abc;
744 } {1 {duplicate column name: abc}}
747 execsql {INSERT INTO t11b VALUES(3,4)}
748 sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11b}
751 sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11b}
754 sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11b}
758 sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}
760 ALTER TABLE t11c ADD COLUMN abc;
763 ALTER TABLE t11c ADD COLUMN abc;
765 } {1 {duplicate column name: abc}}
768 execsql {INSERT INTO t11c VALUES(5,6)}
769 sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11c}
772 sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c}
774 do_test alter-11.10 {
775 sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c}
781 CREATE TABLE t12(a, b, c);
782 CREATE VIEW v1 AS SELECT * FROM t12;
787 ALTER TABLE v1 RENAME TO v2;
789 } {1 {view v1 may not be altered}}
791 execsql { SELECT * FROM v1; }
796 execsql { SELECT * FROM v1; }
800 ALTER TABLE v1 ADD COLUMN new_column;
802 } {1 {Cannot add a column to a view}}
805 # Verify that comments do not interfere with the table rename
810 CREATE TABLE /* hi */ t3102a(x);
811 CREATE TABLE t3102b -- comment
813 CREATE INDEX t3102c ON t3102a(x);
814 SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
816 } {t3102a t3102b t3102c}
819 ALTER TABLE t3102a RENAME TO t3102a_rename;
820 SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
822 } {t3102a_rename t3102b t3102c}
825 ALTER TABLE t3102b RENAME TO t3102b_rename;
826 SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
828 } {t3102a_rename t3102b_rename t3102c}
833 CREATE TABLE t3651(a UNIQUE);
834 ALTER TABLE t3651 ADD COLUMN b UNIQUE;
836 } {1 {Cannot add a UNIQUE column}}
839 ALTER TABLE t3651 ADD COLUMN b PRIMARY KEY;
841 } {1 {Cannot add a PRIMARY KEY column}}
844 #-------------------------------------------------------------------------
845 # Test that it is not possible to use ALTER TABLE on any system table.
847 set system_table_list {1 sqlite_master}
849 ifcapable analyze { lappend system_table_list 2 sqlite_stat1 }
850 ifcapable stat3 { lappend system_table_list 3 sqlite_stat3 }
851 ifcapable stat4 { lappend system_table_list 4 sqlite_stat4 }
853 foreach {tn tbl} $system_table_list {
854 do_test alter-15.$tn.1 {
855 catchsql "ALTER TABLE $tbl RENAME TO xyz"
856 } [list 1 "table $tbl may not be altered"]
858 do_test alter-15.$tn.2 {
859 catchsql "ALTER TABLE $tbl ADD COLUMN xyz"
860 } [list 1 "table $tbl may not be altered"]
863 #------------------------------------------------------------------------
864 # Verify that ALTER TABLE works on tables with the WITHOUT rowid option.
866 do_execsql_test alter-16.1 {
867 CREATE TABLE t16a(a TEXT, b REAL, c INT, PRIMARY KEY(a,b)) WITHOUT rowid;
868 INSERT INTO t16a VALUES('abc',1.25,99);
869 ALTER TABLE t16a ADD COLUMN d TEXT DEFAULT 'xyzzy';
870 INSERT INTO t16a VALUES('cba',5.5,98,'fizzle');
871 SELECT * FROM t16a ORDER BY a;
872 } {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
873 do_execsql_test alter-16.2 {
874 ALTER TABLE t16a RENAME TO t16a_rn;
875 SELECT * FROM t16a_rn ORDER BY a;
876 } {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
878 #-------------------------------------------------------------------------
879 # Verify that NULL values into the internal-use-only sqlite_rename_*()
880 # functions do not cause problems.
882 do_execsql_test alter-17.1 {
883 SELECT sqlite_rename_table('CREATE TABLE xyz(a,b,c)','abc');
884 } {{CREATE TABLE "abc"(a,b,c)}}
885 do_execsql_test alter-17.2 {
886 SELECT sqlite_rename_table('CREATE TABLE xyz(a,b,c)',NULL);
887 } {{CREATE TABLE "(NULL)"(a,b,c)}}
888 do_execsql_test alter-17.3 {
889 SELECT sqlite_rename_table(NULL,'abc');
891 do_execsql_test alter-17.4 {
892 SELECT sqlite_rename_trigger('CREATE TRIGGER r1 ON xyz WHEN','abc');
893 } {{CREATE TRIGGER r1 ON "abc" WHEN}}
894 do_execsql_test alter-17.5 {
895 SELECT sqlite_rename_trigger('CREATE TRIGGER r1 ON xyz WHEN',NULL);
896 } {{CREATE TRIGGER r1 ON "(NULL)" WHEN}}
897 do_execsql_test alter-17.6 {
898 SELECT sqlite_rename_trigger(NULL,'abc');
900 do_execsql_test alter-17.7 {
901 SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES "xyzzy")',
903 } {{CREATE TABLE t1(a REFERENCES "lmnop")}}
904 do_execsql_test alter-17.8 {
905 SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES "xyzzy")',
907 } {{CREATE TABLE t1(a REFERENCES "(NULL)")}}
908 do_execsql_test alter-17.9 {
909 SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES "xyzzy")',
912 do_execsql_test alter-17.10 {
913 SELECT sqlite_rename_parent(NULL,'abc','xyz');
915 do_execsql_test alter-17.11 {
916 SELECT sqlite_rename_parent('create references ''','abc','xyz');
917 } {{create references '}}
918 do_execsql_test alter-17.12 {
919 SELECT sqlite_rename_parent('create references "abc"123" ','abc','xyz');
920 } {{create references "xyz"123" }}
921 do_execsql_test alter-17.13 {
922 SELECT sqlite_rename_parent("references '''",'abc','xyz');