Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2pNl-000dwH-18 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 11:48:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2pNk-00A440-0l for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 11:48:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2pNj-00A43s-31 for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 11:48:11 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2pNh-00000000vH3-0Xrr for pgsql-hackers@postgresql.org; Wed, 18 Mar 2026 11:48:11 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-38bd15d82bdso7196721fa.2 for ; Wed, 18 Mar 2026 04:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773834488; cv=none; d=google.com; s=arc-20240605; b=EDWTpLqaJY1UKWBIPuIHF0n3d+Vu5ablI/V6LgqsCcoSSjKCRVvIXt4O/qQMei7oER AiKR72l2lE4KyvDiev0GF31RIk/sfoJF0GpraeEC2yOon1C8TjxZBTZ/JqGMM4hlEjOL wa0nn+pHZViTLQikALCaM/t1rIVmU1aPIWXAPvSuwMeVHKkUUTwo/fTh+6fn7JrMOE6M 7LOM6QfjCvnNhCr9PaOBng457mBfSugZwMIEVzXvjkc40udw/Kl+izk3wAsXslXsev2m vsgNnFobpPaUnsL9sC7vQgA5qpEzAExrGYHZIJ9rspHidqgJof6e9kC5Hin/8MU8QwGt apZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=tPwWyNgMiPgXndBMDabxCWDoU8CWkTKUb/5dg7Q5bu8=; fh=JdGAwAsHWZpq7G3VjgE8a3tPThceXMzSSkvVOKeHWM4=; b=H1nheUuciyvmTAE68FKX9S/0nA/8KSrHwSbvhq4BuSU+hGwf8mIyR1yzCl6FMjBpLA JVTuDSzvQ5stu+pgzPnvMcVdOmtIhmTY4wx8eOhBnWWGZCvsNWM2ZovXHSRhWIjVYLpz HB953FiQD/dsA6jGJaHFlg36blXJX2vERwkRx0PAG+3w12S+c++EPPtqNpkNybbuG56l TFU3Ny2sw9C2rIoMKtnPPWFIT4eFUoby6Jhp/qRSjZYZumnqewmuHfa0079v+UnCv4KH rkglurz56So5fXxGoivbrQ3D608CXXoBi8TdAXg4SDrtZZqq/NoitlM1tFFypO0Qnpou XB2Q==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773834488; x=1774439288; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tPwWyNgMiPgXndBMDabxCWDoU8CWkTKUb/5dg7Q5bu8=; b=nSeoAW/CGevAY6d/puU9t1prvpC243gkFQ5fFudTncAMG62flfrOObvrckO1BljagH jgIZT/DK3LbRk5CM2mUVx26crQo4JFCTjEIcdblEFOZ4NrsxxU2VeP1oHiDewEDS0QGo owsUZiBKxCfUpvXCCkJKmR5rFG9VDWXBG147leNvOPvL5USZoaLBglDpsk1GwIYOx/LG T77ykFwGA1K+64y79RAioKDcgjDpUj+pFMjrX/jU5pMcmUS4kGAImDwslyh/FLjHQfCp WsiExrxHbl2+pvsXYRVbFmczalD4Ob2y0fywsPjICnsriYiE/d1LJYKoDdpMywf2kiI2 rVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773834488; x=1774439288; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tPwWyNgMiPgXndBMDabxCWDoU8CWkTKUb/5dg7Q5bu8=; b=ok9ZDM3AnB2aStJuIer9MsF2MYYLZXz5nn36/eCXJHbOCwYX88ytT9tUCKaUXGYv40 16Un5AUPDXUYoYVK8OWw6Ti9B3Z0YQoX8ABrgCKZaSGVf3KwG3fDJe+cbo6JcmsK1ca6 NSxkb8qfWqd97fTGYBW6xLfUG0z7sR8Pg8jyFB7vnpRmpYF5gCgw2uY16vP17OGpOxiP gBi4a0BbvhhbMa1BCPN/88VVohmNzwQBNQpR6IQKJ3RmIMzpfOJnOXOCDwaUF1yTirmC w3+dKJ0VsAOvW6atypZYw34/C/ICtrQ6PjYDqf5rWZGLIGfFxy0xZcaY8BH8jAyT8zjJ Lb2A== X-Gm-Message-State: AOJu0YzNKj9imS3l5OTQG9ap4wILZihi2Oq7sGyuMm+1zOW+CQ6DmrRz c/qYAq82YwYtFCTSSsrJR7wYhZqepK4mIK9CrQ6KqoQTBWqKZuEG1KoJgQzAhxcrfabZvZTQOe+ 8PDZUhTkWWIO7zTaIY7aOnLsF9oSMvvc= X-Gm-Gg: ATEYQzzPRZ33bMzzpJ2OhS3ZkirvBNCp/pzYVhSoZhLWsZ4al5wnOuUXr0+dm1FSosG biTaNfx3nsVm9yDaEdqgHPGxfMkJrXylrjIjxPZErW38DiN3L1Zt5AufTwseCbdmYCthzf8R4CN O8UkZJdKNgNEkNiamtOp6HJvssk7ZuU5cv6sgUvze+wfZztQaa90pdVhzlJYxYSmE6OUaiYw22R CeKbY/oGUvBm5PD2NDkGCH6L16+kKNkxgxx/dHKF5+l67wLrXMSWPoMCD6Nh/9M/lJosInjIrKt ehiOMALLRHINYcMXBb2Aq/1KMK/RlM+50QOTH11U3Vn/Prmcru91ammNqRaOY+t1g+MI1XAmfOg 6xrwB X-Received: by 2002:a05:651c:32f:b0:38a:4aee:423d with SMTP id 38308e7fff4ca-38bd588d042mr10736581fa.32.1773834487919; Wed, 18 Mar 2026 04:48:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Matthias van de Meent Date: Wed, 18 Mar 2026 12:47:56 +0100 X-Gm-Features: AaiRm51Db8KXhidGRtxkDPGWeZYE-si3UiUzlRk3j4DzpskHc8anVE1_akV85IQ Message-ID: Subject: Re: Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE array coerce To: jian he Cc: PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 18 Mar 2026 at 12:06, jian he 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.