OLD | NEW |
1 # 2001 September 15 | 1 # 2001 September 15 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 db eval { | 265 db eval { |
266 ANALYZE; | 266 ANALYZE; |
267 DROP TABLE IF EXISTS sqlite_stat1; | 267 DROP TABLE IF EXISTS sqlite_stat1; |
268 DROP TABLE IF EXISTS sqlite_stat2; | 268 DROP TABLE IF EXISTS sqlite_stat2; |
269 DROP TABLE IF EXISTS sqlite_stat3; | 269 DROP TABLE IF EXISTS sqlite_stat3; |
270 DROP TABLE IF EXISTS sqlite_stat4; | 270 DROP TABLE IF EXISTS sqlite_stat4; |
271 SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*'; | 271 SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*'; |
272 } | 272 } |
273 } {} | 273 } {} |
274 | 274 |
| 275 do_test table-5.2.2 { |
| 276 db close |
| 277 forcedelete test.db |
| 278 sqlite3 db test.db |
| 279 db eval { |
| 280 CREATE TABLE t0(a,b); |
| 281 CREATE INDEX t ON t0(a); |
| 282 PRAGMA writable_schema=ON; |
| 283 UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE'; |
| 284 BEGIN; |
| 285 CREATE TABLE t1(x); |
| 286 ROLLBACK; |
| 287 DROP TABLE IF EXISTS t99; |
| 288 } |
| 289 } {} |
| 290 db close |
| 291 forcedelete test.db |
| 292 sqlite3 db test.db |
| 293 |
275 # Make sure an EXPLAIN does not really create a new table | 294 # Make sure an EXPLAIN does not really create a new table |
276 # | 295 # |
277 do_test table-5.3 { | 296 do_test table-5.3 { |
278 ifcapable {explain} { | 297 ifcapable {explain} { |
279 execsql {EXPLAIN CREATE TABLE test1(f1 int)} | 298 execsql {EXPLAIN CREATE TABLE test1(f1 int)} |
280 } | 299 } |
281 execsql {SELECT name FROM sqlite_master WHERE type!='meta'} | 300 execsql {SELECT name FROM sqlite_master WHERE type!='meta'} |
282 } {} | 301 } {} |
283 | 302 |
284 # Make sure an EXPLAIN does not really drop an existing table | 303 # Make sure an EXPLAIN does not really drop an existing table |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 INSERT INTO t1(a) VALUES(1),(2); | 801 INSERT INTO t1(a) VALUES(1),(2); |
783 DROP TABLE IF EXISTS t2; | 802 DROP TABLE IF EXISTS t2; |
784 CREATE TABLE t2(x TEXT, y TEXT); | 803 CREATE TABLE t2(x TEXT, y TEXT); |
785 INSERT INTO t2(x,y) VALUES(3,4); | 804 INSERT INTO t2(x,y) VALUES(3,4); |
786 DROP TABLE IF EXISTS t3; | 805 DROP TABLE IF EXISTS t3; |
787 CREATE TABLE t3 AS | 806 CREATE TABLE t3 AS |
788 SELECT a AS p, coalesce(y,a) AS q FROM t1 LEFT JOIN t2 ON a=x; | 807 SELECT a AS p, coalesce(y,a) AS q FROM t1 LEFT JOIN t2 ON a=x; |
789 SELECT p, q, '|' FROM t3 ORDER BY p; | 808 SELECT p, q, '|' FROM t3 ORDER BY p; |
790 } {1 1 | 2 2 |} | 809 } {1 1 | 2 2 |} |
791 | 810 |
| 811 # 2015-06-16 |
| 812 # Ticket [https://www.sqlite.org/src/tktview/873cae2b6e25b1991ce5e9b782f9cd0409b
96063] |
| 813 # Make sure a CREATE TABLE AS statement correctly rolls back partial changes to
the |
| 814 # sqlite_master table when the SELECT on the right-hand side aborts. |
| 815 # |
| 816 do_catchsql_test table-18.1 { |
| 817 DROP TABLE IF EXISTS t1; |
| 818 BEGIN; |
| 819 CREATE TABLE t1 AS SELECT zeroblob(2e20); |
| 820 } {1 {string or blob too big}} |
| 821 do_execsql_test table-18.2 { |
| 822 COMMIT; |
| 823 PRAGMA integrity_check; |
| 824 } {ok} |
| 825 |
| 826 # 2015-09-09 |
| 827 # Ticket [https://www.sqlite.org/src/info/acd12990885d9276] |
| 828 # "CREATE TABLE ... AS SELECT ... FROM sqlite_master" fails because the row |
| 829 # in the sqlite_master table for the next table is initially populated |
| 830 # with a NULL instead of a record created by OP_Record. |
| 831 # |
| 832 do_execsql_test table-19.1 { |
| 833 CREATE TABLE t19 AS SELECT * FROM sqlite_master; |
| 834 SELECT name FROM t19 ORDER BY name; |
| 835 } {{} savepoint t10 t11 t12 t13 t16 t2 t3 t3\"xyz t4\"abc t7 t8 t9 tablet8 test1
weird} |
| 836 |
| 837 |
| 838 |
792 finish_test | 839 finish_test |
OLD | NEW |