已关闭
[Feat] testcase of pg generated as identity #9226
XXXCA创建于 5月6日关闭于 7月23日
[Feat] testcase of pg generated as identity #9226
已关闭
XXXCA创建于 5月6日关闭于 7月23日
共 30 个文件变更+5690-116
@@ -354,7 +354,11 @@ select @@fetch_status;
354fetch next from c2; -- expect error354fetch next from c2; -- expect error
355ERROR: cursor "c2" does not exist355ERROR: cursor "c2" does not exist
356select @@fetch_status;356select @@fetch_status;
357-ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q]357+ fetch_status
358+--------------
359+ -1
360+(1 row)
361+ 
358rollback transaction;362rollback transaction;
359-- multi cursors363-- multi cursors
360begin transaction;364begin transaction;
@@ -39,13 +39,14 @@ select * from book;
39(4 rows)39(4 rows)
40 40 
41ALTER table book add column id int identity;41ALTER table book add column id int identity;
42-ERROR: multiple identity specifications for column "bookid" of table "book"42+NOTICE: ALTER TABLE will create implicit sequence "book_id_seq_identity" for serial column "book.id"
43+ERROR: Multiple identity columns specified for table "book". Only one identity column per table is allowed.
43ALTER table book alter bookId type text;44ALTER table book alter bookId type text;
44-ERROR: Identity column 'bookid' data type invalid.45+ERROR: Not supported alter identity column bookid type
45drop table if exists book;46drop table if exists book;
46CREATE TABLE book(id int identity, bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50));47CREATE TABLE book(id int identity, bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50));
47NOTICE: CREATE TABLE will create implicit sequence "book_id_seq_identity" for serial column "book.id"48NOTICE: CREATE TABLE will create implicit sequence "book_id_seq_identity" for serial column "book.id"
48-ERROR: table can only have one identity column49+ERROR: Multiple identity columns specified for table "book". Only one identity column per table is allowed.
49CREATE TABLE book50CREATE TABLE book
50(51(
51 bookId int NOT NULL PRIMARY KEY IDENTITY, 52 bookId int NOT NULL PRIMARY KEY IDENTITY,
@@ -265,6 +266,8 @@ CREATE TABLE book(id serial, bookId int identity default 5, bookname char(20));
265NOTICE: CREATE TABLE will create implicit sequence "book_id_seq" for serial column "book.id"266NOTICE: CREATE TABLE will create implicit sequence "book_id_seq" for serial column "book.id"
266NOTICE: CREATE TABLE will create implicit sequence "book_bookid_seq_identity" for serial column "book.bookid"267NOTICE: CREATE TABLE will create implicit sequence "book_bookid_seq_identity" for serial column "book.bookid"
267ERROR: multiple default values specified for column "bookid" of table "book"268ERROR: multiple default values specified for column "bookid" of table "book"
269+LINE 1: CREATE TABLE book(id serial, bookId int identity default 5, ...
270+ ^
268CREATE TABLE t_identity(id serial, col int identity(5,10), col2 text)271CREATE TABLE t_identity(id serial, col int identity(5,10), col2 text)
269partition by range(col)(272partition by range(col)(
270partition p1 VALUES LESS THAN (10),273partition p1 VALUES LESS THAN (10),
@@ -477,9 +480,8 @@ insert into t_identity_0013(name) values('lisi');
477insert into t_identity_0013(name) values('wangwu');480insert into t_identity_0013(name) values('wangwu');
478--error481--error
479update t_identity_0013 set id=4 where name='zhangsan';482update t_identity_0013 set id=4 where name='zhangsan';
480-ERROR: Cannot update identity column "id"483+ERROR: column "id" can only be updated to DEFAULT
481-LINE 1: update t_identity_0013 set id=4 where name='zhangsan';484+DETAIL: Column "id" is an identity column defined as "IDENTITY".
482- ^
483drop table t_identity_0013;485drop table t_identity_0013;
484-- ## ident_current after truncate table. expected: success.486-- ## ident_current after truncate table. expected: success.
485create table t_identity_0021(id int identity(100,1), name varchar(10));487create table t_identity_0021(id int identity(100,1), name varchar(10));
@@ -533,14 +535,30 @@ select scope_identity();
533(1 row)535(1 row)
534 536 
535-- no option.537-- no option.
536-create table t_identity_0023_1 (like t_identity_0023);538+create table t_identity_0023_1_1 (like t_identity_0023);
539+\d+ t_identity_0023_1_1
540+ Table "identity_schema.t_identity_0023_1_1"
541+ Column | Type | Modifiers | Storage | Stats target | Description
542+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
543+ id | integer | not null | plain | |
544+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
545+Has OIDs: no
546+Options: orientation=row, compression=no, collate=1537
547+Character Set: UTF8
548+Collate: utf8mb4_general_ci
549+ 
550+insert t_identity_0023_1_1 (name) values('xxx1');
551+ERROR: null value in column "id" violates not-null constraint
552+DETAIL: Failing row contains (null, xxx1).
553+-- including IDENTITY.
554+create table t_identity_0023_1 (like t_identity_0023 INCLUDING IDENTITY);
537NOTICE: CREATE TABLE will create implicit sequence "t_identity_0023_1_id_seq_identity" for serial column "t_identity_0023_1.id"555NOTICE: CREATE TABLE will create implicit sequence "t_identity_0023_1_id_seq_identity" for serial column "t_identity_0023_1.id"
538\d+ t_identity_0023_1556\d+ t_identity_0023_1
539- Table "identity_schema.t_identity_0023_1"557+ Table "identity_schema.t_identity_0023_1"
540- Column | Type | Modifiers | Storage | Stats target | Description 558+ Column | Type | Modifiers | Storage | Stats target | Description
541---------+-----------------------+-------------------------------------------------------------------------+----------+--------------+-------------559+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
542- id | integer | not null default nextval('t_identity_0023_1_id_seq_identity'::regclass) | plain | | 560+ id | integer | not null identity | plain | |
543- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 561+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
544Has OIDs: no562Has OIDs: no
545Options: orientation=row, compression=no, collate=1537563Options: orientation=row, compression=no, collate=1537
546Character Set: UTF8564Character Set: UTF8
@@ -590,24 +608,27 @@ select * from t_identity_0023_1 order by id;
590 608 
591-- including DEFAULTS.609-- including DEFAULTS.
592create table t_identity_0023_2 (like t_identity_0023 INCLUDING DEFAULTS);610create table t_identity_0023_2 (like t_identity_0023 INCLUDING DEFAULTS);
593-NOTICE: CREATE TABLE will create implicit sequence "t_identity_0023_2_id_seq_identity" for serial column "t_identity_0023_2.id"
594\d+ t_identity_0023_2611\d+ t_identity_0023_2
595- Table "identity_schema.t_identity_0023_2"612+ Table "identity_schema.t_identity_0023_2"
596- Column | Type | Modifiers | Storage | Stats target | Description 613+ Column | Type | Modifiers | Storage | Stats target | Description
597---------+-----------------------+-------------------------------------------------------------------------+----------+--------------+-------------614+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
598- id | integer | not null default nextval('t_identity_0023_2_id_seq_identity'::regclass) | plain | | 615+ id | integer | not null | plain | |
599- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 616+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
600Has OIDs: no617Has OIDs: no
601Options: orientation=row, compression=no, collate=1537618Options: orientation=row, compression=no, collate=1537
602Character Set: UTF8619Character Set: UTF8
603Collate: utf8mb4_general_ci620Collate: utf8mb4_general_ci
604 621 
605insert t_identity_0023_2 (name) values('xxx1');622insert t_identity_0023_2 (name) values('xxx1');
623+ERROR: null value in column "id" violates not-null constraint
624+DETAIL: Failing row contains (null, xxx1).
606insert t_identity_0023_2 (name) values('xxx1');625insert t_identity_0023_2 (name) values('xxx1');
626+ERROR: null value in column "id" violates not-null constraint
627+DETAIL: Failing row contains (null, xxx1).
607select ident_current('t_identity_0023_2');628select ident_current('t_identity_0023_2');
608 ident_current 629 ident_current
609---------------630---------------
610- 101631+
611(1 row)632(1 row)
612 633 
613select scope_identity();634select scope_identity();
@@ -616,7 +637,7 @@ select scope_identity();
616 101637 101
617(1 row)638(1 row)
618 639 
619-drop table t_identity_0023;640+drop table t_identity_0023, t_identity_0023_1_1;
620drop table t_identity_0023_1;641drop table t_identity_0023_1;
621drop table t_identity_0023_2;642drop table t_identity_0023_2;
622-- ## can't insert identity column, expected error.643-- ## can't insert identity column, expected error.
@@ -626,9 +647,9 @@ create table t_identity(id int identity, col text);
626NOTICE: CREATE TABLE will create implicit sequence "t_identity_id_seq_identity" for serial column "t_identity.id"647NOTICE: CREATE TABLE will create implicit sequence "t_identity_id_seq_identity" for serial column "t_identity.id"
627-- expected error.648-- expected error.
628insert into t_identity(id, col) values(2,'zshan');649insert into t_identity(id, col) values(2,'zshan');
629-ERROR: Cannot insert identity column "id"650+ERROR: cannot insert a non-DEFAULT value into column "id"
630-LINE 1: insert into t_identity(id, col) values(2,'zshan');651+DETAIL: Column "id" is an identity column defined as "IDENTITY".
631- ^652+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert".
632select ident_current('t_identity');653select ident_current('t_identity');
633 ident_current 654 ident_current
634---------------655---------------
@@ -665,9 +686,9 @@ insert into t_identity(col) select 'test';
665insert into t_identity(col) select 'test';686insert into t_identity(col) select 'test';
666-- expected error.687-- expected error.
667insert into t_identity(id, col) select 1, 'test';688insert into t_identity(id, col) select 1, 'test';
668-ERROR: Cannot insert identity column "id"689+ERROR: cannot insert a non-DEFAULT value into column "id"
669-LINE 1: insert into t_identity(id, col) select 1, 'test';690+DETAIL: Column "id" is an identity column defined as "IDENTITY".
670- ^691+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert".
671-- expected success.692-- expected success.
672set identity_insert = on;693set identity_insert = on;
673insert into t_identity(id, col) select 1, 'test';694insert into t_identity(id, col) select 1, 'test';
@@ -699,9 +720,9 @@ select * from t_identity order by id;
699-- expected error.720-- expected error.
700insert into t_identity(id, col) values(100, 'newtest')721insert into t_identity(id, col) values(100, 'newtest')
701 on duplicate key update col = VALUES(col);722 on duplicate key update col = VALUES(col);
702-ERROR: Cannot insert identity column "id"723+ERROR: cannot insert a non-DEFAULT value into column "id"
703-LINE 1: insert into t_identity(id, col) values(100, 'newtest')724+DETAIL: Column "id" is an identity column defined as "IDENTITY".
704- ^725+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert".
705-- expected error.726-- expected error.
706insert into t_identity(col) values(100, 'newtest')727insert into t_identity(col) values(100, 'newtest')
707 on duplicate key update col = VALUES(col);728 on duplicate key update col = VALUES(col);
@@ -740,9 +761,9 @@ when not matched then
740merge into target_table AS t using source_table AS s ON t.id = s.id761merge into target_table AS t using source_table AS s ON t.id = s.id
741when not matched then762when not matched then
742 insert (id, name, age) values (s.id, s.name, s.age);763 insert (id, name, age) values (s.id, s.name, s.age);
743-ERROR: Cannot insert identity column "id"764+ERROR: cannot insert a non-DEFAULT value into column "id"
744-LINE 3: insert (id, name, age) values (s.id, s.name, s.age);765+DETAIL: Column "id" is an identity column defined as "IDENTITY".
745- ^766+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert"
746-- expected success.767-- expected success.
747set identity_insert = on;768set identity_insert = on;
748merge into target_table AS t using source_table AS s ON t.id = s.id769merge into target_table AS t using source_table AS s ON t.id = s.id
@@ -795,10 +816,10 @@ NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_02_id_seq_i
795select id as id_alias into t_identity_0024_02_1 from t_identity_0024;816select id as id_alias into t_identity_0024_02_1 from t_identity_0024;
796NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_02_1_id_alias_seq_identity" for serial column "t_identity_0024_02_1.id_alias"817NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_02_1_id_alias_seq_identity" for serial column "t_identity_0024_02_1.id_alias"
797\d+ t_identity_0024_02_1818\d+ t_identity_0024_02_1
798- Table "identity_schema.t_identity_0024_02_1"819+ Table "identity_schema.t_identity_0024_02_1"
799- Column | Type | Modifiers | Storage | Stats target | Description 820+ Column | Type | Modifiers | Storage | Stats target | Description
800-----------+---------+----------------------------------------------------------------------------------+---------+--------------+-------------821+----------+---------+-------------------+---------+--------------+-------------
801- id_alias | integer | not null default nextval('t_identity_0024_02_1_id_alias_seq_identity'::regclass) | plain | | 822+ id_alias | integer | not null identity | plain | |
802Has OIDs: no823Has OIDs: no
803Options: orientation=row, compression=no, collate=1537824Options: orientation=row, compression=no, collate=1537
804Character Set: UTF8825Character Set: UTF8
@@ -813,12 +834,12 @@ select ident_current('t_identity_0024_02_1');
813select * into t_identity_0024_03 from t_identity_0024;834select * into t_identity_0024_03 from t_identity_0024;
814NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_03_id_seq_identity" for serial column "t_identity_0024_03.id"835NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_03_id_seq_identity" for serial column "t_identity_0024_03.id"
815\d+ t_identity_0024_03836\d+ t_identity_0024_03
816- Table "identity_schema.t_identity_0024_03"837+ Table "identity_schema.t_identity_0024_03"
817- Column | Type | Modifiers | Storage | Stats target | Description 838+ Column | Type | Modifiers | Storage | Stats target | Description
818---------+-----------------------+--------------------------------------------------------------------------+----------+--------------+-------------839+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
819- id | integer | not null default nextval('t_identity_0024_03_id_seq_identity'::regclass) | plain | | 840+ id | integer | not null identity | plain | |
820- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 841+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
821- age | integer | | plain | | 842+ age | integer | | plain | |
822Has OIDs: no843Has OIDs: no
823Options: orientation=row, compression=no, collate=1537844Options: orientation=row, compression=no, collate=1537
824Character Set: UTF8845Character Set: UTF8
@@ -833,11 +854,11 @@ select ident_current('t_identity_0024_03');
833select id, age as alias_age into t_identity_0024_04 from t_identity_0024;854select id, age as alias_age into t_identity_0024_04 from t_identity_0024;
834NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_04_id_seq_identity" for serial column "t_identity_0024_04.id"855NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_04_id_seq_identity" for serial column "t_identity_0024_04.id"
835\d+ t_identity_0024_04856\d+ t_identity_0024_04
836- Table "identity_schema.t_identity_0024_04"857+ Table "identity_schema.t_identity_0024_04"
837- Column | Type | Modifiers | Storage | Stats target | Description 858+ Column | Type | Modifiers | Storage | Stats target | Description
838------------+---------+--------------------------------------------------------------------------+---------+--------------+-------------859+-----------+---------+-------------------+---------+--------------+-------------
839- id | integer | not null default nextval('t_identity_0024_04_id_seq_identity'::regclass) | plain | | 860+ id | integer | not null identity | plain | |
840- alias_age | integer | | plain | | 861+ alias_age | integer | | plain | |
841Has OIDs: no862Has OIDs: no
842Options: orientation=row, compression=no, collate=1537863Options: orientation=row, compression=no, collate=1537
843Character Set: UTF8864Character Set: UTF8
@@ -868,9 +889,9 @@ select * from t_identity_0024_04 order by id;
868set identity_insert = off;889set identity_insert = off;
869-- expected: error890-- expected: error
870insert into t_identity_0024_04(id, alias_age) values (1000, 22);891insert into t_identity_0024_04(id, alias_age) values (1000, 22);
871-ERROR: Cannot insert identity column "id"892+ERROR: cannot insert a non-DEFAULT value into column "id"
872-LINE 1: insert into t_identity_0024_04(id, alias_age) values (1000, ...893+DETAIL: Column "id" is an identity column defined as "IDENTITY".
873- ^894+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert".
874set identity_insert = on;895set identity_insert = on;
875-- expected: success896-- expected: success
876insert into t_identity_0024_04(id, alias_age) values (1000, 22);897insert into t_identity_0024_04(id, alias_age) values (1000, 22);
@@ -947,9 +968,9 @@ NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_id1_s
947select * into t_serial_identity_001_1 from t_serial_identity_001;968select * into t_serial_identity_001_1 from t_serial_identity_001;
948NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id_seq_identity" for serial column "t_serial_identity_001_1.id"969NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id_seq_identity" for serial column "t_serial_identity_001_1.id"
949NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1"970NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1"
950-ERROR: Cannot insert identity column "id"971+ERROR: cannot insert a non-DEFAULT value into column "id"
951-LINE 1: ...t * into t_serial_identity_001_1 from t_serial_identity_001;972+DETAIL: Column "id" is an identity column defined as "IDENTITY".
952- ^973+HINT: Use OVERRIDING SYSTEM VALUE to override, Or turn on "identity_insert".
953set identity_insert = on;974set identity_insert = on;
954-- expected: success975-- expected: success
955select * into t_serial_identity_001_1 from t_serial_identity_001;976select * into t_serial_identity_001_1 from t_serial_identity_001;
@@ -957,12 +978,12 @@ NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id_
957NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1"978NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1"
958set identity_insert = off;979set identity_insert = off;
959\d+ t_serial_identity_001_1980\d+ t_serial_identity_001_1
960- Table "identity_schema.t_serial_identity_001_1"981+ Table "identity_schema.t_serial_identity_001_1"
961- Column | Type | Modifiers | Storage | Stats target | Description 982+ Column | Type | Modifiers | Storage | Stats target | Description
962---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------983+--------+-----------------------+-----------------------------------------------------------------------+----------+--------------+-------------
963- id | integer | not null default nextval('t_serial_identity_001_1_id_seq_identity'::regclass) | plain | | 984+ id | integer | not null identity | plain | |
964- id1 | integer | not null default nextval('t_serial_identity_001_1_id1_seq'::regclass) | plain | | 985+ id1 | integer | not null default nextval('t_serial_identity_001_1_id1_seq'::regclass) | plain | |
965- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 986+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
966Has OIDs: no987Has OIDs: no
967Options: orientation=row, compression=no, collate=1537988Options: orientation=row, compression=no, collate=1537
968Character Set: UTF8989Character Set: UTF8
@@ -992,11 +1013,11 @@ set identity_insert = on;
992select id, name into t_identity_numeric_t1_1 from t_identity_numeric_t1;1013select id, name into t_identity_numeric_t1_1 from t_identity_numeric_t1;
993NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t1_1_id_seq_identity" for serial column "t_identity_numeric_t1_1.id"1014NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t1_1_id_seq_identity" for serial column "t_identity_numeric_t1_1.id"
994\d+ t_identity_numeric_t1_11015\d+ t_identity_numeric_t1_1
995- Table "identity_schema.t_identity_numeric_t1_1"1016+ Table "identity_schema.t_identity_numeric_t1_1"
996- Column | Type | Modifiers | Storage | Stats target | Description 1017+ Column | Type | Modifiers | Storage | Stats target | Description
997---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------1018+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
998- id | numeric(25,0) | not null default nextval('t_identity_numeric_t1_1_id_seq_identity'::regclass) | main | | 1019+ id | numeric(25,0) | not null identity | main | |
999- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 1020+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
1000Has OIDs: no1021Has OIDs: no
1001Options: orientation=row, compression=no, collate=15371022Options: orientation=row, compression=no, collate=1537
1002Character Set: UTF81023Character Set: UTF8
@@ -1021,11 +1042,11 @@ select id, name into t_identity_numeric_t2_1 from t_identity_numeric_t2;
1021NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t2_1_id_seq_identity" for serial column "t_identity_numeric_t2_1.id"1042NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t2_1_id_seq_identity" for serial column "t_identity_numeric_t2_1.id"
1022set identity_insert = off;1043set identity_insert = off;
1023\d+ t_identity_numeric_t2_11044\d+ t_identity_numeric_t2_1
1024- Table "identity_schema.t_identity_numeric_t2_1"1045+ Table "identity_schema.t_identity_numeric_t2_1"
1025- Column | Type | Modifiers | Storage | Stats target | Description 1046+ Column | Type | Modifiers | Storage | Stats target | Description
1026---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------1047+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
1027- id | numeric(25,0) | not null default nextval('t_identity_numeric_t2_1_id_seq_identity'::regclass) | main | | 1048+ id | numeric(25,0) | not null identity | main | |
1028- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 1049+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
1029Has OIDs: no1050Has OIDs: no
1030Options: orientation=row, compression=no, collate=15371051Options: orientation=row, compression=no, collate=1537
1031Character Set: UTF81052Character Set: UTF8
@@ -1049,11 +1070,11 @@ select id, name into t_identity_numeric_t3_1 from t_identity_numeric_t3;
1049NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t3_1_id_seq_identity" for serial column "t_identity_numeric_t3_1.id"1070NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t3_1_id_seq_identity" for serial column "t_identity_numeric_t3_1.id"
1050set identity_insert = off;1071set identity_insert = off;
1051\d+ t_identity_numeric_t3_11072\d+ t_identity_numeric_t3_1
1052- Table "identity_schema.t_identity_numeric_t3_1"1073+ Table "identity_schema.t_identity_numeric_t3_1"
1053- Column | Type | Modifiers | Storage | Stats target | Description 1074+ Column | Type | Modifiers | Storage | Stats target | Description
1054---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------1075+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
1055- id | numeric(25,0) | not null default nextval('t_identity_numeric_t3_1_id_seq_identity'::regclass) | main | | 1076+ id | numeric(25,0) | not null identity | main | |
1056- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 1077+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
1057Has OIDs: no1078Has OIDs: no
1058Options: orientation=row, compression=no, collate=15371079Options: orientation=row, compression=no, collate=1537
1059Character Set: UTF81080Character Set: UTF8
@@ -1074,14 +1095,14 @@ drop table t_identity_numeric_t3_1;
1074-- max/min value1095-- max/min value
1075create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10));1096create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10));
1076NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_id_seq_identity" for serial column "t_identity_numeric_t4.id"1097NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_id_seq_identity" for serial column "t_identity_numeric_t4.id"
1077-create table t_identity_numeric_t4_1 (like t_identity_numeric_t4);1098+create table t_identity_numeric_t4_1 (like t_identity_numeric_t4 including identity);
1078NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_1_id_seq_identity" for serial column "t_identity_numeric_t4_1.id"1099NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_1_id_seq_identity" for serial column "t_identity_numeric_t4_1.id"
1079\d+ t_identity_numeric_t4_1;1100\d+ t_identity_numeric_t4_1;
1080- Table "identity_schema.t_identity_numeric_t4_1"1101+ Table "identity_schema.t_identity_numeric_t4_1"
1081- Column | Type | Modifiers | Storage | Stats target | Description 1102+ Column | Type | Modifiers | Storage | Stats target | Description
1082---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------1103+--------+-----------------------+-----------------------------------------------+----------+--------------+-------------
1083- id | numeric(38,0) | not null default nextval('t_identity_numeric_t4_1_id_seq_identity'::regclass) | main | | 1104+ id | numeric(38,0) | not null identity | main | |
1084- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 1105+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
1085Has OIDs: no1106Has OIDs: no
1086Options: orientation=row, compression=no, collate=15371107Options: orientation=row, compression=no, collate=1537
1087Character Set: UTF81108Character Set: UTF8
@@ -1102,7 +1123,7 @@ drop table t_identity_numeric_t4_1;
1102create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10));1123create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10));
1103NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id_seq_identity" for serial column "t_identity_numeric_t5.id"1124NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id_seq_identity" for serial column "t_identity_numeric_t5.id"
1104NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id1_seq" for serial column "t_identity_numeric_t5.id1"1125NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id1_seq" for serial column "t_identity_numeric_t5.id1"
1105-create table t_identity_numeric_t5_1 (like t_identity_numeric_t5);1126+create table t_identity_numeric_t5_1 (like t_identity_numeric_t5 including identity);
1106NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id_seq_identity" for serial column "t_identity_numeric_t5_1.id"1127NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id_seq_identity" for serial column "t_identity_numeric_t5_1.id"
1107NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id1_seq" for serial column "t_identity_numeric_t5_1.id1"1128NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id1_seq" for serial column "t_identity_numeric_t5_1.id1"
1108insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int641129insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64
@@ -1118,16 +1139,16 @@ drop table t_identity_numeric_t5_1;
1118create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10));1139create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10));
1119NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id_seq_identity" for serial column "t_identity_numeric_t6.id"1140NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id_seq_identity" for serial column "t_identity_numeric_t6.id"
1120NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id1_seq" for serial column "t_identity_numeric_t6.id1"1141NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id1_seq" for serial column "t_identity_numeric_t6.id1"
1121-create table t_identity_numeric_t6_1 (like t_identity_numeric_t6);1142+create table t_identity_numeric_t6_1 (like t_identity_numeric_t6 including identity);
1122NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id_seq_identity" for serial column "t_identity_numeric_t6_1.id"1143NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id_seq_identity" for serial column "t_identity_numeric_t6_1.id"
1123NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id1_seq" for serial column "t_identity_numeric_t6_1.id1"1144NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id1_seq" for serial column "t_identity_numeric_t6_1.id1"
1124\d+ t_identity_numeric_t6_11145\d+ t_identity_numeric_t6_1
1125- Table "identity_schema.t_identity_numeric_t6_1"1146+ Table "identity_schema.t_identity_numeric_t6_1"
1126- Column | Type | Modifiers | Storage | Stats target | Description 1147+ Column | Type | Modifiers | Storage | Stats target | Description
1127---------+-----------------------+-------------------------------------------------------------------------------+----------+--------------+-------------1148+--------+-----------------------+-----------------------------------------------------------------------+----------+--------------+-------------
1128- id | numeric(38,0) | not null default nextval('t_identity_numeric_t6_1_id_seq_identity'::regclass) | main | | 1149+ id | numeric(38,0) | not null identity | main | |
1129- id1 | integer | not null default nextval('t_identity_numeric_t6_1_id1_seq'::regclass) | plain | | 1150+ id1 | integer | not null default nextval('t_identity_numeric_t6_1_id1_seq'::regclass) | plain | |
1130- name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | | 1151+ name | character varying(10) | character set UTF8 collate utf8mb4_general_ci | extended | |
1131Has OIDs: no1152Has OIDs: no
1132Options: orientation=row, compression=no, collate=15371153Options: orientation=row, compression=no, collate=1537
1133Character Set: UTF81154Character Set: UTF8
@@ -1148,11 +1169,11 @@ drop table t_identity_numeric_t6_1;
1148create table t_ident (id int identity, col text) with (orientation=column);1169create table t_ident (id int identity, col text) with (orientation=column);
1149NOTICE: CREATE TABLE will create implicit sequence "t_ident_id_seq_identity" for serial column "t_ident.id"1170NOTICE: CREATE TABLE will create implicit sequence "t_ident_id_seq_identity" for serial column "t_ident.id"
1150\d+ t_ident;1171\d+ t_ident;
1151- Table "identity_schema.t_ident"1172+ Table "identity_schema.t_ident"
1152- Column | Type | Modifiers | Storage | Stats target | Description 1173+ Column | Type | Modifiers | Storage | Stats target | Description
1153---------+---------+---------------------------------------------------------------+----------+--------------+-------------1174+--------+---------+-----------------------------------------------+----------+--------------+-------------
1154- id | integer | not null default nextval('t_ident_id_seq_identity'::regclass) | plain | | 1175+ id | integer | not null identity | plain | |
1155- col | text | character set UTF8 collate utf8mb4_general_ci | extended | | 1176+ col | text | character set UTF8 collate utf8mb4_general_ci | extended | |
1156Has OIDs: no1177Has OIDs: no
1157Options: orientation=column, compression=low, collate=15371178Options: orientation=column, compression=low, collate=1537
1158Character Set: UTF81179Character Set: UTF8
@@ -1178,7 +1199,7 @@ drop table t_ident;
1178create sequence identity_t2_id_seq_identity;1199create sequence identity_t2_id_seq_identity;
1179create table identity_t2(id numeric(38, 0) identity(10, 2), b int);1200create table identity_t2(id numeric(38, 0) identity(10, 2), b int);
1180NOTICE: CREATE TABLE will create implicit sequence "identity_t2_id_seq_identity1" for serial column "identity_t2.id"1201NOTICE: CREATE TABLE will create implicit sequence "identity_t2_id_seq_identity1" for serial column "identity_t2.id"
1181-create table identity_t2_1 (like identity_t2);1202+create table identity_t2_1 (like identity_t2 including identity);
1182NOTICE: CREATE TABLE will create implicit sequence "identity_t2_1_id_seq_identity" for serial column "identity_t2_1.id"1203NOTICE: CREATE TABLE will create implicit sequence "identity_t2_1_id_seq_identity" for serial column "identity_t2_1.id"
1183insert into identity_t2_1(b) values (10);1204insert into identity_t2_1(b) values (10);
1184insert into identity_t2_1(b) values (10);1205insert into identity_t2_1(b) values (10);
@@ -1211,5 +1232,16 @@ select id, b from identity_t3_1;
1211drop sequence identity_t3_id_seq_identity;1232drop sequence identity_t3_id_seq_identity;
1212drop table identity_t3;1233drop table identity_t3;
1213drop table identity_t3_1;1234drop table identity_t3_1;
1235+-- compatiable with pg identity
1236+-- error
1237+create table identity_t1(id numeric(38, 0) identity(1, 2) generated always as identity);
1238+NOTICE: CREATE TABLE will create implicit sequence "identity_t1_id_seq_identity" for serial column "identity_t1.id"
1239+ERROR: multiple identity specifications for column "id" of table "identity_t1"
1240+LINE 1: ...able identity_t1(id numeric(38, 0) identity(1, 2) generated ...
1241+ ^
1242+-- error
1243+create table identity_t1(id numeric(38, 0) identity(1, 2), id2 numeric(37, 0) generated always as identity);
1244+NOTICE: CREATE TABLE will create implicit sequence "identity_t1_id_seq_identity" for serial column "identity_t1.id"
1245+ERROR: Multiple identity columns specified for table "identity_t1". Only one identity column per table is allowed.
1214reset current_schema;1246reset current_schema;
1215drop schema identity_schema;1247drop schema identity_schema;
@@ -1177,7 +1177,10 @@ from sys.sysdatabases;
1177 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | | 1177 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1178 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | | 1178 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1179 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | | 1179 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1180-(5 rows)1180+ 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1181+ 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1182+ 10 | 0 | 0 | 0 | Mon Jan 01 00:00:00 1900 | Mon Jan 01 00:00:00 1900 | 0 | 0 | |
1183+(8 rows)
1181 1184 
1182select name, schema_id, principal_id1185select name, schema_id, principal_id
1183from sys.schemas where schema_id < 10000 order by schema_id;1186from sys.schemas where schema_id < 10000 order by schema_id;
@@ -1242,3 +1245,4 @@ drop table employees;
1242drop view high_salary_employees;1245drop view high_salary_employees;
1243reset search_path;1246reset search_path;
1244drop schema sys_view_test_02 cascade;1247drop schema sys_view_test_02 cascade;
1248+reset d_format_behavior_compat_options;
@@ -121,13 +121,13 @@ select count(*) from synonyms;
121(1 row)121(1 row)
122 122 
123set d_format_behavior_compat_options = '';123set d_format_behavior_compat_options = '';
124-select count(*) from syscolumns; 124+select count(*) from syscolumns;
125 count 125 count
126--?.*126--?.*
127--?.*127--?.*
128(1 row)128(1 row)
129 129 
130-set d_format_behavior_compat_options = 'enable_sbr_identifier, default_collation';130+reset d_format_behavior_compat_options;
131select count(*) from sysdatabases; 131select count(*) from sysdatabases;
132 count 132 count
133--?.*133--?.*
@@ -0,0 +1,48 @@
1+create database s_test_pg_identity_dump_restore dbcompatibility 'D';
2+create database s_test_pg_identity_dump_restore_1 dbcompatibility 'D';
3+\c s_test_pg_identity_dump_restore_1
4+create extension shark;
5+\c s_test_pg_identity_dump_restore
6+create extension shark;
7+ 
8+create schema s_test_pg_identity_dump_restore;
9+set current_schema = s_test_pg_identity_dump_restore;
10+ 
11+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY (START WITH 20 INCREMENT 2 NOMAXVALUE NOMINVALUE), b text);
12+CREATE TABLE test_t2 (a int GENERATED BY DEFAULT AS IDENTITY ( START 10 INCREMENT 1 MAXVALUE 2222), b text);
13+ALTER TABLE test_t2 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY (START 20 NOMAXVALUE NOMINVALUE NOCYCLE); -- success
14+ALTER TABLE test_t2 ALTER COLUMN c SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART;
15+CREATE TABLE book(bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50));
16+ 
17+INSERT INTO test_t1 DEFAULT VALUES;
18+INSERT INTO test_t1 DEFAULT VALUES;
19+INSERT INTO test_t2 DEFAULT VALUES;
20+INSERT INTO test_t2 DEFAULT VALUES;
21+INSERT INTO book VALUES('book1','author1'),('book2','author2');
22+INSERT INTO book(bookname,author) VALUES('book3','author3'),('book4','author4');
23+ 
24+ 
25+\! @abs_bindir@/gs_dump s_test_pg_identity_dump_restore -p @portstring@ -f @abs_bindir@/s_test_pg_identity_dump_restore.sql -n s_test_pg_identity_dump_restore -w >/dev/null 2>&1; echo $?
26+\! @abs_bindir@/gsql -ds_test_pg_identity_dump_restore_1 -p @portstring@ -f "@abs_bindir@/s_test_pg_identity_dump_restore.sql"
27+ 
28+\c s_test_pg_identity_dump_restore_1
29+set current_schema = s_test_pg_identity_dump_restore;
30+ 
31+\d+ test_t1
32+\d+ test_t2
33+\d+ book
34+truncate test_t1;
35+truncate test_t2;
36+truncate book;
37+INSERT INTO test_t1 DEFAULT VALUES;
38+INSERT INTO test_t1 DEFAULT VALUES;
39+INSERT INTO test_t2 DEFAULT VALUES;
40+INSERT INTO test_t2 DEFAULT VALUES;
41+INSERT INTO book VALUES('book1','author1'),('book2','author2');
42+INSERT INTO book(bookname,author) VALUES('book3','author3'),('book4','author4');
43+select * from test_t1 order by 1, 2;
44+select * from test_t2 order by 1, 2;
45+select * from book order by 1, 2;
46+\c postgres
47+drop database s_test_pg_identity_dump_restore;
48+drop database s_test_pg_identity_dump_restore_1;
@@ -0,0 +1,147 @@
1+create database s_test_pg_identity_dump_restore dbcompatibility 'D';
2+create database s_test_pg_identity_dump_restore_1 dbcompatibility 'D';
3+\c s_test_pg_identity_dump_restore_1
4+create extension shark;
5+\c s_test_pg_identity_dump_restore
6+create extension shark;
7+create schema s_test_pg_identity_dump_restore;
8+set current_schema = s_test_pg_identity_dump_restore;
9+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY (START WITH 20 INCREMENT 2 NOMAXVALUE NOMINVALUE), b text);
10+NOTICE: CREATE TABLE will create implicit sequence "test_t1_a_seq" for serial column "test_t1.a"
11+CREATE TABLE test_t2 (a int GENERATED BY DEFAULT AS IDENTITY ( START 10 INCREMENT 1 MAXVALUE 2222), b text);
12+NOTICE: CREATE TABLE will create implicit sequence "test_t2_a_seq" for serial column "test_t2.a"
13+ALTER TABLE test_t2 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY (START 20 NOMAXVALUE NOMINVALUE NOCYCLE); -- success
14+NOTICE: ALTER TABLE will create implicit sequence "test_t2_c_seq" for serial column "test_t2.c"
15+ALTER TABLE test_t2 ALTER COLUMN c SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART;
16+CREATE TABLE book(bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50));
17+NOTICE: CREATE TABLE will create implicit sequence "book_bookid_seq_identity" for serial column "book.bookid"
18+INSERT INTO test_t1 DEFAULT VALUES;
19+INSERT INTO test_t1 DEFAULT VALUES;
20+INSERT INTO test_t2 DEFAULT VALUES;
21+INSERT INTO test_t2 DEFAULT VALUES;
22+INSERT INTO book VALUES('book1','author1'),('book2','author2');
23+INSERT INTO book(bookname,author) VALUES('book3','author3'),('book4','author4');
24+\! @abs_bindir@/gs_dump s_test_pg_identity_dump_restore -p @portstring@ -f @abs_bindir@/s_test_pg_identity_dump_restore.sql -n s_test_pg_identity_dump_restore -w >/dev/null 2>&1; echo $?
25+0
26+\! @abs_bindir@/gsql -ds_test_pg_identity_dump_restore_1 -p @portstring@ -f "@abs_bindir@/s_test_pg_identity_dump_restore.sql"
27+SET
28+SET
29+SET
30+SET
31+SET
32+SET
33+SET
34+SET
35+SET
36+SET
37+SET
38+SET
39+CREATE SCHEMA
40+ALTER SCHEMA
41+SET
42+SET
43+SET
44+CREATE TABLE
45+ALTER TABLE
46+ALTER TABLE
47+ALTER SEQUENCE
48+CREATE TABLE
49+ALTER TABLE
50+ALTER TABLE
51+CREATE TABLE
52+ALTER TABLE
53+ALTER TABLE
54+ALTER TABLE
55+ setval
56+--------
57+ 4
58+(1 row)
59+ 
60+ setval
61+--------
62+ 22
63+(1 row)
64+ 
65+ setval
66+--------
67+ 11
68+(1 row)
69+ 
70+ setval
71+--------
72+ 102
73+(1 row)
74+ 
75+--?total time:.*
76+\c s_test_pg_identity_dump_restore_1
77+set current_schema = s_test_pg_identity_dump_restore;
78+\d+ test_t1
79+ Table "s_test_pg_identity_dump_restore.test_t1"
80+ Column | Type | Modifiers | Storage | Stats target | Description
81+--------+---------+-----------------------------------------------+----------+--------------+-------------
82+ a | integer | not null generated always as identity | plain | |
83+ b | text | character set UTF8 collate utf8mb4_general_ci | extended | |
84+Has OIDs: no
85+Options: orientation=row, compression=no, collate=1537
86+Character Set: UTF8
87+Collate: utf8mb4_general_ci
88+ 
89+\d+ test_t2
90+ Table "s_test_pg_identity_dump_restore.test_t2"
91+ Column | Type | Modifiers | Storage | Stats target | Description
92+--------+---------+-----------------------------------------------+----------+--------------+-------------
93+ a | integer | not null generated by default as identity | plain | |
94+ b | text | character set UTF8 collate utf8mb4_general_ci | extended | |
95+ c | integer | not null generated by default as identity | plain | |
96+Has OIDs: no
97+Options: orientation=row, compression=no, collate=1537
98+Character Set: UTF8
99+Collate: utf8mb4_general_ci
100+ 
101+\d+ book
102+ Table "s_test_pg_identity_dump_restore.book"
103+ Column | Type | Modifiers | Storage | Stats target | Description
104+----------+---------------+-----------------------------------------------+----------+--------------+-------------
105+ bookid | integer | not null identity | plain | |
106+ bookname | nvarchar2(50) | character set UTF8 collate utf8mb4_general_ci | extended | |
107+ author | nvarchar2(50) | character set UTF8 collate utf8mb4_general_ci | extended | |
108+Has OIDs: no
109+Options: orientation=row, compression=no, collate=1537
110+Character Set: UTF8
111+Collate: utf8mb4_general_ci
112+ 
113+truncate test_t1;
114+truncate test_t2;
115+truncate book;
116+INSERT INTO test_t1 DEFAULT VALUES;
117+INSERT INTO test_t1 DEFAULT VALUES;
118+INSERT INTO test_t2 DEFAULT VALUES;
119+INSERT INTO test_t2 DEFAULT VALUES;
120+INSERT INTO book VALUES('book1','author1'),('book2','author2');
121+INSERT INTO book(bookname,author) VALUES('book3','author3'),('book4','author4');
122+select * from test_t1 order by 1, 2;
123+ a | b
124+----+---
125+ 24 |
126+ 26 |
127+(2 rows)
128+ 
129+select * from test_t2 order by 1, 2;
130+ a | b | c
131+----+---+-----
132+ 12 | | 104
133+ 13 | | 106
134+(2 rows)
135+ 
136+select * from book order by 1, 2;
137+ bookid | bookname | author
138+--------+----------+---------
139+ 1 | book1 | author1
140+ 2 | book2 | author2
141+ 3 | book3 | author3
142+ 4 | book4 | author4
143+(4 rows)
144+ 
145+\c postgres
146+drop database s_test_pg_identity_dump_restore;
147+drop database s_test_pg_identity_dump_restore_1;
@@ -37,4 +37,4 @@ test: gs_dump_d_nvarchar2_max
37test: temp_table_special_prefix37test: temp_table_special_prefix
38test: sharksysfunction38test: sharksysfunction
39test: alter_sequence39test: alter_sequence
40- 40+test: pg_identity pg_identity_dump_restore
@@ -312,7 +312,11 @@ insert into t_identity_0023(name) values('x3');
312select ident_current('t_identity_0023');312select ident_current('t_identity_0023');
313select scope_identity();313select scope_identity();
314-- no option.314-- no option.
315-create table t_identity_0023_1 (like t_identity_0023);315+create table t_identity_0023_1_1 (like t_identity_0023);
316+\d+ t_identity_0023_1_1
317+insert t_identity_0023_1_1 (name) values('xxx1');
318+-- including IDENTITY.
319+create table t_identity_0023_1 (like t_identity_0023 INCLUDING IDENTITY);
316\d+ t_identity_0023_1320\d+ t_identity_0023_1
317select ident_current('t_identity_0023_1');321select ident_current('t_identity_0023_1');
318insert t_identity_0023_1 (name) values('xxx1');322insert t_identity_0023_1 (name) values('xxx1');
@@ -333,7 +337,7 @@ insert t_identity_0023_2 (name) values('xxx1');
333select ident_current('t_identity_0023_2');337select ident_current('t_identity_0023_2');
334select scope_identity();338select scope_identity();
335 339 
336-drop table t_identity_0023;340+drop table t_identity_0023, t_identity_0023_1_1;
337drop table t_identity_0023_1;341drop table t_identity_0023_1;
338drop table t_identity_0023_2;342drop table t_identity_0023_2;
339-- ## can't insert identity column, expected error.343-- ## can't insert identity column, expected error.
@@ -527,7 +531,7 @@ drop table t_identity_numeric_t3_1;
527---- create table like.531---- create table like.
528-- max/min value532-- max/min value
529create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10));533create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10));
530-create table t_identity_numeric_t4_1 (like t_identity_numeric_t4);534+create table t_identity_numeric_t4_1 (like t_identity_numeric_t4 including identity);
531\d+ t_identity_numeric_t4_1;535\d+ t_identity_numeric_t4_1;
532set identity_insert = on;536set identity_insert = on;
533insert into t_identity_numeric_t4_1(id, name) values(987654321098765432109876543210, 'xxx'); -- over int64537insert into t_identity_numeric_t4_1(id, name) values(987654321098765432109876543210, 'xxx'); -- over int64
@@ -538,7 +542,7 @@ drop table t_identity_numeric_t4_1;
538 542 
539-- start543-- start
540create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10));544create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10));
541-create table t_identity_numeric_t5_1 (like t_identity_numeric_t5);545+create table t_identity_numeric_t5_1 (like t_identity_numeric_t5 including identity);
542insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64546insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64
543select * from t_identity_numeric_t5_1 order by id;547select * from t_identity_numeric_t5_1 order by id;
544drop table t_identity_numeric_t5;548drop table t_identity_numeric_t5;
@@ -546,7 +550,7 @@ drop table t_identity_numeric_t5_1;
546 550 
547-- increment551-- increment
548create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10));552create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10));
549-create table t_identity_numeric_t6_1 (like t_identity_numeric_t6);553+create table t_identity_numeric_t6_1 (like t_identity_numeric_t6 including identity);
550\d+ t_identity_numeric_t6_1554\d+ t_identity_numeric_t6_1
551insert into t_identity_numeric_t6_1(name) values('xxx'); -- over int64555insert into t_identity_numeric_t6_1(name) values('xxx'); -- over int64
552insert into t_identity_numeric_t6_1(name) values('xxx1');556insert into t_identity_numeric_t6_1(name) values('xxx1');
@@ -568,7 +572,7 @@ drop table t_ident;
568-- create table like572-- create table like
569create sequence identity_t2_id_seq_identity;573create sequence identity_t2_id_seq_identity;
570create table identity_t2(id numeric(38, 0) identity(10, 2), b int);574create table identity_t2(id numeric(38, 0) identity(10, 2), b int);
571-create table identity_t2_1 (like identity_t2);575+create table identity_t2_1 (like identity_t2 including identity);
572insert into identity_t2_1(b) values (10);576insert into identity_t2_1(b) values (10);
573insert into identity_t2_1(b) values (10);577insert into identity_t2_1(b) values (10);
574select id, b from identity_t2_1;578select id, b from identity_t2_1;
@@ -586,5 +590,14 @@ select id, b from identity_t3_1;
586drop sequence identity_t3_id_seq_identity;590drop sequence identity_t3_id_seq_identity;
587drop table identity_t3;591drop table identity_t3;
588drop table identity_t3_1;592drop table identity_t3_1;
593+ 
594+ 
595+-- compatiable with pg identity
596+-- error
597+create table identity_t1(id numeric(38, 0) identity(1, 2) generated always as identity);
598+-- error
599+create table identity_t1(id numeric(38, 0) identity(1, 2), id2 numeric(37, 0) generated always as identity);
600+ 
601+ 
589reset current_schema;602reset current_schema;
590drop schema identity_schema;603drop schema identity_schema;
@@ -22,8 +22,10 @@ ALTER [ LARGE ] SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</repl
22 [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE | NOMAXVALUE ]22 [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE | NOMAXVALUE ]
23 [ OWNED BY { <replaceable class="parameter">table_name</replaceable>.<replaceable class="parameter">column_name</replaceable> | NONE } ];23 [ OWNED BY { <replaceable class="parameter">table_name</replaceable>.<replaceable class="parameter">column_name</replaceable> | NONE } ];
24ALTER [ LARGE ] SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>;24ALTER [ LARGE ] SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>;
25+ALTER SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
25 26 
26NOTICE: '[ LARGE ]' is only avaliable in CENTRALIZED mode!27NOTICE: '[ LARGE ]' is only avaliable in CENTRALIZED mode!
28+ 
27</synopsis>29</synopsis>
28 </refsynopsisdiv>30 </refsynopsisdiv>
29 31 
@@ -75,6 +75,9 @@ ADD [ COLUMN ] [IF NOT EXISTS] column_name data_type [ CHARACTER SET | CHARSET c
75 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )75 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )
76 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )76 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
77 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }77 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
78+ | ALTER [ COLUMN ] column_name ADD GENERATED generated_when AS IDENTITY [ ( seq_options) ]
79+ | ALTER [ COLUMN ] column_name alter_identity_column_option [ ... ]
80+ | ALTER [ COLUMN ] column_name DROP IDENTITY [ IF EXISTS ]
78NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!81NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
79NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!82NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
80where column_constraint can be:83where column_constraint can be:
@@ -84,6 +87,7 @@ where column_constraint can be:
84 CHECK ( expression ) |87 CHECK ( expression ) |
85 DEFAULT default_expr |88 DEFAULT default_expr |
86 GENERATED ALWAYS AS ( generation_expr ) [STORED] |89 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
90+ GENERATED generated_when AS IDENTITY ( seq_options ) |
87 AUTO_INCREMENT |91 AUTO_INCREMENT |
88 IDENTITY [ (seed , increment) ] |92 IDENTITY [ (seed , increment) ] |
89 UNIQUE [KEY] index_parameters |93 UNIQUE [KEY] index_parameters |
@@ -93,6 +97,7 @@ where column_constraint can be:
93 [ ON DELETE action ] [ ON UPDATE action ] }97 [ ON DELETE action ] [ ON UPDATE action ] }
94 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]98 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
95NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!99NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
100+NOTICE: 'GENERATED generated_when' in column_constraint not supported in MODIFY and CHANGE syntax!
96where compress_mode can be:101where compress_mode can be:
97{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }102{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
98where table_constraint can be:103where table_constraint can be:
@@ -111,6 +116,20 @@ where table_constraint_using_index can be:
111[ CONSTRAINT constraint_name ]116[ CONSTRAINT constraint_name ]
112 { UNIQUE | PRIMARY KEY } USING INDEX index_name117 { UNIQUE | PRIMARY KEY } USING INDEX index_name
113 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]118 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
119+where generated_when can be:
120+ ALWAYS
121+ | BY DEFAULT
122+where alter_identity_column_option can be:
123+ RESTART [ WITH ] NumericOnly
124+ | SET GENERATED generated_when
125+ | SET seq_option
126+where seq_option can be:
127+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE } NumericOnly
128+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
wofanzheng
wofanzhengwofanzheng5月19日

