BUG #19428: Lazy evaluation of type checking in CASE in SQL functions including subqueries no longer works in 18
| От | PG Bug reporting form |
|---|---|
| Тема | BUG #19428: Lazy evaluation of type checking in CASE in SQL functions including subqueries no longer works in 18 |
| Дата | |
| Msg-id | 19428-d9ac6c4d84c0bc81@postgresql.org обсуждение исходный текст |
| Ответы |
Re: BUG #19428: Lazy evaluation of type checking in CASE in SQL functions including subqueries no longer works in 18
|
| Список | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19428
Logged by: Michael Banck
Email address: michael.banck@credativ.de
PostgreSQL version: 18.3
Operating system: n/a
Description:
A colleague has complained to me that the following (minimal reproducer he
could come up with) worked on pre-18, but no longer does on 18:
SELECT 'hello world' AS arg INTO data;
SELECT NULL AS selector INTO selectors;
CREATE OR REPLACE FUNCTION func(name anyelement)
RETURNS anyelement
LANGUAGE sql
STABLE STRICT
AS $function$
SELECT CASE
WHEN selector IS NULL THEN $1::text
ELSE $1::inet::text
END
FROM (SELECT selector FROM selectors)
$function$;
SELECT func(arg) FROM data;
On 17 or earlier, you get:
func
---------------------------
selector:foo(hello world)
(1 row)
func
---------------------------
selector:bar(hello world)
(1 row)
func
-------------
hello world
(1 row)
on 18 you get:
ERROR: invalid input syntax for type inet: "hello world"
CONTEXT: SQL function "func" statement 1
STATEMENT: SELECT func(arg) FROM data;
I bisected this to 0dca5d68d7b. Looks like they depend on lazy evaluation in
CASE via the subquery to check if the second argument is a valid inet, which
no longer works after 0dca5d68d7b. Is that an intended change?
В списке pgsql-bugs по дате отправления: