Commit ba58eaf0 authored by unknown's avatar unknown

Auto merge

parents aa4b8939 760efb51
......@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
PROJECT(MySql)
......
......@@ -17,15 +17,6 @@
#define BIG_TABLES
#ifdef __WIN2000__
/* We have to do this define before including windows.h to get the AWE API
functions */
#define _WIN32_WINNT 0x0500
#else
/* Get NT 4.0 functions */
#define _WIN32_WINNT 0x0400
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
......
......@@ -2141,4 +2141,24 @@ SELECT * FROM m1;
c1
DROP TABLE m1;
DROP TABLE t1;
#
# Bug45781 infinite hang/crash in "opening tables" after handler tries to
# open merge table
#
DROP TABLE IF EXISTS m1,t1;
CREATE TABLE t1(a int)engine=myisam;
CREATE TABLE t2(a int)engine=myisam;
CREATE TABLE t3(a int)engine=myisam;
CREATE TABLE t4(a int)engine=myisam;
CREATE TABLE t5(a int)engine=myisam;
CREATE TABLE t6(a int)engine=myisam;
CREATE TABLE t7(a int)engine=myisam;
CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7);
SELECT 1 FROM m1;
1
HANDLER m1 OPEN;
ERROR HY000: Table storage engine for 'm1' doesn't have this option
DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7;
SELECT 1 FROM m1;
ERROR 42S02: Table 'test.m1' doesn't exist
End of 5.1 tests
......@@ -1555,4 +1555,28 @@ SELECT * FROM m1;
DROP TABLE m1;
DROP TABLE t1;
--echo #
--echo # Bug45781 infinite hang/crash in "opening tables" after handler tries to
--echo # open merge table
--echo #
--disable_warnings
DROP TABLE IF EXISTS m1,t1;
--enable_warnings
CREATE TABLE t1(a int)engine=myisam;
CREATE TABLE t2(a int)engine=myisam;
CREATE TABLE t3(a int)engine=myisam;
CREATE TABLE t4(a int)engine=myisam;
CREATE TABLE t5(a int)engine=myisam;
CREATE TABLE t6(a int)engine=myisam;
CREATE TABLE t7(a int)engine=myisam;
CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7);
SELECT 1 FROM m1;
--error ER_ILLEGAL_HA
HANDLER m1 OPEN;
DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7;
--error ER_NO_SUCH_TABLE
SELECT 1 FROM m1; # Should not hang!
--echo End of 5.1 tests
......@@ -7375,6 +7375,12 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
/* make * substituting permanent */
SELECT_LEX *select_lex= thd->lex->current_select;
select_lex->with_wild= 0;
/*
The assignment below is translated to memcpy() call (at least on some
platforms). memcpy() expects that source and destination areas do not
overlap. That problem was detected by valgrind.
*/
if (&select_lex->item_list != &fields)
select_lex->item_list= fields;
thd->restore_active_arena(arena, &backup);
......
......@@ -252,14 +252,37 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* for now HANDLER can be used only for real TABLES */
tables->required_type= FRMTYPE_TABLE;
/*
We use open_tables() here, rather than, say,
open_ltable() or open_table() because we would like to be able
to open a temporary table.
*/
error= open_tables(thd, &tables, &counter, 0);
/* restore the state and merge the opened table into handler_tables list */
if (thd->open_tables)
{
if (thd->open_tables->next)
{
/*
We opened something that is more than a single table.
This happens with MERGE engine. Don't try to link
this mess into thd->handler_tables list, close it
and report an error. We must do it right away
because mysql_ha_close_table(), called down the road,
can close a single table only.
*/
close_thread_tables(thd);
my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
error= 1;
}
else
{
/* Merge the opened table into handler_tables list. */
thd->open_tables->next= thd->handler_tables;
thd->handler_tables= thd->open_tables;
}
}
/* Restore the state. */
thd->open_tables= backup_open_tables;
if (error)
......
......@@ -1807,6 +1807,7 @@ JOIN::exec()
curr_join->having= curr_join->tmp_having= 0; // Allready done
/* Change sum_fields reference to calculated fields in tmp_table */
if (curr_join != this)
curr_join->all_fields= *curr_all_fields;
if (!items1)
{
......@@ -1826,8 +1827,11 @@ JOIN::exec()
fields_list.elements, all_fields))
DBUG_VOID_RETURN;
}
if (curr_join != this)
{
curr_join->tmp_all_fields1= tmp_all_fields1;
curr_join->tmp_fields_list1= tmp_fields_list1;
}
curr_join->items1= items1;
}
curr_all_fields= &tmp_all_fields1;
......@@ -1975,9 +1979,12 @@ JOIN::exec()
tmp_fields_list2, tmp_all_fields2,
fields_list.elements, tmp_all_fields1))
DBUG_VOID_RETURN;
if (curr_join != this)
{
curr_join->tmp_fields_list2= tmp_fields_list2;
curr_join->tmp_all_fields2= tmp_all_fields2;
}
}
curr_fields_list= &curr_join->tmp_fields_list2;
curr_all_fields= &curr_join->tmp_all_fields2;
curr_join->set_items_ref_array(items2);
......@@ -2031,9 +2038,12 @@ JOIN::exec()
tmp_table_param.save_copy_field= curr_join->tmp_table_param.copy_field;
tmp_table_param.save_copy_field_end=
curr_join->tmp_table_param.copy_field_end;
if (curr_join != this)
{
curr_join->tmp_all_fields3= tmp_all_fields3;
curr_join->tmp_fields_list3= tmp_fields_list3;
}
}
else
{
curr_join->tmp_table_param.copy_funcs= tmp_table_param.save_copy_funcs;
......
......@@ -466,6 +466,7 @@ public:
group_optimized_away= 0;
all_fields= fields_arg;
if (&fields_list != &fields_arg) /* Avoid valgrind-warning */
fields_list= fields_arg;
bzero((char*) &keyuse,sizeof(keyuse));
tmp_table_param.init();
......
......@@ -47,6 +47,12 @@
#include <myisam.h>
#include <myisammrg.h>
/* this is to get the bison compilation windows warnings out */
#ifdef _MSC_VER
/* warning C4065: switch statement contains 'default' but no 'case' labels */
#pragma warning (disable : 4065)
#endif
int yylex(void *yylval, void *yythd);
const LEX_STRING null_lex_str= {0,0};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment