Re: BUG #19644: byteaout, float8out and float4out are marked IMMUTABLE but depend on GUCs

From: Staroverov Ilja <i(dot)staroverov(at)ftdata(dot)ru>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, "jj-zhang25(at)mails(dot)tsinghua(dot)edu(dot)cn" <jj-zhang25(at)mails(dot)tsinghua(dot)edu(dot)cn>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19644: byteaout, float8out and float4out are marked IMMUTABLE but depend on GUCs
Date: 2026-10-21 04:40:22
Message-ID: 787D78EB-E6D7-4408-9DFA-4AD9C3D4EA5E@localhost.localdomain
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

> Codex reported two other cases:

Thanks for taking the hstore patch, and sorry for the wrong claim: I
missed xpath(), which formats its numeric results through
map_sql_value_to_xml_value().

Looking again, more broadly this time, I found one more in core:
age(timestamptz, timestamptz) is marked IMMUTABLE, but it computes the
difference in the session's time zone, so its result depends on
TimeZone:

SET TimeZone = 'UTC';
SELECT age('2026-03-01 00:00+00'::timestamptz,
'2026-01-31 00:00+00'::timestamptz);
age
-------------
1 mon 1 day

SET TimeZone = 'America/New_York';
-- same query
age
---------
29 days

So a stored generated column defined as age(e, s) with timestamptz
columns gets different values for the same s and e, depending on the
TimeZone at insert time.

However, unlike xpath(), age() is probably used in generated columns
and indexes much more often, so marking it STABLE would break more
existing schemas. I'm not proposing a patch; I just wanted you to know
about it, and leave it to you whether it's worth changing.

--
Ilya Staroverov

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Fujii Masao 2026-10-21 02:39:43 Re: BUG #19644: byteaout, float8out and float4out are marked IMMUTABLE but depend on GUCs