diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-11-24 21:55:16 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-11-24 21:55:16 +0300 |
commit | 932a2751a4aaed69b908432b02581a82e9b5a40e (patch) | |
tree | 7056bd2c1a4611320335310643cad518f475e62e /sql/sql_base.cc | |
parent | 5d16e868c1c1b0b240138e4bac42ed26e8bc1ffd (diff) | |
download | mariadb-git-932a2751a4aaed69b908432b02581a82e9b5a40e.tar.gz |
Backport of:
------------------------------------------------------------
revno: 3559
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: mysql-pe
timestamp: Fri 2009-08-28 15:23:16 -0300
message:
Break down a large and obnoxious "if" statement. Multiple "if" statements
makes it easy to understand and follow the code (specially in a debugger).
sql/sql_base.cc:
Break down a large and obnoxious "if" statement. Multiple "if" statements
makes it easy to understand and follow the code (specially in a debugger).
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 52e203f1130..8f31ef6999a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1680,20 +1680,42 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); for (;;) { - if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) && - (! (res= mysql_lock_have_duplicate(thd, table, table_list)))) || - ((!res->table || res->table != table->table) && - (!check_alias || !(lower_case_table_names ? + /* + Table is unique if it is present only once in the global list + of tables and once in the list of table locks. + */ + if (! (res= find_table_in_global_list(table_list, d_name, t_name)) && + ! (res= mysql_lock_have_duplicate(thd, table, table_list))) + break; + + /* Skip if same underlying table. */ + if (res->table && (res->table == table->table)) + goto next; + + /* Skip if table alias does not match. */ + if (check_alias) + { + if (lower_case_table_names ? my_strcasecmp(files_charset_info, t_alias, res->alias) : - strcmp(t_alias, res->alias))) && - res->select_lex && !res->select_lex->exclude_from_table_unique_test && - !res->prelocking_placeholder)) + strcmp(t_alias, res->alias)) + goto next; + } + + /* + Skip if marked to be excluded (could be a derived table) or if + entry is a prelocking placeholder. + */ + if (res->select_lex && + !res->select_lex->exclude_from_table_unique_test && + !res->prelocking_placeholder) break; + /* If we found entry of this table or table of SELECT which already processed in derived table or top select of multi-update/multi-delete (exclude_from_table_unique_test) or prelocking placeholder. */ +next: table_list= res->next_global; DBUG_PRINT("info", ("found same copy of table or table which we should skip")); |