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 1uewnP-00H0pU-OC for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jul 2025 14:19:44 +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 1uewnN-008JiC-Rk for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jul 2025 14:19:42 +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 1uewnN-008Ji4-I6 for pgsql-hackers@lists.postgresql.org; Thu, 24 Jul 2025 14:19:41 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uewnL-000Z7H-0j for pgsql-hackers@lists.postgresql.org; Thu, 24 Jul 2025 14:19:40 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 52643430BB; Thu, 24 Jul 2025 14:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgresfriends.org; s=gm1; t=1753366776; 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=QGzLsQFMy4B9yl8hHsTf9N34AQILEzD/IYmx93EbyZ8=; b=M/May5gHAoX/j6O+ZrVWMqHCe7laWQb9uFxRFpCerHXJ4UMTv6+3sosRq9+UqXGEMyiipi U5lZZ4e1AJ2zPlUkD0LxDviY7jTB3Gw1E6PQrrueZTf7c5dakRvURTNIMbq1RbAxx8cjo7 9e9MT/GAXfWIFwRITu5ZlQjF1kvXIAoyIxg20PpE+uafh1O0sv3HqSXxWnvFZk+Jb1+8P1 bQSgEeRdmahHA0rK8c0qe5k5fH9aH9bH8kNDoLeEbYKzSrAlxllLN7bW/ZE2glh19GKBK0 sSIdZNjn9Eicu6/ioKwk9Q9a3ZPRfNHNG9+WsIZoD+cEE2WTlAF3L/+9U17idg== Message-ID: Date: Thu, 24 Jul 2025 16:19:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Corey Huinker , Isaac Morland , pgsql-hackers@lists.postgresql.org References: <04afcd1f-ed7d-4c0a-add1-50e3719ccbf9@postgresfriends.org> <762ae707-7fdc-43d8-a77a-3a10d12ce21d@postgresfriends.org> 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: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdektdekjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeggihhkucfhvggrrhhinhhguceovhhikhesphhoshhtghhrvghsfhhrihgvnhgushdrohhrgheqnecuggftrfgrthhtvghrnhepuddtveefleegvddutdejhffhleehhfevheeilefhgeettdeuhfdtffegvdfgteffnecukfhppedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeduugduleemleehtgekmedulegrudemkeeikegvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddvmeekgedvkeemudduvgdtmedvjedtudemudguudelmeelhegtkeemudelrgdumeekieekvgdphhgvlhhopeglkffrggeimedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeduugduleemleehtgekmedulegrudemkeeikegvngdpmhgrihhlfhhrohhmpehvihhksehpohhsthhgrhgvshhfrhhivghnughsrdhorhhgpdhnsggprhgtphhtthhopeegpdhrtghpthhtohepjhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphhtthhopegtohhrvgihrdhhuhhinhhkvghrsehgmhgrihhlrdgtohhmpdhrt ghpthhtohepihhsrggrtgdrmhhorhhlrghnugesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 24/07/2025 15:44, jian he wrote: > just want to confirm my understanding of ``[ FORMAT ]``. > > SELECT CAST('2022-13-32' AS DATE FORMAT 'YYYY-MM-DD' DEFAULT NULL ON > CONVERSION ERROR); > will return NULL. > because ``SELECT to_date('2022-13-32', 'YYYY-MM-DD');`` > will error out, so the above query will fall back to the DEFAULT > expression evaluation. That is correct.  Any error produced during typecasting will fall back to the DEFAULT value.  If not supplied, the behavior is ERROR ON ERROR as it currently is. Any error produced while converting the DEFAULT value to the requested type is raised as an error. -- Vik Fearing