diff options
author | Igor Babaev <igor@askmonty.org> | 2019-04-03 22:52:29 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2019-04-05 15:00:42 -0700 |
commit | b4a7bde76c99b6db28e2983f5247b681dfe91617 (patch) | |
tree | 64efb4c4efef8a4117b3e871cf11e1fc9450a39a /sql/sql_base.cc | |
parent | b30fb701cc040cd9243a3634240672b27f78d142 (diff) | |
download | mariadb-git-b4a7bde76c99b6db28e2983f5247b681dfe91617.tar.gz |
MDEV-19112 WITH clause does not work with information_schema as default database
With INFORMATION_SCHEMA set as the default database the check that a table
referred in the processed query is defined in INORMATION_SCHEMA must
be postponed until all CTE names can be identified.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c282db42fdd..e0a907abfb3 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3344,6 +3344,30 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, goto end; } } + + if (!tables->derived && + is_infoschema_db(tables->db, tables->db_length)) + { + /* + Check whether the information schema contains a table + whose name is tables->schema_table_name + */ + ST_SCHEMA_TABLE *schema_table; + schema_table= find_schema_table(thd, tables->schema_table_name); + if (!schema_table || + (schema_table->hidden && + ((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 || + /* + this check is used for show columns|keys from I_S hidden table + */ + lex->sql_command == SQLCOM_SHOW_FIELDS || + lex->sql_command == SQLCOM_SHOW_KEYS))) + { + my_error(ER_UNKNOWN_TABLE, MYF(0), + tables->schema_table_name, INFORMATION_SCHEMA_NAME.str); + DBUG_RETURN(1); + } + } /* If this TABLE_LIST object is a placeholder for an information_schema table, create a temporary table to represent the information_schema |