Re: Duplicate unique key values in inheritance tables - Mailing list pgsql-hackers

From David Rowley
Subject Re: Duplicate unique key values in inheritance tables
Date
Msg-id CAApHDvo9LJN8PpOzfh5FBy_PVX5e=NzBKceOYRy-Zh7=8KZY3A@mail.gmail.com
Whole thread Raw
In response to Duplicate unique key values in inheritance tables  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Duplicate unique key values in inheritance tables
List pgsql-hackers
On Tue, 16 Jul 2024 at 12:45, Richard Guo <guofenglinux@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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Injection point locking
Next
From: Michael Paquier
Date:
Subject: Re: Allow non-superuser to cancel superuser tasks.