Re: Clarify: default precision on timestamps is 6 - Mailing list pgsql-docs

From Tom Lane
Subject Re: Clarify: default precision on timestamps is 6
Date
Msg-id 1571601.1697229473@sss.pgh.pa.us
Whole thread Raw
In response to Re: Clarify: default precision on timestamps is 6  (Kirk Parker <khp@equatoria.us>)
List pgsql-docs
Kirk Parker <khp@equatoria.us> writes:
> On Fri, Oct 13, 2023 at 7:32 AM David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>> That is precisely what a no default with maximum of six means.  If we say
>> the default is six that would imply storage of less precise values pads
>> significant zeros until there are six.

> Not sure that last statement is correct.  In 13 (only system I have access
> to at the moment) it doesn't look like casting to a precision greater than
> the value originally had causes any padding:

The timestamp types don't have any explicit notion of precision
(unlike, say, numeric).  The stored value is an integer number of
microseconds, nothing else.  I've not checked the output function
recently but it makes sense to me that it'd just drop trailing
zeroes from the display, independently of any claimed precision
for the column.  Meanwhile, when casting a timestamp value to
a declared precision, we handle that by just rounding off the
microseconds count.  This doesn't buy any space savings or anything
like that, it's just for pro-forma compliance with the spec.

I don't see anything particularly wrong with the existing docs.
The limitation to 1-microsecond precision is spelled out in the
table just above the para you quote.

            regards, tom lane



pgsql-docs by date:

Previous
From: Daniel Fredouille
Date:
Subject: Re: unnest multirange, returned order
Next
From: Tomas Pospisek
Date:
Subject: Re: Make SSPI documentation clearer