Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1EV0-00FI7c-Sr for pgsql-general@arkaria.postgresql.org; Thu, 17 Oct 2024 00:36:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t1EUy-00DCpI-MJ for pgsql-general@arkaria.postgresql.org; Thu, 17 Oct 2024 00:36:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1EUy-00DCp9-Bf for pgsql-general@lists.postgresql.org; Thu, 17 Oct 2024 00:36:16 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1EUw-001RdN-CM for pgsql-general@lists.postgresql.org; Thu, 17 Oct 2024 00:36:16 +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 49H0aC8H505769; Wed, 16 Oct 2024 20:36:12 -0400 From: Tom Lane To: David Rowley cc: "Richards, Nina" , "Watzinger, Alexander" , "pgsql-general@lists.postgresql.org" Subject: Re: Support for dates before 4713 BC In-reply-to: References: <0af9ebc00dca444cbd3c5e07752bc5f9@oeaw.ac.at> Comments: In-reply-to David Rowley message dated "Thu, 17 Oct 2024 13:17:01 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <505767.1729125372.1@sss.pgh.pa.us> Date: Wed, 16 Oct 2024 20:36:12 -0400 Message-ID: <505768.1729125372@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > It's by no means a trivial thing to do, but it is possible to > implement new types in PostgreSQL [1]. If you invented your own type, > you could significantly widen the upper and lower bounds when compared > with the standard date type. However, you'd then have to reimplement some large fraction of the existing datetime support to have something useful. We're already inventing freely to use the Gregorian calendar for millenia before Pope Gregory lived, so I see no conceptual argument not to extend that back even further. IIRC the stumbling block for not going back past Julian day 0 was uncertainty about whether the date2j and j2date algorithms behave correctly for negative Julian dates --- which at the time was compounded by the fact that C90 was vague about the rounding direction for integer division with negative inputs. Now that we assume C99 with its well-defined rule for that, at least some of the uncertainty is gone. Somebody would still have to study that code and either prove that it's OK or correct it. And then there would be a nontrivial amount of effort to work outwards and fix anything else that is assuming that limitation. So it would take somebody with considerable motivation to make it happen, but if such a somebody were to appear with a patch, we'd likely take it. (To be clear, I doubt any of the principal current hackers are interested in doing this.) Now, this would still only get you to a lower-bound date somewhere around 300000 BC. If you need to deal with geological or astronomical time spans, then yeah you need a new type --- but presumably you would not feel a need to tie it to Gregorian calendar dates, so the need to reimplement a ton of related logic would not be there. regards, tom lane