From 2061e00c200cc994130c00d58632aecba336273b Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Thu, 17 Jan 2019 22:56:12 +0200 Subject: MDEV-14440: Assertion `inited==RND' failed in handler::ha_rnd_end In the function QUICK_RANGE_SELECT::init_ror_merged_scan we create a seperate handler if the handler in head->file cannot be reused. The flag free_file tells us if we have a seperate handler or not. There are cases where you might create a handler and then there might be a failure(running ALTER) and then we have to revert the handler back to the original one. The code does that but it does not reset the flag 'free_file' in this case. Also backported f2c418079def. --- sql/opt_range.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/opt_range.cc') diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b1f8366d83b..ef40e0b6daa 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2161,6 +2161,7 @@ failure: head->column_bitmaps_set(save_read_set, save_write_set); delete file; file= save_file; + free_file= false; DBUG_RETURN(1); } @@ -7140,6 +7141,8 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, if (ror_intersect_add(intersect, cpk_scan, TRUE) && (intersect->total_cost < min_cost)) intersect_best= intersect; //just set pointer here + else + cpk_scan= 0; // Don't use cpk_scan } else cpk_scan= 0; // Don't use cpk_scan -- cgit v1.2.1