Alexander Lakhin <exclusion@gmail.com> writes: > Please look at the following query: > CREATE TABLE t(i int); > INSERT INTO t VALUES (1); > VACUUM ANALYZE t;
> WITH ir AS (INSERT INTO t VALUES (2) RETURNING i) > SELECT * FROM ir WHERE i = 2;
> which produces ERROR: no relation entry for relid 1 > starting from f7816aec2.
Nice catch.
Thanks for the report! I guess we need something like the attached.
+1.
I'm surprised that this hasn't been noticed before; was the case really unreachable before?
It seems that this case is only reachable with Vars of an INSERT target relation, and it seems that there is no other way to reference such a Var other than using CTE.