pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: 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: Fri, 01 Jul 2022 09:37:59 -0400
Message-ID: <716889.1656682679@sss.pgh.pa.us> (raw)
In-Reply-To: <87y1xdjei1.fsf@wibble.ilmari.org>
References: <2914356f-9e5f-8c59-2995-5997fc48bcba@enterprisedb.com>
	<1844517.1651502932@sss.pgh.pa.us>
	<c030a2ef-02d6-ccdb-8ebe-bc97df69be59@enterprisedb.com>
	<871qv5kt9y.fsf@wibble.ilmari.org>
	<87y1xdjei1.fsf@wibble.ilmari.org>

=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= <ilmari@ilmari.org> writes:
> Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> writes:
>> I dind't pay much attention to this thread earlier, but I was struck by
>> the duplication of the switch statement determining the elemlen,
>> elembyval, and elemalign values between the construct and deconstruct
>> functions.  How about a common function they can both call?

I was wondering about that too while reading the committed version.
However, adding an additional function call would weaken the argument
that this adds just a tolerable amount of overhead, primarily because
you'd need to return a record or introduce pointers or the like.

> I just realised that this would require the error message to not include
> the function name (which isn't really that critical, since it's a
> developer-facing message), but an option would to make it return false
> for unknown types, so each of the calling functions can emit their own
> error message.

Nah, because the point of that was just to direct people to where
to fix it when they need to.  So the message need only refer to
the common function, if we were to change it.

Perhaps a good compromise could be to turn the duplicated code into
a macro that's instantiated in both places?  But I don't actually
see anything much wrong with the code as Peter has it.

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <716889.1656682679@sss.pgh.pa.us>
Permalink:  ../716889.1656682679@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/716889.1656682679@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, ilmari@ilmari.org, peter.eisentraut@enterprisedb.com
  Subject: Re: Refactor construct_array() and deconstruct_array() for built-in types
  In-Reply-To: <716889.1656682679@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