5.3-merge

This commit is contained in:
Sergei Golubchik 2014-03-16 19:21:37 +01:00
commit 5d8c15228e
19 changed files with 293 additions and 41 deletions

View File

@ -0,0 +1,13 @@
--source include/not_embedded.inc
if (!$AUTH_SOCKET_SO) {
skip No unix_socket plugin;
}
if (!$USER) {
skip USER variable is undefined;
}
if (`SELECT count(*) <> 0 FROM mysql.user WHERE user = '$USER'`) {
skip \$USER=$USER which exists in mysql.user;
}

View File

@ -2366,6 +2366,46 @@ id select_type table type possible_keys key key_len ref rows Extra
3 DEPENDENT SUBQUERY pi ref gallery_id gallery_id 4 test.gal.id 4 Using temporary; Using filesort 3 DEPENDENT SUBQUERY pi ref gallery_id gallery_id 4 test.gal.id 4 Using temporary; Using filesort
drop table galleries, pictures; drop table galleries, pictures;
# #
# MDEV-5740: Assertion
#`!derived->first_select()->exclude_from_table_unique_test ||
#derived->outer_select()-> exclude_from_table_unique_test'
#failed on 2nd execution of PS with derived_merge
#
set @save_optimizer_switch5740=@@optimizer_switch;
SET optimizer_switch = 'derived_merge=on';
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (3),(4);
PREPARE stmt FROM '
INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM (SELECT * FROM t1) AS sq
';
EXECUTE stmt;
select * from t1;
a
1
2
3
4
1
2
EXECUTE stmt;
select * from t1;
a
1
2
3
4
1
2
3
4
1
2
deallocate prepare stmt;
drop table t1,t2;
set optimizer_switch=@save_optimizer_switch5740;
#
# end of 5.3 tests # end of 5.3 tests
# #
set optimizer_switch=@exit_optimizer_switch; set optimizer_switch=@exit_optimizer_switch;

View File

@ -0,0 +1,12 @@
update mysql.user set plugin='unix_socket';
flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Plugin 'unix_socket' is not loaded
ERROR HY000: Plugin 'unix_socket' is not loaded
install plugin unix_socket soname 'auth_socket.so';
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'USER'@'localhost'
ERROR 28000: Access denied for user 'USER'@'localhost'
update mysql.user set plugin='';
flush privileges;
uninstall plugin unix_socket;

View File

@ -272,6 +272,22 @@ SELECT NAME_CONST('a', -(1)) OR 1;
NAME_CONST('a', -(1)) OR 1 NAME_CONST('a', -(1)) OR 1
1 1
# #
#MDEV-5446: Assertion `!table || (!table->read_set ||
#bitmap_is_set(table->read_set, field_index))' fails on
#EXPLAIN EXTENDED with VALUES function
#
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,10);
CREATE VIEW v1 AS SELECT * FROM t1;
EXPLAIN EXTENDED SELECT VALUES(b) FROM v1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
Note 1003 select values(10) AS `VALUES(b)` from dual
drop view v1;
drop table t1;
End of 5.3 tests
#
# Bug #52165: Assertion failed: file .\dtoa.c, line 465 # Bug #52165: Assertion failed: file .\dtoa.c, line 465
# #
CREATE TABLE t1 (a SET('a'), b INT); CREATE TABLE t1 (a SET('a'), b INT);

View File

