1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

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
This commit is contained in:
Andrew Dunstan
2021-06-18 07:44:58 -04:00
parent 70293e946e
commit 6432bfe8a3
5 changed files with 63 additions and 4 deletions

View File

@ -11313,9 +11313,10 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/*
* Here we go --- change the recorded column type and collation. (Note
* heapTup is a copy of the syscache entry, so okay to scribble on.) First
* fix up the missing value if any.
* fix up the missing value if any. There shouldn't be any missing values
* for anything except plain tables, but if there are, ignore them.
*/
if (attTup->atthasmissing)
if (rel->rd_rel->relkind == RELKIND_RELATION && attTup->atthasmissing)
{
Datum missingval;
bool missingNull;