mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix various issues with the changes on this branch. Add test cases for the same.
FossilOrigin-Name: 10538ec6fc1642dfc2ca6cef06ce6cb9e124847b421ccf01f5842064fad379ab
This commit is contained in:
@ -26,6 +26,9 @@ do_execsql_test 1.0 {
|
||||
|
||||
CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z UNIQUE);
|
||||
CREATE INDEX t2y ON t2(y);
|
||||
|
||||
CREATE TABLE t3(q, r, s);
|
||||
CREATE INDEX t3rs ON t3(r+s);
|
||||
}
|
||||
|
||||
do_catchsql_test 1.1 {
|
||||
@ -34,7 +37,7 @@ do_catchsql_test 1.1 {
|
||||
|
||||
do_catchsql_test 1.2 {
|
||||
ALTER TABLE v1 DROP COLUMN c;
|
||||
} {1 {cannot drop a column from a view}}
|
||||
} {1 {cannot drop column from view "v1"}}
|
||||
|
||||
ifcapable fts5 {
|
||||
do_execsql_test 1.3.1 {
|
||||
@ -42,7 +45,7 @@ ifcapable fts5 {
|
||||
}
|
||||
do_catchsql_test 1.3.2 {
|
||||
ALTER TABLE ft1 DROP COLUMN two;
|
||||
} {1 {virtual tables may not be altered}}
|
||||
} {1 {cannot drop column from virtual table "ft1"}}
|
||||
}
|
||||
|
||||
do_catchsql_test 1.4 {
|
||||
@ -67,6 +70,10 @@ do_execsql_test 1.7.2 {
|
||||
SELECT sql FROM sqlite_schema WHERE name = 't1'
|
||||
} {{CREATE TABLE t1(a)}}
|
||||
|
||||
do_catchsql_test 1.7.3 {
|
||||
ALTER TABLE t1 DROP COLUMN a;
|
||||
} {1 {error in table t1 after drop column: near ")": syntax error}}
|
||||
|
||||
|
||||
do_catchsql_test 1.8 {
|
||||
ALTER TABLE t2 DROP COLUMN z
|
||||
@ -78,7 +85,11 @@ do_catchsql_test 1.9 {
|
||||
|
||||
do_catchsql_test 1.10 {
|
||||
ALTER TABLE t2 DROP COLUMN y
|
||||
} {1 {cannot drop indexed column: "y"}}
|
||||
} {1 {error in index t2y after drop column: no such column: y}}
|
||||
|
||||
do_catchsql_test 1.11 {
|
||||
ALTER TABLE t3 DROP COLUMN s
|
||||
} {1 {error in index t3rs after drop column: no such column: s}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -109,5 +120,95 @@ foreach {tn wo} {
|
||||
}
|
||||
}]}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
|
||||
do_execsql_test 3.0 {
|
||||
CREATE TABLE t12(a, b, c, CHECK(c>10));
|
||||
CREATE TABLE t13(a, b, c CHECK(c>10));
|
||||
}
|
||||
do_catchsql_test 3.1 {
|
||||
ALTER TABLE t12 DROP COLUMN c;
|
||||
} {1 {error in table t12 after drop column: no such column: c}}
|
||||
|
||||
do_catchsql_test 3.2 {
|
||||
ALTER TABLE t13 DROP COLUMN c;
|
||||
} {0 {}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that generated columns can be dropped. And that other columns from
|
||||
# tables that contain generated columns can be dropped.
|
||||
#
|
||||
foreach {tn wo vs} {
|
||||
1 "" ""
|
||||
2 "" VIRTUAL
|
||||
3 "" STORED
|
||||
4 "WITHOUT ROWID" STORED
|
||||
5 "WITHOUT ROWID" VIRTUAL
|
||||
} {
|
||||
reset_db
|
||||
|
||||
do_execsql_test 4.$tn.0 "
|
||||
CREATE TABLE 'my table'(a, b PRIMARY KEY, c AS (a+b) $vs, d) $wo
|
||||
"
|
||||
do_execsql_test 4.$tn.1 {
|
||||
INSERT INTO "my table"(a, b, d) VALUES(1, 2, 'hello');
|
||||
INSERT INTO "my table"(a, b, d) VALUES(3, 4, 'world');
|
||||
|
||||
SELECT * FROM "my table"
|
||||
} {
|
||||
1 2 3 hello
|
||||
3 4 7 world
|
||||
}
|
||||
|
||||
do_execsql_test 4.$tn.2 {
|
||||
ALTER TABLE "my table" DROP COLUMN c;
|
||||
}
|
||||
do_execsql_test 4.$tn.3 {
|
||||
SELECT * FROM "my table"
|
||||
} {
|
||||
1 2 hello
|
||||
3 4 world
|
||||
}
|
||||
|
||||
do_execsql_test 4.$tn.4 "
|
||||
CREATE TABLE x1(a, b, c PRIMARY KEY, d AS (b+c) $vs, e) $wo
|
||||
"
|
||||
do_execsql_test 4.$tn.5 {
|
||||
INSERT INTO x1(a, b, c, e) VALUES(1, 2, 3, 4);
|
||||
INSERT INTO x1(a, b, c, e) VALUES(5, 6, 7, 8);
|
||||
INSERT INTO x1(a, b, c, e) VALUES(9, 10, 11, 12);
|
||||
SELECT * FROM x1;
|
||||
} {
|
||||
1 2 3 5 4
|
||||
5 6 7 13 8
|
||||
9 10 11 21 12
|
||||
}
|
||||
|
||||
do_execsql_test 4.$tn.6 {
|
||||
ALTER TABLE x1 DROP COLUMN a
|
||||
}
|
||||
do_execsql_test 4.$tn.7 {
|
||||
SELECT * FROM x1
|
||||
} {
|
||||
2 3 5 4
|
||||
6 7 13 8
|
||||
10 11 21 12
|
||||
}
|
||||
do_execsql_test 4.$tn.8 {
|
||||
ALTER TABLE x1 DROP COLUMN e
|
||||
}
|
||||
do_execsql_test 4.$tn.9 {
|
||||
SELECT * FROM x1
|
||||
} {
|
||||
2 3 5
|
||||
6 7 13
|
||||
10 11 21
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ do_execsql_test 1.1 {
|
||||
# slightly different - it rejects the change and rolls back the transaction.
|
||||
do_catchsql_test 1.2 {
|
||||
ALTER TABLE t1 RENAME TO t1new;
|
||||
} {1 {no such column: t1.a}}
|
||||
} {1 {error in table t1new after rename: no such column: t1.a}}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
CREATE TABLE t3(c, d);
|
||||
@ -59,7 +59,7 @@ do_execsql_test 1.4 {
|
||||
|
||||
do_catchsql_test 1.3 {
|
||||
ALTER TABLE t2 RENAME TO t2new;
|
||||
} {1 {no such column: t2.b}}
|
||||
} {1 {error in index t2expr after rename: no such column: t2.b}}
|
||||
do_execsql_test 1.4 {
|
||||
SELECT sql FROM sqlite_master
|
||||
} {
|
||||
|
Reference in New Issue
Block a user