summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPeter Eisentraut2010-07-23 20:04:18 +0000
committerPeter Eisentraut2010-07-23 20:04:18 +0000
commit0156840e4e4647bef6c6278265b748c8a799e317 (patch)
treebcd4d6b77b305378563ef6700d56251767a6995a /src/test
parent87e0b7422d70ff4fb69612ef7ba3cbee6ed8d2ae (diff)
Add more checks against altering typed tables
- Prohibit altering column type - Prohibit changing inheritance - Move checks from Exec to Prep phases in ALTER TABLE code backpatched to 9.0
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/typed_table.out7
-rw-r--r--src/test/regress/sql/typed_table.sql6
2 files changed, 13 insertions, 0 deletions
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index e92cdf65e1f..9b933fdadcb 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -25,12 +25,18 @@ SELECT * FROM get_all_persons();
----+------
(0 rows)
+-- certain ALTER TABLE operations on typed tables are not allowed
ALTER TABLE persons ADD COLUMN comment text;
ERROR: cannot add column to typed table
ALTER TABLE persons DROP COLUMN name;
ERROR: cannot drop column from typed table
ALTER TABLE persons RENAME COLUMN id TO num;
ERROR: cannot rename column of typed table
+ALTER TABLE persons ALTER COLUMN name TYPE varchar;
+ERROR: cannot alter column type of typed table
+CREATE TABLE stuff (id int);
+ALTER TABLE persons INHERIT stuff;
+ERROR: cannot change inheritance of typed table
CREATE TABLE personsx OF person_type (myname WITH OPTIONS NOT NULL); -- error
ERROR: column "myname" does not exist
CREATE TABLE persons2 OF person_type (
@@ -83,3 +89,4 @@ DETAIL: drop cascades to table persons
drop cascades to function get_all_persons()
drop cascades to table persons2
drop cascades to table persons3
+DROP TABLE stuff;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 4e81f1dd6a4..60cb6d6857e 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -13,9 +13,13 @@ $$;
SELECT * FROM get_all_persons();
+-- certain ALTER TABLE operations on typed tables are not allowed
ALTER TABLE persons ADD COLUMN comment text;
ALTER TABLE persons DROP COLUMN name;
ALTER TABLE persons RENAME COLUMN id TO num;
+ALTER TABLE persons ALTER COLUMN name TYPE varchar;
+CREATE TABLE stuff (id int);
+ALTER TABLE persons INHERIT stuff;
CREATE TABLE personsx OF person_type (myname WITH OPTIONS NOT NULL); -- error
@@ -40,3 +44,5 @@ CREATE TABLE persons4 OF person_type (
DROP TYPE person_type RESTRICT;
DROP TYPE person_type CASCADE;
+
+DROP TABLE stuff;