From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Tender Wang <tndrwang(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18500: Detaching a partition with an index manually attached to the parent's index triggers Assert |
Date: | 2024-06-28 11:27:17 |
Message-ID: | 202406281127.piekjwgnulgf@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 2024-Jun-12, Tender Wang wrote:
> I think what you said above. I feel that we need that "tp_pkey" is a
> partition
> of the partitioned index "t_a_idx". For example, below statement:
>
> test=# alter table tp drop constraint tp_pkey;
> ERROR: cannot drop index tp_pkey because index t_a_idx requires it
> HINT: You can drop index t_a_idx instead.
>
> If "tp_pkey" is not a partition of "t_a_idx", the primary key "tp_pkey" can
> be dropped.
I guess you could also fix this by adding a PK constraint to the parent
table, so that the situation is consistent in the other direction.
Here's a proposed patch for master only. It turns all three situations
being reported into ereport(ERROR); in one case I have an XXX comment,
because we have an alternative when attaching a partition that already
has a PK to a partitioned table that has a non-PK index: just create a
separate index in the partition. But that would cause slowness, which
is probably undesirable. I'm inclined to just remove the XXX comment,
but if anyone has other thoughts, they are welcome.
I add an errhint() to one of these new errors, but I'm undecided about
that idea --- should we add errhint() to all three messages, or none?
We can't do this in back branches, of course (incl. 17 at this point),
because that might break existing applications, which means we need to
adjust behavior in some other way, probably similar to what Tender Wang
suggested, namely just don't crash on detach, or something like that.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Attachment | Content-Type | Size |
---|---|---|
v2-0001-WIP-don-t-let-constraint-indexes-attach-to-raw-in.patch | text/x-diff | 5.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-06-28 16:11:17 | Re: LibPQ doesn't say host=* translates to localhost |
Previous Message | Devrim Gündüz | 2024-06-28 10:59:30 | Re: BUG #18500: Detaching a partition with an index manually attached to the parent's index triggers Assert |