Commit 333b1f85 authored by unknown's avatar unknown
Browse files

Fix for bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema(2nd ver)

  Fill schema tables with data before filesort if it's necessary


mysql-test/r/information_schema.result:
  Fix for bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema(2nd ver)
    test result
mysql-test/t/information_schema.test:
  Fix for bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema(2nd ver)
    test case
parent 74f670f2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1089,3 +1089,11 @@ create table mysqltest.t1(a int);
select table_schema from information_schema.tables where table_schema='mysqltest';
table_schema
drop database mysqltest;
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
from information_schema.columns where
table_schema='information_schema' and
(column_type = 'varchar(7)' or column_type = 'varchar(20)')
group by column_type order by num;
column_type	group_concat(table_schema, '.', table_name)	num
varchar(20)	information_schema.COLUMNS	1
varchar(7)	information_schema.ROUTINES,information_schema.VIEWS	2
+9 −0
Original line number Diff line number Diff line
@@ -800,3 +800,12 @@ create table mysqltest.t1(a int);
select table_schema from information_schema.tables where table_schema='mysqltest';
--exec chmod +r $MYSQL_TEST_DIR/var/master-data/mysqltest
drop database mysqltest;

#
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
#
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
from information_schema.columns where
table_schema='information_schema' and
(column_type = 'varchar(7)' or column_type = 'varchar(20)')
group by column_type order by num;
+2 −0
Original line number Diff line number Diff line
@@ -2111,6 +2111,8 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
      were closed in the end of previous prepare or execute call.
    */
    tables->table= 0;
    /* Reset is_schema_table_processed value(needed for I_S tables */
    tables->is_schema_table_processed= FALSE;

    if (tables->prep_on_expr)
    {
+6 −0
Original line number Diff line number Diff line
@@ -11582,6 +11582,12 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
	goto err;
    }
  }

  /* Fill schema tables with data before filesort if it's necessary */
  if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
      get_schema_tables_result(join))
    goto err;

  if (table->s->tmp_table)
    table->file->info(HA_STATUS_VARIABLE);	// Get record count
  table->sort.found_records=filesort(thd, table,sortorder, length,
+11 −1
Original line number Diff line number Diff line
@@ -3845,7 +3845,16 @@ bool get_schema_tables_result(JOIN *join)
    TABLE_LIST *table_list= tab->table->pos_in_table_list;
    if (table_list->schema_table && thd->fill_derived_tables())
    {
      if (&lex->unit != lex->current_select->master_unit()) // is subselect
      bool is_subselect= (&lex->unit != lex->current_select->master_unit());
      /*
        The schema table is already processed and 
        the statement is not a subselect.
        So we don't need to handle this table again.
      */
      if (table_list->is_schema_table_processed && !is_subselect)
        continue;

      if (is_subselect) // is subselect
      {
        table_list->table->file->extra(HA_EXTRA_RESET_STATE);
        table_list->table->file->delete_all_rows();
@@ -3858,6 +3867,7 @@ bool get_schema_tables_result(JOIN *join)
      if (table_list->schema_table->fill_table(thd, table_list,
                                               tab->select_cond))
        result= 1;
      table_list->is_schema_table_processed= TRUE;
    }
  }
  thd->no_warnings_for_error= 0;
Loading