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 1jdG9Y-0007fX-9i for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2020 16:40:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jdG9W-0000w3-L5 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2020 16:40:38 +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 1jdG9W-0000vw-Do for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2020 16:40:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdG9T-0002W7-TD for pgsql-hackers@postgresql.org; Mon, 25 May 2020 16:40:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 04PGeRGE005753; Mon, 25 May 2020 12:40:27 -0400 From: Tom Lane To: Vik Fearing cc: Peter Eisentraut , Thomas Munro , Petr Fedorov , pgsql-hackers Subject: Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch In-reply-to: <9a680979-ad76-4c3b-1bc0-403152cf49dc@postgresfriends.org> References: <42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu> <18389.1575241151@sss.pgh.pa.us> <1c2262e2-6812-7baa-cbdd-63039db12952@phystech.edu> <9a680979-ad76-4c3b-1bc0-403152cf49dc@postgresfriends.org> Comments: In-reply-to Vik Fearing message dated "Mon, 25 May 2020 18:01:07 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5751.1590424827.1@sss.pgh.pa.us> Date: Mon, 25 May 2020 12:40:27 -0400 Message-ID: <5752.1590424827@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Vik Fearing writes: > On 5/25/20 3:28 PM, Peter Eisentraut wrote: >> I looked into this (changing the return types of date_part()/extract() >> from float8 to numeric). > I think what would be better is to have a specific date_part function > for each part and have extract translate to the appropriate one. Doesn't really work for upwards compatibility with existing views, which will have calls to date_part(text, ...) embedded in them. Actually, now that I think about it, changing the result type of date_part() is likely to be problematic anyway for such cases. It's not going to be good if pg_upgrade's dump/restore of a view results in a new output column type; especially if it's a materialized view. So maybe what we'd have to do is leave date_part() alone for legacy compatibility, and invent new functions that the extract() syntax would now be translated to. While at it, maybe we could fix things so that the syntax reverse-lists the same way instead of injecting Postgres-isms... regards, tom lane