summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-01-30 22:30:52 +0100
committerSergei Golubchik <serg@mariadb.org>2018-02-12 13:35:12 +0100
commit34857b9166922552191fa88ab9bb008a8cf707e0 (patch)
tree8af91857f2559f9211aa7692c378156481d1fad1
parentf894f902a41ecbd7477ef821cebc70f288aea060 (diff)
downloadmariadb-git-34857b9166922552191fa88ab9bb008a8cf707e0.tar.gz
cleanup: find_field_in_table()
don't duplicate functionality, use TABLE::find_field_by_name() also, set cached_field_index_ptr for _rowid field
-rw-r--r--sql/sql_base.cc33
1 files changed, 7 insertions, 26 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 44facb37a89..2ef24a551e5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5628,7 +5628,7 @@ Field *
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
bool allow_rowid, uint *cached_field_index_ptr)
{
- Field **field_ptr, *field;
+ Field *field;
uint cached_field_index= *cached_field_index_ptr;
DBUG_ENTER("find_field_in_table");
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,
if (cached_field_index < table->s->fields &&
!my_strcasecmp(system_charset_info,
table->field[cached_field_index]->field_name.str, name))
- field_ptr= 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));
- }
- }
+ field= table->field[cached_field_index];
else
{
- if (!(field_ptr= table->field))
- DBUG_RETURN((Field *)0);
- for (; *field_ptr; ++field_ptr)
- if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name.str,
- name))
- break;
+ LEX_CSTRING fname= {name, length};
+ field= table->find_field_by_name(&fname);
}
- 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_RETURN((Field*)0);
-
- *cached_field_index_ptr= (uint)(field_ptr - table->field);
- field= *field_ptr;
}
else
{
@@ -5679,6 +5659,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
DBUG_RETURN((Field*) 0);
field= table->field[table->s->rowid_field_offset-1];
}
+ *cached_field_index_ptr= field->field_index;
update_field_dependencies(thd, field, table);