should be it
This commit is contained in:
85
external/duckdb/test/sql/storage/alter/alter_column_constraint.test
vendored
Normal file
85
external/duckdb/test/sql/storage/alter/alter_column_constraint.test
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
# name: test/sql/storage/alter/alter_column_constraint.test
|
||||
# description: Issue #1785: ALTER TABLE causes constraints lost in database file after exiting
|
||||
# group: [alter]
|
||||
|
||||
# load the DB from disk
|
||||
load __TEST_DIR__/add_column_constraint.db
|
||||
|
||||
statement ok
|
||||
CREATE TABLE IF NOT EXISTS a(id INT PRIMARY KEY);
|
||||
|
||||
statement ok
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
|
||||
# add column
|
||||
statement ok
|
||||
ALTER TABLE a ADD COLUMN c REAL;
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
restart
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
# add default
|
||||
statement ok
|
||||
ALTER TABLE a ALTER COLUMN c SET DEFAULT 10;
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
restart
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
# rename column
|
||||
statement ok
|
||||
ALTER TABLE a RENAME c TO d;
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
restart
|
||||
|
||||
statement error
|
||||
INSERT INTO a(id) VALUES (1);
|
||||
----
|
||||
|
||||
# rename table
|
||||
statement ok
|
||||
ALTER TABLE a RENAME TO b;
|
||||
|
||||
statement error
|
||||
INSERT INTO b(id) VALUES (1);
|
||||
----
|
||||
|
||||
restart
|
||||
|
||||
statement error
|
||||
INSERT INTO b(id) VALUES (1);
|
||||
----
|
||||
|
||||
# drop column
|
||||
statement ok
|
||||
ALTER TABLE b DROP d;
|
||||
|
||||
statement error
|
||||
INSERT INTO b(id) VALUES (1);
|
||||
----
|
||||
|
||||
restart
|
||||
|
||||
statement error
|
||||
INSERT INTO b(id) VALUES (1);
|
||||
----
|
||||
|
||||
statement ok
|
||||
INSERT INTO b(id) VALUES (2);
|
||||
Reference in New Issue
Block a user