[MDEV-27585] Auto-increment on secondary column increments unexpectedly with DESC key Created: 2022-01-23  Updated: 2022-01-26  Resolved: 2022-01-26

Status: Closed
Project: MariaDB Server
Component/s: Character Sets, Storage Engine - MyISAM
Affects Version/s: N/A
Fix Version/s: 10.8.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-13756 Implement descending index: KEY (a DE... Closed

 Description   

In all 4 cases below values 'a' and 'ä' (C3A4) are inserted into a char column with latin1_swedish_ci collation. The symbols are not equal according to this collation.
The column is a first part of a 2-part key, while the second part is an auto-incremented integer. Since the symbols in the first column differ, the value of the second one is not expected to be incremented.

In one case, when 'ä' is inserted first and 'a' next and the table has a descending index, the value is however incremented. In other three cases it is not.

set names latin1 collate latin1_swedish_ci;
 
select 'ä' = 'a', 'ä' > 'a';
 
# Table with DESC
 
create table t1 (
  c char(16),
  i int auto_increment,
  index (c,i desc)
) engine=MyISAM collate latin1_swedish_ci;
insert into t1 (c) values ('a'),('ä');
select * from t1 order by c, i;
 
# Same table with DESC, reverse order of INSERT
 
create table t2 (
  c char(16),
  i int auto_increment,
  index (c,i desc)
) engine=MyISAM collate latin1_swedish_ci;
insert into t2 (c) values ('ä'),('a');
select * from t2 order by c, i;
 
# Table with ASC
 
create table t3 (
  c char(16),
  i int auto_increment,
  index (c,i)
) engine=MyISAM collate latin1_swedish_ci;
insert into t3 (c) values ('a'),('ä');
select * from t3 order by c, i;
 
# Same table with ASC, reverse order of INSERT
 
create table t4 (
  c char(16),
  i int auto_increment,
  index (c,i)
) engine=MyISAM collate latin1_swedish_ci;
insert into t4 (c) values ('ä'),('a');
select * from t4 order by c, i;
 
drop table t1, t2, t3, t4;

preview-10.8-MDEV-13756-desc-indexes c10e10c6

insert into t2 (c) values ('ä'),('a');
select * from t2 order by c, i;
c	i
a	2
ä	1

Not reproducible with Aria.


Generated at Thu Feb 08 09:54:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.