aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/dependency.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index eec66d20116..8e9f101f223 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -1713,10 +1713,24 @@ find_expr_references_walker(Node *node,
else if (IsA(node, FieldSelect))
{
FieldSelect *fselect = (FieldSelect *) node;
+ Oid argtype = exprType((Node *) fselect->arg);
+ Oid reltype = get_typ_typrelid(argtype);
- /* result type might not appear anywhere else in expression */
- add_object_address(OCLASS_TYPE, fselect->resulttype, 0,
- context->addrs);
+ /*
+ * We need a dependency on the specific column named in FieldSelect,
+ * assuming we can identify the pg_class OID for it. (Probably we
+ * always can at the moment, but in future it might be possible for
+ * argtype to be RECORDOID.) If we can make a column dependency then
+ * we shouldn't need a dependency on the column's type; but if we
+ * can't, make a dependency on the type, as it might not appear
+ * anywhere else in the expression.
+ */
+ if (OidIsValid(reltype))
+ add_object_address(OCLASS_CLASS, reltype, fselect->fieldnum,
+ context->addrs);
+ else
+ add_object_address(OCLASS_TYPE, fselect->resulttype, 0,
+ context->addrs);
/* the collation might not be referenced anywhere else, either */
if (OidIsValid(fselect->resultcollid) &&
fselect->resultcollid != DEFAULT_COLLATION_OID)
@@ -1726,10 +1740,20 @@ find_expr_references_walker(Node *node,
else if (IsA(node, FieldStore))
{
FieldStore *fstore = (FieldStore *) node;
+ Oid reltype = get_typ_typrelid(fstore->resulttype);
- /* result type might not appear anywhere else in expression */
- add_object_address(OCLASS_TYPE, fstore->resulttype, 0,
- context->addrs);
+ /* similar considerations to FieldSelect, but multiple column(s) */
+ if (OidIsValid(reltype))
+ {
+ ListCell *l;
+
+ foreach(l, fstore->fieldnums)
+ add_object_address(OCLASS_CLASS, reltype, lfirst_int(l),
+ context->addrs);
+ }
+ else
+ add_object_address(OCLASS_TYPE, fstore->resulttype, 0,
+ context->addrs);
}
else if (IsA(node, RelabelType))
{