Is this temp table behaviour documented?
-
02-11-2019 - |
题
Query Language (SQL) and PL/pgSQL functions treat temp tables differently:
begin;
create table foo(id) as values (1);
select * from foo;
/*
id
----
1
*/
savepoint s;
create function f() returns setof integer language sql as $$
create temporary table foo(id) on commit drop as values (2);
select id from foo;
$$;
select * from f();
/*
f
---
1
*/
rollback to s;
create function f() returns setof integer language plpgsql as $$
begin
create temporary table foo(id) on commit drop as values (2);
return query select id from foo;
end;
$$;
select * from f();
/*
f
---
2
*/
rollback;
The docs say:
...Existing permanent tables with the same name are not visible to the current session while the temporary table exists, unless they are referenced with schema-qualified names...
This does not mention the exception demonstrated above. Is this documented elsewhere?
没有正确的解决方案
不隶属于 dba.stackexchange