Re: proposal: fix corner use case of variadic fuctions usage

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Vik Reykja <vikreykja(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: fix corner use case of variadic fuctions usage
Date: 2013-01-23 08:07:03
Message-ID: CAFj8pRDBnJgFPaRT_42cQSfXpS2QDbrN5ZK2yX52qknDC2yqzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

2013/1/23 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> what should be result of concat(variadic NULL::int[])
>> I enabled this use case, but what should be result?
>
> I think there are two somewhat defensible theories:
>
> (1) punt, and return NULL overall. So in this case the variadic
> function would act as if it were STRICT. That seems a bit weird though
> if the function is not strict otherwise.
>
> (2) Treat the NULL as if it were a zero-length array, giving rise to
> zero ordinary parameters. This could be problematic if the function
> can't cope very well with zero parameters ... but on the other hand,
> if it can't do so, then what will it do with VARIADIC '{}'::int[] ?

This is repeated question - how much is NULL ~ '{}'

There is only one precedent, I think

postgres=# select '>>>' || array_to_string('{}'::int[], '') || '<<<';
?column?
----------
>>><<<
(1 row)

postgres=# select '>>>' || array_to_string(NULL::int[], '') || '<<<';
?column?
----------

(1 row)

but this function is STRICT - so there is no precedent :(

>
> I lean a little bit towards (2) but it's definitely a judgment call.
> Anybody have any other arguments one way or the other?
>

> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cliff de Carteret 2013-01-23 09:14:35 Re: Pg_xlog increase due to postgres crash (disk full)
Previous Message Tom Lane 2013-01-23 07:28:53 Re: proposal: fix corner use case of variadic fuctions usage

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-01-23 08:15:39 Re: .gitignore additions
Previous Message Heikki Linnakangas 2013-01-23 07:59:58 Re: WIP: index support for regexp search