mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge branch 'mysql/5.5' into 5.5
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2015 Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2000, 2016 Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2016 MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -23128,32 +23128,52 @@ static void print_join(THD *thd,
|
||||
/* List is reversed => we should reverse it before using */
|
||||
List_iterator_fast<TABLE_LIST> ti(*tables);
|
||||
TABLE_LIST **table;
|
||||
uint non_const_tables= 0;
|
||||
|
||||
/*
|
||||
If the QT_NO_DATA_EXPANSION flag is specified, we print the
|
||||
original table list, including constant tables that have been
|
||||
optimized away, as the constant tables may be referenced in the
|
||||
expression printed by Item_field::print() when this flag is given.
|
||||
Otherwise, only non-const tables are printed.
|
||||
|
||||
Example:
|
||||
|
||||
Original SQL:
|
||||
select * from (select 1) t
|
||||
|
||||
Printed without QT_NO_DATA_EXPANSION:
|
||||
select '1' AS `1` from dual
|
||||
|
||||
Printed with QT_NO_DATA_EXPANSION:
|
||||
select `t`.`1` from (select 1 AS `1`) `t`
|
||||
*/
|
||||
const bool print_const_tables= (query_type & QT_NO_DATA_EXPANSION);
|
||||
size_t tables_to_print= 0;
|
||||
|
||||
for (TABLE_LIST *t= ti++; t ; t= ti++)
|
||||
{
|
||||
/*
|
||||
See comment in print_table_array() about the second part of the
|
||||
condition
|
||||
*/
|
||||
if (!t->optimized_away && !is_eliminated_table(eliminated_tables, t))
|
||||
non_const_tables++;
|
||||
/* See comment in print_table_array() about the second condition */
|
||||
if (print_const_tables || !t->optimized_away)
|
||||
if (!is_eliminated_table(eliminated_tables, t))
|
||||
tables_to_print++;
|
||||
}
|
||||
if (!non_const_tables)
|
||||
if (tables_to_print == 0)
|
||||
{
|
||||
str->append(STRING_WITH_LEN("dual"));
|
||||
return; // all tables were optimized away
|
||||
}
|
||||
ti.rewind();
|
||||
|
||||
if (!(table= (TABLE_LIST **)thd->alloc(sizeof(TABLE_LIST*) *
|
||||
non_const_tables)))
|
||||
if (!(table= static_cast<TABLE_LIST **>(thd->alloc(sizeof(TABLE_LIST*) *
|
||||
tables_to_print))))
|
||||
return; // out of memory
|
||||
|
||||
TABLE_LIST *tmp, **t= table + (non_const_tables - 1);
|
||||
TABLE_LIST *tmp, **t= table + (tables_to_print - 1);
|
||||
while ((tmp= ti++))
|
||||
{
|
||||
if (tmp->optimized_away || is_eliminated_table(eliminated_tables, tmp))
|
||||
if (tmp->optimized_away && !print_const_tables)
|
||||
continue;
|
||||
if (is_eliminated_table(eliminated_tables, tmp))
|
||||
continue;
|
||||
*t--= tmp;
|
||||
}
|
||||
@ -23173,7 +23193,7 @@ static void print_join(THD *thd,
|
||||
*/
|
||||
if ((*table)->sj_inner_tables)
|
||||
{
|
||||
TABLE_LIST **end= table + non_const_tables;
|
||||
TABLE_LIST **end= table + tables_to_print;
|
||||
for (TABLE_LIST **t2= table; t2!=end; t2++)
|
||||
{
|
||||
if (!(*t2)->sj_inner_tables)
|
||||
@ -23186,7 +23206,7 @@ static void print_join(THD *thd,
|
||||
}
|
||||
}
|
||||
print_table_array(thd, eliminated_tables, str, table,
|
||||
table + non_const_tables, query_type);
|
||||
table + tables_to_print, query_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user