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 1tkpLJ-0077wr-9C for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Feb 2025 19:02:45 +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 1tkpLH-00CPCU-MA for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Feb 2025 19:02:43 +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.94.2) (envelope-from ) id 1tkpLH-00CPCK-AA for pgsql-bugs@lists.postgresql.org; Wed, 19 Feb 2025 19:02:43 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tkpLD-001lGR-30 for pgsql-bugs@lists.postgresql.org; Wed, 19 Feb 2025 19:02:41 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5D79644240; Wed, 19 Feb 2025 19:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgresfriends.org; s=gm1; t=1739991756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N/u+Dc4ZKOzKkEQCBOQPZwFgPCFydvacE0CbsLGdtQk=; b=Dv2XD3JrKkUaR7AkqpW+t9gxjtbuaRAfjtlhbFTGKmrbdb1jROZmvELOu1FvJZjYjtR0n6 ywroWDQlBQq7W0BeErWxwGizzTX1hikGtrnUG5B8WxOKMMap8+S3saxGWIlE7yE5KryJ7z h8+YaatQX6ubMsdvpY4v9LH2M1EWofjq9209czlt4Ejq8BHghI7vLMJzcVY397f9ffz8iJ YQfKeszN92fP+kWDZAM+LKQFl9xxnJM/+uW/A5sEOYJVVPqU8jy5Rwe1Rd6Yc2jlPClUuL Yn17cXYC913OSPDJ/t9IkFkSaqHeyqwbHywjr7f5+gUlS8qJ4fwyj5cTaejVew== Message-ID: Date: Wed, 19 Feb 2025 20:02:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE To: Chris BSomething , Tom Lane Cc: "David G. Johnston" , PostgreSQL Bug List References: <18594-af265c6988d431d8@postgresql.org> <0838f16a-8b3d-4c39-9ad8-5d27791e9dec@dunslane.net> <3501446.1724890288@sss.pgh.pa.us> <1149960.1739844738@sss.pgh.pa.us> Content-Language: en-US From: Vik Fearing In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeihedthecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeggihhkucfhvggrrhhinhhguceovhhikhesphhoshhtghhrvghsfhhrihgvnhgushdrohhrgheqnecuggftrfgrthhtvghrnhepuddtveefleegvddutdejhffhleehhfevheeilefhgeettdeuhfdtffegvdfgteffnecukfhppedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeeghegvkeemvdgssgeimeehtgeludemughftgegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddvmeekgedvkeemudduvgdtmedvjedtudemgeehvgekmedvsggsieemhegtledumegufhgtgedphhgvlhhopeglkffrggeimedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeeghegvkeemvdgssgeimeehtgeludemughftgegngdpmhgrihhlfhhrohhmpehvihhksehpohhsthhgrhgvshhfrhhivghnughsrdhorhhgpdhnsggprhgtphhtthhopeegpdhrtghpthhtohepgihpuhhsohhsthhomhhoshesghhmrghilhdrtghomhdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtghpthhtohepuggrvhhiugdrg hdrjhhohhhnshhtohhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 19/02/2025 13:50, Chris BSomething wrote: > > On Tue, 18 Feb 2025 at 10:12, Tom Lane wrote: > > I think such a rule would be pretty dangerous, even if we could > implement it easily.  As an example, if you entered something you > meant as a timestamp, but you fat-fingered the punctuation or > something, it'd likely fall back to being considered just "text", > > > I don't get that, I thought timestamps have to be preceded by "TIMESTAMP". The SQL standard requires you to do that, but PostgreSQL is a bit more lax about it (and in my humble opinion, thankfully so). If you did prefix your literals with their type, you wouldn't be having these problems in the first place. The problem stems from postgres treating your unmarked literal as "unknown" and then trying to figure out what the heck it is. -- Vik Fearing