MCPcopy Create free account
hub / github.com/MariaDB/server / find_dup_table

Function find_dup_table

sql/sql_base.cc:1151–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1149*/
1150
1151static
1152TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
1153 uint check_flag)
1154{
1155 TABLE_LIST *res= 0;
1156 DBUG_ENTER("find_dup_table");
1157 DBUG_PRINT("enter", ("table alias: %s", table->alias.str));
1158
1159 /*
1160 If this function called for query which update table (INSERT/UPDATE/...)
1161 then we have in table->table pointer to TABLE object which we are
1162 updating even if it is VIEW so we need TABLE_LIST of this TABLE object
1163 to get right names (even if lower_case_table_names used).
1164
1165 If this function called for CREATE command that we have not opened table
1166 (table->table equal to 0) and right names is in current TABLE_LIST
1167 object.
1168 */
1169 if (table->table &&
1170 thd->lex->sql_command != SQLCOM_UPDATE &&
1171 thd->lex->sql_command != SQLCOM_UPDATE_MULTI &&
1172 thd->lex->sql_command != SQLCOM_DELETE &&
1173 thd->lex->sql_command != SQLCOM_DELETE_MULTI)
1174 {
1175 /* All MyISAMMRG children are plain MyISAM tables. */
1176 DBUG_ASSERT(table->table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
1177
1178 table= table->find_underlying_table(table->table);
1179 /*
1180 as far as we have table->table we have to find real TABLE_LIST of
1181 it in underlying tables
1182 */
1183 DBUG_ASSERT(table);
1184 }
1185 const Lex_ident_db d_name= table->db;
1186 const Lex_ident_table t_name= table->table_name;
1187 const Lex_ident_table t_alias= table->alias;
1188
1189 DBUG_PRINT("info", ("real table: %s.%s", d_name.str, t_name.str));
1190 for (TABLE_LIST *tl= table_list; tl ; tl= tl->next_global, res= 0)
1191 {
1192 if (tl->select_lex && tl->select_lex->master_unit() &&
1193 tl->select_lex->master_unit()->executed)
1194 {
1195 /*
1196 There is no sense to check tables of already executed parts
1197 of the query
1198 */
1199 continue;
1200 }
1201 /*
1202 Table is unique if it is present only once in the global list
1203 of tables and once in the list of table locks.
1204 */
1205 if (! (res= find_table_in_global_list(tl, &d_name, &t_name)))
1206 break;
1207 tl= res; // We can continue search after this table
1208

Callers 1

unique_table_callbackFunction · 0.85

Calls 11

find_underlying_tableMethod · 0.80
master_unitMethod · 0.80
is_merged_derivedMethod · 0.80
is_excludedMethod · 0.80
streqMethod · 0.45
is_multitableMethod · 0.45
outer_selectMethod · 0.45
set_as_multitableMethod · 0.45

Tested by

no test coverage detected