diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ea690422eac..b995beb53e3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7550,6 +7550,30 @@ double adjust_quick_cost(double quick_cost, ha_rows records) } +#ifndef DBUG_OFF + +char dbug_join_prefix_buf[256]; + +const char* dbug_print_join_prefix(const POSITION *join_positions, + uint idx, + JOIN_TAB *s) +{ + char *buf= dbug_join_prefix_buf; + String str(buf, sizeof(dbug_join_prefix_buf), &my_charset_bin); + str.length(0); + for (uint i=0; i!=idx; i++) + { + str.append(join_positions[i].table->table->alias); + str.append(','); + } + str.append(s->table->alias); + if (str.c_ptr_safe() == buf) + return buf; + else + return "Couldn't fit into buffer"; +} +#endif + /** Find the best access path for an extension of a partial execution plan and add this path to the plan. @@ -7573,6 +7597,14 @@ double adjust_quick_cost(double quick_cost, ha_rows records) @param pos OUT Table access plan @param loose_scan_pos OUT Table plan that uses loosescan, or set cost to DBL_MAX if not possible. + @detail + Use this to print the current join prefix: + + dbug_print_join_prefix(join_positions, idx, s) + + Use this as breakpoint condition to stop at join prefix "t1,t2,t3": + + $_streq(dbug_print_join_prefix(join_positions, idx, s), "t1,t2,t3") @return None