From: | "wenjing(dot)zwj" <wenjing(dot)zwj(at)alibaba-inc(dot)com> |
---|---|
To: | Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(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-03-19 10:21:25 |
Message-ID: | 5EA176DD-4114-4E1D-AF56-9AA4381EA7C2@alibaba-inc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
postgres=# CREATE LOCAL TEMPORARY TABLE gtt1(c1 serial PRIMARY KEY, c2 VARCHAR (50) UNIQUE NOT NULL) ON COMMIT DELETE ROWS;
CREATE TABLE
postgres=# CREATE LOCAL TEMPORARY TABLE gtt2(c1 integer NOT NULL, c2 integer NOT NULL,
postgres(# PRIMARY KEY (c1, c2),
postgres(# FOREIGN KEY (c1) REFERENCES gtt1 (c1)) ON COMMIT PRESERVE ROWS;
ERROR: unsupported ON COMMIT and foreign key combination
DETAIL: Table "gtt2" references "gtt1", but they do not have the same ON COMMIT setting.
postgres=# CREATE LOCAL TEMPORARY TABLE gtt3(c1 serial PRIMARY KEY, c2 VARCHAR (50) UNIQUE NOT NULL) ON COMMIT PRESERVE ROWS;
CREATE TABLE
postgres=#
postgres=# CREATE LOCAL TEMPORARY TABLE gtt4(c1 integer NOT NULL, c2 integer NOT NULL,
postgres(# PRIMARY KEY (c1, c2),
postgres(# FOREIGN KEY (c1) REFERENCES gtt3 (c1)) ON COMMIT DELETE ROWS;
CREATE TABLE
The same behavior applies to the local temp table.
I think, Cause of the problem is temp table with on commit delete rows is not good for reference tables.
So, it the error message ”cannot reference an on commit delete rows temporary table.“ ?
> 2020年3月13日 下午10:16,Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com> 写道:
>
> Hi Wenjing,
>
> Please check the below combination of GTT with Primary and Foreign key relations, with the ERROR message.
>
> Case1:
> postgres=# CREATE GLOBAL TEMPORARY TABLE gtt1(c1 serial PRIMARY KEY, c2 VARCHAR (50) UNIQUE NOT NULL) ON COMMIT DELETE ROWS;
> CREATE TABLE
>
> postgres=# CREATE GLOBAL TEMPORARY TABLE gtt2(c1 integer NOT NULL, c2 integer NOT NULL,
> PRIMARY KEY (c1, c2),
> FOREIGN KEY (c1) REFERENCES gtt1 (c1)) ON COMMIT PRESERVE ROWS;
> ERROR: unsupported ON COMMIT and foreign key combination
> DETAIL: Table "gtt2" references "gtt1", but they do not have the same ON COMMIT setting.
>
> Case2:
> postgres=# CREATE GLOBAL TEMPORARY TABLE gtt1(c1 serial PRIMARY KEY, c2 VARCHAR (50) UNIQUE NOT NULL) ON COMMIT PRESERVE ROWS;
> CREATE TABLE
>
> postgres=# CREATE GLOBAL TEMPORARY TABLE gtt2(c1 integer NOT NULL, c2 integer NOT NULL,
> PRIMARY KEY (c1, c2),
> FOREIGN KEY (c1) REFERENCES gtt1 (c1)) ON COMMIT DELETE ROWS;
> CREATE TABLE
>
> In "case2" although both the primary table and foreign key GTT do not have the same ON COMMIT setting, still we are able to create the PK-FK relations with GTT.
>
> So I hope the detail message(DETAIL: Table "gtt2" references "gtt1", but they do not have the same ON COMMIT setting.) in "Case1" should be more clear(something like "wrong combination of ON COMMIT setting").
>
> --
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com <http://www.enterprisedb.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Hubert Zhang | 2020-03-19 10:29:19 | Re: Print physical file path when checksum check fails |
Previous Message | Amit Langote | 2020-03-19 10:04:47 | Re: [PATCH] Add schema and table names to partition error |