Re: string_to_array has to be stable?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string_to_array has to be stable?
Date: 2010-07-29 00:25:35
Message-ID: 27283.1280363135@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> On Tue, 2010-07-20 at 11:31 +0200, Pavel Stehule wrote:
>> I am working on to_array, to_string functions and I am looking on
>> string_to_array function. I am surprised so this function is marked as
>> immutable

> What's wrong with that? "current_date" is the part that's changing, and
> it's being passed as an argument to the function. If the argument
> changes, an immutable function can return a different result.

string_to_array() seems fine to me: it's a predictable transformation
from text to text. However, I think that there really is an issue with
array_to_string(), because that takes an anyarray and invokes the array
element's type output function. Type output functions are not
necessarily immutable, and if the input is of a type where that's not
true, then the array_to_string() transformation isn't immutable either.
An example is that date's output function produces different results
depending on datestyle.

I can't remember offhand whether there are any volatile type output
functions, but if there were we'd really need to mark array_to_string()
as volatile. That would be unpleasant for performance though. I'd
rather compromise on stable. Thoughts?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2010-07-29 00:51:09 Re: string_to_array has to be stable?
Previous Message Tom Lane 2010-07-28 23:36:05 Re: do we need to postpone beta4?