From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: mark.a.sloan@gmail.com
Subject: BUG #17243: explain wtih recursive cte error?
Date: Fri, 22 Oct 2021 00:49:41 +0000
Message-ID: <17243-45ee0e3a03063b9b@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 17243
Logged by: mark sloan
Email address: mark.a.sloan@gmail.com
PostgreSQL version: 14.0
Operating system: MacOS
Description:
Seeing a issue with 'EXPLAIN' throwing an error on a query that otherwise
runs without issue.
example query case.
---------------------------------------------
select x.v into explainctebug from (values('foo'),('bar'),('baz')) as
x(v);
query:
with recursive a as
(
select v, '' as x, 0 as n from explainctebug
union all
select v, substring(v,n+1,1) as x, n+1 as n from a where n < length(v)
)
select x, count(*) from a where n > 0
group by x order by count(*) desc;
returns.
x | count
---+-------
a | 2
b | 2
o | 2
r | 1
z | 1
f | 1
(6 rows)
--------
EXPLAIN verbose with recursive a as
(
select v, '' as x, 0 as n from explainctebug
union all
select v, substring(v,n+1,1) as x, n+1 as n from a where n < length(v)
)
select x, count(*) from a where n > 0
group by x order by count(*) desc ;
returns
QUERY PLAN
---------------------------------------------------------------------------------------
Sort (cost=5835.36..5835.86 rows=200 width=40)
Output: a.x, (count(*))
Sort Key: (count(*)) DESC
CTE a
-> Recursive Union (cost=0.00..4697.37 rows=46690 width=68)
-> Seq Scan on public.explainctebug (cost=0.00..23.60 rows=1360
width=68)
Output: explainctebug.v, ''::text, 0
-> WorkTable Scan on a a_1 (cost=0.00..374.00 rows=4533
width=68)
Output: a_1.v, "substring"(a_1.v, (a_1.n + 1), 1), (a_1.n +
1)
Filter: (a_1.n < length(a_1.v))
-> HashAggregate (cost=1128.34..1130.34 rows=200 width=40)
Output: a.x, count(*)
Group Key: a.x
-> CTE Scan on a (cost=0.00..1050.52 rows=15563 width=32)
Output: a.v, a.x, a.n
Filter: (a.n > 0)
(16 rows)
EXPLAIN with recursive a as
(
select v, '' as x, 0 as n from explainctebug
union all
select v, substring(v,n+1,1) as x, n+1 as n from a where n < length(v)
)
select x, count(*) from a where n > 0
group by x order by count(*) desc ;
returns.
ERROR: could not find RecursiveUnion for WorkTableScan with wtParam 0
this seems like it might be a bug?
PostgreSQL 14.0 on x86_64-apple-darwin20.6.0, compiled by Apple clang
version 13.0.0 (clang-1300.0.29.3), 64-bit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, mark.a.sloan@gmail.com
Subject: Re: BUG #17243: explain wtih recursive cte error?
In-Reply-To: <17243-45ee0e3a03063b9b@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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