pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gergely Czuczy <gergely.czuczy@harmless.hu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17360: array_to_string should be immutable instead of stable
Date: Mon, 10 Jan 2022 16:01:56 +0100
Message-ID: <8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu> (raw)
In-Reply-To: <2187793.1641826463@sss.pgh.pa.us>
References: <17360-a50d754b72a97cad@postgresql.org>
	<2187793.1641826463@sss.pgh.pa.us>

Hello,

Thanks for explaining Tom, I wasn't aware these things on the internals.

Wouldn't it possible to add polymorphs for immutable types, like 
func(text[]), func(int[]), etc, mark those immutable, and keep the 
generic for all the other not-explicitly-dealt-with types as stable? 
Again, I don't really know the implementation details here, so it's just 
my tuppence.

Thanks again for explaining it.

Regards,
Gergely

On 2022. 01. 10. 15:54, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> The array_to_string function should have a volatility of immutable,
> Nope.  It invokes an arbitrary datatype I/O function,
> which might only be stable.  As an example:
>
> regression=# begin;
> BEGIN
> regression=*# select array_to_string(array[now()], ',');
>          array_to_string
> -------------------------------
>   2022-01-10 09:47:06.605304-05
> (1 row)
>
> regression=*# set timezone to UTC;
> SET
> regression=*# select array_to_string(array[now()], ',');
>          array_to_string
> -------------------------------
>   2022-01-10 14:47:06.605304+00
> (1 row)
>
> Actually, in principle somebody could make a datatype
> whose output function is volatile.  It's not clear
> what the use-case is, though, so we've established a
> project policy that code that invokes some arbitrary
> I/O function may assume that function is at least stable.
> Thus, array_to_string() is marked stable, and likewise
> for some other polymorphic functions such as format().
>
> Ideally, perhaps, we'd determine the volatility level of
> polymorphic functions like array_to_string() based on the
> actual input data types --- but it's hard to see how to do
> that.
>
> 			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu>
Permalink:  ../8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu/
Also on:    postgresql.org/message-id/8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu

 · 

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-bugs@postgresql.org
  Cc: gergely.czuczy@harmless.hu, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17360: array_to_string should be immutable instead of stable
  In-Reply-To: <8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu>

* 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