Re: [Proposal] Global temporary tables

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com>, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>
Cc: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, 蔡松露(子嘉) <zijia(at)taobao(dot)com>, "Cai, Le" <le(dot)cai(at)alibaba-inc(dot)com>, 萧少聪(铁庵) <shaocong(dot)xsc(at)alibaba-inc(dot)com>
Subject: Re: [Proposal] Global temporary tables
Date: 2020-03-16 07:59:40
Message-ID: 3d0d4860-f0a4-53a1-8277-889521563724@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 16.03.2020 9:23, Prabhat Sahu wrote:
> 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)
>
> --
>
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com <http://www.enterprisedb.com/>
>

It seems to be expected behavior: GTT data is private to the session and
postgres_fdw establish its own session where content of the table is empty.
But if you insert some data in f_gtt1, then you will be able to select
this data from it because of connection cache in postgres_fdw.

--

Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 曾文旌 (义从) 2020-03-16 08:05:32 Re: [Proposal] Global temporary tables
Previous Message Michael Paquier 2020-03-16 07:57:38 Re: Collation versioning