aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index b53d92b4dae..23405711d1d 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -550,6 +550,7 @@ RelationBuildTupleDesc(Relation relation)
{
Form_pg_attribute attp;
int attnum;
+ bool atthasmissing;
attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple);
@@ -563,6 +564,22 @@ RelationBuildTupleDesc(Relation relation)
attp,
ATTRIBUTE_FIXED_PART_SIZE);
+ /*
+ * Fix atthasmissing flag - it's only for plain tables. Others
+ * should not have missing values set, but there may be some left from
+ * before when we placed that check, so this code defensively ignores
+ * such values.
+ */
+ atthasmissing = attp->atthasmissing;
+ if (relation->rd_rel->relkind != RELKIND_RELATION && atthasmissing)
+ {
+ Form_pg_attribute nattp;
+
+ atthasmissing = false;
+ nattp = TupleDescAttr(relation->rd_att, attnum - 1);
+ nattp->atthasmissing = false;
+ }
+
/* Update constraint/default info */
if (attp->attnotnull)
constr->has_not_null = true;
@@ -584,7 +601,7 @@ RelationBuildTupleDesc(Relation relation)
}
/* Likewise for a missing value */
- if (attp->atthasmissing)
+ if (atthasmissing)
{
Datum missingval;
bool missingNull;