【问题】这里把无参序列选项写成了 MINVALUE,但实际语义应是 NOMINVALUE;同样的笔误在 doc/src/sgml/ref/create_table.sgmlin:74 也存在。按当前文档,用户会被引导去写一个需要参数的 MINVALUE,而不是真正可用的“取消最小值限制”语法。 【建议】建议把两处的选项列表统一改成 NOMINVALUE,与现有 CREATE/ALTER SEQUENCE 文档保持一致。

likedislike
129+where seq_options can be:
130+ seq_option
131+ | OWNED BY name
132+ | RESTART [ WITH ] NumericOnly
114 133 
115NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.134NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
116NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!135NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -124,6 +143,7 @@ NOTICE: '[ FIRST | AFTER column_name ]' in 'MODIFY | CHANGE [ COLUMN ] ...' clau
124NOTICE: '[ CHARACTER SET | CHARSET charset ]' is only available in CENTRALIZED mode and B-format database!143NOTICE: '[ CHARACTER SET | CHARSET charset ]' is only available in CENTRALIZED mode and B-format database!
125NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database!144NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database!
126NOTICE: 'IDENTITY [ (seed , increment) ]' is only avaliable in D-format database!145NOTICE: 'IDENTITY [ (seed , increment) ]' is only avaliable in D-format database!
146+ 
127</synopsis>147</synopsis>
128</refsynopsisdiv>148</refsynopsisdiv>
129</refentry>149</refentry>
@@ -29,6 +29,7 @@ where column_constraint can be:
29 NULL |29 NULL |
30 CHECK ( expression ) |30 CHECK ( expression ) |
31 DEFAULT default_expr |31 DEFAULT default_expr |
32+ GENERATED [ ALWAYS | BY DEFAULT ] AS IDENTITY [ ( seq_options ) ] |
32 GENERATED ALWAYS AS ( generation_expr ) [STORED] |33 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
33 AUTO_INCREMENT |34 AUTO_INCREMENT |
34 IDENTITY [ (seed , increment) ] |35 IDENTITY [ (seed , increment) ] |
@@ -51,7 +52,7 @@ where table_constraint can be:
51where compress_mode can be:52where compress_mode can be:
52{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }53{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
53where like_option can be:54where like_option can be:
54-{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }55+{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | IDENTITY | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }
55where index_parameters can be:56where index_parameters can be:
56[ WITH ( {storage_parameter = value} [, ... ] ) ]57[ WITH ( {storage_parameter = value} [, ... ] ) ]
57[ USING INDEX TABLESPACE tablespace_name ]58[ USING INDEX TABLESPACE tablespace_name ]
@@ -68,6 +69,10 @@ where list_distribution_rules can be:
68 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |69 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |
69 SLICE REFERENCES table_name70 SLICE REFERENCES table_name
70]71]
72+where seq_options can be:
73+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE | RESTART [ WITH ] } NumericOnly
74+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
wofanzheng
wofanzhengwofanzheng5月19日

