pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Refactor construct_array() and deconstruct_array() for built-in types
Date: Mon, 02 May 2022 10:48:52 -0400
Message-ID: <1844517.1651502932@sss.pgh.pa.us> (raw)
In-Reply-To: <2914356f-9e5f-8c59-2995-5997fc48bcba@enterprisedb.com>
References: <2914356f-9e5f-8c59-2995-5997fc48bcba@enterprisedb.com>

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> There are many calls to construct_array() and deconstruct_array() for 
> built-in types, for example, when dealing with system catalog columns. 
> These all hardcode the type attributes necessary to pass to these functions.

> To simplify this a bit, add construct_array_builtin(), 
> deconstruct_array_builtin() as wrappers that centralize this hardcoded 
> knowledge.  This simplifies many call sites and reduces the amount of 
> hardcoded stuff that is spread around.

> I also considered having genbki.pl generate lookup tables for these 
> hardcoded values, similar to schemapg.h, but that ultimately seemed 
> excessive.

+1 --- the added overhead of the switch statements is probably a
reasonable price to pay for the notational simplification and
bug-proofing.

One minor coding gripe is that compilers that don't know that elog(ERROR)
doesn't return will certainly generate "use of possibly-uninitialized
variable" complaints.  Suggest inserting "return NULL;" or similar into
the default: cases.  I'd also use more specific error wording to help
people find where they need to add code when they make use of a new type;
maybe like "type %u not supported by construct_array_builtin".

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <1844517.1651502932@sss.pgh.pa.us>
Permalink:  ../1844517.1651502932@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1844517.1651502932@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter.eisentraut@enterprisedb.com
  Subject: Re: Refactor construct_array() and deconstruct_array() for built-in types
  In-Reply-To: <1844517.1651502932@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox