Skip to content

Commit 8103526

Browse files
committed
MDEV-9667: Server hangs after select count(distinct name) from t2 where a=8366 and b>=5 and b<=5;
In row_search_for_mysql function on XtraDB there was a old logic where null bytes were inited. This caused server to think that key value is null and continue on incorrect path.
1 parent 8942824 commit 8103526

File tree

4 files changed

+48
-15
lines changed

4 files changed

+48
-15
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB;
2+
insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm");
3+
select count(distinct name) from t2 where a=8366 and b>=5 and b<=5;
4+
count(distinct name)
5+
1
6+
select count(distinct name) from t2 where a=8366 and b=5;
7+
count(distinct name)
8+
1
9+
select count(distinct name) from t2 where a=8366 and b between 5 and 5.5;
10+
count(distinct name)
11+
1
12+
select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5;
13+
sum(distinct a)
14+
8366
15+
select sum(distinct a) from t2 where a=8366 and b=5;
16+
sum(distinct a)
17+
8366
18+
select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5;
19+
sum(distinct a)
20+
8366
21+
drop table t2;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--source include/have_innodb.inc
2+
3+
#
4+
# MDEV-9667: Server hangs after select count(distinct name) from t2 where a=8366 and b>=5 and b<=5;
5+
#
6+
7+
create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB;
8+
9+
insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm");
10+
11+
select count(distinct name) from t2 where a=8366 and b>=5 and b<=5;
12+
select count(distinct name) from t2 where a=8366 and b=5;
13+
select count(distinct name) from t2 where a=8366 and b between 5 and 5.5;
14+
select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5;
15+
select sum(distinct a) from t2 where a=8366 and b=5;
16+
select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5;
17+
18+
drop table t2;

storage/xtradb/handler/ha_innodb.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7559,7 +7559,7 @@ ha_innobase::write_row(
75597559

75607560
if (share->ib_table != prebuilt->table) {
75617561
fprintf(stderr,
7562-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
7562+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
75637563
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
75647564
}
75657565

@@ -7801,7 +7801,7 @@ ha_innobase::write_row(
78017801

78027802
if (share->ib_table != prebuilt->table) {
78037803
fprintf(stderr,
7804-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
7804+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
78057805
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
78067806
}
78077807

@@ -8139,7 +8139,7 @@ ha_innobase::update_row(
81398139

81408140
if (share->ib_table != prebuilt->table) {
81418141
fprintf(stderr,
8142-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
8142+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
81438143
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
81448144
}
81458145

@@ -8242,7 +8242,7 @@ ha_innobase::update_row(
82428242

82438243
if (share->ib_table != prebuilt->table) {
82448244
fprintf(stderr,
8245-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
8245+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
82468246
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
82478247
}
82488248

@@ -11117,7 +11117,7 @@ ha_innobase::truncate()
1111711117

1111811118
if (share->ib_table != prebuilt->table) {
1111911119
fprintf(stderr,
11120-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
11120+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1112111121
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1112211122
}
1112311123

@@ -11138,7 +11138,7 @@ ha_innobase::truncate()
1113811138

1113911139
if (share->ib_table != prebuilt->table) {
1114011140
fprintf(stderr,
11141-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
11141+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1114211142
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1114311143
}
1114411144

@@ -12439,7 +12439,7 @@ ha_innobase::analyze(
1243912439

1244012440
if (share->ib_table != prebuilt->table) {
1244112441
fprintf(stderr,
12442-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
12442+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1244312443
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1244412444
}
1244512445

@@ -12455,7 +12455,7 @@ ha_innobase::analyze(
1245512455

1245612456
if (share->ib_table != prebuilt->table) {
1245712457
fprintf(stderr,
12458-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
12458+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1245912459
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1246012460
}
1246112461

@@ -13629,7 +13629,7 @@ ha_innobase::transactional_table_lock(
1362913629

1363013630
if (share->ib_table != prebuilt->table) {
1363113631
fprintf(stderr,
13632-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
13632+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1363313633
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1363413634
}
1363513635

storage/xtradb/row/row0sel.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,12 +3738,6 @@ row_search_for_mysql(
37383738
ut_error;
37393739
}
37403740

3741-
/* init null bytes with default values as they might be
3742-
left uninitialized in some cases and these uninited bytes
3743-
might be copied into mysql record buffer that leads to
3744-
valgrind warnings */
3745-
memcpy(buf, prebuilt->default_rec, prebuilt->null_bitmap_len);
3746-
37473741
#if 0
37483742
/* August 19, 2005 by Heikki: temporarily disable this error
37493743
print until the cursor lock count is done correctly.

0 commit comments

Comments
 (0)