From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com> |
Cc: | 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>, tushar <tushar(dot)ahuja(at)enterprisedb(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-03-25 12:57:05 |
Message-ID: | CAFj8pRAYOCwV0Kr+5=a3EUz=NTSkD=x1mO-Wp0w2TepbJNVxnQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
st 25. 3. 2020 v 13:53 odesílatel Prabhat Sahu <
prabhat(dot)sahu(at)enterprisedb(dot)com> napsal:
> Hi All,
>
> Please check the behavior of GTT having column with "SERIAL" datatype and
> column with default value as "SEQUENCE" as below:
>
>
> *Session1:*postgres=# create sequence gtt_c3_seq;
> CREATE SEQUENCE
> postgres=# create global temporary table gtt(c1 int, c2 serial, c3 int
> default nextval('gtt_c3_seq') not null) on commit preserve rows;
> CREATE TABLE
>
> -- Structure of column c2 and c3 are similar:
> postgres=# \d+ gtt
> Table "public.gtt"
> Column | Type | Collation | Nullable | Default
> | Storage | Stats target | Description
>
> --------+---------+-----------+----------+---------------------------------+---------+--------------+-------------
> c1 | integer | | |
> | plain | |
> c2 | integer | | not null | nextval('gtt_c2_seq'::regclass)
> | plain | |
> c3 | integer | | not null | nextval('gtt_c3_seq'::regclass)
> | plain | |
> Access method: heap
> Options: on_commit_delete_rows=false
>
> postgres=# insert into gtt select generate_series(1,3);
> INSERT 0 3
> postgres=# select * from gtt;
> c1 | c2 | c3
> ----+----+----
> 1 | 1 | 1
> 2 | 2 | 2
> 3 | 3 | 3
> (3 rows)
>
>
> *Session2:*postgres=# insert into gtt select generate_series(1,3);
> INSERT 0 3
> postgres=# select * from gtt;
> c1 | c2 | c3
> ----+----+----
> 1 | 1 | 4
> 2 | 2 | 5
> 3 | 3 | 6
> (3 rows)
>
> Kindly let me know, Is this behavior expected?
>
It is interesting side effect - theoretically it is not important, because
sequence ensure just unique values - so values are not important.
You created classic shared sequence so the behave is correct and expected.
Pavel
> --
>
> With Regards,
> Prabhat Kumar Sahu
> EnterpriseDB: http://www.enterprisedb.com
>
From | Date | Subject | |
---|---|---|---|
Next Message | David Steele | 2020-03-25 13:00:39 | Re: Columns correlation and adaptive query optimization |
Previous Message | Peter Eisentraut | 2020-03-25 12:53:23 | Re: Make mesage at end-of-recovery less scary. |