From: | Zhang Mingli <zmlpostgres(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Targetlist lost when CTE join <targetlist lost when CTE join> |
Date: | 2023-06-28 08:52:34 |
Message-ID: | 98c12b08-85bc-4464-80a5-f13955124223@Spark |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
Mini repo
create table t1(c1 int, c2 int);
CREATE TABLE
create table t2(c1 int, c2 int);
CREATE TABLE
explain with cte1 as (insert into t2 values (1, 2) returning *) select * from cte1 join t1 using(c1);
QUERY PLAN
----------------------------------------------------------------
Hash Join (cost=0.04..41.23 rows=11 width=12)
Hash Cond: (t1.c1 = cte1.c1)
CTE cte1
-> Insert on t2 (cost=0.00..0.01 rows=1 width=8)
-> Result (cost=0.00..0.01 rows=1 width=8)
-> Seq Scan on t1 (cost=0.00..32.60 rows=2260 width=8)
-> Hash (cost=0.02..0.02 rows=1 width=8)
-> CTE Scan on cte1 (cost=0.00..0.02 rows=1 width=8)
(8 rows)
with cte1 as (insert into t2 values (1, 2) returning *) select * from cte1 join t1 using(c1);
c1 | c2 | c2
----+----+----
(0 rows)
truncate t2;
TRUNCATE TABLE
with cte1 as (insert into t2 values (1, 2) returning *) select cte1.*, t1.* from cte1 join t1 using(c1);
c1 | c2 | c1 | c2
----+----+----+----
(0 rows)
Table t1 and t2 both has 2 columns: c1, c2, when CTE join select *, the result target list seems to lost one’s column c1.
But it looks good when select cte1.* and t1.* explicitly .
Is it a bug?
Regards,
Zhang Mingli
From | Date | Subject | |
---|---|---|---|
Next Message | Zhang Mingli | 2023-06-28 08:55:09 | Re: Targetlist lost when CTE join <targetlist lost when CTE join> |
Previous Message | Joel Jacobson | 2023-06-28 08:50:20 | Re: Do we want a hashset type? |