diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-03 14:49:17 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-03 14:49:17 +0200 |
commit | 533a13af069d8c9e6c5f4e1a72851497185ade03 (patch) | |
tree | 4623752e0c114e582fbbc0afcc02b67dede26b50 /sql/opt_sum.cc | |
parent | 4b3690b50433a169d9feed5dc45044a8934b5582 (diff) | |
parent | e6290a8270daf884f551230307225b358939bfab (diff) | |
download | mariadb-git-533a13af069d8c9e6c5f4e1a72851497185ade03.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r-- | sql/opt_sum.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 0a3c30a176d..af2d9ddc2e7 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) { |