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-04-01T03:22:49Z
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 →
  1. PageAddItemExtended(): Add LP_UNUSED assertion.

  2. Remove temporary files after backend crash

  3. Fix comment in indexing.c

  4. Fix failure to ignore leftover temp tables after a server crash.


> 2020年3月31日 下午9:59,Prabhat Sahu <prabhat.sahu@enterprisedb.com> 写道:
> 
> Hi Wenjing,
> Thanks for the new patch.
> I saw with the patch(gtt_v23.patch), we are supporting the new concept "global temporary sequence"(i.e. session-specific sequence), is this intentional?
It was supported in earlier versions,
This causes the sequence built into the GTT to automatically become a "global temp sequence",
Such as create global temp table (a serial);
Like GTT, the global temp sequnce is used individually for each session.

Recently, I added the global temp sequence syntax so that it can be created independently.
The purpose of this is to enable such sequence built into the GTT to support pg_dump and pg_restore.


Wenjing


> 
> postgres=# create global temporary sequence gt_seq;
> CREATE SEQUENCE
> postgres=# create sequence seq;
> CREATE SEQUENCE
> postgres=# \d+
>                               List of relations
>  Schema |  Name  |   Type   | Owner | Persistence |    Size    | Description 
> --------+--------+----------+-------+-------------+------------+-------------
>  public | gt_seq | sequence | edb   | session     | 8192 bytes | 
>  public | seq    | sequence | edb   | permanent   | 8192 bytes | 
> (2 rows)
> 
> postgres=# select nextval('gt_seq'), nextval('seq');
>  nextval | nextval 
> ---------+---------
>        1 |       1
> (1 row)
> 
> postgres=# select nextval('gt_seq'), nextval('seq');
>  nextval | nextval 
> ---------+---------
>        2 |       2
> (1 row)
> 
> -- Exit and re-connect to psql prompt:
> postgres=# \q
> [edb@localhost bin]$ ./psql postgres 
> psql (13devel)
> Type "help" for help.
> 
> postgres=# select nextval('gt_seq'), nextval('seq');
>  nextval | nextval 
> ---------+---------
>        1 |       3
> (1 row)
> 
> postgres=# select nextval('gt_seq'), nextval('seq');
>  nextval | nextval 
> ---------+---------
>        2 |       4
> (1 row)
> 
> On Tue, Mar 31, 2020 at 9:46 AM 曾文旌 <wenjing.zwj@alibaba-inc.com <mailto:wenjing.zwj@alibaba-inc.com>> wrote:
> 
> 
>> 2020年3月27日 下午5:21,tushar <tushar.ahuja@enterprisedb.com <mailto:tushar.ahuja@enterprisedb.com>> 写道:
>> 
>> On 3/27/20 10:55 AM, 曾文旌 wrote:
>>>> Hi Wenjing,
>>>> This patch(gtt_v21_pg13.patch) is not applicable on PG HEAD, I hope you have prepared the patch on top of some previous commit. 
>>>> Could you please rebase the patch which we can apply on HEAD ?
>>> Yes, It looks like the built-in functions are in conflict with new code.
>>> 
>>> 
>> This error message looks wrong  to me-
>> 
>> postgres=# reindex table concurrently t ;
>> ERROR:  cannot create indexes on global temporary tables using concurrent mode
>> postgres=# 
>> 
>> Better message would be-
>> 
>> ERROR:  cannot reindex global temporary tables concurrently
>> 
> I found that the local temp table automatically disables concurrency mode.
> so, I made some improvements, The reindex GTT behaves the same as the local temp table.
> 
> 
> Wenjing
> 
> 
> 
>> 
>> -- 
>> regards,tushar
>> EnterpriseDB  https://www.enterprisedb.com/ <https://www.enterprisedb.com/>
>> The Enterprise PostgreSQL Company
> 
> 
> 
> -- 
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com <http://www.enterprisedb.com/>