1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

A fix and a test case for Bug#56540 "Exception (crash) in

sql_show.cc during rqg_info_schema test on Windows".

Ensure we do not access freed memory when filling
information_schema.views when one of the views
could not be properly opened.



mysql-test/r/information_schema.result:
  Update results - a fix for Bug#56540.
mysql-test/t/information_schema.test:
  Add a test case for Bug#56540
sql/sql_base.cc:
  Push an error into the Diagnostics area
  when we return an error.
  This directs get_all_tables() to the execution
  branch which doesn't involve 'process_table()'
  when no table/view was opened.
sql/sql_show.cc:
  Do not try to access underlying table fields
  when opening of a view failed. The underlying
  table is closed in that case, and accessing
  its fields may lead to dereferencing a damaged 
  pointer.
This commit is contained in:
Konstantin Osipov
2010-10-14 20:56:56 +04:00
parent 5a57a45c66
commit 248625d910
4 changed files with 124 additions and 8 deletions

View File

@@ -4934,18 +4934,29 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables,
else
table->field[4]->store(STRING_WITH_LEN("NONE"), cs);
if (table->pos_in_table_list->table_open_method &
OPEN_FULL_TABLE)
/*
Only try to fill in the information about view updatability
if it is requested as part of the top-level query (i.e.
it's select * from i_s.views, as opposed to, say, select
security_type from i_s.views). Do not try to access the
underlying tables if there was an error when opening the
view: all underlying tables are released back to the table
definition cache on error inside open_normal_and_derived_tables().
If a field is not assigned explicitly, it defaults to NULL.
*/
if (res == FALSE &&
table->pos_in_table_list->table_open_method & OPEN_FULL_TABLE)
{
updatable_view= 0;
if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE)
{
/*
We should use tables->view->select_lex.item_list here and
can not use Field_iterator_view because the view always uses
temporary algorithm during opening for I_S and
TABLE_LIST fields 'field_translation' & 'field_translation_end'
are uninitialized is this case.
We should use tables->view->select_lex.item_list here
and can not use Field_iterator_view because the view
always uses temporary algorithm during opening for I_S
and TABLE_LIST fields 'field_translation'
& 'field_translation_end' are uninitialized is this
case.
*/
List<Item> *fields= &tables->view->select_lex.item_list;
List_iterator<Item> it(*fields);