aboutsummaryrefslogtreecommitdiff
path: root/src/test/regress/sql/alter_table.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress/sql/alter_table.sql')
-rw-r--r--src/test/regress/sql/alter_table.sql63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index d675579977b..abb3a6aa134 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1393,6 +1393,69 @@ alter table at_partitioned attach partition at_part_2 for values from (1000) to
alter table at_partitioned alter column b type numeric using b::numeric;
\d at_part_1
\d at_part_2
+drop table at_partitioned;
+
+-- Alter column type when no table rewrite is required
+-- Also check that comments are preserved
+create table at_partitioned(id int, name varchar(64), unique (id, name))
+ partition by hash(id);
+comment on constraint at_partitioned_id_name_key on at_partitioned is 'parent constraint';
+comment on index at_partitioned_id_name_key is 'parent index';
+create table at_partitioned_0 partition of at_partitioned
+ for values with (modulus 2, remainder 0);
+comment on constraint at_partitioned_0_id_name_key on at_partitioned_0 is 'child 0 constraint';
+comment on index at_partitioned_0_id_name_key is 'child 0 index';
+create table at_partitioned_1 partition of at_partitioned
+ for values with (modulus 2, remainder 1);
+comment on constraint at_partitioned_1_id_name_key on at_partitioned_1 is 'child 1 constraint';
+comment on index at_partitioned_1_id_name_key is 'child 1 index';
+insert into at_partitioned values(1, 'foo');
+insert into at_partitioned values(3, 'bar');
+
+create temp table old_oids as
+ select relname, oid as oldoid, relfilenode as oldfilenode
+ from pg_class where relname like 'at_partitioned%';
+
+select relname,
+ c.oid = oldoid as orig_oid,
+ case relfilenode
+ when 0 then 'none'
+ when c.oid then 'own'
+ when oldfilenode then 'orig'
+ else 'OTHER'
+ end as storage,
+ obj_description(c.oid, 'pg_class') as desc
+ from pg_class c left join old_oids using (relname)
+ where relname like 'at_partitioned%'
+ order by relname;
+
+select conname, obj_description(oid, 'pg_constraint') as desc
+ from pg_constraint where conname like 'at_partitioned%'
+ order by conname;
+
+alter table at_partitioned alter column name type varchar(127);
+
+-- Note: these tests currently show the wrong behavior for comments :-(
+
+select relname,
+ c.oid = oldoid as orig_oid,
+ case relfilenode
+ when 0 then 'none'
+ when c.oid then 'own'
+ when oldfilenode then 'orig'
+ else 'OTHER'
+ end as storage,
+ obj_description(c.oid, 'pg_class') as desc
+ from pg_class c left join old_oids using (relname)
+ where relname like 'at_partitioned%'
+ order by relname;
+
+select conname, obj_description(oid, 'pg_constraint') as desc
+ from pg_constraint where conname like 'at_partitioned%'
+ order by conname;
+
+-- Don't remove this DROP, it exposes bug #15672
+drop table at_partitioned;
-- disallow recursive containment of row types
create temp table recur1 (f1 int);