pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15777: Unexpected error in select from view with set-returning function and union
2+ messages / 2 participants
[nested] [flat]
* BUG #15777: Unexpected error in select from view with set-returning function and union
@ 2019-04-24 13:13 PG Bug reporting form <noreply@postgresql.org>
2019-04-24 13:46 ` Re: BUG #15777: Unexpected error in select from view with set-returning function and union Sergei Kornilov <sk@zsrv.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2019-04-24 13:13 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: svfront@mail.ru
The following bug has been logged on the website:
Bug reference: 15777
Logged by: Danil Mihailov
Email address: svfront@mail.ru
PostgreSQL version: 11.2
Operating system: Debian 9.8
Description:
uname -a
Linux bnode-test 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64
GNU/Linux
Test stand:
CREATE TABLE public.test_dummy
(
a integer[],
b integer[]
);
CREATE OR REPLACE VIEW public.test_dummy_view AS
SELECT unnest(test_dummy.a) AS id,
'a'::text AS c
FROM test_dummy
WHERE test_dummy.a IS NOT NULL
UNION
SELECT unnest(test_dummy.b) AS id,
'b'::text AS c
FROM test_dummy
WHERE test_dummy.b IS NOT NULL;
INSERT INTO test_dummy(a, b)
VALUES
(ARRAY[1,2], null),
(null, ARRAY[3,4]);
Test case:
SELECT id, c FROM test_dummy_view; -- works fine
SELECT id, c FROM test_dummy_view WHERE c = 'a'; -- error
Verbose log message:
2019-04-24 15:59:42.143 MSK [112107] danila@inetstat ОШИБКА: 0A000:
функция, возвращающая множество, вызвана в контексте, где ему нет места
2019-04-24 15:59:42.143 MSK [112107] danila@inetstat ПОЛОЖЕНИЕ:
ExecInitFunc, execExpr.c:2212
2019-04-24 15:59:42.143 MSK [112107] danila@inetstat ОПЕРАТОР: SELECT id, c
FROM test_dummy_view WHERE c = 'a';
Translation:
set-valued function called in context that cannot accept a set
But:
WITH foo AS (
SELECT unnest(a) AS id, 'a' AS c
FROM test_dummy WHERE a IS NOT NULL
UNION
SELECT unnest(b) AS id, 'b' AS c
FROM test_dummy WHERE b IS NOT NULL
)
SELECT * FROM foo WHERE c = 'a'; -- works fine
Also workaround with LATERAL in view works too;
In Postgres 9.6 all queries work as expected.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15777: Unexpected error in select from view with set-returning function and union
2019-04-24 13:13 BUG #15777: Unexpected error in select from view with set-returning function and union PG Bug reporting form <noreply@postgresql.org>
@ 2019-04-24 13:46 ` Sergei Kornilov <sk@zsrv.org>
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Kornilov @ 2019-04-24 13:46 UTC (permalink / raw)
To: svfront@mail.ru <svfront@mail.ru>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hello
Thank you for report!
I reproduced this bug in REL_11_2, but not in REL_11_STABLE. Seems already fixed in stable branch by commit https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=925f46ffb82f0b25c94e7997caff732ea... and therefore will be shipped in next minor update 11.3 (scheduled for May 9).
regards, Sergei
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-04-24 13:46 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 13:13 BUG #15777: Unexpected error in select from view with set-returning function and union PG Bug reporting form <noreply@postgresql.org>
2019-04-24 13:46 ` Sergei Kornilov <sk@zsrv.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox