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;
|
create or replace table t (a int) with system versioning;
|
||||||
insert into t values (1), (2), (3);
|
insert into t values (1), (2), (3);
|
||||||
delete from t where a<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;
|
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
|
a b
|
||||||
1 -1
|
|
||||||
2 -2
|
|
||||||
3 1
|
3 1
|
||||||
insert into t values (4, NULL);
|
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
a b
|
a b
|
||||||
1 -1
|
1 NULL
|
||||||
2 -2
|
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
|
3 1
|
||||||
4 2
|
4 2
|
||||||
create or replace table t (a int) with system versioning engine=innodb;
|
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;
|
create or replace table t (a int) with system versioning;
|
||||||
insert into t values (1), (2), (3);
|
insert into t values (1), (2), (3);
|
||||||
delete from t where a<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;
|
select * from t for system_time all;
|
||||||
a b
|
a b
|
||||||
1 -1
|
1 NULL
|
||||||
2 -2
|
2 NULL
|
||||||
3 1
|
3 1
|
||||||
insert into t values (4, NULL);
|
insert into t values (4, 0);
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
a b
|
a b
|
||||||
1 -1
|
1 NULL
|
||||||
2 -2
|
2 NULL
|
||||||
3 1
|
3 1
|
||||||
4 2
|
4 2
|
||||||
create or replace table t (
|
create or replace table t (
|
||||||
|
@ -219,9 +219,16 @@ call verify_vtq;
|
|||||||
create or replace table t (a int) with system versioning;
|
create or replace table t (a int) with system versioning;
|
||||||
insert into t values (1), (2), (3);
|
insert into t values (1), (2), (3);
|
||||||
delete from t where a<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 unique;
|
||||||
|
alter table t add b int auto_increment null unique;
|
||||||
|
select * from t;
|
||||||
select * from t for system_time all;
|
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;
|
select * from t for system_time all;
|
||||||
|
|
||||||
create or replace table t (a int) with system versioning engine=innodb;
|
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;
|
delete from t where a<3;
|
||||||
# kvm-deb-trusty-ppc64le fails with "Out of range value for column 'b' at row 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
|
--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;
|
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;
|
select * from t for system_time all;
|
||||||
|
|
||||||
create or replace table t (
|
create or replace table t (
|
||||||
|
@ -3056,34 +3056,23 @@ int handler::update_auto_increment()
|
|||||||
enum enum_check_fields save_count_cuted_fields;
|
enum enum_check_fields save_count_cuted_fields;
|
||||||
DBUG_ENTER("handler::update_auto_increment");
|
DBUG_ENTER("handler::update_auto_increment");
|
||||||
|
|
||||||
// System Versioning: handle ALTER ADD COLUMN AUTO_INCREMENT
|
// ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT
|
||||||
if (thd->lex->sql_command == SQLCOM_ALTER_TABLE && table->versioned())
|
if (thd->lex->sql_command == SQLCOM_ALTER_TABLE)
|
||||||
{
|
{
|
||||||
Field *end= table->vers_end_field();
|
if (table->versioned())
|
||||||
DBUG_ASSERT(end);
|
|
||||||
bitmap_set_bit(table->read_set, end->field_index);
|
|
||||||
if (!end->is_max())
|
|
||||||
{
|
{
|
||||||
uchar *ptr= table->next_number_field->ptr;
|
Field *end= table->vers_end_field();
|
||||||
switch (table->next_number_field->pack_length())
|
DBUG_ASSERT(end);
|
||||||
|
bitmap_set_bit(table->read_set, end->field_index);
|
||||||
|
if (!end->is_max())
|
||||||
{
|
{
|
||||||
case 8:
|
if (!table->next_number_field->real_maybe_null())
|
||||||
int8store(ptr, vers_auto_decrement--);
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
||||||
break;
|
table->next_number_field->set_null();
|
||||||
case 4:
|
DBUG_RETURN(0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
}
|
||||||
|
table->next_number_field->set_notnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2865,8 +2865,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint auto_inc_intervals_count;
|
uint auto_inc_intervals_count;
|
||||||
|
|
||||||
ulonglong vers_auto_decrement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Instrumented table associated with this handler.
|
Instrumented table associated with this handler.
|
||||||
This member should be set to NULL when no instrumentation is in place,
|
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)
|
else if (keep_versioned)
|
||||||
{
|
{
|
||||||
to->file->vers_auto_decrement= 0xffffffffffffffff;
|
|
||||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||||
{
|
{
|
||||||
query_start= thd->query_start_TIME();
|
query_start= thd->query_start_TIME();
|
||||||
|
Reference in New Issue
Block a user