PL/pgSQL THEN binging in condition
От | PetSerAl |
---|---|
Тема | PL/pgSQL THEN binging in condition |
Дата | |
Msg-id | CAKygsHSpPYjBuh=02bdwSHMSa2RZwwn7fxUKirGYB67SMj1Sbg@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: PL/pgSQL THEN binging in condition
|
Список | pgsql-bugs |
postgres=# SELECT version();
version
------------------------------------------------------------
PostgreSQL 16.4, compiled by Visual C++ build 1940, 64-bit
(1 row)
postgres=# DO $$
postgres$# BEGIN
postgres$# IF
postgres$# CASE
postgres$# WHEN TRUE
postgres$# THEN TRUE
postgres$# END
postgres$# THEN
postgres$# NULL;
postgres$# END IF;
postgres$# END
postgres$# $$;
ERROR: syntax error at end of input
LINE 5: WHEN TRUE
^
version
------------------------------------------------------------
PostgreSQL 16.4, compiled by Visual C++ build 1940, 64-bit
(1 row)
postgres=# DO $$
postgres$# BEGIN
postgres$# IF
postgres$# CASE
postgres$# WHEN TRUE
postgres$# THEN TRUE
postgres$# END
postgres$# THEN
postgres$# NULL;
postgres$# END IF;
postgres$# END
postgres$# $$;
ERROR: syntax error at end of input
LINE 5: WHEN TRUE
^
It seems error here because first THEN bound to IF statement rather than CASE expression. Workaround here would be using parenthesis:
postgres=# DO $$
postgres$# BEGIN
postgres$# IF
postgres$# (CASE
postgres$# WHEN TRUE
postgres$# THEN TRUE
postgres$# END)
postgres$# THEN
postgres$# NULL;
postgres$# END IF;
postgres$# END
postgres$# $$;
DO
postgres$# BEGIN
postgres$# IF
postgres$# (CASE
postgres$# WHEN TRUE
postgres$# THEN TRUE
postgres$# END)
postgres$# THEN
postgres$# NULL;
postgres$# END IF;
postgres$# END
postgres$# $$;
DO
If behavior can not be changed for compatibility reasons, it at least can use better error message.
В списке pgsql-bugs по дате отправления: