Re: BUG #18007: age(timestamp, timestamp) is marked as immutable, but using age(date, date) says it's not

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Braiam <braiamp(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, braiamp+pg(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18007: age(timestamp, timestamp) is marked as immutable, but using age(date, date) says it's not
Date: 2023-06-29 19:25:49
Message-ID: 28E5C3E3-5350-4870-870F-BFCBBB705611@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On Jun 29, 2023, at 11:29, Braiam <braiamp(at)gmail(dot)com> wrote:
> Function age(timestamp with time zone, timestamp with time zone) is
> marked as immutable. Postgres shouldn't complain about it.

It's not the age() function as such that is the problem, but the (stable) cast from date to timestamptz. Stable or volatile inputs to an immutable function make the expression result non-immutable.

For example, abs() is marked as immutable, but you can't do this:

xof=# CREATE TABLE t (i integer);
CREATE TABLE
xof=# CREATE INDEX ON t((abs(random()+i)));
ERROR: functions in index expression must be marked IMMUTABLE

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Braiam 2023-06-29 19:58:11 Re: BUG #18007: age(timestamp, timestamp) is marked as immutable, but using age(date, date) says it's not
Previous Message Tom Lane 2023-06-29 19:25:35 Re: BUG #17994: Invalidating relcache corrupts tupDesc inside ExecEvalFieldStoreDeForm()