3676 Norvald H. Ryeng 2011-12-19
Bug#11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
`TAB->REF.USE_COUNT'
Code cleanup. Move setting of unlock_row function from
make_join_readinfo() to pick_table_access_method().
modified:
sql/sql_executor.cc
sql/sql_select.cc
3675 Norvald H. Ryeng 2011-12-19
Bug#11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
`TAB->REF.USE_COUNT'
Problem: Queries that use an index to access a table and read rows in
descending order while comparing with a constant value trigger an
assertion when a row that does not match the condition is found.
During optimization, make_join_readinfo() first calls
pick_table_access_method() to set access methods. Later, recognizing
that the join type is JT_EQ_REF, it also sets read_record.unlock_row
to join_read_key_unlock_row(). This function expects the use_count
field to be incremented by join_read_key().
During JOIN::exec(), create_sort_index() calls
test_if_skip_sort_order(). Here, the special case of using the index
to achieve descending sort is identified, and the access method is
changed to use join_read_last_key() instead of
join_read_key(). However, the unlock_row function is not changed.
The assertion is triggered when evaluate_join_record() finds a row
that does not match the condition and calls join_read_key_unlock_row()
to unlock the row before getting the next row. The use_count variable
is not used by join_read_last_key(), but join_read_key_unlock_row()
expects that it was incremented by the read function.
Fix: Set read_record.unlock_row to the default rr_unlock_row() in
test_if_skip_sort_order().
@ mysql-test/include/order_by.inc
Test case for bug #11885377.
@ mysql-test/r/order_by_all.result
Test case for bug #11885377.
@ mysql-test/r/order_by_icp_mrr.result
Test case for bug #11885377.
@ mysql-test/r/order_by_none.result
Test case for bug #11885377.
@ sql/sql_select.cc
Reset read_record.unlock_row to default function.
modified:
mysql-test/include/order_by.inc
mysql-test/r/order_by_all.result
mysql-test/r/order_by_icp_mrr.result
mysql-test/r/order_by_none.result
sql/sql_select.cc
3674 Sunny Bains 2011-12-19
Revert UT_LIST changes. Older C++ compilers croak on the changes. Need to test
on PB2 before recommitting.
modified:
storage/innobase/buf/buf0buddy.cc
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0flu.cc
storage/innobase/buf/buf0lru.cc
storage/innobase/dict/dict0dict.cc
storage/innobase/dict/dict0mem.cc
storage/innobase/dyn/dyn0dyn.cc
storage/innobase/fil/fil0fil.cc
storage/innobase/include/dict0mem.h
storage/innobase/include/lock0lock.h
storage/innobase/include/lock0priv.h
storage/innobase/include/lock0types.h
storage/innobase/include/mem0mem.ic
storage/innobase/include/sync0sync.h
storage/innobase/include/trx0roll.h
storage/innobase/include/trx0trx.h
storage/innobase/include/usr0sess.h
storage/innobase/include/ut0lst.h
storage/innobase/lock/lock0iter.cc
storage/innobase/lock/lock0lock.cc
storage/innobase/log/log0log.cc
storage/innobase/log/log0recv.cc
storage/innobase/mem/mem0mem.cc
storage/innobase/mem/mem0pool.cc
storage/innobase/os/os0sync.cc
storage/innobase/pars/pars0opt.cc
storage/innobase/pars/pars0pars.cc
storage/innobase/pars/pars0sym.cc
storage/innobase/que/que0que.cc
storage/innobase/read/read0read.cc
storage/innobase/row/row0ftsort.cc
storage/innobase/row/row0ins.cc
storage/innobase/row/row0merge.cc
storage/innobase/row/row0mysql.cc
storage/innobase/srv/srv0mon.cc
storage/innobase/srv/srv0srv.cc
storage/innobase/sync/sync0rw.cc
storage/innobase/sync/sync0sync.cc
storage/innobase/trx/trx0roll.cc
storage/innobase/trx/trx0rseg.cc
storage/innobase/trx/trx0sys.cc
storage/innobase/trx/trx0trx.cc
storage/innobase/trx/trx0undo.cc
storage/innobase/usr/usr0sess.cc
storage/innobase/ut/ut0mem.cc
=== modified file 'mysql-test/include/order_by.inc'
--- a/mysql-test/include/order_by.inc 2011-10-12 13:30:13 +0000
+++ b/mysql-test/include/order_by.inc 2011-12-19 09:22:28 +0000
@@ -1738,3 +1738,15 @@ SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.
ORDER BY t1.i1 LIMIT 5;
DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
+--echo # `TAB->REF.USE_COUNT'
+--echo #
+
+CREATE TABLE t1(a INT PRIMARY KEY);
+CREATE TABLE t2(b INT,c INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1,2), (2,3);
+SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2;
+DROP TABLE t1, t2;
=== modified file 'mysql-test/r/order_by_all.result'
--- a/mysql-test/r/order_by_all.result 2011-10-12 13:30:13 +0000
+++ b/mysql-test/r/order_by_all.result 2011-12-19 09:22:28 +0000
@@ -2587,4 +2587,17 @@ i1 i2
4 4
5 5
DROP TABLE t1, t2, t3;
+#
+# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
+# `TAB->REF.USE_COUNT'
+#
+CREATE TABLE t1(a INT PRIMARY KEY);
+CREATE TABLE t2(b INT,c INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1,2), (2,3);
+SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2;
+(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC)
+NULL
+NULL
+DROP TABLE t1, t2;
set optimizer_switch=default;
=== modified file 'mysql-test/r/order_by_icp_mrr.result'
--- a/mysql-test/r/order_by_icp_mrr.result 2011-10-12 13:30:13 +0000
+++ b/mysql-test/r/order_by_icp_mrr.result 2011-12-19 09:22:28 +0000
@@ -2587,4 +2587,17 @@ i1 i2
4 4
5 5
DROP TABLE t1, t2, t3;
+#
+# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
+# `TAB->REF.USE_COUNT'
+#
+CREATE TABLE t1(a INT PRIMARY KEY);
+CREATE TABLE t2(b INT,c INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1,2), (2,3);
+SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2;
+(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC)
+NULL
+NULL
+DROP TABLE t1, t2;
set optimizer_switch=default;
=== modified file 'mysql-test/r/order_by_none.result'
--- a/mysql-test/r/order_by_none.result 2011-10-12 13:30:13 +0000
+++ b/mysql-test/r/order_by_none.result 2011-12-19 09:22:28 +0000
@@ -2586,4 +2586,17 @@ i1 i2
4 4
5 5
DROP TABLE t1, t2, t3;
+#
+# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION
+# `TAB->REF.USE_COUNT'
+#
+CREATE TABLE t1(a INT PRIMARY KEY);
+CREATE TABLE t2(b INT,c INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1,2), (2,3);
+SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2;
+(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC)
+NULL
+NULL
+DROP TABLE t1, t2;
set optimizer_switch=default;
=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc 2011-12-15 09:00:42 +0000
+++ b/sql/sql_executor.cc 2011-12-19 09:53:30 +0000
@@ -1738,6 +1738,7 @@ sub_select_sjm(JOIN *join, JOIN_TAB *joi
last_tab->read_record.copy_field_end= sjm->copy_field +
sjm->table_cols.elements;
last_tab->read_record.read_record= rr_sequential_and_unpack;
+ DBUG_ASSERT(last_tab->read_record.unlock_row == rr_unlock_row);
// Clear possible outer join information from earlier use of this join tab
last_tab->last_inner= NULL;
@@ -3188,35 +3189,41 @@ pick_table_access_method(JOIN_TAB *tab)
case JT_REF:
tab->read_first_record= join_read_always_key;
tab->read_record.read_record= join_read_next_same;
+ tab->read_record.unlock_row= rr_unlock_row;
break;
case JT_REF_OR_NULL:
tab->read_first_record= join_read_always_key_or_null;
tab->read_record.read_record= join_read_next_same_or_null;
+ tab->read_record.unlock_row= rr_unlock_row;
break;
case JT_CONST:
tab->read_first_record= join_read_const;
tab->read_record.read_record= join_no_more_records;
+ tab->read_record.unlock_row= rr_unlock_row;
break;
case JT_EQ_REF:
tab->read_first_record= join_read_key;
tab->read_record.read_record= join_no_more_records;
+ tab->read_record.unlock_row= join_read_key_unlock_row;
break;
case JT_FT:
tab->read_first_record= join_ft_read_first;
tab->read_record.read_record= join_ft_read_next;
+ tab->read_record.unlock_row= rr_unlock_row;
break;
case JT_SYSTEM:
tab->read_first_record= join_read_system;
tab->read_record.read_record= join_no_more_records;
+ tab->read_record.unlock_row= rr_unlock_row;
break;
- /* keep gcc happy */
default:
+ tab->read_record.unlock_row= rr_unlock_row;
break;
}
}
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2011-12-15 17:14:28 +0000
+++ b/sql/sql_select.cc 2011-12-19 09:53:30 +0000
@@ -2672,7 +2672,6 @@ make_join_readinfo(JOIN *join, ulonglong
TABLE *const table= tab->table;
bool icp_other_tables_ok;
tab->read_record.table= table;
- tab->read_record.unlock_row= rr_unlock_row;
tab->next_select=sub_select; /* normal select */
tab->cache_idx_cond= 0;
/*
@@ -2706,8 +2705,6 @@ make_join_readinfo(JOIN *join, ulonglong
}
switch (tab->type) {
case JT_EQ_REF:
- tab->read_record.unlock_row= join_read_key_unlock_row;
- /* fall through */
case JT_REF_OR_NULL:
case JT_REF:
if (tab->select)
@@ -4049,6 +4046,7 @@ check_reverse_order:
*/
tab->read_first_record= join_read_last_key;
tab->read_record.read_record= join_read_prev_same;
+ tab->read_record.unlock_row= rr_unlock_row;
}
}
else if (select && select->quick)
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (norvald.ryeng:3674 to 3676) Bug#11885377 | Norvald H. Ryeng | 19 Dec |