summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-10-29 16:20:57 +0200
committerMonty <monty@mariadb.org>2020-10-29 16:22:30 +0200
commit14798d3cd139430c1d23f14d810a27c5410f7161 (patch)
tree7cccfa56fd3dc5308cc3055758471977226fca3c /sql/opt_sum.cc
parent1e778a3b5624f97fdf44a15fd6cee3d615891cff (diff)
downloadmariadb-git-14798d3cd139430c1d23f14d810a27c5410f7161.tar.gz
MDEV-23159 Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2'...
The problem was that opt_sum_query() was, as part of MIN/MAX optimization, doing read operations on constant tables that where already closed Fixed by ensuring we don't try to read from tables that are closed.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index adfad29bb34..525d7390a26 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -399,20 +399,28 @@ int opt_sum_query(THD *thd,
break;
}
longlong info_limit= 1;
- table->file->info_push(INFO_KIND_FORCE_LIMIT_BEGIN, &info_limit);
- if (likely(!(error= table->file->ha_index_init((uint) ref.key, 1))))
- error= (is_max ?
- get_index_max_value(table, &ref, range_fl) :
- get_index_min_value(table, &ref, item_field, range_fl,
- prefix_len));
+ error= 0;
+ table->file->info_push(INFO_KIND_FORCE_LIMIT_BEGIN, &info_limit);
+ if (!table->const_table)
+ {
+ if (likely(!(error= table->file->ha_index_init((uint) ref.key,
+ 1))))
+ error= (is_max ?
+ get_index_max_value(table, &ref, range_fl) :
+ get_index_min_value(table, &ref, item_field, range_fl,
+ prefix_len));
+ }
/* Verify that the read tuple indeed matches the search key */
if (!error &&
reckey_in_range(is_max, &ref, item_field->field,
conds, range_fl, prefix_len))
error= HA_ERR_KEY_NOT_FOUND;
- table->file->ha_end_keyread();
- table->file->ha_index_end();
+ if (!table->const_table)
+ {
+ table->file->ha_end_keyread();
+ table->file->ha_index_end();
+ }
table->file->info_push(INFO_KIND_FORCE_LIMIT_END, NULL);
if (error)
{