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 1rZaUb-005KHt-RN for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 17:53:22 +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 1rZaUa-00C2Zf-Ky for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 17:53:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZaUa-00C2XP-Be for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 17:53:20 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZaUX-006P2I-HB for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 17:53:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 41CHr97c2245611; Mon, 12 Feb 2024 12:53:09 -0500 From: Tom Lane To: "David E. Wheeler" cc: Erik Wienhold , jian he , Jim Jones , =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= , pgsql-hackers@lists.postgresql.org, Pavel Stehule Subject: Re: Patch: Add parse_type Function In-reply-to: References: <87il33kmmn.fsf@wibble.ilmari.org> <505981B3-2572-41E0-896C-964DDF7048A9@justatheory.com> <1317430675.73641.1707616376477@office.mailbox.org> Comments: In-reply-to "David E. Wheeler" message dated "Mon, 12 Feb 2024 11:37:46 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2245609.1707760389.1@sss.pgh.pa.us> Date: Mon, 12 Feb 2024 12:53:09 -0500 Message-ID: <2245610.1707760389@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David E. Wheeler" writes: > [ v4-0001-Add-parse_type-SQL-function.patch ] It strikes me that this is basically to_regtype() with the additional option to return the typmod. That leads to some questions: * Should we choose a name related to to_regtype? I don't have any immediate suggestions, but since you didn't seem entirely set on parse_type, maybe it's worth thinking along those lines. OTOH, to the extent that people would use this with format_type, maybe parse_type is fine. * Perhaps the type OID output argument should be declared regtype not plain OID? It wouldn't make any difference for passing it to format_type, but in other use-cases perhaps regtype would be more readable. It's not a deal-breaker either way of course, since you can cast oid to regtype or vice versa. * Maybe the code should be in adt/regproc.c not format_type.c. * Experience with to_regtype suggests strongly that people would prefer "return NULL" to failure for an unrecognized type name. Skimming the patch, I notice that the manual addition to builtins.h should be unnecessary: the pg_proc.dat entry should be enough to create an extern in fmgrprotos.h. Also, I'm pretty sure that reformat_dat_file.pl will think your pg_proc.dat entry is overly verbose. See https://www.postgresql.org/docs/devel/system-catalog-initial-data.html regards, tom lane