On Tue, 16 Jul 2024 at 12:45, Richard Guo <guofengli...@gmail.com> wrote:
> As a workaround for this issue, I'm considering whether we can skip
> checking functional dependency on primary keys for inheritance
> parents, given that we cannot guarantee uniqueness on the keys in this
> case.  Maybe something like below.
>
> @@ -1421,7 +1427,9 @@ check_ungrouped_columns_walker(Node *node,
>         Assert(var->varno > 0 &&
>                (int) var->varno <= list_length(context->pstate->p_rtable));
>         rte = rt_fetch(var->varno, context->pstate->p_rtable);
> -       if (rte->rtekind == RTE_RELATION)
> +       if (rte->rtekind == RTE_RELATION &&
> +           !(rte->relkind == RELKIND_RELATION &&
> +             rte->inh && has_subclass(rte->relid)))
>         {
>             if (check_functional_grouping(rte->relid,
>
> Any thoughts?

The problem with doing that is that it might mean queries that used to
work no longer work.  CREATE VIEW could also fail where it used to
work which could render pg_dumps unrestorable.

Because it's a parser issue, I don't think we can fix it the same way
as a5be4062f was fixed.

I don't have any ideas on what we can do about this right now, but
thought it was worth sharing the above.

David


Reply via email to