Skip to content

Commit cc99a41

Browse files
committed
cleanup: extract common condition into a function
1 parent a0e5dd5 commit cc99a41

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

sql/sql_show.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,6 +4563,19 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
45634563
}
45644564

45654565

4566+
/*
4567+
Hide error for a non-existing table.
4568+
For example, this error can occur when we use a where condition
4569+
with a db name and table, but the table does not exist or
4570+
there is a view with the same name.
4571+
*/
4572+
static bool hide_object_error(uint err)
4573+
{
4574+
return err == ER_NO_SUCH_TABLE || err == ER_WRONG_OBJECT ||
4575+
err == ER_NOT_SEQUENCE;
4576+
}
4577+
4578+
45664579
/**
45674580
Fill I_S table with data obtained by performing full-blown table open.
45684581
@@ -4691,16 +4704,8 @@ fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root,
46914704
of backward compatibility.
46924705
*/
46934706
if (!is_show_fields_or_keys && result && thd->is_error() &&
4694-
(thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE ||
4695-
thd->get_stmt_da()->sql_errno() == ER_WRONG_OBJECT ||
4696-
thd->get_stmt_da()->sql_errno() == ER_NOT_SEQUENCE))
4707+
hide_object_error(thd->get_stmt_da()->sql_errno()))
46974708
{
4698-
/*
4699-
Hide error for a non-existing table.
4700-
For example, this error can occur when we use a where condition
4701-
with a db name and table, but the table does not exist or
4702-
there is a view with the same name.
4703-
*/
47044709
result= false;
47054710
thd->clear_error();
47064711
}
@@ -4791,8 +4796,8 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
47914796
else
47924797
table->field[3]->store(STRING_WITH_LEN("ERROR"), cs);
47934798

4794-
if (unlikely(thd->is_error() &&
4795-
thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE))
4799+
if (unlikely(thd->is_error()) &&
4800+
hide_object_error(thd->get_stmt_da()->sql_errno()))
47964801
{
47974802
thd->clear_error();
47984803
return 0;
@@ -5032,9 +5037,7 @@ static int fill_schema_table_from_frm(THD *thd, MEM_ROOT *mem_root,
50325037
share= tdc_acquire_share(thd, &table_list, GTS_TABLE | GTS_VIEW);
50335038
if (!share)
50345039
{
5035-
if (thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE ||
5036-
thd->get_stmt_da()->sql_errno() == ER_WRONG_OBJECT ||
5037-
thd->get_stmt_da()->sql_errno() == ER_NOT_SEQUENCE)
5040+
if (hide_object_error(thd->get_stmt_da()->sql_errno()))
50385041
{
50395042
res= 0;
50405043
}

0 commit comments

Comments
 (0)