Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d751f42a
Commit
d751f42a
authored
Jan 24, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-27586 Auto-increment does not work with DESC on MERGE table
also fix handler::get_auto_increment()
parent
72b5b8b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
mysql-test/main/merge.result
mysql-test/main/merge.result
+14
-0
mysql-test/main/merge.test
mysql-test/main/merge.test
+11
-0
sql/handler.cc
sql/handler.cc
+7
-4
No files found.
mysql-test/main/merge.result
View file @
d751f42a
...
...
@@ -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
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
#
mysql-test/main/merge.test
View file @
d751f42a
...
...
@@ -2872,6 +2872,17 @@ create table tm (a int, key(a)) engine=merge union(t);
select
*
from
tm
;
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
# End of 10.8 tests
--
echo
#
sql/handler.cc
View file @
d751f42a
...
...
@@ -4112,6 +4112,9 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
int
error
;
MY_BITMAP
*
old_read_set
;
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
())
return
;
...
...
@@ -4133,7 +4136,8 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
if
(
table
->
s
->
next_number_keypart
==
0
)
{
// 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
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
->
s
->
next_number_key_offset
);
error
=
ha_index_read_map
(
table
->
record
[
1
],
key
,
make_prev_keypart_map
(
table
->
s
->
next_number_keypart
),
HA_READ_PREFIX_LAST
);
make_prev_keypart_map
(
table
->
s
->
next_number_keypart
),
rev
?
HA_READ_KEY_EXACT
:
HA_READ_PREFIX_LAST
);
/*
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment