diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2021-06-18 07:44:58 -0400 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2021-06-18 07:46:21 -0400 |
| commit | 6432bfe8a372a1c1d4ee8edc91be7fe9910bf51d (patch) | |
| tree | f2fed26584c44999e2e030746077db8badeac798 /src/test/regress/sql/fast_default.sql | |
| parent | 70293e946e60bb7eb58f74656667458406a1b461 (diff) | |
Don't set a fast default for anything but a plain table
The fast default code added in Release 11 omitted to check that the
table a fast default was being added to was a plain table. Thus one
could be added to a foreign table, which predicably blows up. Here we
perform that check.
In addition, on the back branches, since some of these might have
escaped into the wild, if we encounter a missing value for
an attribute of something other than a plain table we ignore it.
Fixes bug #17056
Backpatch to release 11,
Reviewed by: Andres Freund, Álvaro Herrera and Tom Lane
Diffstat (limited to 'src/test/regress/sql/fast_default.sql')
| -rw-r--r-- | src/test/regress/sql/fast_default.sql | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/regress/sql/fast_default.sql b/src/test/regress/sql/fast_default.sql index 4589b9e58d1..16a3b7ca51d 100644 --- a/src/test/regress/sql/fast_default.sql +++ b/src/test/regress/sql/fast_default.sql @@ -524,8 +524,22 @@ SET LOCAL enable_seqscan = false; SELECT * FROM t WHERE a IS NULL; ROLLBACK; +-- verify that a default set on a non-plain table doesn't set a missing +-- value on the attribute +CREATE FOREIGN DATA WRAPPER dummy; +CREATE SERVER s0 FOREIGN DATA WRAPPER dummy; +CREATE FOREIGN TABLE ft1 (c1 integer NOT NULL) SERVER s0; +ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer DEFAULT 0; +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10); +SELECT count(*) + FROM pg_attribute + WHERE attrelid = 'ft1'::regclass AND + (attmissingval IS NOT NULL OR atthasmissing); -- cleanup +DROP FOREIGN TABLE ft1; +DROP SERVER s0; +DROP FOREIGN DATA WRAPPER dummy; DROP TABLE vtype; DROP TABLE vtype2; DROP TABLE follower; |
