Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object

Поиск
Список
Период
Сортировка
От jian he
Тема Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object
Дата
Msg-id CACJufxE-PJyKmoDnZDEt+anKdtV1MvfA+u9x_S9CvorYUQ9Bww@mail.gmail.com
обсуждение исходный текст
Ответ на Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
On Mon, Sep 15, 2025 at 8:40 PM jian he <jian.universality@gmail.com> wrote:
>
> Summary of attached v4:
> v4-0001: Handles ALTER TABLE DROP COLUMN when whole-row Vars are
> referenced in check constraints and indexes.
>
> v4-0002: Handles ALTER TABLE ALTER COLUMN SET DATA TYPE when whole-row
> Vars are referenced in check constraints and indexes.
>
> v4-0003: Handle ALTER TABLE ALTER COLUMN SET DATA TYPE and ALTER TABLE DROP
> COLUMN when policy objects reference whole-row Vars.  Policy quals and check
> quals may contain whole-row Vars and can include sublinks (unplanned
> subqueries), pull_varattnos is not enough to locate whole-row Var. Instead,
> obtain the whole-row type OID and recursively check each Var in expression node
> to see if its vartype matches the whole-row type OID.

in v4, I use

+ TupleConstr *constr = RelationGetDescr(rel)->constr;
+
+ if (constr && constr->num_check > 0)
+{
+    systable_beginscan
+}
to check if a relation's check constraint expression contains a whole-row or
not.  however this will have multiple systable_beginscan if multiple check
constraints contain wholerow expr.

I changed it to systable_beginscan pg_constraint once and check if the scan
returned pg_constraint tuple meets our condition or not.

and some minor adjustments to regression tests.

Вложения

В списке pgsql-hackers по дате отправления: