pg_attribute.atttypmod for interval type - Mailing list pgsql-hackers

From Greg Rychlewski
Subject pg_attribute.atttypmod for interval type
Date
Msg-id CAKemG7WDAwJ0PqeB=EfYyY_LmdCw_h17zbormNedG6455cGiuA@mail.gmail.com
Whole thread Raw
Responses Re: pg_attribute.atttypmod for interval type
List pgsql-hackers
Hi,

I work on a driver for Postgres that utilizes the extended query protocol and have a question about the row description message for interval types.

I am trying to use the type modifier value from the message to determine the precision of the interval. This is something I can do for timestamp types because the type modifier in the message is equal to the precision (or -1 if not specified).

For interval types it seems like the type modifier is related to the precision but the values are not equal. Using Postgres 13.10 I see the following values for pg_attribute.attttypmod when creating columns of type interval(1), interval(2), ..., interval(6)

 2147418113

 2147418114

 2147418115

 2147418116

 2147418117

 2147418118


I can see the value goes up by 1 each time the precision is increased, but I'm not sure how to interpret the fact that it starts at  2147418113 instead of 1.


My question is: how are the values meant to be interpreted for interval types? Thanks very much for your help.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_upgrade failing for 200+ million Large Objects
Next
From: Tom Lane
Date:
Subject: Re: pg_attribute.atttypmod for interval type