MDEV-36469 don't check is_infoschema_db for null db

The is_infoschema_db is a deep character set based
comparision. In in many cases the db is still
an empty structure.

Doing this comparion early prevents a UBSAN error
by not performing character set operations on
a null pointer.
This commit is contained in:
Daniel Black 2025-04-03 18:29:24 +11:00
parent bb1d88b6dc
commit db5bb6f333
2 changed files with 3 additions and 2 deletions

View File

@ -165,6 +165,7 @@ public:
*/
class Lex_ident_db: public Lex_ident_fs
{
public:
bool is_null() const
{
return length == 0 && str == NULL;
@ -174,7 +175,6 @@ class Lex_ident_db: public Lex_ident_fs
{
return length == 0 && str != NULL;
}
public:
static bool check_name(const LEX_CSTRING &str);
static bool check_name_with_error(const LEX_CSTRING &str);
public:

View File

@ -8111,7 +8111,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
DBUG_RETURN(0);
else
fqtn= FALSE;
bool info_schema= is_infoschema_db(&db);
bool info_schema= (db.is_null() || db.is_empty())
? false : is_infoschema_db(&db);
if (!table->sel && info_schema &&
(table_options & TL_OPTION_UPDATING) &&
/* Special cases which are processed by commands itself */