Re: [Proposal] Global temporary tables
曾文旌 (义从) <wenjing.zwj@alibaba-inc.com>
From: 曾文旌(义从) <wenjing.zwj@alibaba-inc.com>
To: Prabhat Sahu <prabhat.sahu@enterprisedb.com>
Cc: "tushar" <tushar.ahuja@enterprisedb.com>, "Pavel Stehule" <pavel.stehule@gmail.com>, "Robert Haas" <robertmhaas@gmail.com>, "Tomas Vondra" <tomas.vondra@2ndquadrant.com>, "Konstantin Knizhnik" <k.knizhnik@postgrespro.ru>, "PostgreSQL Hackers" <pgsql-hackers@postgresql.org>, 蔡松露(子嘉) <zijia@taobao.com>, Cai, Le <le.cai@alibaba-inc.com>, 萧少聪(铁庵) <shaocong.xsc@alibaba-inc.com>
Date: 2020-03-16T08:05:32Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
PageAddItemExtended(): Add LP_UNUSED assertion.
- 30aaab26e521 14.0 cited
-
Remove temporary files after backend crash
- cd91de0d1795 14.0 cited
-
Fix comment in indexing.c
- 9fd2952cf492 14.0 cited
-
Fix failure to ignore leftover temp tables after a server crash.
- 6919b7e32947 9.3.0 cited
> 2020年3月16日 下午2:23,Prabhat Sahu <prabhat.sahu@enterprisedb.com> 写道:
>
> Hi Wenjing,
> Please check the below scenario, where the Foreign table on GTT not showing records.
>
> postgres=# create extension postgres_fdw;
> CREATE EXTENSION
> postgres=# do $d$
> begin
> execute $$create server fdw foreign data wrapper postgres_fdw options (host 'localhost',dbname 'postgres',port '$$||current_setting('port')||$$')$$;
> end;
> $d$;
> DO
> postgres=# create user mapping for public server fdw;
> CREATE USER MAPPING
>
> postgres=# create table lt1 (c1 integer, c2 varchar(50));
> CREATE TABLE
> postgres=# insert into lt1 values (1,'c21');
> INSERT 0 1
> postgres=# create foreign table ft1 (c1 integer, c2 varchar(50)) server fdw options (table_name 'lt1');
> CREATE FOREIGN TABLE
> postgres=# select * from ft1;
> c1 | c2
> ----+-----
> 1 | c21
> (1 row)
>
> postgres=# create global temporary table gtt1 (c1 integer, c2 varchar(50));
> CREATE TABLE
> postgres=# insert into gtt1 values (1,'gtt_c21');
> INSERT 0 1
> postgres=# create foreign table f_gtt1 (c1 integer, c2 varchar(50)) server fdw options (table_name 'gtt1');
> CREATE FOREIGN TABLE
>
> postgres=# select * from gtt1;
> c1 | c2
> ----+---------
> 1 | gtt_c21
> (1 row)
>
> postgres=# select * from f_gtt1;
> c1 | c2
> ----+----
> (0 rows)
>
> --
I understand that postgre_fdw works similar to dblink.
postgre_fdw access to the table requires a new connection.
The data in the GTT table is empty in the newly established connection.
Because GTT shares structure but not data between connections.
Try local temp table:
create temporary table ltt1 (c1 integer, c2 varchar(50));
insert into ltt1 values (1,'gtt_c21');
create foreign table f_ltt1 (c1 integer, c2 varchar(50)) server fdw options (table_name 'ltt1');
select * from ltt1;
c1 | c2
----+---------
1 | gtt_c21
(1 row)
select * from l_gtt1;
ERROR: relation "l_gtt1" does not exist
LINE 1: select * from l_gtt1;
Wenjing
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com <http://www.enterprisedb.com/>