diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/expected/alter_table.out | 30 | ||||
-rw-r--r-- | src/test/regress/sql/alter_table.sql | 11 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index df9c5ffd947..a7b38dd0830 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -2247,12 +2247,26 @@ alter table recur1 alter column f2 type recur2; -- fails ERROR: composite type recur1 cannot be made a member of itself -- SET STORAGE may need to add a TOAST table create table test_storage (a text); +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass; + has_toast_table +----------------- + t +(1 row) + alter table test_storage alter a set storage plain; -alter table test_storage add b int default 0; -- rewrite table to remove its TOAST table +-- rewrite table to remove its TOAST table; need a non-constant column default +alter table test_storage add b int default random()::int; +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass; + has_toast_table +----------------- + f +(1 row) + alter table test_storage alter a set storage extended; -- re-add TOAST table select reltoastrelid <> 0 as has_toast_table -from pg_class -where oid = 'test_storage'::regclass; + from pg_class where oid = 'test_storage'::regclass; has_toast_table ----------------- t @@ -2262,11 +2276,11 @@ where oid = 'test_storage'::regclass; create index test_storage_idx on test_storage (b, a); alter table test_storage alter column a set storage external; \d+ test_storage - Table "public.test_storage" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+---------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | external | | - b | integer | | | 0 | plain | | + Table "public.test_storage" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+-------------------+----------+--------------+------------- + a | text | | | | external | | + b | integer | | | random()::integer | plain | | Indexes: "test_storage_idx" btree (b, a) diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 4884476c3af..8506e9ffbea 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -1532,13 +1532,16 @@ alter table recur1 alter column f2 type recur2; -- fails -- SET STORAGE may need to add a TOAST table create table test_storage (a text); +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass; alter table test_storage alter a set storage plain; -alter table test_storage add b int default 0; -- rewrite table to remove its TOAST table +-- rewrite table to remove its TOAST table; need a non-constant column default +alter table test_storage add b int default random()::int; +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass; alter table test_storage alter a set storage extended; -- re-add TOAST table - select reltoastrelid <> 0 as has_toast_table -from pg_class -where oid = 'test_storage'::regclass; + from pg_class where oid = 'test_storage'::regclass; -- test that SET STORAGE propagates to index correctly create index test_storage_idx on test_storage (b, a); |