Re: SUM() of INTERVAL type produces INTERVAL with no precision

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: SUM() of INTERVAL type produces INTERVAL with no precision
Date: 2021-12-03 15:15:36
Message-ID: 2292656.1638544536@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com> writes:
> When doing a SUM( ) aggregate on an INTERVAL HOUR TO SECOND(0) column, the resulting type loses the interval type qualifiers...

We don't generally attribute a typmod (which is what interval field
specs are) to the output of any function, other than the ones that are
specifically identified in the catalogs as cast-to-a-particular-typmod
infrastructure. Why do you care? The value is the same regardless.

> The type of a SELECT item is important to us because we have generic C code that identifies the PQfmod() type, to properly interpret the string value returned by PQgetvalue().

I think you have vastly overestimated the value of PQfmod. Moreover,
if you think you need it to interpret the output data, you are mistaken.
There is no situation in which Postgres output formats are
typmod-specific; in fact, the output function API doesn't even pass
the typmod.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-12-03 15:32:03 Re: Max connections reached without max connections reached
Previous Message Achilleas Mantzios 2021-12-03 12:35:55 Re: Require details that how to find user creation date in postgresql Database