Re: [PATCH] no table rewrite when set column type to constrained domain

Поиск
Список
Период
Сортировка
От jian he
Тема Re: [PATCH] no table rewrite when set column type to constrained domain
Дата
Msg-id CACJufxFhWyWzf2sJS9txSKeyA8hstxGDb8q2QWWwbo5Q1smPMA@mail.gmail.com
обсуждение исходный текст
Ответ на [PATCH] no table rewrite when set column type to constrained domain  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
On Thu, Jul 10, 2025 at 2:00 AM jian he <jian.universality@gmail.com> wrote:
>
> we can add a new boolean field, coerce_to_domain, to NewColumnValue. this field
> is set to true only when changing an existing column's type to a constrained
> domain. In such cases, a table scan is enough—no table rewrite is needed.
> coerce_to_domain will set to false, if table rewrite is required.

I realized that "coerce_to_domain" is not so good in this context.
maybe there are other scenarios, we added a NewColumnValue and we also
only need table scan.
so I changed it to scan_only.


/*
 * ....
 * If scan_only is true, it means only a table scan is required.
 * Currently, this is supported only by the ALTER COLUMN SET DATA TYPE command,
 * where the column's data type is being changed to a constrained domain.
 */
typedef struct NewColumnValue
{
    AttrNumber    attnum;         /* which column */
    Expr       *expr;                    /* expression to compute */
    ExprState  *exprstate;         /* execution state */
    bool        is_generated;       /* is it a GENERATED expression? */
    bool        scan_only;           /* table scan only */
} NewColumnValue;

Вложения

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