Commit 34857b91 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: find_field_in_table()

don't duplicate functionality, use TABLE::find_field_by_name()

also, set cached_field_index_ptr for _rowid field
parent f894f902
...@@ -5628,7 +5628,7 @@ Field * ...@@ -5628,7 +5628,7 @@ Field *
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
bool allow_rowid, uint *cached_field_index_ptr) bool allow_rowid, uint *cached_field_index_ptr)
{ {
Field **field_ptr, *field; Field *field;
uint cached_field_index= *cached_field_index_ptr; uint cached_field_index= *cached_field_index_ptr;
DBUG_ENTER("find_field_in_table"); DBUG_ENTER("find_field_in_table");
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(), DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
...@@ -5638,38 +5638,18 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, ...@@ -5638,38 +5638,18 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
if (cached_field_index < table->s->fields && if (cached_field_index < table->s->fields &&
!my_strcasecmp(system_charset_info, !my_strcasecmp(system_charset_info,
table->field[cached_field_index]->field_name.str, name)) table->field[cached_field_index]->field_name.str, name))
field_ptr= table->field + cached_field_index; field= table->field[cached_field_index];
else if (table->s->name_hash.records)
{
field_ptr= (Field**) my_hash_search(&table->s->name_hash, (uchar*) name,
length);
if (field_ptr)
{
/*
field_ptr points to field in TABLE_SHARE. Convert it to the matching
field in table
*/
field_ptr= (table->field + (field_ptr - table->s->field));
}
}
else else
{ {
if (!(field_ptr= table->field)) LEX_CSTRING fname= {name, length};
DBUG_RETURN((Field *)0); field= table->find_field_by_name(&fname);
for (; *field_ptr; ++field_ptr)
if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name.str,
name))
break;
} }
if (field_ptr && *field_ptr) if (field)
{ {
if ((*field_ptr)->invisible == INVISIBLE_FULL && if (field->invisible == INVISIBLE_FULL &&
DBUG_EVALUATE_IF("test_completely_invisible", 0, 1)) DBUG_EVALUATE_IF("test_completely_invisible", 0, 1))
DBUG_RETURN((Field*)0); DBUG_RETURN((Field*)0);
*cached_field_index_ptr= (uint)(field_ptr - table->field);
field= *field_ptr;
} }
else else
{ {
...@@ -5679,6 +5659,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, ...@@ -5679,6 +5659,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
DBUG_RETURN((Field*) 0); DBUG_RETURN((Field*) 0);
field= table->field[table->s->rowid_field_offset-1]; field= table->field[table->s->rowid_field_offset-1];
} }
*cached_field_index_ptr= field->field_index;
update_field_dependencies(thd, field, table); update_field_dependencies(thd, field, table);
......
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