@ -2344,6 +2344,28 @@ id a2 a3 id a2 a3
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-5686: degenerate disjunct in NOT IN subquery
#
CREATE TABLE t1 (a int, b int, c varchar(3)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1,'CAN'),(2,2,'AUS');
CREATE TABLE t2 (f int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3);
EXPLAIN EXTENDED
SELECT * FROM t2
WHERE f NOT IN (SELECT b FROM t1
WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select 3 AS `f` from dual where (not(<expr_cache><3>(<in_optimizer>(3,<exists>(select `test`.`t1`.`b` from `test`.`t1` where (((`test`.`t1`.`c` = 'USA') or (`test`.`t1`.`c` <> 'USA')) and trigcond(((<cache>(3) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`))) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) having trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))))
SELECT * FROM t2
WHERE f NOT IN (SELECT b FROM t1
WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b);
f
3
DROP TABLE t1,t2;
#
# MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT # MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT
# #
CREATE TABLE t1 (a INT) ENGINE=MyISAM; CREATE TABLE t1 (a INT) ENGINE=MyISAM;

View File

@ -5002,6 +5002,22 @@ v1_field1
deallocate prepare my_stmt; deallocate prepare my_stmt;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
#
#MDEV-5717: Server crash with insert statement containing DEFAULT into
#view
#
CREATE TABLE t1 (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`test` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1);
INSERT INTO v1 SET test = DEFAULT;
select * from v1;
id test
1 0
drop view v1;
drop table t1;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 5.3 tests. # -- End of 5.3 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------

View File

@ -1,20 +1,4 @@
--source include/not_embedded.inc --source include/have_unix_socket.inc
# If we run this as root, $USER gets authenticated as the `root' user, and we
# get .result differences from CURRENT_USER().
--source include/not_as_root.inc
# The previous check verifies that the user does not have root permissions.
# However in some cases tests are run under a user named 'root',
# even although this user does not have real root permissions.
# This test should be skipped in this case, since it does not expect
# that there are records in mysql.user where user=<username>
if ($USER=="root") {
skip Cannot be run by user named 'root' even if it does not have all privileges;
}
if (!$AUTH_SOCKET_SO) {
skip No auth_socket plugin;
}
if (!$USER) { if (!$USER) {
skip USER variable is undefined; skip USER variable is undefined;

View File

@ -1703,6 +1703,33 @@ ORDER BY gallery_name ASC
drop table galleries, pictures; drop table galleries, pictures;
--echo #
--echo # MDEV-5740: Assertion
--echo #`!derived->first_select()->exclude_from_table_unique_test ||
--echo #derived->outer_select()-> exclude_from_table_unique_test'
--echo #failed on 2nd execution of PS with derived_merge
--echo #
set @save_optimizer_switch5740=@@optimizer_switch;
SET optimizer_switch = 'derived_merge=on';
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (3),(4);
PREPARE stmt FROM '
INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM (SELECT * FROM t1) AS sq
';
EXECUTE stmt;
select * from t1;
EXECUTE stmt;
select * from t1;
deallocate prepare stmt;
drop table t1,t2;
set optimizer_switch=@save_optimizer_switch5740;
--echo # --echo #
--echo # end of 5.3 tests --echo # end of 5.3 tests
--echo # --echo #

View File

@ -0,0 +1,29 @@
--source include/have_unix_socket.inc
#
# MDEV-3909 remote user enumeration
# unix_socket tests
#
update mysql.user set plugin='unix_socket';
flush privileges;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $USER USER
--error ER_PLUGIN_IS_NOT_LOADED
connect (fail,localhost,$USER);
--error ER_PLUGIN_IS_NOT_LOADED
change_user $USER;
eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $USER USER
--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
connect (fail,localhost,$USER);
--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
change_user $USER;
update mysql.user set plugin='';
flush privileges;
uninstall plugin unix_socket;

View File

@ -308,6 +308,22 @@ SELECT NAME_CONST('a', -(1 AND 2)) AND 1;
SELECT NAME_CONST('a', -(1)) OR 1; SELECT NAME_CONST('a', -(1)) OR 1;
--echo # --echo #
--echo #MDEV-5446: Assertion `!table || (!table->read_set ||
--echo #bitmap_is_set(table->read_set, field_index))' fails on
--echo #EXPLAIN EXTENDED with VALUES function
--echo #
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,10);
CREATE VIEW v1 AS SELECT * FROM t1;
EXPLAIN EXTENDED SELECT VALUES(b) FROM v1;
drop view v1;
drop table t1;
--echo End of 5.3 tests
--echo #
--echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465 --echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465
--echo # --echo #
@ -379,4 +395,3 @@ drop table t1,tv;
--echo # --echo #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #

View File

@ -1888,6 +1888,27 @@ ORDER BY v2.id;
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-5686: degenerate disjunct in NOT IN subquery
--echo #
CREATE TABLE t1 (a int, b int, c varchar(3)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1,'CAN'),(2,2,'AUS');
CREATE TABLE t2 (f int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3);
EXPLAIN EXTENDED
SELECT * FROM t2
WHERE f NOT IN (SELECT b FROM t1
WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b);
SELECT * FROM t2
WHERE f NOT IN (SELECT b FROM t1
WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b);
DROP TABLE t1,t2;
--echo # --echo #
--echo # MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT --echo # MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT
--echo # --echo #

View File

@ -4918,6 +4918,25 @@ deallocate prepare my_stmt;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
--echo #
--echo #MDEV-5717: Server crash with insert statement containing DEFAULT into
--echo #view
--echo #
CREATE TABLE t1 (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`test` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1);
INSERT INTO v1 SET test = DEFAULT;
select * from v1;
drop view v1;
drop table t1;
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests. --echo # -- End of 5.3 tests.
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------

View File

@ -8360,6 +8360,8 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
{ {
tmp_field->init(field_arg->field->table); tmp_field->init(field_arg->field->table);
set_field(tmp_field); set_field(tmp_field);
// the index is important when read bits set
tmp_field->field_index= field_arg->field->field_index;
} }
} }
return FALSE; return FALSE;

View File

@ -3857,7 +3857,7 @@ public:
bool walk(Item_processor processor, bool walk_subquery, uchar *args) bool walk(Item_processor processor, bool walk_subquery, uchar *args)
{ {
return arg->walk(processor, walk_subquery, args) || return (arg && arg->walk(processor, walk_subquery, args)) ||
(this->*processor)(args); (this->*processor)(args);
} }

View File

@ -9148,7 +9148,12 @@ bool acl_authenticate(THD *thd, uint connect_errors,
auth_plugin_name= &mpvio.acl_user->plugin; auth_plugin_name= &mpvio.acl_user->plugin;
res= do_auth_once(thd, auth_plugin_name, &mpvio); res= do_auth_once(thd, auth_plugin_name, &mpvio);
} }
if (mpvio.make_it_fail)
{
mpvio.status= MPVIO_EXT::FAILURE;
res= CR_ERROR;
}
Security_context *sctx= thd->security_ctx; Security_context *sctx= thd->security_ctx;
const ACL_USER *acl_user= mpvio.acl_user; const ACL_USER *acl_user= mpvio.acl_user;

View File

@ -1939,6 +1939,17 @@ retry:
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
for (TABLE_LIST *tl= table_list;;) for (TABLE_LIST *tl= table_list;;)
{ {
if (tl &&
tl->select_lex && tl->select_lex->master_unit() &&
tl->select_lex->master_unit()->executed)
{
/*
There is no sense to check tables of already executed parts
of the query
*/
tl= tl->next_global;
continue;
}
/* /*
Table is unique if it is present only once in the global list Table is unique if it is present only once in the global list
of tables and once in the list of table locks. of tables and once in the list of table locks.

View File

@ -68,8 +68,10 @@ mysql_handle_derived(LEX *lex, uint phases)
{ {
bool res= FALSE; bool res= FALSE;
THD *thd= lex->thd; THD *thd= lex->thd;
DBUG_ENTER("mysql_handle_derived");
DBUG_PRINT("enter", ("phases: 0x%x", phases));
if (!lex->derived_tables) if (!lex->derived_tables)
return FALSE; DBUG_RETURN(FALSE);
lex->thd->derived_tables_processing= TRUE; lex->thd->derived_tables_processing= TRUE;
@ -127,7 +129,7 @@ mysql_handle_derived(LEX *lex, uint phases)
} }
} }
lex->thd->derived_tables_processing= FALSE; lex->thd->derived_tables_processing= FALSE;
return res; DBUG_RETURN(res);
} }
/* /*
@ -166,8 +168,10 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
THD *thd= lex->thd; THD *thd= lex->thd;
uint8 allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE : uint8 allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE :
DT_PHASES_MATERIALIZE); DT_PHASES_MATERIALIZE);
DBUG_ENTER("mysql_handle_single_derived");
DBUG_PRINT("enter", ("phases: 0x%x allowed: 0x%x", phases, allowed_phases));
if (!lex->derived_tables) if (!lex->derived_tables)
return FALSE; DBUG_RETURN(FALSE);
lex->thd->derived_tables_processing= TRUE; lex->thd->derived_tables_processing= TRUE;
@ -189,7 +193,7 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
break; break;
} }
lex->thd->derived_tables_processing= FALSE; lex->thd->derived_tables_processing= FALSE;
return res; DBUG_RETURN(res);
} }
@ -354,16 +358,17 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
uint tablenr; uint tablenr;
SELECT_LEX *parent_lex= derived->select_lex; SELECT_LEX *parent_lex= derived->select_lex;
Query_arena *arena, backup; Query_arena *arena, backup;
DBUG_ENTER("mysql_derived_merge");
if (derived->merged) if (derived->merged)
return FALSE; DBUG_RETURN(FALSE);
if (dt_select->uncacheable & UNCACHEABLE_RAND) if (dt_select->uncacheable & UNCACHEABLE_RAND)
{ {
/* There is random function => fall back to materialization. */ /* There is random function => fall back to materialization. */
derived->change_refs_to_fields(); derived->change_refs_to_fields();
derived->set_materialized_derived(); derived->set_materialized_derived();
return FALSE; DBUG_RETURN(FALSE);
} }
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI || if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
@ -467,7 +472,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
exit_merge: exit_merge:
if (arena) if (arena)
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);
return res; DBUG_RETURN(res);
} }
@ -492,14 +497,15 @@ exit_merge:
bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
{ {
DBUG_ENTER("mysql_derived_merge_for_insert");
if (derived->merged_for_insert) if (derived->merged_for_insert)
return FALSE; DBUG_RETURN(FALSE);
if (derived->is_materialized_derived()) if (derived->is_materialized_derived())
return mysql_derived_prepare(thd, lex, derived); DBUG_RETURN(mysql_derived_prepare(thd, lex, derived));
if (!derived->is_multitable()) if (!derived->is_multitable())
{ {
if (!derived->single_table_updatable()) if (!derived->single_table_updatable())
return derived->create_field_translation(thd); DBUG_RETURN(derived->create_field_translation(thd));
if (derived->merge_underlying_list) if (derived->merge_underlying_list)
{ {
derived->table= derived->merge_underlying_list->table; derived->table= derived->merge_underlying_list->table;
@ -507,7 +513,7 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
derived->merged_for_insert= TRUE; derived->merged_for_insert= TRUE;
} }
} }
return FALSE; DBUG_RETURN(FALSE);
} }
@ -761,9 +767,10 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
SELECT_LEX *save_current_select= lex->current_select; SELECT_LEX *save_current_select= lex->current_select;
bool res= FALSE; bool res= FALSE;
DBUG_ENTER("mysql_derived_optimize");
if (unit->optimized) if (unit->optimized)
return FALSE; DBUG_RETURN(FALSE);
lex->current_select= first_select; lex->current_select= first_select;
if (unit->is_union()) if (unit->is_union())
@ -803,7 +810,7 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
} }
err: err:
lex->current_select= save_current_select; lex->current_select= save_current_select;
return res; DBUG_RETURN(res);
} }
@ -825,11 +832,12 @@ err:
bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
{ {
DBUG_ENTER("mysql_derived_create");
TABLE *table= derived->table; TABLE *table= derived->table;
SELECT_LEX_UNIT *unit= derived->get_unit(); SELECT_LEX_UNIT *unit= derived->get_unit();
if (table->created) if (table->created)
return FALSE; DBUG_RETURN(FALSE);
select_union *result= (select_union*)unit->result; select_union *result= (select_union*)unit->result;
if (table->s->db_type() == TMP_ENGINE_HTON) if (table->s->db_type() == TMP_ENGINE_HTON)
{ {
@ -839,13 +847,13 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
&result->tmp_table_param.recinfo, &result->tmp_table_param.recinfo,
(unit->first_select()->options | (unit->first_select()->options |
thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS))) thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS)))
return(TRUE); DBUG_RETURN(TRUE);
} }
if (open_tmp_table(table)) if (open_tmp_table(table))
return TRUE; DBUG_RETURN(TRUE);
table->file->extra(HA_EXTRA_WRITE_CACHE); table->file->extra(HA_EXTRA_WRITE_CACHE);
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
return FALSE; DBUG_RETURN(FALSE);
} }
@ -874,11 +882,12 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
{ {
DBUG_ENTER("mysql_derived_fill");
SELECT_LEX_UNIT *unit= derived->get_unit(); SELECT_LEX_UNIT *unit= derived->get_unit();
bool res= FALSE; bool res= FALSE;
if (unit->executed && !unit->uncacheable && !unit->describe) if (unit->executed && !unit->uncacheable && !unit->describe)
return FALSE; DBUG_RETURN(FALSE);
/*check that table creation passed without problems. */ /*check that table creation passed without problems. */
DBUG_ASSERT(derived->table && derived->table->created); DBUG_ASSERT(derived->table && derived->table->created);
SELECT_LEX *first_select= unit->first_select(); SELECT_LEX *first_select= unit->first_select();
@ -920,7 +929,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
unit->cleanup(); unit->cleanup();
lex->current_select= save_current_select; lex->current_select= save_current_select;
return res; DBUG_RETURN(res);
} }
@ -943,6 +952,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived)
{ {
DBUG_ENTER("mysql_derived_reinit");
st_select_lex_unit *unit= derived->get_unit(); st_select_lex_unit *unit= derived->get_unit();
if (derived->table) if (derived->table)
@ -952,6 +962,6 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived)
/* for derived tables & PS (which can't be reset by Item_subquery) */ /* for derived tables & PS (which can't be reset by Item_subquery) */
unit->reinit_exec_mechanism(); unit->reinit_exec_mechanism();
unit->set_thd(thd); unit->set_thd(thd);
return FALSE; DBUG_RETURN(FALSE);
} }

