Skip to content

Commit

Permalink
Merge pull request #13 from percona-ysorokin/ps-8.0-bug1657941-part_t…
Browse files Browse the repository at this point in the history
…able_crash

Fix bug 76418 / 1657941 (Server crashes when querying partitioning table MySQL_5.7.14)
  • Loading branch information
laurynas-biveinis authored Aug 23, 2017
2 parents f43d757 + f7e279e commit bd8d6ac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
13 changes: 13 additions & 0 deletions mysql-test/suite/parts/r/bug76418.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE t1(
id INT UNSIGNED NOT NULL,
dttm DATETIME NOT NULL,
PRIMARY KEY(id, dttm)
) ENGINE=InnoDB
PARTITION BY RANGE COLUMNS(dttm) (
PARTITION pf_201612 VALUES LESS THAN ('20170101') ENGINE=InnoDB
);
SELECT * FROM t1 WHERE dttm > '2017-01-19' ORDER BY id DESC;
id dttm
SELECT * FROM t1 WHERE dttm > '2017-01-19' ORDER BY id ASC;
id dttm
DROP TABLE t1;
17 changes: 17 additions & 0 deletions mysql-test/suite/parts/t/bug76418.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# lp:1657941 / Oracle Bug #76418 "Server crashes when querying partitioning table"
#

CREATE TABLE t1(
id INT UNSIGNED NOT NULL,
dttm DATETIME NOT NULL,
PRIMARY KEY(id, dttm)
) ENGINE=InnoDB
PARTITION BY RANGE COLUMNS(dttm) (
PARTITION pf_201612 VALUES LESS THAN ('20170101') ENGINE=InnoDB
);

SELECT * FROM t1 WHERE dttm > '2017-01-19' ORDER BY id DESC;
SELECT * FROM t1 WHERE dttm > '2017-01-19' ORDER BY id ASC;

DROP TABLE t1;
18 changes: 13 additions & 5 deletions sql/partitioning/partition_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2694,12 +2694,20 @@ int Partition_helper::partition_scan_set_up(uchar * buf, bool idx_read_flag)
&m_part_spec);
else
{
// TODO: set to get_first_used_part() instead!
m_part_spec.start_part= 0;
// TODO: Implement bitmap_get_last_set() and use that here!
m_part_spec.end_part= m_tot_parts - 1;
m_part_spec.start_part= m_part_info->get_first_used_partition();
m_part_spec.end_part= m_part_spec.start_part;

uint i= m_part_spec.end_part;
while (i != MY_BIT_NONE)
{
i= m_part_info->get_next_used_partition(i);
if (i != MY_BIT_NONE)
m_part_spec.end_part= i;
}
}
if (m_part_spec.start_part > m_part_spec.end_part)
if (m_part_spec.start_part == MY_BIT_NONE ||
m_part_spec.end_part == MY_BIT_NONE ||
m_part_spec.start_part > m_part_spec.end_part)
{
/*
We discovered a partition set but the set was empty so we report
Expand Down

0 comments on commit bd8d6ac

Please sign in to comment.