Skip to content

Commit d92bb0c

Browse files
committed
Bug#20030284 - HANDLE_FATAL_SIGNAL (SIG=11) IN NAME_HASH_SEARCH
Follow up patch to backport patch committed in 5.8 to 5.7.
1 parent f537206 commit d92bb0c

File tree

4 files changed

+36
-48
lines changed

4 files changed

+36
-48
lines changed

sql/sql_base.cc

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,11 @@ void close_thread_tables(THD *thd)
15961596
for (table= thd->derived_tables ; table ; table= next)
15971597
{
15981598
next= table->next;
1599+
1600+
// Restore original name of materialized table
1601+
if (!table->pos_in_table_list->schema_table)
1602+
table->pos_in_table_list->reset_name_temporary();
1603+
15991604
free_tmp_table(thd, table);
16001605
}
16011606
thd->derived_tables= 0;
@@ -4804,25 +4809,6 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
48044809
if (tables->is_derived())
48054810
goto end;
48064811

4807-
if (tables->is_view())
4808-
{
4809-
/*
4810-
We restore view's name and database possibly wiped out by derived tables
4811-
processing and fall back to standard open process in order to
4812-
obtain proper metadata locks and do other necessary steps like
4813-
stored routine processing.
4814-
*/
4815-
if (tables->db != tables->view_db.str)
4816-
{
4817-
tables->db= tables->view_db.str;
4818-
tables->db_length= tables->view_db.length;
4819-
}
4820-
if (tables->table_name != tables->view_name.str)
4821-
{
4822-
tables->table_name= tables->view_name.str;
4823-
tables->table_name_length= tables->view_name.length;
4824-
}
4825-
}
48264812
/*
48274813
If this TABLE_LIST object is a placeholder for an information_schema
48284814
table, create a temporary table to represent the information_schema

sql/sql_derived.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,10 @@ bool TABLE_LIST::setup_materialized_derived(THD *thd)
126126
DBUG_RETURN(true); /* purecov: inspected */
127127

128128
table= derived_result->table;
129-
130-
table_name= table->s->table_name.str;
131-
table_name_length= table->s->table_name.length;
132-
133129
table->pos_in_table_list= this;
134130

135-
// Erasing the database name is needed for alignment with temp. table
136-
db= (char *)"";
137-
db_length= 0;
131+
// Make table's name same as the underlying materialized table
132+
set_name_temporary();
138133

139134
table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
140135
#ifndef NO_EMBEDDED_ACCESS_CHECKS

sql/table.cc

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6456,28 +6456,11 @@ void TABLE_LIST::reinit_before_use(THD *thd)
64566456
table= 0;
64576457

64586458
/*
6459-
Reset table_name and table_name_length,if it is a anonymous derived table
6460-
or schema table. They are not valid as TABLEs were closed in the end of
6461-
previous prepare or execute call. For derived table of view, restore view's
6462-
name and database wiped out by derived table processing.
6463-
6464-
*/
6465-
if (is_view_or_derived())
6466-
{
6467-
if (is_view())
6468-
{
6469-
db= view_db.str;
6470-
db_length= view_db.length;
6471-
table_name= view_name.str;
6472-
table_name_length= view_name.length;
6473-
}
6474-
else
6475-
{
6476-
table_name= NULL;
6477-
table_name_length= 0;
6478-
}
6479-
}
6480-
else if (schema_table_name)
6459+
Reset table_name and table_name_length for schema table.
6460+
They are not valid as TABLEs were closed in the end of previous prepare
6461+
or execute call.
6462+
*/
6463+
if (schema_table_name)
64816464
{
64826465
table_name= schema_table_name;
64836466
table_name_length= strlen(schema_table_name);

sql/table.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,30 @@ struct TABLE_LIST
19121912
return derived;
19131913
}
19141914

1915+
/// Set temporary name from underlying temporary table:
1916+
void set_name_temporary()
1917+
{
1918+
DBUG_ASSERT(is_view_or_derived() && uses_materialization());
1919+
table_name= table->s->table_name.str;
1920+
table_name_length= table->s->table_name.length;
1921+
db= (char *)"";
1922+
db_length= 0;
1923+
}
1924+
1925+
/// Reset original name for temporary table.
1926+
void reset_name_temporary()
1927+
{
1928+
DBUG_ASSERT(is_view_or_derived() && uses_materialization());
1929+
DBUG_ASSERT(db != view_db.str && table_name != view_name.str);
1930+
if (is_view())
1931+
{
1932+
db= view_db.str;
1933+
db_length= view_db.length;
1934+
}
1935+
table_name= view_name.str;
1936+
table_name_length= view_name.length;
1937+
}
1938+
19151939
/// Resolve a derived table or view reference
19161940
bool resolve_derived(THD *thd, bool apply_semijoin);
19171941

0 commit comments

Comments
 (0)