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.96) (envelope-from ) id 1wGIfG-0065Hb-0V for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Apr 2026 15:41:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGIfE-006zVS-3B for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Apr 2026 15:41:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wGIfE-006zVH-0r for pgsql-bugs@lists.postgresql.org; Fri, 24 Apr 2026 15:41:56 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wGIfB-00000002b1N-3wlQ for pgsql-bugs@lists.postgresql.org; Fri, 24 Apr 2026 15:41:55 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 0FA2CEC0513; Fri, 24 Apr 2026 11:41:53 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 24 Apr 2026 11:41:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1777045313; x=1777131713; bh=pvfBmOj3U8lnjcU7jJQnjLhxnvKfL2K4 J672kTm8v7w=; b=AI+eLDGuBFKp16Ng+g66WJR/rCO2eYuvKAqPNHHl4exjix0g v5iIMAPfvsfaAtsNytQkkz3SBWvrOOnVmqbgLlLNaA27wGi9udBEU1knzVxchgLc eJL+X3i3x3iQ4MBADDeN2XK0lyrxcZcHAQR+EQI8nlPx2XBfJc0BHMD/ASM6UzFz WrDK09ztpRLhbJ0sHKZUkkgLmoog889j2S8lhoz6atn+oBvpwGU6+jHuAgwNsfeh yRAINZveLKEITcgsR3PpAoO1V0vv3J9+UhB+QDtGHBiZPkHA+0OiCISqItyfO6U2 CPy/2KTrvZvZqdAO1Dpv+44yEpcCJKHb6sWaUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1777045313; x= 1777131713; bh=pvfBmOj3U8lnjcU7jJQnjLhxnvKfL2K4J672kTm8v7w=; b=S 2UEixc+aT68HCnYUahahaxi5RUhekOXy6GMeDLZFoRabiY4LmLR/jvhIM+N9qHjB +kNn18gdyftFLd8FCtZheXQ6xbVODtLP4aq/FNdMYQBtO2n5VAlz4xN+n/l4L1iC B64mfcX/X/TjDRGHlYTsbbe8uj8H0js1iy0TBlpMMlg0BZIMtYei06xZjImtIEnN L3luLvqMGapIVJm5YpniPPvQ4m4zGB/cdfDdxY4rPBUhAz9X50cm6dCBWUwuP+Jr 6H4oHeG+h6kyl4HKd3wRMnyIgPmjvc/YiGHP+OqwKBjEKu8pkzv9j3sAwt6eBWwK SRtyECAjQdiaNKcesheAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdejtdegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgvrhcu gfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenuc ggtffrrghtthgvrhhnpefgjedthfekfedtuefgieelheetleejgefhueeltdfhueetvdff udekfeejhfegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohep hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthhglhesshhsshdrphhghhdrph grrdhushdprhgtphhtthhopegurghnihgvlheshigvshhqlhdrshgvpdhrtghpthhtohep mhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidprhgtphhtthhopegrhihushhhthhifi grrhhirdhslhhgtddusehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqsghu ghhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Apr 2026 11:41:51 -0400 (EDT) Message-ID: Date: Fri, 24 Apr 2026 17:41:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: to_date()/to_timestamp() silently accept month=0 and day=0 To: Tom Lane , Daniel Gustafsson Cc: Michael Paquier , Ayush Tiwari , pgsql-bugs@lists.postgresql.org References: <1444609.1776958814@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <1444609.1776958814@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 23.04.26 17:40, Tom Lane wrote: > Daniel Gustafsson writes: >>> On 23 Apr 2026, at 09:57, Michael Paquier wrote: >>> Perhaps we could consider strengthening such inputs on HEAD once v20 >>> opens for business? It would be really a scary thing to backpatch, >>> still a major release is a different thing. > >> This could definitely not be backpatched IMO, a quick check in v14 shows the >> same behaviour. The gregorian calendar goes from BC1 to AD1 and does not >> define a year 0, to_date('0000','YYYY') correctly returns year 0001, handling >> months/days in the same way at least makes it consistent (though I didn't scour >> the archives to see if it was intentionally done like that). > > Looking at the code, I think it intentionally interprets zero as > "missing data". See for example the stanza at formatting.c:4650ff > where tm_mon and tm_mday can be backfilled from a DDD field. > > I'm disinclined to change the behavior around this; you're far > more likely to get complaints than kudos. Complaints from whom? Oracle rejects these, and PostgreSQL generally also rejects these dates/times in other contexts. I think this should be rejected.