Re: [Proposal] Global temporary tables

From: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
To: Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com>, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>
Cc: 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>, Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>, 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-02-25 13:56:02
Message-ID: e10cb6cd-e4f9-84ff-0b7e-1dd453bfaa36@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi ,

pg_upgrade  scenario is failing if database is containing  global
temporary table

=============================
centos(at)tushar-ldap-docker bin]$ ./psql postgres
psql (13devel)
Type "help" for help.

postgres=# create global temporary table  t(n int);
CREATE TABLE
postgres=# \q
===============================

run pg_upgrade -

[centos(at)tushar-ldap-docker bin]$ ./pg_upgrade -d /tmp/t1/ -D /tmp/t2 -b
. -B .
Performing Consistency Checks
-----------------------------
Checking cluster versions    ok
Checking database user is the install user                   ok
Checking database connection settings                       ok
Checking for prepared transactions                             ok
Checking for reg* data types in user tables                 ok
--
--
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                        ok
Freezing all rows in the new cluster                          ok
Deleting files from new pg_xact                                ok
--
--
Restoring database schemas in the new cluster
ok
Copying user relation files
  /tmp/t1/base/13585/16384
error while copying relation "public.t": could not open file
"/tmp/t1/base/13585/16384": No such file or directory
Failure, exiting

regards,

On 2/25/20 7:06 PM, Prabhat Sahu wrote:
> Hi All,
>
> Please check the below findings on GTT.
> _-- Scenario 1:_
> Under "information_schema", We are not allowed to create "temporary
> table", whereas we can CREATE/DROP "Global Temporary Table", is it
> expected ?
>
> postgres=# create temporary table information_schema.temp1(c1 int);
> ERROR:  cannot create temporary relation in non-temporary schema
> LINE 1: create temporary table information_schema.temp1(c1 int);
>                                ^
>
> postgres=# create global temporary table information_schema.temp1(c1 int);
> CREATE TABLE
>
> postgres=# drop table information_schema.temp1 ;
> DROP TABLE
>
> _-- Scenario 2:_
> Here I am getting the same error message in both the below cases.
> We may add a "global" keyword with GTT related error message.
>
> postgres=# create global temporary table gtt1 (c1 int unique);
> CREATE TABLE
> postgres=# create temporary table tmp1 (c1 int unique);
> CREATE TABLE
>
> postgres=# create temporary table tmp2 (c1 int references gtt1(c1) );
> ERROR:  constraints on temporary tables may reference only temporary
> tables
>
> postgres=# create global temporary table gtt2 (c1 int references
> tmp1(c1) );
> ERROR:  constraints on temporary tables may reference only temporary
> tables
>
> Thanks,
> Prabhat Sahu
>
> On Tue, Feb 25, 2020 at 2:25 PM 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com
> <mailto:wenjing(dot)zwj(at)alibaba-inc(dot)com>> wrote:
>
>
>
>> 2020年2月24日 下午5:44,Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com
>> <mailto:prabhat(dot)sahu(at)enterprisedb(dot)com>> 写道:
>>
>> On Fri, Feb 21, 2020 at 9:10 PM 曾文旌(义从)
>> <wenjing(dot)zwj(at)alibaba-inc(dot)com
>> <mailto:wenjing(dot)zwj(at)alibaba-inc(dot)com>> wrote:
>>
>> Hi,
>> I have started testing the "Global temporary table" feature,
>> That's great, I see hope.
>> from "gtt_v11-pg13.patch". Below is my findings:
>>
>> -- session 1:
>> postgres=# create global temporary table gtt1(a int);
>> CREATE TABLE
>>
>> -- seeeion 2:
>> postgres=# truncate gtt1 ;
>> ERROR:  could not open file "base/13585/t3_16384": No such
>> file or directory
>>
>> is it expected?
>>
>> Oh ,this is a bug, I fixed it.
>>
>> Thanks for the patch.
>> I have verified the same, Now the issue is resolved with v12 patch.
>>
>> Kindly confirm the below scenario:
>>
>> postgres=# create global temporary table gtt1 (c1 int unique);
>> CREATE TABLE
>>
>> postgres=# create global temporary table gtt2 (c1 int references
>> gtt1(c1) );
>> ERROR:  referenced relation "gtt1" is not a global temp table
>>
>> postgres=# create table tab2 (c1 int references gtt1(c1) );
>> ERROR:  referenced relation "gtt1" is not a global temp table
>>
>> Thanks,
>> Prabhat Sahu
>
> GTT supports foreign key constraints
> in global_temporary_table_v13-pg13.patch
>
>
> Wenjing
>
>
>
>
>
> --
>
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com <http://www.enterprisedb.com/>
>

--
regards,tushar
EnterpriseDB https://www.enterprisedb.com/
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-02-25 14:00:55 Re: pg_trigger.tgparentid
Previous Message Pavel Stehule 2020-02-25 13:49:32 Re: [Proposal] Global temporary tables