View File

@ -3605,6 +3605,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
{ {
conds->update_used_tables(); conds->update_used_tables();
conds= remove_eq_conds(join->thd, conds, &join->cond_value); conds= remove_eq_conds(join->thd, conds, &join->cond_value);
if (conds && conds->type() == Item::COND_ITEM &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= &((Item_cond_and*) conds)->cond_equal;
join->select_lex->where= conds; join->select_lex->where= conds;
if (join->cond_value == Item::COND_FALSE) if (join->cond_value == Item::COND_FALSE)
{ {
@ -13594,7 +13597,10 @@ optimize_cond(JOIN *join, COND *conds,
Remove all and-levels where CONST item != CONST item Remove all and-levels where CONST item != CONST item
*/ */
DBUG_EXECUTE("where",print_where(conds,"after const change", QT_ORDINARY);); DBUG_EXECUTE("where",print_where(conds,"after const change", QT_ORDINARY););
conds= remove_eq_conds(thd, conds, cond_value) ; conds= remove_eq_conds(thd, conds, cond_value);
if (conds && conds->type() == Item::COND_ITEM &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= &((Item_cond_and*) conds)->cond_equal;
DBUG_EXECUTE("info",print_where(conds,"after remove", QT_ORDINARY);); DBUG_EXECUTE("info",print_where(conds,"after remove", QT_ORDINARY););
} }
DBUG_RETURN(conds); DBUG_RETURN(conds);

View File

@ -2083,9 +2083,11 @@ struct TABLE_LIST
} }
inline void set_merged_derived() inline void set_merged_derived()
{ {
DBUG_ENTER("set_merged_derived");
derived_type= ((derived_type & DTYPE_MASK) | derived_type= ((derived_type & DTYPE_MASK) |
DTYPE_TABLE | DTYPE_MERGE); DTYPE_TABLE | DTYPE_MERGE);
set_check_merged(); set_check_merged();
DBUG_VOID_RETURN;
} }
inline bool is_materialized_derived() inline bool is_materialized_derived()
{ {
@ -2093,9 +2095,11 @@ struct TABLE_LIST
} }
void set_materialized_derived() void set_materialized_derived()
{ {
DBUG_ENTER("set_materialized_derived");
derived_type= ((derived_type & DTYPE_MASK) | derived_type= ((derived_type & DTYPE_MASK) |
DTYPE_TABLE | DTYPE_MATERIALIZE); DTYPE_TABLE | DTYPE_MATERIALIZE);
set_check_materialized(); set_check_materialized();
DBUG_VOID_RETURN;
} }
inline bool is_multitable() inline bool is_multitable()
{ {