Re: interval_scale not work as expected? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: interval_scale not work as expected?
Date
Msg-id 2170251.1697416123@sss.pgh.pa.us
Whole thread Raw
In response to interval_scale not work as expected?  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
jian he <jian.universality@gmail.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



pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: interval_scale not work as expected?
Next
From: Peter Smith
Date:
Subject: Re: PGDOCS - add more links in the pub/sub reference pages