diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-02-20 16:04:29 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2018-02-20 16:04:29 +0100 |
commit | 2ae3888557f2baedc8d43711e5ffc8cb964ff958 (patch) | |
tree | f805b0b17c7005c37e0864f8563367fb31edf211 | |
parent | d23fcc427cb4010b33defc69547089afeb9af811 (diff) | |
download | mariadb-git-bb-10.3-MDEV-13749.tar.gz |
MDEV-13749: Server crashes in _ma_unique_hash / JOIN_CACHE::generate_full_extensions on INTERSECTbb-10.3-MDEV-13749
Expect index except unique constrain in case of heap table conversion.
-rw-r--r-- | mysql-test/r/intersect.result | 35 | ||||
-rw-r--r-- | mysql-test/t/intersect.test | 40 | ||||
-rw-r--r-- | storage/maria/ha_maria.cc | 32 |
3 files changed, 98 insertions, 9 deletions
diff --git a/mysql-test/r/intersect.result b/mysql-test/r/intersect.result index 05adaf160ed..5dc1ea68831 100644 --- a/mysql-test/r/intersect.result +++ b/mysql-test/r/intersect.result @@ -702,4 +702,39 @@ intersect (select 3 from dual having t.i <> 3)); i drop table t; +# +# MDEV-13749: Server crashes in _ma_unique_hash / +# JOIN_CACHE::generate_full_extensions on INTERSECT +# +CREATE TABLE t1 (a varchar(32)) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'); +CREATE TABLE t2 (b varchar(32)) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'); +CREATE TABLE t3 (c varchar(32)) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'); +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +; +a b c +drop table t1,t2,t3; # End of 10.3 tests diff --git a/mysql-test/t/intersect.test b/mysql-test/t/intersect.test index 98b6d1eb1c6..5415002ef5a 100644 --- a/mysql-test/t/intersect.test +++ b/mysql-test/t/intersect.test @@ -205,4 +205,44 @@ select i from t where drop table t; +--echo # +--echo # MDEV-13749: Server crashes in _ma_unique_hash / +--echo # JOIN_CACHE::generate_full_extensions on INTERSECT +--echo # + +CREATE TABLE t1 (a varchar(32)) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('Jakarta'),('Lisbon'),('Honolulu'),('Lusaka'),('Barcelona'),('Taipei'), +('Brussels'),('Orlando'),('Osaka'),('Quito'),('Lima'),('Tunis'), +('Unalaska'),('Rotterdam'),('Zagreb'),('Ufa'),('Ryazan'),('Xiamen'), +('London'),('Izmir'),('Samara'),('Bern'),('Zhengzhou'),('Vladivostok'), +('Yangon'),('Victoria'),('Warsaw'),('Luanda'),('Leon'),('Bangkok'), +('Wellington'),('Zibo'),('Qiqihar'),('Delhi'),('Hamburg'),('Ottawa'), +('Vaduz'); + +CREATE TABLE t2 (b varchar(32)) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('Gaza'),('Jeddah'),('Beirut'),('Incheon'),('Tbilisi'),('Izmir'), +('Quito'),('Riga'),('Freetown'),('Zagreb'),('Caracas'),('Orlando'), +('Kingston'),('Turin'),('Xinyang'),('Osaka'),('Albany'),('Geneva'), +('Omsk'),('Kazan'),('Quezon'),('Indore'),('Odessa'),('Xiamen'), +('Winnipeg'),('Yakutsk'),('Nairobi'),('Ufa'),('Helsinki'),('Vilnius'), +('Aden'),('Liverpool'),('Honolulu'),('Frankfurt'),('Glasgow'), +('Vienna'),('Jackson'),('Jakarta'),('Sydney'),('Oslo'),('Novgorod'), +('Norilsk'),('Izhevsk'),('Istanbul'),('Nice'); + +CREATE TABLE t3 (c varchar(32)) ENGINE=MyISAM; +INSERT INTO t3 VALUES +('Nicosia'),('Istanbul'),('Richmond'),('Stockholm'),('Dublin'), +('Wichita'),('Warsaw'),('Glasgow'),('Winnipeg'),('Irkutsk'),('Quito'), +('Xiamen'),('Berlin'),('Rome'),('Denver'),('Dallas'),('Kabul'), +('Prague'),('Izhevsk'),('Tirana'),('Sofia'),('Detroit'),('Sorbonne'); + +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +INTERSECT +SELECT * FROM t1 LEFT OUTER JOIN t2 LEFT OUTER JOIN t3 ON b < c ON a > b +; + +drop table t1,t2,t3; + --echo # End of 10.3 tests diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 17b56096114..0ddea4abcd9 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3964,15 +3964,29 @@ Item *ha_maria::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) int ha_maria::find_unique_row(uchar *record, uint constrain_no) { - MARIA_UNIQUEDEF *def= file->s->uniqueinfo + constrain_no; - ha_checksum unique_hash= _ma_unique_hash(def, record); - int rc= _ma_check_unique(file, def, record, unique_hash, HA_OFFSET_ERROR); - if (rc) - { - file->cur_row.lastpos= file->dup_key_pos; - if ((*file->read_record)(file, record, file->cur_row.lastpos)) - return -1; - file->update|= HA_STATE_AKTIV; /* Record is read */ + int rc; + if (file->s->state.header.uniques) + { + DBUG_ASSERT(file->s->state.header.uniques > constrain_no); + MARIA_UNIQUEDEF *def= file->s->uniqueinfo + constrain_no; + ha_checksum unique_hash= _ma_unique_hash(def, record); + rc= _ma_check_unique(file, def, record, unique_hash, HA_OFFSET_ERROR); + if (rc) + { + file->cur_row.lastpos= file->dup_key_pos; + if ((*file->read_record)(file, record, file->cur_row.lastpos)) + return -1; + file->update|= HA_STATE_AKTIV; /* Record is read */ + } + } + else + { + /* + It is case when just unique index used instead unicue constrain + (conversion from heap table). + */ + DBUG_ASSERT(file->s->state.header.keys > constrain_no); + rc= maria_rfirst(file, record, constrain_no); } // invert logic return (rc ? 0 : 1); |