Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1isTLN-0007DI-05 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jan 2020 15:15:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1isTLK-0004lt-MD for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jan 2020 15:15:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1isTLK-0004lm-Ad for pgsql-bugs@lists.postgresql.org; Fri, 17 Jan 2020 15:15:26 +0000 Received: from courriel.mines-paristech.fr ([77.158.173.149] helo=antispam-1.ensmp.fr) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1isTLD-00014U-9m for pgsql-bugs@lists.postgresql.org; Fri, 17 Jan 2020 15:15:24 +0000 Received: from smtp-4.mines-paristech.fr (smtp-4.ensmp.fr [77.158.173.143]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by antispam-1.ensmp.fr (antispam.mines-paristech.fr) with ESMTPS id 771D755FC9; Fri, 17 Jan 2020 16:15:16 +0100 (CET) Received: from pseudopolis-wln.cri.ensmp.fr (adsl.cri.pck.nerim.net [213.41.146.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-4.mines-paristech.fr (Postfix) with ESMTPSA id 31EA62C030E; Fri, 17 Jan 2020 16:15:16 +0100 (CET) Date: Fri, 17 Jan 2020 16:15:15 +0100 (CET) From: Fabien COELHO X-X-Sender: fabien@pseudo To: Tom Lane cc: szx9231@gmail.com, PostgreSQL Bugs Subject: Re: BUG #16216: the result of to_date function with negative year number not same as BC year number In-Reply-To: <26771.1579273182@sss.pgh.pa.us> Message-ID: References: <16216-68da08087f3aeb78@postgresql.org> <26771.1579273182@sss.pgh.pa.us> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2056645051-1869562713-1579274116=:31891" X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrtdejgdejfecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvffujgfkfhgfgggtsehmtderredtreelnecuhfhrohhmpefhrggsihgvnhcuvefqgffnjffquceotghovghlhhhosegtrhhirdgvnhhsmhhprdhfrheqnecukfhppedvudefrdeguddrudegiedrvddvfeenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2056645051-1869562713-1579274116=:31891 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT >> ISTM that the documentation does not say that -120 is supported as meaning >> BC. > > Indeed it does not. The behavior is "correct" in terms of our internals, > as you say, but I'm a bit distressed to find that we're exposing the > internals this much. I agree. > If we do anything about this, my vote would be to throw an error for > zero or negative year field. Yep, being stricter. > OTOH, the point of to_date is mostly not to throw an error, so maybe we > should leave it be. I'll think about it. >> BTW I found another oddity while trying strange date patterns: >> sql> SELECT DATE 'Jan 1, 0001 AD'; >> # 0001-01-01 >> But: >> sql> SELECT DATE 'Jan 1, 1 AD'; >> # 2001-01-01 # WT*? > > I'm pretty sure that's intentional; if you specify two or fewer > year digits, a year between 1970 and 2069 is presumed to be meant. Hmmm. Ok, I see. If I write a fuzzy "31/12/01", I'm pretty okay with 2001-12-31. but if I write '1 AD', I would expect '1 AD'. -- Fabien. --2056645051-1869562713-1579274116=:31891--