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 1wFowC-005aaK-2M for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Apr 2026 07:57:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFowB-000Zku-3D for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Apr 2026 07:57:28 +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 1wFowB-000ZkR-2N for pgsql-bugs@lists.postgresql.org; Thu, 23 Apr 2026 07:57:27 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFow9-00000002NpM-10P9 for pgsql-bugs@lists.postgresql.org; Thu, 23 Apr 2026 07:57:26 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 60CEC14000A9; Thu, 23 Apr 2026 03:57:24 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 23 Apr 2026 03:57:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc: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=fm2; t=1776931044; x=1777017444; bh=z6SbtWQYA6 CaonREr4f09ARju1/bsIgPDeq20Jigoes=; b=mAkqfZzb5KJnmQxAIHIj2tpcAM 66yBhlqlE/YwUroy2DVqfS0YsFFHqn81vAuujmPrJhKfXHsHL+WpNpdf+KWlRQr8 8apQBKF5TJfoM/zegU0ce9lP1SXlMjzo9zuIG2qWTGkYugc8JrItrht0dQ8ySTBH 2pGiYEq981WVR+iMIipbxjZtWGiQBjg1ZTlf3CIq0WcyLejnIsj0Qa/x/lzLK12Z aZ6+ud8/QTIJU+leqDKXr8lD1ZGEX5ZD0swgqDvuDQixy7jp4rNEWoqDaT+A4QkO YBThzf0qq3JQKd7YLtrHRM9reqYBSUIRNL3DGCAhTG6V0+H09qAGOiyhs1aQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= 1776931044; x=1777017444; bh=z6SbtWQYA6CaonREr4f09ARju1/bsIgPDeq 20Jigoes=; b=AcYji/l+irhnEBYMW9Qq4UYUGCXLhKkzBbxu+aPw5cD9lH7acVE /ZaBQ3nMdjm1/PyGOUP51COjUqSLR19Fnlt2uS1zJeXLwUwbJue6+PAWXokrT7c5 U9keIMoTVaqh/x45Y8Mn+Ff/UCr6wLlSOwxiiMpcthAuoWyNnMlYBbe8dr1YwHrW aOyeM8ZFPn+kS1hfRaweDRqv7LnlwOkQytn4JbxREgUbH8eilrGqX4yj5umi7LsV ocpqKPjx/6eP+8ywkSwsxlwlPUl3ccPzvan0Ltg7V5wDtJvyJ+AIa8k+Oqb3RTMe UXe8NnsNpfzwX0oJRxXkMitLKlKoWdIzkGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeiieeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe etleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvg hlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopegrhihushhhthhifigrrhhirdhslhhgtddusehgmhgrihhlrd gtohhmpdhrtghpthhtohepphhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgv shhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Apr 2026 03:57:23 -0400 (EDT) Date: Thu, 23 Apr 2026 16:57:19 +0900 From: Michael Paquier To: Ayush Tiwari Cc: pgsql-bugs@lists.postgresql.org Subject: Re: to_date()/to_timestamp() silently accept month=0 and day=0 Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HlIKK0q25Kt6Z2yN" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --HlIKK0q25Kt6Z2yN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 22, 2026 at 07:48:00PM +0530, Ayush Tiwari wrote: > Inputs with month =3D 00 or day =3D 00 are accepted silently and normaliz= ed to > January / day 1, instead of being rejected as out of range. >=20 > Simple repro steps: >=20 > SELECT to_date('2024-00-15', 'YYYY-MM-DD'); > SELECT to_date('2024-01-00', 'YYYY-MM-DD'); > SELECT to_timestamp('2024-00-15', 'YYYY-MM-DD'); > SELECT to_timestamp('2024-01-00', 'YYYY-MM-DD'); >=20 > Observed results here: >=20 > to_date('2024-00-15', 'YYYY-MM-DD') -> 2024-01-15 > to_date('2024-01-00', 'YYYY-MM-DD') -> 2024-01-01 > to_timestamp('2024-00-15', 'YYYY-MM-DD') -> 2024-01-15 00:00:00+05:30 > to_timestamp('2024-01-00', 'YYYY-MM-DD') -> 2024-01-01 00:00:00+05:30 >=20 > I would expect all four calls to error, similar to how an invalid date > literal is rejected. While I agree with your feeling that it would be less confusing if these patterns are rejected, throwing an error could also mean an impact on existing applications that relied on the existing historical behavior of replacing these zeroes defined in input, where they'd expect a 01. So that would be a silent behavior change introduced in a minor release. 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. Any thoughts or opinions from others? -- Michael --HlIKK0q25Kt6Z2yN Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnp0N4ACgkQnvQgOdby QH0EPQ/9FzSqn6b9kwn/acTjK0oLB7sapxvc0gozZl6CMaNJN8of/KSg55StJ39R c0wr3VxznP5f+ejAKSPRdlH992LEjUXWSqNDQ88drkNxHIz0+Cfw96liOWUeLlZR zFDAGOub/403ecFs/w0theD8qVKblhm4Ml2LYdYka2vcUsDSBqLQrlhuBPIqx5i9 gL4juB11PjaWYC0UAbHQ+JaLcHCkO55xFw04SyYBtj+zPjqtgIXDScmONs0Vp0lA fmWxMqtlvxAMx1TpzjAWGUX6CTsyGgzE7J8Jro3JVUdHAvoa//MWyOgKfNCuObLI PhmyOYRCiSvsKO8Dr0buQpBIVOycpcRPKJmhOshCJhQ85Lt9TvUt4RTL/hNWsPhq ZKjnZQIXOkcfmBsgdyx1gDhdNufJMRrZGgkyPet62GoZ8kvJ19RaIeI9s3OS6zT0 hhK2BBzKFIW2v6drTp9dCFFZUjq0Ybd8luHuB5OwHV3949Pa3dDwaKQPgp7Anyu+ AkMXvj/FybRCfvm5CMZpWI7R0dfYpkhZXI2pFJ4HszuayA7PGvUxy4cTA9z7U0Ak kwjqxJIxB9uoyTOiT2fUnuDHgNOlchT9MowNBKuvIPdWSNnsXvCdTkdpWQ3tsPmu E5qB113DPIfOVCT0nmja4SEXuWW74TFTNJ3ayJJEDkch8DhlspA= =KUHg -----END PGP SIGNATURE----- --HlIKK0q25Kt6Z2yN--