public inbox for [email protected]
help / color / mirror / Atom feedFrom: Matthias van de Meent <[email protected]>
To: jian he <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE array coerce
Date: Wed, 18 Mar 2026 12:47:56 +0100
Message-ID: <CAEze2Wi4M1grsR0q27etuB-jncJ6qN-1FMdRX-2PkQxcFpM3sQ@mail.gmail.com> (raw)
In-Reply-To: <CACJufxE9rmyJv4a-gBxMykFPgzom1OYHp0XnNSYGfzEKQA=N_w@mail.gmail.com>
References: <CACJufxE9rmyJv4a-gBxMykFPgzom1OYHp0XnNSYGfzEKQA=N_w@mail.gmail.com>
On Wed, 18 Mar 2026 at 12:06, jian he <[email protected]> wrote:
>
> Hi.
>
> Context: https://git.postgresql.org/cgit/postgresql.git/commit/?id=3c5926301aea476025f118159688a6a88b2738bc
> Also see build_coercion_expression, COERCION_PATH_ARRAYCOERCE handling.
>
> It's doable to skip a table rewrite when changing a column's data type from
> one array type to another. We just need some logic to handle
> ArrayCoerceExpr within ATColumnChangeRequiresRewrite.
Are you sure about that?
IIRC, arrays store the element data type's OID on disk (^1), and if we
move from arrays of type X to arrays of type Y then that should also
change the array's on-disk OID: Generic array functions like array_out
rely on the array's type oid to select the lower-level functions to
call into when recursing; and would get the wrong type information if
we don't update this.
This could cause visible differences in output when you change the
time zone of your database after changing the column type from e.g.
timestamptz[] to timestamp[], or enum[] to oid[] if we ever implement
a binary coercible cast from enum to oid (or int, but oid seems more
appropriate).
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
(^1): Possibly DOMAIN-typed arrays only store the base type, in which
case this would work in the restricted case of coercing to
domain-typed arrays, but I don't think the general case of
binary-coercible types is allowable.
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE array coerce
In-Reply-To: <CAEze2Wi4M1grsR0q27etuB-jncJ6qN-1FMdRX-2PkQxcFpM3sQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox