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 1wfOA4-005QRx-1X for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 20:37:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfOA2-0034i0-31 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 20:37:26 +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 1wfOA2-0034hs-20 for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 20:37:26 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfO9z-00000001OsR-3kHD for pgsql-hackers@postgresql.org; Thu, 02 Jul 2026 20:37:26 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-c0e124d2a21so280064266b.2 for ; Thu, 02 Jul 2026 13:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783024642; cv=none; d=google.com; s=arc-20260327; b=Oid4Cgb6bWgvADOGuVXJKl5Ssu8K4bhG6syEvMWD7EDb1zsvoYKjLpp/Gh+Dd7vCrv hLBmxk6CwjZXlxxHF+fjtTp1SkiQcuDs6dbKu1l47gafrpelPgMC1ync9sqMSBdLhJIQ z1+oLplpuOuBaJf1JUF9Wd/+VePlf3rWP1dmDF1CPu+Y1vQQ0TzxY+sfROeVi4z4ZmXI 36jzWMr86eF8+COK1OgVuJ9uXn3io/H6WNFo1YDfetBs+TWFXj4fSRdzynSp9WIn7iBo kz6MXUR61UsKlOOrfKqBmDej7QeL5BeECv1hImKuL6EtKooc1LTEriLp8w/K6NeErlqO KLog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LYVilgsQDwLw/ZfxxR8mQnUPX1TFKiQWIfiR/R/uxHg=; fh=IQi+BqhlwuOMOUWOZkLxJROTQD0tDwv0Znnj4Xy1RpI=; b=EaEOcQrzjeuK8ZcVmNLd7cwTYBPe+tBIwvEW6++0TGaY0htpcMEYLq7vWOKbybh1E4 BcQbUO5In52BZi2TyNe/go4J7toXe9KnzjS00SyH1gLrkdmdVXrW03tnHwcxi/TRke2T 4prZeqsJUVxCMLUC6GEM6XjusLKWDkBRySVp/exNn7BwkCzBv3ZaXI754sJTcQcw8OaO 7ZP5ZTBwdh7G299l9PsrkbA0K9TmgM9wHEhCSy6qT1SeVba2zyItrqdtqzpWGk/pbOW8 Ei/7jKA9/6TIbbjgtyWGg055Iu1TcBaBofvgcIuAoGfMgS37ZiSna+v1UjW64K5GVhoP hIQw==; 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=20251104; t=1783024642; x=1783629442; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LYVilgsQDwLw/ZfxxR8mQnUPX1TFKiQWIfiR/R/uxHg=; b=fF6g2GQo52m2zadSczwPov2iH0BQe33CQLk42pVDo966UwantLK80ou+TGulADHw6Z s1sJ5Yvb0e1UmJLDg2SPNF11sqOGb5zpHAIZhRg6X9KevhsyOGTx8TJDcgi+JAGhz82y vxAv+XbuhIt1X/lIgFmnlY/DUlIxaUTSwEC3ya2ZVmJ1HuHR1rTzM8sxRP/CaXZ2u+as DkP03fmU6AdmgdKjP/vnA0A/Sh7JL85VaFbXS/IJAV0bCGXP48DJS8tp/qyjh7w6Rk7s Gqk9es5s4dryH1tRgyRmlsw1lsoQ66hQa27IHGhfMEKKl4rs+DWjIIBYnhGHg6nmB/qP k3fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783024642; x=1783629442; h=content-transfer-encoding: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=LYVilgsQDwLw/ZfxxR8mQnUPX1TFKiQWIfiR/R/uxHg=; b=b3oW6scEK+SvmqU3GUcB8gmSNyEvAihRvL2fwlmTlCXocb45gntOLrIUHkhpG1JwnL XVf7f01M4EQD4L1Jh5XfziEBI4Kwyctwim4O5BsOzoYw7o0FkdmKtYO1vhr5zWxcU9ju i+JtCZOftKGql2aj2tPj9gAGswBj+KENVBYUhh11yY+wtFtnypJsSTXfLYmNiDVlrnek Q+UuoioDRGymc8000Y/bm9dLUeZtnVLS12NgtaX+gZVsMe4fVGl9WImmpMfWYsHjaNAF ZJqeWNNE2kSDG+YidwGo+LLi4+9ZF2eO/1DP/cvil4T3tvEG8c9JTzULN8AF1YjaCeS0 m1cA== X-Forwarded-Encrypted: i=1; AHgh+RoK2vFL3ydGee10hSn1SbQGJOltd0BTbo/TOE/fDF9zJH/k2nNvIy+A9lFXGetuyUEpADUAiay1U29Pi0F2@postgresql.org X-Gm-Message-State: AOJu0YyVSUdyStOZcLklTpGPpzbcZLOaawgwW+TFggX5gik79eCERweT ZmJP6xQeak/41tT3xRaz2zvxDWtcSCazZOIE1q0gfug771cK0xTVvq6ai0Kh7qr9UflOjUeugXb YeUP1PQSHh6VpWhhjNOeGTcRzpzLp+RY= X-Gm-Gg: AfdE7clKikdHFedC5a97RzTwq+tBgebLtjzK112Zp4kLK0/3a2wnaP9yYMq9fL/HxjA K8Wt4jpp2bFdSF7fsFSUJOY0KSv8EVYi+vpZGMdHLGncYLG621uGGMeJ4nYvbknmfPmzV3QALrL 5X1UGlkk8M3orGOrGAKPWBvWw8bJuGWJlmsHOEuPOrS/po4FtxxMeZCLiUNed6TXslCOSQq5Amd nh6RU2Jp9bb7nP71Yfg4puXkpECdHzeWNdEdgU6L8T+cty+wiNkCIRCCJlv16Vz1bJA+hG5HG8P OH4kW7fp/Hhu70yuqKVjc9Z6Xm5l X-Received: by 2002:a17:906:f58a:b0:bfe:ed35:e859 with SMTP id a640c23a62f3a-c12ae8893d7mr343725166b.53.1783024642211; Thu, 02 Jul 2026 13:37:22 -0700 (PDT) MIME-Version: 1.0 References: <4c358bf8-87e8-4760-83d5-a6f9fcd88907@postgresfriends.org> <1b702de4-86b0-4144-a2d0-38266296894f@postgresfriends.org> <82b4223e-84d4-432d-8167-dd698ce489f5@postgresfriends.org> In-Reply-To: From: Robert Haas Date: Thu, 2 Jul 2026 16:37:08 -0400 X-Gm-Features: AVVi8CfjGflIiPnrrUN5mZqNSx9PMLD6sIJElitPSHPe3gQRjZMosKeMmoE5lG8 Message-ID: Subject: Re: implement CAST(expr AS type FORMAT 'template') To: "David G. Johnston" Cc: Haibo Yan , jian he , Corey Huinker , Zsolt Parragi , Vik Fearing , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 1, 2026 at 4:59=E2=80=AFPM David G. Johnston wrote: > I think the fact the standard put this inside the 'cast(...)' means it's = quite reasonable to consider the aspect part of a cast definition as oppose= d to something wholly different. > > When we issue "create table" both pg_class and pg_attribute are modified.= It seems quite reasonable that executing "create cast" causes both pg_cas= t and pg_cast_format to be populated. I don't see how this would work. The existence of a regular cast doesn't mean there has to be a format cast, and the existence of a format cast doesn't mean there has to be a regular cast. Expressions that use a format cast need to depend on the pg_format_cast entry, and expressions that use a regular cast need to depend on the pg_cast entry. I mean, I'm not saying something else is totally impossible. You could for example create the pg_cast entry always and make it some kind of dummy entry when there's only a format cast. Then all casts could depend on the pg_cast entry. But then we'd still have to have ALTER CAST commands that modify the format-cast part of the object and the non-format cast part of the object separately. That seems extremely unpleasant to sort out, especially since right now a cast can't be modified after it's created, and changing that might have security implications. But even apart from that it doesn't seems like it will make for a very awkward user experience. I agree with Peter that I'm not really sure why we want to implement this in the first place; it doesn't seem to add any value over just having functions. The above is just a discussion about what we should do (or what I think we should do) if we do want to have it. --=20 Robert Haas EDB: http://www.enterprisedb.com