已关闭
[Feat] testcase of pg generated as identity #9226
XXXCA创建于 5月6日关闭于 7月23日
[Feat] testcase of pg generated as identity #9226
已关闭
共 30 个文件变更+5690-116
| @@ -354,7 +354,11 @@ select @@fetch_status; | |||
| 354 | fetch next from c2; -- expect error | 354 | fetch next from c2; -- expect error |
| 355 | ERROR: cursor "c2" does not exist | 355 | ERROR: cursor "c2" does not exist |
| 356 | select @@fetch_status; | 356 | select @@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 | + | ||
| 358 | rollback transaction; | 362 | rollback transaction; |
| 359 | -- multi cursors | 363 | -- multi cursors |
| 360 | begin transaction; | 364 | begin transaction; |
| @@ -39,13 +39,14 @@ select * from book; | |||
| 39 | (4 rows) | 39 | (4 rows) |
| 40 | 40 | ||
| 41 | ALTER table book add column id int identity; | 41 | ALTER 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. | ||
| 43 | ALTER table book alter bookId type text; | 44 | ALTER table book alter bookId type text; |
| 44 | -ERROR: Identity column 'bookid' data type invalid. | 45 | +ERROR: Not supported alter identity column bookid type |
| 45 | drop table if exists book; | 46 | drop table if exists book; |
| 46 | CREATE TABLE book(id int identity, bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50)); | 47 | CREATE TABLE book(id int identity, bookId int IDENTITY, bookname NVARCHAR(50), author NVARCHAR(50)); |
| 47 | NOTICE: CREATE TABLE will create implicit sequence "book_id_seq_identity" for serial column "book.id" | 48 | NOTICE: CREATE TABLE will create implicit sequence "book_id_seq_identity" for serial column "book.id" |
| 48 | -ERROR: table can only have one identity column | 49 | +ERROR: Multiple identity columns specified for table "book". Only one identity column per table is allowed. |
| 49 | CREATE TABLE book | 50 | CREATE 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)); | |||
| 265 | NOTICE: CREATE TABLE will create implicit sequence "book_id_seq" for serial column "book.id" | 266 | NOTICE: CREATE TABLE will create implicit sequence "book_id_seq" for serial column "book.id" |
| 266 | NOTICE: CREATE TABLE will create implicit sequence "book_bookid_seq_identity" for serial column "book.bookid" | 267 | NOTICE: CREATE TABLE will create implicit sequence "book_bookid_seq_identity" for serial column "book.bookid" |
| 267 | ERROR: multiple default values specified for column "bookid" of table "book" | 268 | ERROR: multiple default values specified for column "bookid" of table "book" |
| 269 | +LINE 1: CREATE TABLE book(id serial, bookId int identity default 5, ... | ||
| 270 | + ^ | ||
| 268 | CREATE TABLE t_identity(id serial, col int identity(5,10), col2 text) | 271 | CREATE TABLE t_identity(id serial, col int identity(5,10), col2 text) |
| 269 | partition by range(col)( | 272 | partition by range(col)( |
| 270 | partition p1 VALUES LESS THAN (10), | 273 | partition p1 VALUES LESS THAN (10), |
| @@ -477,9 +480,8 @@ insert into t_identity_0013(name) values('lisi'); | |||
| 477 | insert into t_identity_0013(name) values('wangwu'); | 480 | insert into t_identity_0013(name) values('wangwu'); |
| 478 | --error | 481 | --error |
| 479 | update t_identity_0013 set id=4 where name='zhangsan'; | 482 | update 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 | - ^ | ||
| 483 | drop table t_identity_0013; | 485 | drop table t_identity_0013; |
| 484 | -- ## ident_current after truncate table. expected: success. | 486 | -- ## ident_current after truncate table. expected: success. |
| 485 | create table t_identity_0021(id int identity(100,1), name varchar(10)); | 487 | create 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); | ||
| 537 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_0023_1_id_seq_identity" for serial column "t_identity_0023_1.id" | 555 | NOTICE: 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_1 | 556 | \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 | | |
| 544 | Has OIDs: no | 562 | Has OIDs: no |
| 545 | Options: orientation=row, compression=no, collate=1537 | 563 | Options: orientation=row, compression=no, collate=1537 |
| 546 | Character Set: UTF8 | 564 | Character Set: UTF8 |
| @@ -590,24 +608,27 @@ select * from t_identity_0023_1 order by id; | |||
| 590 | 608 | ||
| 591 | -- including DEFAULTS. | 609 | -- including DEFAULTS. |
| 592 | create table t_identity_0023_2 (like t_identity_0023 INCLUDING DEFAULTS); | 610 | create 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_2 | 611 | \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 | | |
| 600 | Has OIDs: no | 617 | Has OIDs: no |
| 601 | Options: orientation=row, compression=no, collate=1537 | 618 | Options: orientation=row, compression=no, collate=1537 |
| 602 | Character Set: UTF8 | 619 | Character Set: UTF8 |
| 603 | Collate: utf8mb4_general_ci | 620 | Collate: utf8mb4_general_ci |
| 604 | 621 | ||
| 605 | insert t_identity_0023_2 (name) values('xxx1'); | 622 | insert 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). | ||
| 606 | insert t_identity_0023_2 (name) values('xxx1'); | 625 | insert 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). | ||
| 607 | select ident_current('t_identity_0023_2'); | 628 | select ident_current('t_identity_0023_2'); |
| 608 | ident_current | 629 | ident_current |
| 609 | --------------- | 630 | --------------- |
| 610 | - 101 | 631 | + |
| 611 | (1 row) | 632 | (1 row) |
| 612 | 633 | ||
| 613 | select scope_identity(); | 634 | select scope_identity(); |
| @@ -616,7 +637,7 @@ select scope_identity(); | |||
| 616 | 101 | 637 | 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; |
| 620 | drop table t_identity_0023_1; | 641 | drop table t_identity_0023_1; |
| 621 | drop table t_identity_0023_2; | 642 | drop 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); | |||
| 626 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_id_seq_identity" for serial column "t_identity.id" | 647 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_id_seq_identity" for serial column "t_identity.id" |
| 627 | -- expected error. | 648 | -- expected error. |
| 628 | insert into t_identity(id, col) values(2,'zshan'); | 649 | insert 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". |
| 632 | select ident_current('t_identity'); | 653 | select ident_current('t_identity'); |
| 633 | ident_current | 654 | ident_current |
| 634 | --------------- | 655 | --------------- |
| @@ -665,9 +686,9 @@ insert into t_identity(col) select 'test'; | |||
| 665 | insert into t_identity(col) select 'test'; | 686 | insert into t_identity(col) select 'test'; |
| 666 | -- expected error. | 687 | -- expected error. |
| 667 | insert into t_identity(id, col) select 1, 'test'; | 688 | insert 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. |
| 672 | set identity_insert = on; | 693 | set identity_insert = on; |
| 673 | insert into t_identity(id, col) select 1, 'test'; | 694 | insert 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. |
| 700 | insert into t_identity(id, col) values(100, 'newtest') | 721 | insert 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. |
| 706 | insert into t_identity(col) values(100, 'newtest') | 727 | insert 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 | |||
| 740 | merge into target_table AS t using source_table AS s ON t.id = s.id | 761 | merge into target_table AS t using source_table AS s ON t.id = s.id |
| 741 | when not matched then | 762 | when 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. |
| 747 | set identity_insert = on; | 768 | set identity_insert = on; |
| 748 | merge into target_table AS t using source_table AS s ON t.id = s.id | 769 | merge 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 | |||
| 795 | select id as id_alias into t_identity_0024_02_1 from t_identity_0024; | 816 | select id as id_alias into t_identity_0024_02_1 from t_identity_0024; |
| 796 | NOTICE: 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" | 817 | NOTICE: 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_1 | 818 | \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 | | |
| 802 | Has OIDs: no | 823 | Has OIDs: no |
| 803 | Options: orientation=row, compression=no, collate=1537 | 824 | Options: orientation=row, compression=no, collate=1537 |
| 804 | Character Set: UTF8 | 825 | Character Set: UTF8 |
| @@ -813,12 +834,12 @@ select ident_current('t_identity_0024_02_1'); | |||
| 813 | select * into t_identity_0024_03 from t_identity_0024; | 834 | select * into t_identity_0024_03 from t_identity_0024; |
| 814 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_03_id_seq_identity" for serial column "t_identity_0024_03.id" | 835 | NOTICE: 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_03 | 836 | \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 | | |
| 822 | Has OIDs: no | 843 | Has OIDs: no |
| 823 | Options: orientation=row, compression=no, collate=1537 | 844 | Options: orientation=row, compression=no, collate=1537 |
| 824 | Character Set: UTF8 | 845 | Character Set: UTF8 |
| @@ -833,11 +854,11 @@ select ident_current('t_identity_0024_03'); | |||
| 833 | select id, age as alias_age into t_identity_0024_04 from t_identity_0024; | 854 | select id, age as alias_age into t_identity_0024_04 from t_identity_0024; |
| 834 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_0024_04_id_seq_identity" for serial column "t_identity_0024_04.id" | 855 | NOTICE: 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_04 | 856 | \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 | | |
| 841 | Has OIDs: no | 862 | Has OIDs: no |
| 842 | Options: orientation=row, compression=no, collate=1537 | 863 | Options: orientation=row, compression=no, collate=1537 |
| 843 | Character Set: UTF8 | 864 | Character Set: UTF8 |
| @@ -868,9 +889,9 @@ select * from t_identity_0024_04 order by id; | |||
| 868 | set identity_insert = off; | 889 | set identity_insert = off; |
| 869 | -- expected: error | 890 | -- expected: error |
| 870 | insert into t_identity_0024_04(id, alias_age) values (1000, 22); | 891 | insert 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". |
| 874 | set identity_insert = on; | 895 | set identity_insert = on; |
| 875 | -- expected: success | 896 | -- expected: success |
| 876 | insert into t_identity_0024_04(id, alias_age) values (1000, 22); | 897 | insert 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 | |||
| 947 | select * into t_serial_identity_001_1 from t_serial_identity_001; | 968 | select * into t_serial_identity_001_1 from t_serial_identity_001; |
| 948 | NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id_seq_identity" for serial column "t_serial_identity_001_1.id" | 969 | NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id_seq_identity" for serial column "t_serial_identity_001_1.id" |
| 949 | NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1" | 970 | NOTICE: 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". |
| 953 | set identity_insert = on; | 974 | set identity_insert = on; |
| 954 | -- expected: success | 975 | -- expected: success |
| 955 | select * into t_serial_identity_001_1 from t_serial_identity_001; | 976 | select * 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_ | |||
| 957 | NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1" | 978 | NOTICE: CREATE TABLE will create implicit sequence "t_serial_identity_001_1_id1_seq" for serial column "t_serial_identity_001_1.id1" |
| 958 | set identity_insert = off; | 979 | set identity_insert = off; |
| 959 | \d+ t_serial_identity_001_1 | 980 | \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 | | |
| 966 | Has OIDs: no | 987 | Has OIDs: no |
| 967 | Options: orientation=row, compression=no, collate=1537 | 988 | Options: orientation=row, compression=no, collate=1537 |
| 968 | Character Set: UTF8 | 989 | Character Set: UTF8 |
| @@ -992,11 +1013,11 @@ set identity_insert = on; | |||
| 992 | select id, name into t_identity_numeric_t1_1 from t_identity_numeric_t1; | 1013 | select id, name into t_identity_numeric_t1_1 from t_identity_numeric_t1; |
| 993 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t1_1_id_seq_identity" for serial column "t_identity_numeric_t1_1.id" | 1014 | NOTICE: 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_1 | 1015 | \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 | | |
| 1000 | Has OIDs: no | 1021 | Has OIDs: no |
| 1001 | Options: orientation=row, compression=no, collate=1537 | 1022 | Options: orientation=row, compression=no, collate=1537 |
| 1002 | Character Set: UTF8 | 1023 | Character Set: UTF8 |
| @@ -1021,11 +1042,11 @@ select id, name into t_identity_numeric_t2_1 from t_identity_numeric_t2; | |||
| 1021 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t2_1_id_seq_identity" for serial column "t_identity_numeric_t2_1.id" | 1042 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t2_1_id_seq_identity" for serial column "t_identity_numeric_t2_1.id" |
| 1022 | set identity_insert = off; | 1043 | set identity_insert = off; |
| 1023 | \d+ t_identity_numeric_t2_1 | 1044 | \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 | | |
| 1029 | Has OIDs: no | 1050 | Has OIDs: no |
| 1030 | Options: orientation=row, compression=no, collate=1537 | 1051 | Options: orientation=row, compression=no, collate=1537 |
| 1031 | Character Set: UTF8 | 1052 | Character Set: UTF8 |
| @@ -1049,11 +1070,11 @@ select id, name into t_identity_numeric_t3_1 from t_identity_numeric_t3; | |||
| 1049 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t3_1_id_seq_identity" for serial column "t_identity_numeric_t3_1.id" | 1070 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t3_1_id_seq_identity" for serial column "t_identity_numeric_t3_1.id" |
| 1050 | set identity_insert = off; | 1071 | set identity_insert = off; |
| 1051 | \d+ t_identity_numeric_t3_1 | 1072 | \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 | | |
| 1057 | Has OIDs: no | 1078 | Has OIDs: no |
| 1058 | Options: orientation=row, compression=no, collate=1537 | 1079 | Options: orientation=row, compression=no, collate=1537 |
| 1059 | Character Set: UTF8 | 1080 | Character Set: UTF8 |
| @@ -1074,14 +1095,14 @@ drop table t_identity_numeric_t3_1; | |||
| 1074 | -- max/min value | 1095 | -- max/min value |
| 1075 | create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10)); | 1096 | create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10)); |
| 1076 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_id_seq_identity" for serial column "t_identity_numeric_t4.id" | 1097 | NOTICE: 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); |
| 1078 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t4_1_id_seq_identity" for serial column "t_identity_numeric_t4_1.id" | 1099 | NOTICE: 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 | | |
| 1085 | Has OIDs: no | 1106 | Has OIDs: no |
| 1086 | Options: orientation=row, compression=no, collate=1537 | 1107 | Options: orientation=row, compression=no, collate=1537 |
| 1087 | Character Set: UTF8 | 1108 | Character Set: UTF8 |
| @@ -1102,7 +1123,7 @@ drop table t_identity_numeric_t4_1; | |||
| 1102 | create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10)); | 1123 | create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10)); |
| 1103 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id_seq_identity" for serial column "t_identity_numeric_t5.id" | 1124 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id_seq_identity" for serial column "t_identity_numeric_t5.id" |
| 1104 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_id1_seq" for serial column "t_identity_numeric_t5.id1" | 1125 | NOTICE: 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); |
| 1106 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id_seq_identity" for serial column "t_identity_numeric_t5_1.id" | 1127 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id_seq_identity" for serial column "t_identity_numeric_t5_1.id" |
| 1107 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id1_seq" for serial column "t_identity_numeric_t5_1.id1" | 1128 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t5_1_id1_seq" for serial column "t_identity_numeric_t5_1.id1" |
| 1108 | insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64 | 1129 | insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64 |
| @@ -1118,16 +1139,16 @@ drop table t_identity_numeric_t5_1; | |||
| 1118 | create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10)); | 1139 | create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10)); |
| 1119 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id_seq_identity" for serial column "t_identity_numeric_t6.id" | 1140 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id_seq_identity" for serial column "t_identity_numeric_t6.id" |
| 1120 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_id1_seq" for serial column "t_identity_numeric_t6.id1" | 1141 | NOTICE: 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); |
| 1122 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id_seq_identity" for serial column "t_identity_numeric_t6_1.id" | 1143 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id_seq_identity" for serial column "t_identity_numeric_t6_1.id" |
| 1123 | NOTICE: CREATE TABLE will create implicit sequence "t_identity_numeric_t6_1_id1_seq" for serial column "t_identity_numeric_t6_1.id1" | 1144 | NOTICE: 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_1 | 1145 | \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 | | |
| 1131 | Has OIDs: no | 1152 | Has OIDs: no |
| 1132 | Options: orientation=row, compression=no, collate=1537 | 1153 | Options: orientation=row, compression=no, collate=1537 |
| 1133 | Character Set: UTF8 | 1154 | Character Set: UTF8 |
| @@ -1148,11 +1169,11 @@ drop table t_identity_numeric_t6_1; | |||
| 1148 | create table t_ident (id int identity, col text) with (orientation=column); | 1169 | create table t_ident (id int identity, col text) with (orientation=column); |
| 1149 | NOTICE: CREATE TABLE will create implicit sequence "t_ident_id_seq_identity" for serial column "t_ident.id" | 1170 | NOTICE: 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 | | |
| 1156 | Has OIDs: no | 1177 | Has OIDs: no |
| 1157 | Options: orientation=column, compression=low, collate=1537 | 1178 | Options: orientation=column, compression=low, collate=1537 |
| 1158 | Character Set: UTF8 | 1179 | Character Set: UTF8 |
| @@ -1178,7 +1199,7 @@ drop table t_ident; | |||
| 1178 | create sequence identity_t2_id_seq_identity; | 1199 | create sequence identity_t2_id_seq_identity; |
| 1179 | create table identity_t2(id numeric(38, 0) identity(10, 2), b int); | 1200 | create table identity_t2(id numeric(38, 0) identity(10, 2), b int); |
| 1180 | NOTICE: CREATE TABLE will create implicit sequence "identity_t2_id_seq_identity1" for serial column "identity_t2.id" | 1201 | NOTICE: 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); |
| 1182 | NOTICE: CREATE TABLE will create implicit sequence "identity_t2_1_id_seq_identity" for serial column "identity_t2_1.id" | 1203 | NOTICE: CREATE TABLE will create implicit sequence "identity_t2_1_id_seq_identity" for serial column "identity_t2_1.id" |
| 1183 | insert into identity_t2_1(b) values (10); | 1204 | insert into identity_t2_1(b) values (10); |
| 1184 | insert into identity_t2_1(b) values (10); | 1205 | insert into identity_t2_1(b) values (10); |
| @@ -1211,5 +1232,16 @@ select id, b from identity_t3_1; | |||
| 1211 | drop sequence identity_t3_id_seq_identity; | 1232 | drop sequence identity_t3_id_seq_identity; |
| 1212 | drop table identity_t3; | 1233 | drop table identity_t3; |
| 1213 | drop table identity_t3_1; | 1234 | drop 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. | ||
| 1214 | reset current_schema; | 1246 | reset current_schema; |
| 1215 | drop schema identity_schema; | 1247 | drop 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 | ||
| 1182 | select name, schema_id, principal_id | 1185 | select name, schema_id, principal_id |
| 1183 | from sys.schemas where schema_id < 10000 order by schema_id; | 1186 | from sys.schemas where schema_id < 10000 order by schema_id; |
| @@ -1242,3 +1245,4 @@ drop table employees; | |||
| 1242 | drop view high_salary_employees; | 1245 | drop view high_salary_employees; |
| 1243 | reset search_path; | 1246 | reset search_path; |
| 1244 | drop schema sys_view_test_02 cascade; | 1247 | drop 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 | ||
| 123 | set d_format_behavior_compat_options = ''; | 123 | set 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; |
| 131 | select count(*) from sysdatabases; | 131 | select 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 | |||
| 37 | test: temp_table_special_prefix | 37 | test: temp_table_special_prefix |
| 38 | test: sharksysfunction | 38 | test: sharksysfunction |
| 39 | test: alter_sequence | 39 | test: alter_sequence |
| 40 | - | 40 | +test: pg_identity pg_identity_dump_restore |
| @@ -312,7 +312,11 @@ insert into t_identity_0023(name) values('x3'); | |||
| 312 | select ident_current('t_identity_0023'); | 312 | select ident_current('t_identity_0023'); |
| 313 | select scope_identity(); | 313 | select 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_1 | 320 | \d+ t_identity_0023_1 |
| 317 | select ident_current('t_identity_0023_1'); | 321 | select ident_current('t_identity_0023_1'); |
| 318 | insert t_identity_0023_1 (name) values('xxx1'); | 322 | insert t_identity_0023_1 (name) values('xxx1'); |
| @@ -333,7 +337,7 @@ insert t_identity_0023_2 (name) values('xxx1'); | |||
| 333 | select ident_current('t_identity_0023_2'); | 337 | select ident_current('t_identity_0023_2'); |
| 334 | select scope_identity(); | 338 | select scope_identity(); |
| 335 | 339 | ||
| 336 | -drop table t_identity_0023; | 340 | +drop table t_identity_0023, t_identity_0023_1_1; |
| 337 | drop table t_identity_0023_1; | 341 | drop table t_identity_0023_1; |
| 338 | drop table t_identity_0023_2; | 342 | drop 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 value | 532 | -- max/min value |
| 529 | create table t_identity_numeric_t4(id numeric(38, 0) identity, name varchar(10)); | 533 | create 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; |
| 532 | set identity_insert = on; | 536 | set identity_insert = on; |
| 533 | insert into t_identity_numeric_t4_1(id, name) values(987654321098765432109876543210, 'xxx'); -- over int64 | 537 | insert 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 | -- start | 543 | -- start |
| 540 | create table t_identity_numeric_t5(id numeric(38, 0) identity(987654321098765432100000, 2), id1 serial, name varchar(10)); | 544 | create 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); |
| 542 | insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64 | 546 | insert into t_identity_numeric_t5_1(name) values('xxx'); -- over int64 |
| 543 | select * from t_identity_numeric_t5_1 order by id; | 547 | select * from t_identity_numeric_t5_1 order by id; |
| 544 | drop table t_identity_numeric_t5; | 548 | drop table t_identity_numeric_t5; |
| @@ -546,7 +550,7 @@ drop table t_identity_numeric_t5_1; | |||
| 546 | 550 | ||
| 547 | -- increment | 551 | -- increment |
| 548 | create table t_identity_numeric_t6(id numeric(38, 0) identity(2, 987654321098765432100000), id1 serial, name varchar(10)); | 552 | create 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_1 | 554 | \d+ t_identity_numeric_t6_1 |
| 551 | insert into t_identity_numeric_t6_1(name) values('xxx'); -- over int64 | 555 | insert into t_identity_numeric_t6_1(name) values('xxx'); -- over int64 |
| 552 | insert into t_identity_numeric_t6_1(name) values('xxx1'); | 556 | insert into t_identity_numeric_t6_1(name) values('xxx1'); |
| @@ -568,7 +572,7 @@ drop table t_ident; | |||
| 568 | -- create table like | 572 | -- create table like |
| 569 | create sequence identity_t2_id_seq_identity; | 573 | create sequence identity_t2_id_seq_identity; |
| 570 | create table identity_t2(id numeric(38, 0) identity(10, 2), b int); | 574 | create 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); |
| 572 | insert into identity_t2_1(b) values (10); | 576 | insert into identity_t2_1(b) values (10); |
| 573 | insert into identity_t2_1(b) values (10); | 577 | insert into identity_t2_1(b) values (10); |
| 574 | select id, b from identity_t2_1; | 578 | select id, b from identity_t2_1; |
| @@ -586,5 +590,14 @@ select id, b from identity_t3_1; | |||
| 586 | drop sequence identity_t3_id_seq_identity; | 590 | drop sequence identity_t3_id_seq_identity; |
| 587 | drop table identity_t3; | 591 | drop table identity_t3; |
| 588 | drop table identity_t3_1; | 592 | drop 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 | + | ||
| 589 | reset current_schema; | 602 | reset current_schema; |
| 590 | drop schema identity_schema; | 603 | drop 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 } ]; |
| 24 | ALTER [ LARGE ] SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>; | 24 | ALTER [ 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 | ||
| 26 | NOTICE: '[ LARGE ]' is only avaliable in CENTRALIZED mode! | 27 | NOTICE: '[ 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 ] | ||
| 78 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 81 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 79 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 82 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 80 | where column_constraint can be: | 83 | where 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 ] |
| 95 | NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database! | 99 | NOTICE: '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! | ||
| 96 | where compress_mode can be: | 101 | where compress_mode can be: |
| 97 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 102 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 98 | where table_constraint can be: | 103 | where 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_name | 117 | { 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 } | ||
| 129 | +where seq_options can be: | ||
| 130 | + seq_option | ||
| 131 | + | OWNED BY name | ||
| 132 | + | RESTART [ WITH ] NumericOnly | ||
| 114 | 133 | ||
| 115 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 134 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 116 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 135 | NOTICE: '[ 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 | |||
| 124 | NOTICE: '[ CHARACTER SET | CHARSET charset ]' is only available in CENTRALIZED mode and B-format database! | 143 | NOTICE: '[ CHARACTER SET | CHARSET charset ]' is only available in CENTRALIZED mode and B-format database! |
| 125 | NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database! | 144 | NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database! |
| 126 | NOTICE: 'IDENTITY [ (seed , increment) ]' is only avaliable in D-format database! | 145 | NOTICE: '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: | |||
| 51 | where compress_mode can be: | 52 | where compress_mode can be: |
| 52 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 53 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 53 | where like_option can be: | 54 | where 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 } |
| 55 | where index_parameters can be: | 56 | where 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_name | 70 | 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 } | ||
【问题】这里把无参序列选项写成了 MINVALUE,但实际语义应是 NOMINVALUE 【建议】建议修正 ![]() ![]() | |||
| 75 | + | OWNED BY name | ||
| 71 | 76 | ||
| 72 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 77 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 73 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 78 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! |
| @@ -14,6 +14,7 @@ | |||
| 14 | INSERT [/*+ plan_hint */] INTO | 14 | INSERT [/*+ 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 THEN | 25 | 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 | ||
| 30 | where partition_clause can be: | 31 | where 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!] |
| 14 | REPLACE [LOW_PRIORITY | DELAYED] | 14 | REPLACE [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},...),...},... |
| 17 | OR: | 18 | OR: |
| 18 | REPLACE [LOW_PRIORITY | DELAYED] | 19 | REPLACE [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 ] | ||
| 74 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 77 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 75 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 78 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 76 | where column_constraint can be: | 79 | where 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 ] |
| 91 | NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database! | 95 | NOTICE: '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! | ||
| 92 | where compress_mode can be: | 97 | where compress_mode can be: |
| 93 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 98 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 94 | where table_constraint can be: | 99 | where 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_name | 113 | { 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 | ||
| 111 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 130 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 112 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 131 | NOTICE: '[ 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) | |||
| 84 | select 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; | 84 | select 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 | YES | 87 | +--? test_b1 | coverage | .* | coverage | proc_coverage | CHECK | YES |
| 88 | (1 row) | 88 | (1 row) |
| 89 | 89 | ||
| 90 | select CHARACTER_SET_NAME,DEFAULT_COLLATE_NAME,DESCRIPTION,MAXLEN from INFORMATION_SCHEMA.CHARACTER_SETS order by 1,2,3,4 limit 1; | 90 | select 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 | |||
| 96 | select CONSTRAINT_CATALOG,CONSTRAINT_SCHEMA,CONSTRAINT_NAME,CHECK_CLAUSE FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS order by 1,2,3,4 limit 1; | 96 | select 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 NULL | 99 | +--? test_b1 | coverage | .* | coverage_id IS NOT NULL |
| 100 | (1 row) | 100 | (1 row) |
| 101 | 101 | ||
| 102 | select COLLATION_NAME,CHARACTER_SET_NAME,IS_DEFAULT,IS_COMPILED,SORTLEN,PAD_ATTRIBUTE from INFORMATION_SCHEMA.COLLATIONS order by 1,2,3,4 limit 1; | 102 | select 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: | |||
| 535 | where compress_mode can be: | 536 | where compress_mode can be: |
| 536 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 537 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 537 | where like_option can be: | 538 | where 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 } |
| 539 | where index_parameters can be: | 540 | where 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_name | 554 | 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 | ||
| 556 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 561 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 557 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 562 | NOTICE: '[ 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 ] | ||
| 783 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 791 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 784 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 792 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 785 | where column_constraint can be: | 793 | where 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 ] |
| 800 | NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database! | 809 | NOTICE: '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! | ||
| 801 | where compress_mode can be: | 811 | where compress_mode can be: |
| 802 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 812 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 803 | where table_constraint can be: | 813 | where 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_name | 827 | { 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 | ||
| 820 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 844 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 821 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 845 | NOTICE: '[ 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 | |||
| 47 | LINE 1: ... gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ... | 47 | LINE 1: ... gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ... |
| 48 | ^ | 48 | ^ |
| 49 | CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ALWAYS AS (a * 2) STORED); | 49 | CREATE 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 column | 54 | -- reference to system column not allowed in generated column |
| 54 | CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED); | 55 | CREATE 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 THEN | 19 | 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 | ]; |
| 23 | NOTICE: 'subquery' in the UPDATE and INSERT clauses are only avaliable in CENTRALIZED mode! | 24 | NOTICE: '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 | |||
| 5724 | ERROR: cannot change sequence owned by auto_increment column | 5724 | ERROR: cannot change sequence owned by auto_increment column |
| 5725 | CONTEXT: referenced column: nextval | 5725 | CONTEXT: referenced column: nextval |
| 5726 | drop table t_auto_nextval_test; | 5726 | drop 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 regression | 5743 | \c regression |
| 5728 | clean connection to all force for database autoinc_b_db; | 5744 | clean connection to all force for database autoinc_b_db; |
| 5729 | drop database if exists autoinc_b_db; | 5745 | drop database if exists autoinc_b_db; |
| @@ -11,6 +11,7 @@ Syntax: | |||
| 11 | INSERT [/*+ plan_hint */] INTO | 11 | INSERT [/*+ 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: | |||
| 474 | where compress_mode can be: | 475 | where compress_mode can be: |
| 475 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 476 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 476 | where like_option can be: | 477 | where 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 } |
| 478 | where index_parameters can be: | 479 | where 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_name | 493 | 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 | ||
| 495 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 500 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 496 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 501 | NOTICE: '[ 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 ] | ||
| 722 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 730 | NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 723 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! | 731 | NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database! |
| 724 | where column_constraint can be: | 732 | where 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 ] |
| 739 | NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database! | 748 | NOTICE: '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! | ||
| 740 | where compress_mode can be: | 750 | where compress_mode can be: |
| 741 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } | 751 | { DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } |
| 742 | where table_constraint can be: | 752 | where 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_name | 766 | { 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 | ||
| 759 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. | 783 | NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios. |
| 760 | NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database! | 784 | NOTICE: '[ 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 function | 519 | # test for rotate and unrotate function |
| 520 | test: gb_ora_rotate_unrotate | 520 | test: gb_ora_rotate_unrotate |
| 521 | 521 | ||
| 522 | +test: pg_identity pg_identity_dump_restore | ||
| 523 | + | ||
| 522 | # test for string type char byte semantic | 524 | # test for string type char byte semantic |
| 523 | test: bpchar_charbyte bpchar_cast bpchar_copy bpchar_index bpchar_regexmatch varchar_charbyte varchar_cast varchar_copy varchar_index varchar_regexmatch char_length_semantic | 525 | test: bpchar_charbyte bpchar_cast bpchar_copy bpchar_index bpchar_regexmatch varchar_charbyte varchar_cast varchar_copy varchar_index varchar_regexmatch char_length_semantic |
| 524 | test: gs_dump_char_semantic | 526 | test: gs_dump_char_semantic |
| @@ -1703,6 +1703,12 @@ create table t_auto_nextval_test(a int, b int auto_increment primary key); | |||
| 1703 | select nextval('t_auto_nextval_test_b_seq'); -- error | 1703 | select nextval('t_auto_nextval_test_b_seq'); -- error |
| 1704 | drop table t_auto_nextval_test; | 1704 | drop 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 regression | 1712 | \c regression |
| 1707 | clean connection to all force for database autoinc_b_db; | 1713 | clean connection to all force for database autoinc_b_db; |
| 1708 | drop database if exists autoinc_b_db; | 1714 | drop database if exists autoinc_b_db; |


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