Wrong provolatile value for to_timestamp (1 argument) - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Wrong provolatile value for to_timestamp (1 argument)
Date
Msg-id 20220705.172957.2068967435108479827.t-ishii@sranhm.sra.co.jp
Whole thread Raw
Responses Re: Wrong provolatile value for to_timestamp (1 argument)
List pgsql-hackers
I found that provolatile attribute of to_timestamp in pg_proc is
wrong:

test=# select provolatile, proargtypes from pg_proc where proname = 'to_timestamp' and proargtypes[0] = 701;
 provolatile | proargtypes 
-------------+-------------
 i           | 701
(1 row)

'i' (immutable) is clearly wrong since the function's return value can
be changed depending on the time zone settings.

Actually the manual says functions depending on time zone settings
should be labeled STABLE.

https://www.postgresql.org/docs/14/xfunc-volatility.html

"A common error is to label a function IMMUTABLE when its results
depend on a configuration parameter. For example, a function that
manipulates timestamps might well have results that depend on the
TimeZone setting. For safety, such functions should be labeled STABLE
instead."

It's intersting that two arguments form of to_timestamp has correct
attribute value ('s': stable) for provolatile in pg_proc.

Do we want to fix this for PG16? I think it's too late for 15.

Best reagards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Handle infinite recursion in logical replication setup
Next
From: Dilip Kumar
Date:
Subject: Re: making relfilenodes 56 bits