LightDB24.1 Sequence支持设置minvalue小于INT64_MIN
背景介绍
Oracle数据库支持设置sequence的minvalue为-1000000000000000000000000000,在用户迁移到LightDB时,sequence设置minvalue为-1000000000000000000000000000会报错。为了兼容Oracle数据库的使用习惯,在LightDB24.1版本中,对于minvalue小于INT64_MIN(-9223372036854775808)做了处理,使得minvalue值被设置为INT64_MIN。
使用约束:
- oracle兼容模式下生效
使用示例
- 在oracle兼容模式下
lightdb@oracle_test=# show lightdb_dblevel_syntax_compatible_type ;
lightdb_dblevel_syntax_compatible_type
----------------------------------------
Oracle
(1 row)
lightdb@oracle_test=# create sequence s1 minvalue -1000000000000000000000000000;
NOTICE: minvalue out of range, set sequence min value to -9223372036854775808
CREATE SEQUENCE
lightdb@oracle_test=# \d+ s1
Sequence "public.s1"
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
--------+----------------------+----------------------+---------------------+-----------+---------+-------
bigint | -9223372036854775808 | -9223372036854775808 | 9223372036854775807 | 1 | no | 1
lightdb@oracle_test=#
- 非oracle兼容模式
lightdb@postgres=# show lightdb_dblevel_syntax_compatible_type ;
lightdb_dblevel_syntax_compatible_type
----------------------------------------
off
(1 row)
lightdb@postgres=#
lightdb@postgres=# create sequence s1 minvalue -1000000000000000000000000000;
ERROR: value "-1000000000000000000000000000" is out of range for type bigint
lightdb@postgres=# \d+ s1
Did not find any relation named "s1".
lightdb@postgres=#