Simple cleanups
- Removing use of calls to current_thd - More DBUG_PRINT - Code style changes - Made some local functions static Ensure that calls to print_keyuse are locked with mutex to get all lines in same debug packet
This commit is contained in:
parent
8c815751c9
commit
67c56ab1e4
27
sql/item.cc
27
sql/item.cc
@ -4415,18 +4415,23 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
|
|||||||
Item_ident *resolved_item,
|
Item_ident *resolved_item,
|
||||||
Item_ident *mark_item)
|
Item_ident *mark_item)
|
||||||
{
|
{
|
||||||
const char *db_name= (resolved_item->db_name ?
|
DBUG_ENTER("mark_as_dependent");
|
||||||
resolved_item->db_name : "");
|
|
||||||
const char *table_name= (resolved_item->table_name ?
|
|
||||||
resolved_item->table_name : "");
|
|
||||||
/* store pointer on SELECT_LEX from which item is dependent */
|
/* store pointer on SELECT_LEX from which item is dependent */
|
||||||
if (mark_item && mark_item->can_be_depended)
|
if (mark_item && mark_item->can_be_depended)
|
||||||
|
{
|
||||||
|
DBUG_PRINT("info", ("mark_item: %p lex: %p", mark_item, last));
|
||||||
mark_item->depended_from= last;
|
mark_item->depended_from= last;
|
||||||
if (current->mark_as_dependent(thd, last, /** resolved_item psergey-thu
|
}
|
||||||
**/mark_item))
|
if (current->mark_as_dependent(thd, last,
|
||||||
return TRUE;
|
/** resolved_item psergey-thu **/ mark_item))
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
if (thd->lex->describe & DESCRIBE_EXTENDED)
|
if (thd->lex->describe & DESCRIBE_EXTENDED)
|
||||||
{
|
{
|
||||||
|
const char *db_name= (resolved_item->db_name ?
|
||||||
|
resolved_item->db_name : "");
|
||||||
|
const char *table_name= (resolved_item->table_name ?
|
||||||
|
resolved_item->table_name : "");
|
||||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||||
ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
|
ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
|
||||||
db_name, (db_name[0] ? "." : ""),
|
db_name, (db_name[0] ? "." : ""),
|
||||||
@ -4434,7 +4439,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
|
|||||||
resolved_item->field_name,
|
resolved_item->field_name,
|
||||||
current->select_number, last->select_number);
|
current->select_number, last->select_number);
|
||||||
}
|
}
|
||||||
return FALSE;
|
DBUG_RETURN(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6886,7 +6891,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
|
|||||||
{
|
{
|
||||||
/* The current reference cannot be resolved in this query. */
|
/* The current reference cannot be resolved in this query. */
|
||||||
my_error(ER_BAD_FIELD_ERROR,MYF(0),
|
my_error(ER_BAD_FIELD_ERROR,MYF(0),
|
||||||
this->full_name(), current_thd->where);
|
this->full_name(), thd->where);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7021,7 +7026,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
|
|||||||
goto error;
|
goto error;
|
||||||
thd->change_item_tree(reference, fld);
|
thd->change_item_tree(reference, fld);
|
||||||
mark_as_dependent(thd, last_checked_context->select_lex,
|
mark_as_dependent(thd, last_checked_context->select_lex,
|
||||||
thd->lex->current_select, fld, fld);
|
current_sel, fld, fld);
|
||||||
/*
|
/*
|
||||||
A reference is resolved to a nest level that's outer or the same as
|
A reference is resolved to a nest level that's outer or the same as
|
||||||
the nest level of the enclosing set function : adjust the value of
|
the nest level of the enclosing set function : adjust the value of
|
||||||
@ -7038,7 +7043,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
|
|||||||
{
|
{
|
||||||
/* The item was not a table field and not a reference */
|
/* The item was not a table field and not a reference */
|
||||||
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
||||||
this->full_name(), current_thd->where);
|
this->full_name(), thd->where);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* Should be checked in resolve_ref_in_select_and_group(). */
|
/* Should be checked in resolve_ref_in_select_and_group(). */
|
||||||
|
@ -464,6 +464,7 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
|
|||||||
{
|
{
|
||||||
List_iterator<Ref_to_outside> it(upper_refs);
|
List_iterator<Ref_to_outside> it(upper_refs);
|
||||||
Ref_to_outside *upper;
|
Ref_to_outside *upper;
|
||||||
|
DBUG_ENTER("recalc_used_tables");
|
||||||
|
|
||||||
used_tables_cache= 0;
|
used_tables_cache= 0;
|
||||||
while ((upper= it++))
|
while ((upper= it++))
|
||||||
@ -523,6 +524,8 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
|
|||||||
he has done const table detection, and that will be our chance to update
|
he has done const table detection, and that will be our chance to update
|
||||||
const_tables_cache.
|
const_tables_cache.
|
||||||
*/
|
*/
|
||||||
|
DBUG_PRINT("exit", ("used_tables_cache: %llx", used_tables_cache));
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1989,7 +1992,7 @@ bool Item_allany_subselect::is_maxmin_applicable(JOIN *join)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
|
Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
|
||||||
Item **where_item,
|
Item **where_item,
|
||||||
Item **having_item)
|
Item **having_item)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,7 @@ TEST_join(JOIN *join)
|
|||||||
|
|
||||||
#define FT_KEYPART (MAX_REF_PARTS+10)
|
#define FT_KEYPART (MAX_REF_PARTS+10)
|
||||||
|
|
||||||
void print_keyuse(KEYUSE *keyuse)
|
static void print_keyuse(KEYUSE *keyuse)
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
char buf2[64];
|
char buf2[64];
|
||||||
@ -266,14 +266,11 @@ void print_keyuse(KEYUSE *keyuse)
|
|||||||
else
|
else
|
||||||
fieldname= key_info->key_part[keyuse->keypart].field->field_name;
|
fieldname= key_info->key_part[keyuse->keypart].field->field_name;
|
||||||
ll2str(keyuse->used_tables, buf2, 16, 0);
|
ll2str(keyuse->used_tables, buf2, 16, 0);
|
||||||
DBUG_LOCK_FILE;
|
|
||||||
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize: %u used_tables: %s "
|
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize: %u used_tables: %s "
|
||||||
"ref_table_rows: %lu keypart_map: %0lx\n",
|
"ref_table_rows: %lu keypart_map: %0lx\n",
|
||||||
keyuse->table->alias.c_ptr(), fieldname, str.ptr(),
|
keyuse->table->alias.c_ptr(), fieldname, str.ptr(),
|
||||||
(uint) keyuse->optimize, buf2, (ulong) keyuse->ref_table_rows,
|
(uint) keyuse->optimize, buf2, (ulong) keyuse->ref_table_rows,
|
||||||
(ulong) keyuse->keypart_map);
|
(ulong) keyuse->keypart_map);
|
||||||
DBUG_UNLOCK_FILE;
|
|
||||||
//key_part_map keypart_map; --?? there can be several?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -282,9 +279,9 @@ void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
|
|||||||
{
|
{
|
||||||
DBUG_LOCK_FILE;
|
DBUG_LOCK_FILE;
|
||||||
fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements);
|
fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements);
|
||||||
DBUG_UNLOCK_FILE;
|
|
||||||
for(uint i=0; i < keyuse_array->elements; i++)
|
for(uint i=0; i < keyuse_array->elements; i++)
|
||||||
print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
|
print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
|
||||||
|
DBUG_UNLOCK_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user