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: v6-0001-Refuse-to-drop-a-column-whose-row-type-is-stored-.patch
Description: Binary data

Reply via email to