开放ALTER SEQUENCE支持修改cache

This commit is contained in:
luozihao
2021-03-30 17:22:52 +08:00
parent 4c77c0bb63
commit 0f4e2bcb41
4 changed files with 98 additions and 1 deletions

View File

@ -1990,7 +1990,8 @@ static void check_value_min_max(int64 value, int64 min_value, int64 max_value)
/* isInit is true for DefineSequence, false for AlterSequence, we use it
* to differentiate them
*/
if (strcmp(defel->defname, "owned_by") != 0 && strcmp(defel->defname, "maxvalue") != 0) {
if (strcmp(defel->defname, "owned_by") != 0 && strcmp(defel->defname, "maxvalue") != 0 &&
strcmp(defel->defname, "cache") != 0) {
ereport(
ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("ALTER SEQUENCE is not yet supported.")));
}

View File

@ -0,0 +1,21 @@
drop table if exists test_tab;
drop sequence if exists test_seq;
create sequence test_seq cache 2;
create table test_tab(id int default nextVal('test_seq'), name varchar(20));
create user test_user with password 'openGauss@123';
grant all privileges to test_user;
select last_value from test_seq;
insert into test_tab(name) values('test1');
select last_value from test_seq;
insert into test_tab(name) values('test2'),('test3');
select * from test_tab;
select last_value from test_seq;
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "insert into test_tab(name) values('test5');"
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select last_value from test_seq;"
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select * from test_tab;"
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "insert into test_tab(name) values('test7');"
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select last_value from test_seq;"
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select * from test_tab;"
drop user test_user cascade;
drop table if exists test_tab;
drop sequence if exists test_seq;

View File

@ -0,0 +1,74 @@
drop table if exists test_tab;
NOTICE: table "test_tab" does not exist, skipping
drop sequence if exists test_seq;
NOTICE: sequence "test_seq" does not exist, skipping
create sequence test_seq cache 2;
create table test_tab(id int default nextVal('test_seq'), name varchar(20));
create user test_user with password 'openGauss@123';
grant all privileges to test_user;
select last_value from test_seq;
last_value
------------
1
(1 row)
insert into test_tab(name) values('test1');
select last_value from test_seq;
last_value
------------
2
(1 row)
insert into test_tab(name) values('test2'),('test3');
select * from test_tab;
id | name
----+-------
1 | test1
2 | test2
3 | test3
(3 rows)
select last_value from test_seq;
last_value
------------
4
(1 row)
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "insert into test_tab(name) values('test5');"
INSERT 0 1
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select last_value from test_seq;"
last_value
------------
6
(1 row)
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select * from test_tab;"
id | name
----+-------
1 | test1
2 | test2
3 | test3
5 | test5
(4 rows)
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "insert into test_tab(name) values('test7');"
INSERT 0 1
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select last_value from test_seq;"
last_value
------------
8
(1 row)
\! @abs_bindir@/gsql -d regression -p @portstring@ -U test_user -W openGauss@123 -c "select * from test_tab;"
id | name
----+-------
1 | test1
2 | test2
3 | test3
5 | test5
7 | test7
(5 rows)
drop user test_user cascade;
drop table if exists test_tab;
drop sequence if exists test_seq;

View File

@ -760,3 +760,4 @@ test: leaky_function_operator
#test: gs_guc
test: smp
test: sequence_cache_test