mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
remove 'vers_auto_decrement'
Do not generate fake values when adding an auto-inc column to a versioned table. This is not a auto-inc issue, but a more general case of adding a not nullalble unique column to a table with history. We don't support it yet, not even with a special auto-inc hack. As a workaround, one can use a nullable unique column, that works.
This commit is contained in:
committed by
Aleksey Midenkov
parent
6a7911d4c8
commit
d3845132fc
@ -426,17 +426,24 @@ No A B C D
|
||||
create or replace table t (a int) with system versioning;
|
||||
insert into t values (1), (2), (3);
|
||||
delete from t where a<3;
|
||||
alter table t add b int not null unique;
|
||||
ERROR 23000: Duplicate entry '...' for key 'b'
|
||||
alter table t add b int auto_increment unique;
|
||||
select * from t for system_time all;
|
||||
ERROR 42000: Table '#sql-temporary' uses an extension that doesn't exist in this MariaDB version
|
||||
alter table t add b int auto_increment null unique;
|
||||
select * from t;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
3 1
|
||||
insert into t values (4, NULL);
|
||||
select * from t for system_time all;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 1
|
||||
insert into t values (4, 0);
|
||||
select * from t for system_time all;
|
||||
a b
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 1
|
||||
4 2
|
||||
create or replace table t (a int) with system versioning engine=innodb;
|
||||
@ -467,17 +474,17 @@ No A B C D
|
||||
create or replace table t (a int) with system versioning;
|
||||
insert into t values (1), (2), (3);
|
||||
delete from t where a<3;
|
||||
alter table t add b tinyint auto_increment unique;
|
||||
alter table t add b tinyint auto_increment null unique;
|
||||
select * from t for system_time all;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 1
|
||||
insert into t values (4, NULL);
|
||||
insert into t values (4, 0);
|
||||
select * from t for system_time all;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 1
|
||||
4 2
|
||||
create or replace table t (
|
||||
|
@ -219,9 +219,16 @@ call verify_vtq;
|
||||
create or replace table t (a int) with system versioning;
|
||||
insert into t values (1), (2), (3);
|
||||
delete from t where a<3;
|
||||
--replace_regex /'0-[- 0-9.:]+'/'...'/
|
||||
--error ER_DUP_ENTRY
|
||||
alter table t add b int not null unique;
|
||||
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
|
||||
--error ER_UNSUPPORTED_EXTENSION
|
||||
alter table t add b int auto_increment unique;
|
||||
alter table t add b int auto_increment null unique;
|
||||
select * from t;
|
||||
select * from t for system_time all;
|
||||
insert into t values (4, NULL);
|
||||
insert into t values (4, 0);
|
||||
select * from t for system_time all;
|
||||
|
||||
create or replace table t (a int) with system versioning engine=innodb;
|
||||
@ -240,9 +247,9 @@ insert into t values (1), (2), (3);
|
||||
delete from t where a<3;
|
||||
# kvm-deb-trusty-ppc64le fails with "Out of range value for column 'b' at row 3"
|
||||
--error 0,ER_WARN_DATA_OUT_OF_RANGE
|
||||
alter table t add b tinyint auto_increment unique;
|
||||
alter table t add b tinyint auto_increment null unique;
|
||||
select * from t for system_time all;
|
||||
insert into t values (4, NULL);
|
||||
insert into t values (4, 0);
|
||||
select * from t for system_time all;
|
||||
|
||||
create or replace table t (
|
||||
|
@ -3056,35 +3056,24 @@ int handler::update_auto_increment()
|
||||
enum enum_check_fields save_count_cuted_fields;
|
||||
DBUG_ENTER("handler::update_auto_increment");
|
||||
|
||||
// System Versioning: handle ALTER ADD COLUMN AUTO_INCREMENT
|
||||
if (thd->lex->sql_command == SQLCOM_ALTER_TABLE && table->versioned())
|
||||
// ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT
|
||||
if (thd->lex->sql_command == SQLCOM_ALTER_TABLE)
|
||||
{
|
||||
if (table->versioned())
|
||||
{
|
||||
Field *end= table->vers_end_field();
|
||||
DBUG_ASSERT(end);
|
||||
bitmap_set_bit(table->read_set, end->field_index);
|
||||
if (!end->is_max())
|
||||
{
|
||||
uchar *ptr= table->next_number_field->ptr;
|
||||
switch (table->next_number_field->pack_length())
|
||||
{
|
||||
case 8:
|
||||
int8store(ptr, vers_auto_decrement--);
|
||||
break;
|
||||
case 4:
|
||||
int4store(ptr, vers_auto_decrement--);
|
||||
break;
|
||||
case 2:
|
||||
int2store(ptr, vers_auto_decrement--);
|
||||
break;
|
||||
case 1:
|
||||
*ptr= static_cast<uchar>(vers_auto_decrement--);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(false);
|
||||
}
|
||||
if (!table->next_number_field->real_maybe_null())
|
||||
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
||||
table->next_number_field->set_null();
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
table->next_number_field->set_notnull();
|
||||
}
|
||||
|
||||
/*
|
||||
next_insert_id is a "cursor" into the reserved interval, it may go greater
|
||||
|
@ -2865,8 +2865,6 @@ public:
|
||||
*/
|
||||
uint auto_inc_intervals_count;
|
||||
|
||||
ulonglong vers_auto_decrement;
|
||||
|
||||
/**
|
||||
Instrumented table associated with this handler.
|
||||
This member should be set to NULL when no instrumentation is in place,
|
||||
|
@ -10112,7 +10112,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
}
|
||||
else if (keep_versioned)
|
||||
{
|
||||
to->file->vers_auto_decrement= 0xffffffffffffffff;
|
||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||
{
|
||||
query_start= thd->query_start_TIME();
|
||||
|
Reference in New Issue
Block a user