Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtAHu-0007Sa-1L for pgsql-general@arkaria.postgresql.org; Fri, 03 Dec 2021 15:15:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mtAHr-0007qW-Qh for pgsql-general@arkaria.postgresql.org; Fri, 03 Dec 2021 15:15:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtAHr-0007qM-G5 for pgsql-general@lists.postgresql.org; Fri, 03 Dec 2021 15:15:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtAHk-00028F-H7 for pgsql-general@lists.postgresql.org; Fri, 03 Dec 2021 15:15:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B3FFanK2292657; Fri, 3 Dec 2021 10:15:36 -0500 From: Tom Lane To: Sebastien Flaesch cc: pgsql-general Subject: Re: SUM() of INTERVAL type produces INTERVAL with no precision In-reply-to: References: Comments: In-reply-to Sebastien Flaesch message dated "Fri, 03 Dec 2021 11:05:16 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2292655.1638544536.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 03 Dec 2021 10:15:36 -0500 Message-ID: <2292656.1638544536@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sebastien Flaesch writes: > When doing a SUM( ) aggregate on an INTERVAL HOUR TO SECOND(0) column, t= he 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 c= ode that identifies the PQfmod() type, to properly interpret the string va= lue 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