【问题】这里把无参序列选项写成了 MINVALUE,但实际语义应是 NOMINVALUE 【建议】建议修正

likedislike
75+ | OWNED BY name
71 76 
72NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.77NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
73NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!78NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -14,6 +14,7 @@
14INSERT [/*+ plan_hint */] INTO14INSERT [/*+ plan_hint */] INTO
15 { table_name [partition_clause] [ AS alias ] [ ( column_name [, ...] ) ]15 { table_name [partition_clause] [ AS alias ] [ ( column_name [, ...] ) ]
16 | ( query [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] ) [ AS ] alias [ ( column_name [, ...] ) ] }16 | ( query [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] ) [ AS ] alias [ ( column_name [, ...] ) ] }
17+ [ OVERRIDING { SYSTEM | USER } VALUE ]
17 { DEFAULT VALUES | VALUES {( { expression | DEFAULT } [, ...] ) }[, ...] | query }18 { DEFAULT VALUES | VALUES {( { expression | DEFAULT } [, ...] ) }[, ...] | query }
18 [ ON DUPLICATE KEY UPDATE { NOTHING | { column_name = { expression | DEFAULT } } [, ...] [ WHERE condition ] } ]19 [ ON DUPLICATE KEY UPDATE { NOTHING | { column_name = { expression | DEFAULT } } [, ...] [ WHERE condition ] } ]
19 [ RETURNING {* | {output_expression [ [ AS ] output_name ] }[, ...]} ];20 [ RETURNING {* | {output_expression [ [ AS ] output_name ] }[, ...]} ];
@@ -23,8 +23,9 @@ ON ( condition )
23]23]
24[24[
25 WHEN NOT MATCHED THEN25 WHEN NOT MATCHED THEN
26- INSERT { DEFAULT VALUES |26+ INSERT [ ( column_name [, ...] ) ]
27- [ ( column_name [, ...] ) ] VALUES ( { expression | subquery | DEFAULT } [, ...] ) [, ...] [ WHERE condition ] }27+ [ OVERRIDING { SYSTEM | USER } VALUE ]
28+ { DEFAULT VALUES | VALUES ( { expression | subquery | DEFAULT } [, ...] ) [, ...] [ WHERE condition ] }
28];29];
29 30 
30where partition_clause can be:31where partition_clause can be:
@@ -13,6 +13,7 @@
13[NOTICE:REPLACE only has gained support in MySQL compatibility!]13[NOTICE:REPLACE only has gained support in MySQL compatibility!]
14REPLACE [LOW_PRIORITY | DELAYED]14REPLACE [LOW_PRIORITY | DELAYED]
15 [INTO] tbl_name [(col_name,...)]15 [INTO] tbl_name [(col_name,...)]
16+ [ OVERRIDING { SYSTEM | USER } VALUE ]
16 {VALUES | VALUE ({expr},...),...},...17 {VALUES | VALUE ({expr},...),...},...
17OR:18OR:
18REPLACE [LOW_PRIORITY | DELAYED]19REPLACE [LOW_PRIORITY | DELAYED]
@@ -71,6 +71,9 @@ ADD [ COLUMN ] [IF NOT EXISTS] column_name data_type [ CHARACTER SET | CHARSET c
71 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )71 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )
72 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )72 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
73 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }73 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
74+ | ALTER [ COLUMN ] column_name ADD GENERATED generated_when AS IDENTITY [ ( seq_options) ]
75+ | ALTER [ COLUMN ] column_name alter_identity_column_option [ ... ]
76+ | ALTER [ COLUMN ] column_name DROP IDENTITY [ IF EXISTS ]
74NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!77NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
75NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!78NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
76where column_constraint can be:79where column_constraint can be:
@@ -80,6 +83,7 @@ where column_constraint can be:
80 CHECK ( expression ) |83 CHECK ( expression ) |
81 DEFAULT default_expr |84 DEFAULT default_expr |
82 GENERATED ALWAYS AS ( generation_expr ) [STORED] |85 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
86+ GENERATED generated_when AS IDENTITY ( seq_options ) |
83 AUTO_INCREMENT |87 AUTO_INCREMENT |
84 IDENTITY [ (seed , increment) ] |88 IDENTITY [ (seed , increment) ] |
85 UNIQUE [KEY] index_parameters |89 UNIQUE [KEY] index_parameters |
@@ -89,6 +93,7 @@ where column_constraint can be:
89 [ ON DELETE action ] [ ON UPDATE action ] }93 [ ON DELETE action ] [ ON UPDATE action ] }
90 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]94 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
91NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!95NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
96+NOTICE: 'GENERATED generated_when' in column_constraint not supported in MODIFY and CHANGE syntax!
92where compress_mode can be:97where compress_mode can be:
93{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }98{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
94where table_constraint can be:99where table_constraint can be:
@@ -107,6 +112,20 @@ where table_constraint_using_index can be:
107[ CONSTRAINT constraint_name ]112[ CONSTRAINT constraint_name ]
108 { UNIQUE | PRIMARY KEY } USING INDEX index_name113 { UNIQUE | PRIMARY KEY } USING INDEX index_name
109 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]114 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
115+where generated_when can be:
116+ ALWAYS
117+ | BY DEFAULT
118+where alter_identity_column_option can be:
119+ RESTART [ WITH ] NumericOnly
120+ | SET GENERATED generated_when
121+ | SET seq_option
122+where seq_option can be:
123+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE } NumericOnly
124+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
125+where seq_options can be:
126+ seq_option
127+ | OWNED BY name
128+ | RESTART [ WITH ] NumericOnly
110 129 
111NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.130NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
112NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!131NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -84,7 +84,7 @@ PARTITION BY RANGE (c1) SUBPARTITION BY RANGE (c2)
84select CONSTRAINT_CATALOG,CONSTRAINT_SCHEMA,CONSTRAINT_NAME,TABLE_SCHEMA,TABLE_NAME,CONSTRAINT_TYPE,ENFORCED from information_schema.table_constraints order by 1,2,3,4 limit 1;84select CONSTRAINT_CATALOG,CONSTRAINT_SCHEMA,CONSTRAINT_NAME,TABLE_SCHEMA,TABLE_NAME,CONSTRAINT_TYPE,ENFORCED from information_schema.table_constraints order by 1,2,3,4 limit 1;
85 constraint_catalog | constraint_schema | constraint_name | table_schema | table_name | constraint_type | enforced 85 constraint_catalog | constraint_schema | constraint_name | table_schema | table_name | constraint_type | enforced
86--------------------+-------------------+-----------------------+--------------+---------------+-----------------+----------86--------------------+-------------------+-----------------------+--------------+---------------+-----------------+----------
87- test_b1 | coverage | 4994_13141_1_not_null | coverage | proc_coverage | CHECK | YES87+--? test_b1 | coverage | .* | coverage | proc_coverage | CHECK | YES
88(1 row)88(1 row)
89 89 
90select CHARACTER_SET_NAME,DEFAULT_COLLATE_NAME,DESCRIPTION,MAXLEN from INFORMATION_SCHEMA.CHARACTER_SETS order by 1,2,3,4 limit 1;90select CHARACTER_SET_NAME,DEFAULT_COLLATE_NAME,DESCRIPTION,MAXLEN from INFORMATION_SCHEMA.CHARACTER_SETS order by 1,2,3,4 limit 1;
@@ -96,7 +96,7 @@ select CHARACTER_SET_NAME,DEFAULT_COLLATE_NAME,DESCRIPTION,MAXLEN from INFORMATI
96select CONSTRAINT_CATALOG,CONSTRAINT_SCHEMA,CONSTRAINT_NAME,CHECK_CLAUSE FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS order by 1,2,3,4 limit 1;96select CONSTRAINT_CATALOG,CONSTRAINT_SCHEMA,CONSTRAINT_NAME,CHECK_CLAUSE FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS order by 1,2,3,4 limit 1;
97 constraint_catalog | constraint_schema | constraint_name | check_clause 97 constraint_catalog | constraint_schema | constraint_name | check_clause
98--------------------+-------------------+-----------------------+-------------------------98--------------------+-------------------+-----------------------+-------------------------
99- test_b1 | coverage | 4994_13141_1_not_null | coverage_id IS NOT NULL99+--? test_b1 | coverage | .* | coverage_id IS NOT NULL
100(1 row)100(1 row)
101 101 
102select COLLATION_NAME,CHARACTER_SET_NAME,IS_DEFAULT,IS_COMPILED,SORTLEN,PAD_ATTRIBUTE from INFORMATION_SCHEMA.COLLATIONS order by 1,2,3,4 limit 1;102select COLLATION_NAME,CHARACTER_SET_NAME,IS_DEFAULT,IS_COMPILED,SORTLEN,PAD_ATTRIBUTE from INFORMATION_SCHEMA.COLLATIONS order by 1,2,3,4 limit 1;
@@ -513,6 +513,7 @@ where column_constraint can be:
513 NULL |513 NULL |
514 CHECK ( expression ) |514 CHECK ( expression ) |
515 DEFAULT default_expr |515 DEFAULT default_expr |
516+ GENERATED [ ALWAYS | BY DEFAULT ] AS IDENTITY [ ( seq_options ) ] |
516 GENERATED ALWAYS AS ( generation_expr ) [STORED] |517 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
517 AUTO_INCREMENT |518 AUTO_INCREMENT |
518 IDENTITY [ (seed , increment) ] |519 IDENTITY [ (seed , increment) ] |
@@ -535,7 +536,7 @@ where table_constraint can be:
535where compress_mode can be:536where compress_mode can be:
536{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }537{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
537where like_option can be:538where like_option can be:
538-{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }539+{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | IDENTITY | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }
539where index_parameters can be:540where index_parameters can be:
540[ WITH ( {storage_parameter = value} [, ... ] ) ]541[ WITH ( {storage_parameter = value} [, ... ] ) ]
541[ USING INDEX TABLESPACE tablespace_name ]542[ USING INDEX TABLESPACE tablespace_name ]
@@ -552,6 +553,10 @@ where list_distribution_rules can be:
552 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |553 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |
553 SLICE REFERENCES table_name554 SLICE REFERENCES table_name
554]555]
556+where seq_options can be:
557+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE | RESTART [ WITH ] } NumericOnly
558+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
559+ | OWNED BY name
555 560 
556NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.561NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
557NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!562NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -780,6 +785,9 @@ ADD [ COLUMN ] [IF NOT EXISTS] column_name data_type [ CHARACTER SET | CHARSET c
780 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )785 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )
781 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )786 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
782 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }787 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
788+ | ALTER [ COLUMN ] column_name ADD GENERATED generated_when AS IDENTITY [ ( seq_options) ]
789+ | ALTER [ COLUMN ] column_name alter_identity_column_option [ ... ]
790+ | ALTER [ COLUMN ] column_name DROP IDENTITY [ IF EXISTS ]
783NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!791NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
784NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!792NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
785where column_constraint can be:793where column_constraint can be:
@@ -789,6 +797,7 @@ where column_constraint can be:
789 CHECK ( expression ) |797 CHECK ( expression ) |
790 DEFAULT default_expr |798 DEFAULT default_expr |
791 GENERATED ALWAYS AS ( generation_expr ) [STORED] |799 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
800+ GENERATED generated_when AS IDENTITY ( seq_options ) |
792 AUTO_INCREMENT |801 AUTO_INCREMENT |
793 IDENTITY [ (seed , increment) ] |802 IDENTITY [ (seed , increment) ] |
794 UNIQUE [KEY] index_parameters |803 UNIQUE [KEY] index_parameters |
@@ -798,6 +807,7 @@ where column_constraint can be:
798 [ ON DELETE action ] [ ON UPDATE action ] }807 [ ON DELETE action ] [ ON UPDATE action ] }
799 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]808 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
800NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!809NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
810+NOTICE: 'GENERATED generated_when' in column_constraint not supported in MODIFY and CHANGE syntax!
801where compress_mode can be:811where compress_mode can be:
802{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }812{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
803where table_constraint can be:813where table_constraint can be:
@@ -816,6 +826,20 @@ where table_constraint_using_index can be:
816[ CONSTRAINT constraint_name ]826[ CONSTRAINT constraint_name ]
817 { UNIQUE | PRIMARY KEY } USING INDEX index_name827 { UNIQUE | PRIMARY KEY } USING INDEX index_name
818 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]828 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
829+where generated_when can be:
830+ ALWAYS
831+ | BY DEFAULT
832+where alter_identity_column_option can be:
833+ RESTART [ WITH ] NumericOnly
834+ | SET GENERATED generated_when
835+ | SET seq_option
836+where seq_option can be:
837+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE } NumericOnly
838+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
839+where seq_options can be:
840+ seq_option
841+ | OWNED BY name
842+ | RESTART [ WITH ] NumericOnly
819 843 
820NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.844NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
821NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!845NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -47,8 +47,9 @@ ERROR: both default and generation expression specified for column "b" of table
47LINE 1: ... gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ...47LINE 1: ... gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ...
48 ^48 ^
49CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ALWAYS AS (a * 2) STORED);49CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ALWAYS AS (a * 2) STORED);
50-ERROR: syntax error at or near "identity"50+NOTICE: CREATE TABLE will create implicit sequence "gtest_err_5b_b_seq" for serial column "gtest_err_5b.b"
51-LINE 1: ..._5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity G...51+ERROR: both default and generation expression specified for column "b" of table "gtest_err_5b"
52+LINE 1: ...t PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ...
52 ^53 ^
53-- reference to system column not allowed in generated column54-- reference to system column not allowed in generated column
54CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED);55CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED);
@@ -17,8 +17,9 @@ ON ( condition )
17]17]
18[18[
19 WHEN NOT MATCHED THEN19 WHEN NOT MATCHED THEN
20- INSERT { DEFAULT VALUES |20+ INSERT [ ( column_name [, ...] ) ]
21- [ ( column_name [, ...] ) ] VALUES ( { expression | subquery | DEFAULT } [, ...] ) [, ...] [ WHERE condition ] }21+ [ OVERRIDING { SYSTEM | USER } VALUE ]
22+ { DEFAULT VALUES | VALUES ( { expression | subquery | DEFAULT } [, ...] ) [, ...] [ WHERE condition ] }
22];23];
23NOTICE: 'subquery' in the UPDATE and INSERT clauses are only avaliable in CENTRALIZED mode!24NOTICE: 'subquery' in the UPDATE and INSERT clauses are only avaliable in CENTRALIZED mode!
24 25 
@@ -5724,6 +5724,22 @@ select nextval('t_auto_nextval_test_b_seq'); -- error
5724ERROR: cannot change sequence owned by auto_increment column5724ERROR: cannot change sequence owned by auto_increment column
5725CONTEXT: referenced column: nextval5725CONTEXT: referenced column: nextval
5726drop table t_auto_nextval_test;5726drop table t_auto_nextval_test;
5727+-- error cases
5728+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY auto_increment, b text);
5729+NOTICE: CREATE TABLE will create implicit sequence "test_t1_a_seq" for serial column "test_t1.a"
5730+ERROR: multiple default values specified for column "a" of table "test_t1"
5731+LINE 1: ...TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY auto_incre...
5732+ ^
5733+CREATE TABLE test_t1 (a timestamptz GENERATED ALWAYS AS IDENTITY ON UPDATE current_timestamp, b text);
5734+ERROR: Identity column 'a' data type invalid.
5735+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY ON UPDATE current_timestamp, b text);
5736+NOTICE: CREATE TABLE will create implicit sequence "test_t1_a_seq" for serial column "test_t1.a"
5737+ERROR: column "a" is of type integer but default expression is of type timestamp with time zone
5738+HINT: You will need to rewrite or cast the expression.
5739+CREATE TABLE test_t1 (a int ON UPDATE current_timestamp auto_increment, b text);
5740+ERROR: multiple default values specified for column "a" of table "test_t1"
5741+LINE 1: ... TABLE test_t1 (a int ON UPDATE current_timestamp auto_incre...
5742+ ^
5727\c regression5743\c regression
5728clean connection to all force for database autoinc_b_db;5744clean connection to all force for database autoinc_b_db;
5729drop database if exists autoinc_b_db;5745drop database if exists autoinc_b_db;
@@ -11,6 +11,7 @@ Syntax:
11INSERT [/*+ plan_hint */] INTO11INSERT [/*+ plan_hint */] INTO
12 { table_name [partition_clause] [ AS alias ] [ ( column_name [, ...] ) ]12 { table_name [partition_clause] [ AS alias ] [ ( column_name [, ...] ) ]
13 | ( query [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] ) [ AS ] alias [ ( column_name [, ...] ) ] }13 | ( query [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] ) [ AS ] alias [ ( column_name [, ...] ) ] }
14+ [ OVERRIDING { SYSTEM | USER } VALUE ]
14 { DEFAULT VALUES | VALUES {( { expression | DEFAULT } [, ...] ) }[, ...] | query }15 { DEFAULT VALUES | VALUES {( { expression | DEFAULT } [, ...] ) }[, ...] | query }
15 [ ON DUPLICATE KEY UPDATE { NOTHING | { column_name = { expression | DEFAULT } } [, ...] [ WHERE condition ] } ]16 [ ON DUPLICATE KEY UPDATE { NOTHING | { column_name = { expression | DEFAULT } } [, ...] [ WHERE condition ] } ]
16 [ RETURNING {* | {output_expression [ [ AS ] output_name ] }[, ...]} ];17 [ RETURNING {* | {output_expression [ [ AS ] output_name ] }[, ...]} ];
@@ -0,0 +1,39 @@
1+create database test_pg_identity_dump_restore dbcompatibility 'A';
2+create database test_pg_identity_dump_restore_1 dbcompatibility 'A';
3+\c test_pg_identity_dump_restore
4+create schema test_pg_identity_dump_restore;
5+set current_schema = test_pg_identity_dump_restore;
6+ 
7+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY (START WITH 20 INCREMENT 2 NOMAXVALUE NOMINVALUE), b text);
8+CREATE TABLE test_t2 (a int GENERATED BY DEFAULT AS IDENTITY ( START 10 INCREMENT 1 MAXVALUE 2222), b text);
9+ALTER TABLE test_t2 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY (START 20 NOMAXVALUE NOMINVALUE NOCYCLE); -- success
10+ALTER TABLE test_t2 ALTER COLUMN c SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART;
11+ 
12+INSERT INTO test_t1 DEFAULT VALUES;
13+INSERT INTO test_t1 DEFAULT VALUES;
14+INSERT INTO test_t2 DEFAULT VALUES;
15+INSERT INTO test_t2 DEFAULT VALUES;
16+ 
17+ 
18+\! @abs_bindir@/gs_dump test_pg_identity_dump_restore -p @portstring@ -f @abs_bindir@/test_pg_identity_dump_restore.sql -n test_pg_identity_dump_restore -w >/dev/null 2>&1; echo $?
19+\! @abs_bindir@/gsql -dtest_pg_identity_dump_restore_1 -p @portstring@ -f "@abs_bindir@/test_pg_identity_dump_restore.sql";
20+ 
21+\c test_pg_identity_dump_restore_1
22+set current_schema = test_pg_identity_dump_restore;
23+ 
24+\d+ test_t1
25+\d+ test_t2
26+truncate test_t1;
27+truncate test_t2;
28+\d+ test_t2_c_seq
29+ 
30+INSERT INTO test_t1 DEFAULT VALUES;
31+INSERT INTO test_t1 DEFAULT VALUES;
32+INSERT INTO test_t2 DEFAULT VALUES;
33+INSERT INTO test_t2 DEFAULT VALUES;
34+select * from test_t1 order by 1, 2;
35+select * from test_t2 order by 1, 2;
36+ 
37+\c regression
38+DROP DATABASE test_pg_identity_dump_restore;
39+DROP DATABASE test_pg_identity_dump_restore_1;
@@ -452,6 +452,7 @@ where column_constraint can be:
452 NULL |452 NULL |
453 CHECK ( expression ) |453 CHECK ( expression ) |
454 DEFAULT default_expr |454 DEFAULT default_expr |
455+ GENERATED [ ALWAYS | BY DEFAULT ] AS IDENTITY [ ( seq_options ) ] |
455 GENERATED ALWAYS AS ( generation_expr ) [STORED] |456 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
456 AUTO_INCREMENT |457 AUTO_INCREMENT |
457 IDENTITY [ (seed , increment) ] |458 IDENTITY [ (seed , increment) ] |
@@ -474,7 +475,7 @@ where table_constraint can be:
474where compress_mode can be:475where compress_mode can be:
475{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }476{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
476where like_option can be:477where like_option can be:
477-{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }478+{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | IDENTITY | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | PARTITION | RELOPTIONS | DISTRIBUTION | ALL }
478where index_parameters can be:479where index_parameters can be:
479[ WITH ( {storage_parameter = value} [, ... ] ) ]480[ WITH ( {storage_parameter = value} [, ... ] ) ]
480[ USING INDEX TABLESPACE tablespace_name ]481[ USING INDEX TABLESPACE tablespace_name ]
@@ -491,6 +492,10 @@ where list_distribution_rules can be:
491 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |492 ( SLICE name VALUES (DEFAULT) [DATANODE datanode_name] ) |
492 SLICE REFERENCES table_name493 SLICE REFERENCES table_name
493]494]
495+where seq_options can be:
496+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE | RESTART [ WITH ] } NumericOnly
497+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
498+ | OWNED BY name
494 499 
495NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.500NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
496NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!501NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -719,6 +724,9 @@ ADD [ COLUMN ] [IF NOT EXISTS] column_name data_type [ CHARACTER SET | CHARSET c
719 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )724 | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )
720 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )725 | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
721 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }726 | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
727+ | ALTER [ COLUMN ] column_name ADD GENERATED generated_when AS IDENTITY [ ( seq_options) ]
728+ | ALTER [ COLUMN ] column_name alter_identity_column_option [ ... ]
729+ | ALTER [ COLUMN ] column_name DROP IDENTITY [ IF EXISTS ]
722NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!730NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
723NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!731NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
724where column_constraint can be:732where column_constraint can be:
@@ -728,6 +736,7 @@ where column_constraint can be:
728 CHECK ( expression ) |736 CHECK ( expression ) |
729 DEFAULT default_expr |737 DEFAULT default_expr |
730 GENERATED ALWAYS AS ( generation_expr ) [STORED] |738 GENERATED ALWAYS AS ( generation_expr ) [STORED] |
739+ GENERATED generated_when AS IDENTITY ( seq_options ) |
731 AUTO_INCREMENT |740 AUTO_INCREMENT |
732 IDENTITY [ (seed , increment) ] |741 IDENTITY [ (seed , increment) ] |
733 UNIQUE [KEY] index_parameters |742 UNIQUE [KEY] index_parameters |
@@ -737,6 +746,7 @@ where column_constraint can be:
737 [ ON DELETE action ] [ ON UPDATE action ] }746 [ ON DELETE action ] [ ON UPDATE action ] }
738 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]747 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
739NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!748NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
749+NOTICE: 'GENERATED generated_when' in column_constraint not supported in MODIFY and CHANGE syntax!
740where compress_mode can be:750where compress_mode can be:
741{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }751{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
742where table_constraint can be:752where table_constraint can be:
@@ -755,6 +765,20 @@ where table_constraint_using_index can be:
755[ CONSTRAINT constraint_name ]765[ CONSTRAINT constraint_name ]
756 { UNIQUE | PRIMARY KEY } USING INDEX index_name766 { UNIQUE | PRIMARY KEY } USING INDEX index_name
757 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]767 [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
768+where generated_when can be:
769+ ALWAYS
770+ | BY DEFAULT
771+where alter_identity_column_option can be:
772+ RESTART [ WITH ] NumericOnly
773+ | SET GENERATED generated_when
774+ | SET seq_option
775+where seq_option can be:
776+ { MAXVALUE | MINVALUE | START WITH | START | INCREMENT [ BY ] | CACHE } NumericOnly
777+ | { NOMAXVALUE | MINVALUE | NO MAXVALUE | NO MINVALUE | NOCYCLE | [ NO ] CYCLE }
778+where seq_options can be:
779+ seq_option
780+ | OWNED BY name
781+ | RESTART [ WITH ] NumericOnly
758 782 
759NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.783NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
760NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!784NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
@@ -0,0 +1,119 @@
1+create database test_pg_identity_dump_restore dbcompatibility 'A';
2+create database test_pg_identity_dump_restore_1 dbcompatibility 'A';
3+\c test_pg_identity_dump_restore
4+create schema test_pg_identity_dump_restore;
5+set current_schema = test_pg_identity_dump_restore;
6+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY (START WITH 20 INCREMENT 2 NOMAXVALUE NOMINVALUE), b text);
7+NOTICE: CREATE TABLE will create implicit sequence "test_t1_a_seq" for serial column "test_t1.a"
8+CREATE TABLE test_t2 (a int GENERATED BY DEFAULT AS IDENTITY ( START 10 INCREMENT 1 MAXVALUE 2222), b text);
9+NOTICE: CREATE TABLE will create implicit sequence "test_t2_a_seq" for serial column "test_t2.a"
10+ALTER TABLE test_t2 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY (START 20 NOMAXVALUE NOMINVALUE NOCYCLE); -- success
11+NOTICE: ALTER TABLE will create implicit sequence "test_t2_c_seq" for serial column "test_t2.c"
12+ALTER TABLE test_t2 ALTER COLUMN c SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART;
13+INSERT INTO test_t1 DEFAULT VALUES;
14+INSERT INTO test_t1 DEFAULT VALUES;
15+INSERT INTO test_t2 DEFAULT VALUES;
16+INSERT INTO test_t2 DEFAULT VALUES;
17+\! @abs_bindir@/gs_dump test_pg_identity_dump_restore -p @portstring@ -f @abs_bindir@/test_pg_identity_dump_restore.sql -n test_pg_identity_dump_restore -w >/dev/null 2>&1; echo $?
18+0
19+\! @abs_bindir@/gsql -dtest_pg_identity_dump_restore_1 -p @portstring@ -f "@abs_bindir@/test_pg_identity_dump_restore.sql";
20+SET
21+SET
22+SET
23+SET
24+SET
25+SET
26+SET
27+SET
28+SET
29+SET
30+SET
31+CREATE SCHEMA
32+ALTER SCHEMA
33+SET
34+SET
35+SET
36+CREATE TABLE
37+ALTER TABLE
38+ALTER TABLE
39+CREATE TABLE
40+ALTER TABLE
41+ALTER TABLE
42+ALTER TABLE
43+ setval
44+--------
45+ 22
46+(1 row)
47+ 
48+ setval
49+--------
50+ 11
51+(1 row)
52+ 
53+ setval
54+--------
55+ 102
56+(1 row)
57+ 
58+--?total time:.*
59+\c test_pg_identity_dump_restore_1
60+set current_schema = test_pg_identity_dump_restore;
61+\d+ test_t1
62+ Table "test_pg_identity_dump_restore.test_t1"
63+ Column | Type | Modifiers | Storage | Stats target | Description
64+--------+---------+---------------------------------------+----------+--------------+-------------
65+ a | integer | not null generated always as identity | plain | |
66+ b | text | | extended | |
67+Has OIDs: no
68+Options: orientation=row, compression=no
69+ 
70+\d+ test_t2
71+ Table "test_pg_identity_dump_restore.test_t2"
72+ Column | Type | Modifiers | Storage | Stats target | Description
73+--------+---------+-------------------------------------------+----------+--------------+-------------
74+ a | integer | not null generated by default as identity | plain | |
75+ b | text | | extended | |
76+ c | integer | not null generated by default as identity | plain | |
77+Has OIDs: no
78+Options: orientation=row, compression=no
79+ 
80+truncate test_t1;
81+truncate test_t2;
82+\d+ test_t2_c_seq
83+ Sequence "test_pg_identity_dump_restore.test_t2_c_seq"
84+ Column | Type | Value | Storage
85+---------------+---------+---------------------+---------
86+ sequence_name | name | test_t2_c_seq | plain
87+ last_value | bigint | 102 | plain
88+ start_value | bigint | 100 | plain
89+ increment_by | bigint | 2 | plain
90+ max_value | bigint | 9223372036854775807 | plain
91+ min_value | bigint | 1 | plain
92+ cache_value | bigint | 1 | plain
93+ log_cnt | bigint | 0 | plain
94+ is_cycled | boolean | f | plain
95+ is_called | boolean | t | plain
96+ uuid | bigint | 0 | plain
97+Sequence for identity column: test_pg_identity_dump_restore.test_t2.c
98+ 
99+INSERT INTO test_t1 DEFAULT VALUES;
100+INSERT INTO test_t1 DEFAULT VALUES;
101+INSERT INTO test_t2 DEFAULT VALUES;
102+INSERT INTO test_t2 DEFAULT VALUES;
103+select * from test_t1 order by 1, 2;
104+ a | b
105+----+---
106+ 24 |
107+ 26 |
108+(2 rows)
109+ 
110+select * from test_t2 order by 1, 2;
111+ a | b | c
112+----+---+-----
113+ 12 | | 104
114+ 13 | | 106
115+(2 rows)
116+ 
117+\c regression
118+DROP DATABASE test_pg_identity_dump_restore;
119+DROP DATABASE test_pg_identity_dump_restore_1;
@@ -519,6 +519,8 @@ test: test_binary_suffix
519# test for rotate and unrotate function519# test for rotate and unrotate function
520test: gb_ora_rotate_unrotate520test: gb_ora_rotate_unrotate
521 521 
522+test: pg_identity pg_identity_dump_restore
523+ 
522# test for string type char byte semantic524# test for string type char byte semantic
523test: bpchar_charbyte bpchar_cast bpchar_copy bpchar_index bpchar_regexmatch varchar_charbyte varchar_cast varchar_copy varchar_index varchar_regexmatch char_length_semantic525test: bpchar_charbyte bpchar_cast bpchar_copy bpchar_index bpchar_regexmatch varchar_charbyte varchar_cast varchar_copy varchar_index varchar_regexmatch char_length_semantic
524test: gs_dump_char_semantic526test: gs_dump_char_semantic
@@ -1703,6 +1703,12 @@ create table t_auto_nextval_test(a int, b int auto_increment primary key);
1703select nextval('t_auto_nextval_test_b_seq'); -- error1703select nextval('t_auto_nextval_test_b_seq'); -- error
1704drop table t_auto_nextval_test;1704drop table t_auto_nextval_test;
1705 1705 
1706+-- error cases
1707+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY auto_increment, b text);
1708+CREATE TABLE test_t1 (a timestamptz GENERATED ALWAYS AS IDENTITY ON UPDATE current_timestamp, b text);
1709+CREATE TABLE test_t1 (a int GENERATED ALWAYS AS IDENTITY ON UPDATE current_timestamp, b text);
1710+CREATE TABLE test_t1 (a int ON UPDATE current_timestamp auto_increment, b text);
1711+ 
1706\c regression1712\c regression
1707clean connection to all force for database autoinc_b_db;1713clean connection to all force for database autoinc_b_db;
1708drop database if exists autoinc_b_db;1714drop database if exists autoinc_b_db;