pg_attribute.atttypmod for interval type

From: Greg Rychlewski <greg(dot)rychlewski(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: pg_attribute.atttypmod for interval type
Date: 2024-07-27 03:57:24
Message-ID: CAKemG7WDAwJ0PqeB=EfYyY_LmdCw_h17zbormNedG6455cGiuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-07-27 04:32:25 Re: pg_attribute.atttypmod for interval type
Previous Message Tom Lane 2024-07-27 03:08:06 Re: pg_upgrade failing for 200+ million Large Objects