Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qEwK6-0000QX-Dk for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jun 2023 18:24:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qEwK4-0000KW-G2 for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jun 2023 18:24:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qEwK4-0000KN-87 for pgsql-bugs@lists.postgresql.org; Thu, 29 Jun 2023 18:24:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qEwK1-0018kB-TE for pgsql-bugs@lists.postgresql.org; Thu, 29 Jun 2023 18:24:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 35TIOlBh1576666; Thu, 29 Jun 2023 14:24:47 -0400 From: Tom Lane To: Braiam cc: 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: References: <18007-036782307e002bf6@postgresql.org> <1573129.1688061162@sss.pgh.pa.us> Comments: In-reply-to Braiam message dated "Thu, 29 Jun 2023 14:20:44 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1576664.1688063087.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 29 Jun 2023 14:24:47 -0400 Message-ID: <1576665.1688063087@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Braiam writes: > On Thu, Jun 29, 2023 at 1:52=E2=80=AFPM Tom Lane wro= te: >> 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 =3D# explain verbose select age(current_date, current_date); QUERY PLAN = = = --------------------------------------------------------------------------= ------------------------- Result (cost=3D0.00..0.02 rows=3D1 width=3D16) Output: age((CURRENT_DATE)::timestamp with time zone, (CURRENT_DATE)::t= imestamp with time zone) (2 rows) regards, tom lane