Set `serial_normalization` to avoid Integer overflow

This commit is contained in:
Marco Belladelli 2024-05-03 09:08:51 +02:00 committed by Christian Beikov
parent c9d92347aa
commit 2769fd1b3c
2 changed files with 5 additions and 0 deletions

View File

@ -863,6 +863,7 @@ SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';
SET CLUSTER SETTING jobs.retention_time = '15s'; SET CLUSTER SETTING jobs.retention_time = '15s';
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false; SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s'; SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
SET CLUSTER SETTING sql.defaults.serial_normalization = 'sql_sequence_cached';
ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600; ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600; ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
@ -903,6 +904,7 @@ SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';
SET CLUSTER SETTING jobs.retention_time = '15s'; SET CLUSTER SETTING jobs.retention_time = '15s';
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false; SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s'; SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
SET CLUSTER SETTING sql.defaults.serial_normalization = 'sql_sequence_cached';
ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600; ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600; ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
SET CLUSTER SETTING sql.defaults.serial_normalization=sql_sequence; SET CLUSTER SETTING sql.defaults.serial_normalization=sql_sequence;

View File

@ -29,6 +29,9 @@ public class CockroachDBIdentityColumnSupport extends IdentityColumnSupportImpl
@Override @Override
public String getIdentityColumnString(int type) { public String getIdentityColumnString(int type) {
// Note that the unique_rowid() function used to generated values with serial_normalization=rowid (default)
// will always produce INT8 (Types.BIGINT) values which might not fit other data types.
// See https://www.cockroachlabs.com/docs/stable/serial.html
switch ( type ) { switch ( type ) {
case Types.TINYINT: case Types.TINYINT:
case Types.SMALLINT: case Types.SMALLINT: