pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Braiam <braiamp@gmail.com>
Cc: braiamp+pg@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18007: age(timestamp, timestamp) is marked as immutable, but using age(date, date) says it's not
Date: Thu, 29 Jun 2023 14:24:47 -0400
Message-ID: <1576665.1688063087@sss.pgh.pa.us> (raw)
In-Reply-To: <CAG=7Bt_DtoMoAA7iKCgYvV2Np1Xv1K29QKGggihnt04WSrAKfQ@mail.gmail.com>
References: <18007-036782307e002bf6@postgresql.org>
	<1573129.1688061162@sss.pgh.pa.us>
	<CAG=7Bt_DtoMoAA7iKCgYvV2Np1Xv1K29QKGggihnt04WSrAKfQ@mail.gmail.com>

Braiam <braiamp@gmail.com> writes:
> On Thu, Jun 29, 2023 at 1:52 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> There is no age(date, date) function.  What we have is age(timestamp,
>> timestamp) and age(timestamptz, timestamptz), so the parser has to
>> choose which type to coerce to --- and it prefers timestamptz.

> According to \df+ age both timestamptz and timestamp are immutable:

True, but not very relevant: it's the coercion from date that's
giving you trouble.

> So, whatever type is coerced into pre-function evaluation comes
> with strange results. I'm not aware of a way that I can see what
> kind of type is being coerced into.

EXPLAIN will show that, eg

=# explain verbose select age(current_date, current_date);
                                            QUERY PLAN                          
                   
---------------------------------------------------------------------------------------------------
 Result  (cost=0.00..0.02 rows=1 width=16)
   Output: age((CURRENT_DATE)::timestamp with time zone, (CURRENT_DATE)::timestamp with time zone)
(2 rows)

			regards, tom lane





view thread (9+ messages)  latest in thread

Message-ID: <1576665.1688063087@sss.pgh.pa.us>
Permalink:  ../1576665.1688063087@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1576665.1688063087@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, braiamp@gmail.com, braiamp+pg@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18007: age(timestamp, timestamp) is marked as immutable, but using age(date, date) says it's not
  In-Reply-To: <1576665.1688063087@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox