Re: interval_scale not work as expected?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: interval_scale not work as expected?
Date: 2023-10-16 00:28:43
Message-ID: 2170251.1697416123@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jian he <jian(dot)universality(at)gmail(dot)com> writes:
> I thought:
> SELECT pg_catalog.interval('1 day 01:23:45.6789'::interval, 0)
> is same as
> SELECT interval(0) '1 day 01:23:45.6789'

[ shrug ] No, it isn't. Interval typmods have to carry a lot
more than just the fractional precision, because of all the
weird syntactic baggage that the SQL spec has for interval
types (i.e., YEAR TO MONTH and other options). timestamp.h
has (some of) the details about what gets packed into an
interval typmod.

Even with simpler types, there generally isn't a one-to-one
correlation between user-visible precision and the encoded
typmod.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-10-16 00:45:30 Re: PGDOCS - add more links in the pub/sub reference pages
Previous Message Alexander Korotkov 2023-10-16 00:18:33 pgsql: Add support event triggers on authenticated login