| From: | Nikhil Sontakke <nikhil(at)planetscale(dot)com> |
|---|---|
| To: | Manu <manuelreyesbravo(at)gmail(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Dropping a composite attribute causes data integrity violations |
| Date: | 2026-11-27 09:56:34 |
| Message-ID: | CA+UBoq0bJZOU2_v65fdAqT2K6pmLbnaUvYSL8f00Ntbnfj+L+w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Manu,
> One more thing, which v4 had too: DROP DOMAIN d CASCADE over 8000
> tables, each with a column of d and a primary key, takes 1.1 s with v5
> against 168 ms on master
Well, what would be practical scenarios for dependencies? 100? 500? Or 1000?
And this is DDL which does not happen that frequently.
Anyways, I took a stab at fixing it, v6 checks all the relations of a
command
together, so those catalogs are scanned once. Median of 5 runs:
tables master v6
100 6.7 ms 8.8 ms
1000 65 ms 89 ms
8000 581 ms 819 ms
So, the cost is now roughly 1.4x higher instead of quadratic.
> Short version: with v5 the silent loss is back on every internal path.
Right, v5 leaves those paths as they are on master, including the
bypass of a refused DROP TABLE tt CASCADE at session exit. I agree that
refusing up front is the way to fix it, and would welcome your patch,
as a separate patch or thread. It should cover all the composite cases,
as they all need a temporary type in a permanent column or attribute.
It won't cover everything, though. In a set of such scenarios I tried,
a permanent table's CHECK, column default, expression index or
partition key referencing a temporary type (or a temporary sequence) is
dropped at session exit as well, no composite involved; for a partition
key it is the whole partitioned table, with its partitions. That
reproduces on 14 as well as master. So I'd keep this patch to explicit
drops and handle temporary dependencies on their own.
v6 is also rebased over 3b60740cc25, which it needs: without it,
dropping an attribute of a type returned by a hash index expression
trips the "why are we here?" assertion, now that drops go through
check_composite_type_dependency(). I added that case to
alter_column_type.sql. Full test suite passes.
Regards,
Nikhil
---
Nikhil Sontakke
PlanetScale
| Attachment | Content-Type | Size |
|---|---|---|
| v6-0001-Refuse-to-drop-a-column-whose-row-type-is-stored-.patch | application/octet-stream | 50.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayoub Kazar | 2026-11-27 09:57:42 | Re: Simplify the uniqueness proof for self-join elimination |
| Previous Message | shveta malik | 2026-11-27 09:24:35 | Re: Fix race between copying and dropping a replication slot |