forked from duckdb/duckdb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request duckdb#9932 from taniabogatsch/attach-schema-bug
Fix ATTACH of foreign key
- Loading branch information
Showing
5 changed files
with
65 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# name: test/sql/attach/attach_dependencies.test | ||
# description: Test that we can ATTACH databases with dependencies in the schema | ||
# group: [attach] | ||
|
||
# foreign key | ||
|
||
load __TEST_DIR__/fk.db | ||
|
||
statement ok | ||
CREATE TABLE pk_tbl (id INTEGER PRIMARY KEY, name VARCHAR UNIQUE); | ||
|
||
statement ok | ||
CREATE TABLE fk_tbl (id INTEGER REFERENCES pk_tbl(id)); | ||
|
||
# alter columns | ||
|
||
load __TEST_DIR__/alter_column.db | ||
|
||
statement ok | ||
CREATE TABLE tbl_alter_column (id INT, other INT, nn_col INT NOT NULL, rm INT, rename_c INT, my_def INT, drop_def INT DEFAULT 10, new_null_col INT); | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ADD COLUMN k INTEGER; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ALTER other SET DATA TYPE VARCHAR USING concat(other, '_', 'yay'); | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ALTER COLUMN nn_col DROP NOT NULL; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column DROP rm; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column RENAME rename_c TO my_new_col; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ALTER COLUMN my_def SET DEFAULT 10; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ALTER COLUMN drop_def DROP DEFAULT; | ||
|
||
statement ok | ||
ALTER TABLE tbl_alter_column ALTER COLUMN new_null_col SET NOT NULL; | ||
|
||
# now attach all databases | ||
|
||
load __TEST_DIR__/other.db | ||
|
||
statement ok | ||
ATTACH '__TEST_DIR__/fk.db'; | ||
|
||
statement ok | ||
ATTACH '__TEST_DIR__/alter_column.db'; |