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.94.2) (envelope-from ) id 1uhl3A-003iV5-3t for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Aug 2025 08:23:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uhl38-006XLw-8n for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Aug 2025 08:23:34 +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.94.2) (envelope-from ) id 1uhl37-006XLo-Vd for pgsql-hackers@lists.postgresql.org; Fri, 01 Aug 2025 08:23:33 +0000 Received: from mail-vk1-xa32.google.com ([2607:f8b0:4864:20::a32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uhl35-000AVO-0e for pgsql-hackers@postgresql.org; Fri, 01 Aug 2025 08:23:33 +0000 Received: by mail-vk1-xa32.google.com with SMTP id 71dfb90a1353d-53927febb37so410993e0c.0 for ; Fri, 01 Aug 2025 01:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754036609; x=1754641409; 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=8FwYjHWg7xvydyixL+f7g4LNxCrSItyMqheqUs9V3kA=; b=ZtTmLJyxS9aoQRWOFLgpyuwzrp0YaVm3Lsm4ARjsXP8uM0zuPatMKxZUnq2Nac+Ih8 0Q/kBUocUWjjHg/3F+vO86OJjDJSqdXCph4P57+xymVeHWJAulvYWclTSk903OzATkz2 W4OkhIThJLdv5hOdfkHggc52evIptpBpR+qk7VpsuhZZ+0A9weleb7jpqwQeXjh8XYiS ZZd9ytJMZaj7rwFZ1+RWAMMXul7fqjd/OqQsksAXF4yGDifKO8D0RYZA0t/2RBVZzlf0 24UIdxQm0Gv42+cgDDjFBnTLVd41tYoCgZzgDNHRw0vKZw4zSkVv7v/C7v7csYQD9Y6o eytg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754036609; x=1754641409; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8FwYjHWg7xvydyixL+f7g4LNxCrSItyMqheqUs9V3kA=; b=E2eF9VbwTyU1nQKsGqNM4p3lhO2ykcUtFNQo02h4vp4XpAm62PmzJ9l3mnftIl42N3 OTzd4uAnohQ4HXyAd6eV5Esli3oLPPutI1B4Uy+LGz/bpLU1bLnt068yOaLpaIeyYLrL P2fifBS15eJY9FgDYB1MgIkDdGMt+WKomFHRTRxP6pHvSCmraxBh2aBoFuUg9W9oj1+9 7aij5hjXe7t18MtMkhsKX3Whpyk2zb+lSVIOQWHB+s0pUpUQmZTmiC/Fql2Pni/7VG87 C2iNc+rzuh2+VbKbUmm1tAryMN8Qip+G26OP0i2MPhA3uZgj1v7sZSabK29ToRV1/zRe HQDw== X-Forwarded-Encrypted: i=1; AJvYcCX6pgVqPJE0FT2pArs8IAUOA/FYs0qFmpkchcpwX4s7v+5FsirwFNAhkQzwse1Wcrg6DVVRbZw+d05MTwzt@postgresql.org X-Gm-Message-State: AOJu0YwBtQ+O+NU3DygSk8KDin2U/ZE5iGpeZn/ZzuqNQ12xXqNQ+rMu Cke0dV0M21jM4phb23kKCeVpLVJxP95asSMvOxKb6p8336d0RnJP4RW2ZukSqtzrfJmqhROKBnQ mNtbSadd9gX21sIfcWcfapEE1YIbzeRU= X-Gm-Gg: ASbGncvrmShx5usclE4gKPvfr8Qs49NFqq4rQr6VG7pqWSlvT6OktSuCBFRRZlHmPed 08nXHMZAD99M0bbcLXM3vylPufoWnVgPcbzLGDtwbaH1pOZPeDPHeFx+USjObfqPM/gKOhovSB3 iUrWLrbbSTwBbUH54J7NiPHNdRLvlKEdQPN63TEueddUlOvEtQWCKweiPLMFP0WlPeDzl23GJeL 3zi1YLHtI3lcuX6L92PzJZ23SCNPlVwkauDekjOtpfoZro= X-Google-Smtp-Source: AGHT+IGSXbBRIWU8T/aDSLg56DgVDQEvXKuBUqXHbOCIr99asceLuhDCYkTfyvqcrg6kexz4B1+VKYyihlWJfas9xGg= X-Received: by 2002:a05:6122:459b:b0:531:2afc:463f with SMTP id 71dfb90a1353d-5394bb4f350mr677956e0c.6.1754036609128; Fri, 01 Aug 2025 01:23:29 -0700 (PDT) MIME-Version: 1.0 References: <4c358bf8-87e8-4760-83d5-a6f9fcd88907@postgresfriends.org> <1b702de4-86b0-4144-a2d0-38266296894f@postgresfriends.org> In-Reply-To: From: jian he Date: Fri, 1 Aug 2025 16:22:52 +0800 X-Gm-Features: Ac12FXwPibLSa_MxdgGwBXyeHGM2ZQ16FPT0jUj8xN0JfTf8o6p6KsPDmx7-uNY Message-ID: Subject: Re: implement CAST(expr AS type FORMAT 'template') To: "David G. Johnston" Cc: 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 Tue, Jul 29, 2025 at 11:54=E2=80=AFAM David G. Johnston wrote: > > The slight variation to this would be to specify these 2/4 and 1-arg func= tions as optional =E2=80=9Cformat_in=E2=80=9D and =E2=80=9Cformat_out=E2=80= =9D optional properties (like typmod_in). The format-aware code can look f= or these which will end up having the full implementation while the current= IO functions would simply stub out calls, passing null as the format. (Or = maybe some variation that looks similar to typmod handling=E2=80=A6which I = haven=E2=80=99t looked at.) > This may also work. typmod_in, typmod_out, which is associated with typmod, which is used in many places. The only use case for (typformatin, typformatout) is CAST expression. so we also need to consider the overhead of adding two oid columns (typformatin, typformatout) to pg_type. another question is: should we first implement CAST(expr AS type FORMAT 'template') for limited = types (to_date, to_char, to_number, to_timestamptz) or first try to make it more generic?