Re: general purpose array_sort - Mailing list pgsql-hackers

From jian he
Subject Re: general purpose array_sort
Date
Msg-id CACJufxHM7LeLJfjb8LitLRjYp_mY9iVPQEZ58sPFXeWxM-FjCQ@mail.gmail.com
Whole thread Raw
In response to Re: general purpose array_sort  (Aleksander Alekseev <aleksander@timescale.com>)
Responses Re: general purpose array_sort
List pgsql-hackers
On Tue, Oct 29, 2024 at 12:48 AM Aleksander Alekseev
<aleksander@timescale.com> wrote:.
>
> 0001:
>
> > +{ oid => '8810', descr => 'sort array',
> > +  proname => 'array_sort', provolatile => 'v', prorettype => 'anyarray',
> > +  proargtypes => 'anyarray', prosrc => 'array_sort'},
>
> I would expect that array_sort() should be IMMUTABLE. Is there a
> reason for it to be VOLATILE?
>

https://www.postgresql.org/docs/current/sql-createfunction.html says:

IMMUTABLE indicates that the function cannot modify the database and always
returns the same result when given the same argument values; that is, it does
not do database lookups or otherwise use information not directly present in its
argument list. If this option is given, any call of the function with
all-constant arguments can be immediately replaced with the function value.


+ {
+ typentry = lookup_type_cache(elmtyp, TYPECACHE_LT_OPR);
+ if (!OidIsValid(typentry->lt_opr))
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("could not identify ordering operator for type %s",
+ format_type_be(elmtyp))));

This error can happen. I think this conflicts with the doc IMMUTABLE
description.



pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Add isolation test template in injection_points for wait/wakeup/detach
Next
From: Peter Eisentraut
Date:
Subject: Re: -Wformat-signedness