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.


Reply via email to