mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-27586 Auto-increment does not work with DESC on MERGE table
also fix handler::get_auto_increment()
This commit is contained in:
@ -3913,5 +3913,19 @@ select * from tm;
|
|||||||
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||||
drop table tm, t;
|
drop table tm, t;
|
||||||
#
|
#
|
||||||
|
# MDEV-27586 Auto-increment does not work with DESC on MERGE table
|
||||||
|
#
|
||||||
|
create table t (a int not null, primary key(a desc)) engine=myisam;
|
||||||
|
create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first;
|
||||||
|
insert into tm () values ();
|
||||||
|
insert into tm () values ();
|
||||||
|
insert into tm () values ();
|
||||||
|
select * from tm;
|
||||||
|
a
|
||||||
|
3
|
||||||
|
2
|
||||||
|
1
|
||||||
|
drop table tm, t;
|
||||||
|
#
|
||||||
# End of 10.8 tests
|
# End of 10.8 tests
|
||||||
#
|
#
|
||||||
|
@ -2872,6 +2872,17 @@ create table tm (a int, key(a)) engine=merge union(t);
|
|||||||
select * from tm;
|
select * from tm;
|
||||||
drop table tm, t;
|
drop table tm, t;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-27586 Auto-increment does not work with DESC on MERGE table
|
||||||
|
--echo #
|
||||||
|
create table t (a int not null, primary key(a desc)) engine=myisam;
|
||||||
|
create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first;
|
||||||
|
insert into tm () values ();
|
||||||
|
insert into tm () values ();
|
||||||
|
insert into tm () values ();
|
||||||
|
select * from tm;
|
||||||
|
drop table tm, t;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.8 tests
|
--echo # End of 10.8 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -4112,6 +4112,9 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
|
|||||||
int error;
|
int error;
|
||||||
MY_BITMAP *old_read_set;
|
MY_BITMAP *old_read_set;
|
||||||
bool rnd_inited= (inited == RND);
|
bool rnd_inited= (inited == RND);
|
||||||
|
bool rev= table->key_info[table->s->next_number_index].
|
||||||
|
key_part[table->s->next_number_keypart].key_part_flag &
|
||||||
|
HA_REVERSE_SORT;
|
||||||
|
|
||||||
if (rnd_inited && ha_rnd_end())
|
if (rnd_inited && ha_rnd_end())
|
||||||
return;
|
return;
|
||||||
@ -4133,7 +4136,8 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
|
|||||||
|
|
||||||
if (table->s->next_number_keypart == 0)
|
if (table->s->next_number_keypart == 0)
|
||||||
{ // Autoincrement at key-start
|
{ // Autoincrement at key-start
|
||||||
error= ha_index_last(table->record[1]);
|
error= rev ? ha_index_first(table->record[1])
|
||||||
|
: ha_index_last(table->record[1]);
|
||||||
/*
|
/*
|
||||||
MySQL implicitly assumes such method does locking (as MySQL decides to
|
MySQL implicitly assumes such method does locking (as MySQL decides to
|
||||||
use nr+increment without checking again with the handler, in
|
use nr+increment without checking again with the handler, in
|
||||||
@ -4148,9 +4152,8 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
|
|||||||
table->key_info + table->s->next_number_index,
|
table->key_info + table->s->next_number_index,
|
||||||
table->s->next_number_key_offset);
|
table->s->next_number_key_offset);
|
||||||
error= ha_index_read_map(table->record[1], key,
|
error= ha_index_read_map(table->record[1], key,
|
||||||
make_prev_keypart_map(table->s->
|
make_prev_keypart_map(table->s->next_number_keypart),
|
||||||
next_number_keypart),
|
rev ? HA_READ_KEY_EXACT : HA_READ_PREFIX_LAST);
|
||||||
HA_READ_PREFIX_LAST);
|
|
||||||
/*
|
/*
|
||||||
MySQL needs to call us for next row: assume we are inserting ("a",null)
|
MySQL needs to call us for next row: assume we are inserting ("a",null)
|
||||||
here, we return 3, and next this statement will want to insert
|
here, we return 3, and next this statement will want to insert
|
||||||
|
Reference in New Issue
Block a user