Commit a593e03d authored by Sergei Petrunia's avatar Sergei Petrunia

Add dbug_print_sel_arg() debugging help function

parent d6ea03fa
......@@ -14786,6 +14786,113 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
DBUG_VOID_RETURN;
}
static String dbug_print_sel_arg_buf;
static void
print_sel_arg_key(Field *field, const uchar *key, String *out)
{
TABLE *table= field->table;
my_bitmap_map *old_sets[2];
dbug_tmp_use_all_columns(table, old_sets, table->read_set, table->write_set);
if (field->real_maybe_null())
{
if (*key)
{
out->append("NULL");
goto end;
}
key++; // Skip null byte
}
field->set_key_image(key, field->pack_length());
if (field->type() == MYSQL_TYPE_BIT)
(void) field->val_int_as_str(out, 1);
else
field->val_str(out);
end:
dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets);
}
/*
@brief
Produce a string representation of an individual SEL_ARG and return pointer
to it
@detail
Intended usage:
(gdb) p dbug_print_sel_arg(ptr)
*/
const char *dbug_print_sel_arg(SEL_ARG *sel_arg)
{
StringBuffer<64> buf;
String &out= dbug_print_sel_arg_buf;
out.length(0);
if (!sel_arg)
{
out.append("NULL");
goto end;
}
out.append("SEL_ARG(");
const char *stype;
switch(sel_arg->type) {
case SEL_ARG::IMPOSSIBLE:
stype="IMPOSSIBLE";
break;
case SEL_ARG::MAYBE:
stype="MAYBE";
break;
case SEL_ARG::MAYBE_KEY:
stype="MAYBE_KEY";
break;
case SEL_ARG::KEY_RANGE:
default:
stype=nullptr;
}
if (stype)
{
out.append("type=");
out.append(stype);
goto end;
}
if (sel_arg->min_flag & NO_MIN_RANGE)
out.append("-inf");
else
{
print_sel_arg_key(sel_arg->field, sel_arg->min_value, &buf);
out.append(buf);
}
out.append((sel_arg->min_flag & NEAR_MIN)? "<" : "<=");
out.append(sel_arg->field->field_name);
out.append((sel_arg->max_flag & NEAR_MAX)? "<" : "<=");
if (sel_arg->max_flag & NO_MAX_RANGE)
out.append("+inf");
else
{
print_sel_arg_key(sel_arg->field, sel_arg->max_value, &buf);
out.append(buf);
}
out.append(")");
end:
return dbug_print_sel_arg_buf.c_ptr_safe();
}
/*****************************************************************************
** Print a quick range for debugging
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment