Re: Dropping a composite attribute causes data integrity violations

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: Nikhil Sontakke <nikhil(at)planetscale(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-28 09:23:19
Message-ID: 179585779991.2113905.14111271673614236343@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Nikhil,

v6 works for me: the cost is now linear, and everything else behaves
as in v5. Here, DROP DOMAIN d CASCADE with N tables that each have a
column of d takes about 1.3 times as long as on master with 100 tables
and 1.44 times with 8000 (243 ms against 170 ms), with or without a
primary key, so it grows with N the way master does. The hash index
case you added trips the assertion without 3b60740cc25 and fails with
a clean error with it. make check, isolation and test_decoding pass,
with no new warnings from gcc or clang.

On Fri, Nov 27, 2026 at 3:26 PM Nikhil Sontakke
<nikhil(at)planetscale(dot)com> wrote:
> Well, what would be practical scenarios for dependencies? 100? 500? Or 1000?
> And this is DDL which does not happen that frequently.

Fair point. What worried me was the quadratic shape, not the time
itself, and with v6 that is gone, so the cost is no longer an issue
for me.

I also read the new per-command check. Each error is raised at the
first stored use found, so sharing the visited types between the
relations of one command can't hide a use. A DROP DOMAIN that drops
columns of two tables whose row types are both stored through one
composite type is refused by v6 just as by v5.

As you suggested, I'll post the patch that refuses temporary types up
front in a separate thread.

> 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.

I see the same on 14 to 19 and master, and agree to keep them out of
this patch. A stored generated column that uses a temporary type is
dropped too, with its data. I'll look at covering these in that
separate thread as well.

Regards,
Manu

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Ishjaap Singh 2026-11-28 09:16:35 Re: [PATCH] psql: Fix REPACK index completion after a column list