Loading mysql-test/r/select.result +17 −0 Original line number Diff line number Diff line Loading @@ -2682,3 +2682,20 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); INSERT INTO t2 VALUES (2), (4), (6); SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; a 2 4 EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where DROP TABLE t1,t2; mysql-test/t/select.test +16 −0 Original line number Diff line number Diff line Loading @@ -2255,3 +2255,19 @@ AND FK_firma_id = 2; drop table t1; # # Test for bug #10084: STRAIGHT_JOIN with ON expression # CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); INSERT INTO t2 VALUES (2), (4), (6); SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; DROP TABLE t1,t2; sql/mysql_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -844,7 +844,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length); void mysql_stmt_free(THD *thd, char *packet); void mysql_stmt_reset(THD *thd, char *packet); void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length); void reset_stmt_for_execute(THD *thd, LEX *lex); void reinit_stmt_before_use(THD *thd, LEX *lex); void init_stmt_after_parse(THD*, LEX*); /* sql_handler.cc */ Loading sql/sp_head.cc +1 −1 Original line number Diff line number Diff line Loading @@ -1355,7 +1355,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, implemented at the same time as ability not to store LEX for instruction if it is not really used. */ reset_stmt_for_execute(thd, m_lex); reinit_stmt_before_use(thd, m_lex); /* If requested check whenever we have access to tables in LEX's table list Loading sql/sql_prepare.cc +34 −24 Original line number Diff line number Diff line Loading @@ -1656,6 +1656,17 @@ static bool init_param_array(Prepared_statement *stmt) return FALSE; } /* Cleanup PS after execute/prepare and restore THD state */ static void cleanup_stmt_and_thd_after_use(Statement *stmt, THD *thd) { stmt->lex->unit.cleanup(); cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); thd->cleanup_after_query(); } /* Given a query string with parameter markers, create a Prepared Statement from it and send PS info back to the client. Loading Loading @@ -1760,12 +1771,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, thd->lex->sphead= NULL; } lex_end(lex); lex->unit.cleanup(); close_thread_tables(thd); cleanup_stmt_and_thd_after_use(stmt, thd); thd->restore_backup_statement(stmt, &thd->stmt_backup); cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); thd->cleanup_after_query(); thd->current_arena= thd; if (error) Loading Loading @@ -1808,10 +1816,10 @@ void init_stmt_after_parse(THD *thd, LEX *lex) /* Reinit prepared statement/stored procedure before execution */ void reset_stmt_for_execute(THD *thd, LEX *lex) void reinit_stmt_before_use(THD *thd, LEX *lex) { SELECT_LEX *sl= lex->all_selects_list; DBUG_ENTER("reset_stmt_for_execute"); DBUG_ENTER("reinit_stmt_before_use"); if (lex->empty_field_list_on_rset) { Loading Loading @@ -2007,7 +2015,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) thd->stmt_backup.set_statement(thd); thd->set_statement(stmt); thd->current_arena= stmt; reset_stmt_for_execute(thd, stmt->lex); reinit_stmt_before_use(thd, stmt->lex); /* From now cursors assume that thd->mem_root is clean */ if (expanded_query.length() && alloc_query(thd, (char *)expanded_query.ptr(), Loading @@ -2031,17 +2039,18 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) if (cursor && cursor->is_open()) { /* It's safer if we grab THD state after mysql_execute_command is finished and not in Cursor::open(), because currently the call to Cursor::open is buried deep in JOIN::exec of the top level join. */ cursor->init_from_thd(thd); cursor->state= stmt->state; } else { thd->lex->unit.cleanup(); cleanup_items(stmt->free_list); close_thread_tables(thd); cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); close_thread_tables(thd); /* to close derived tables */ thd->rollback_item_tree_changes(); thd->cleanup_after_query(); } thd->set_statement(&thd->stmt_backup); Loading Loading @@ -2119,7 +2128,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, { DBUG_ENTER("execute_stmt"); reset_stmt_for_execute(thd, stmt->lex); reinit_stmt_before_use(thd, stmt->lex); if (expanded_query->length() && alloc_query(thd, (char *)expanded_query->ptr(), Loading @@ -2141,14 +2150,11 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); thd->lex->unit.cleanup(); thd->current_arena= thd; cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); reset_stmt_params(stmt); close_thread_tables(thd); // to close derived tables cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); thd->set_statement(&thd->stmt_backup); thd->cleanup_after_query(); thd->current_arena= thd; if (stmt->state == Item_arena::PREPARED) stmt->state= Item_arena::EXECUTED; Loading @@ -2171,7 +2177,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) /* assume there is always place for 8-16 bytes */ ulong stmt_id= uint4korr(packet); ulong num_rows= uint4korr(packet+4); Statement *stmt; Prepared_statement *stmt; DBUG_ENTER("mysql_stmt_fetch"); if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch"))) Loading @@ -2185,7 +2191,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) thd->current_arena= stmt; thd->set_n_backup_statement(stmt, &thd->stmt_backup); stmt->cursor->init_thd(thd); if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), QUERY_PRIOR); Loading @@ -2197,11 +2202,16 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); /* Restore THD state */ stmt->cursor->reset_thd(thd); thd->restore_backup_statement(stmt, &thd->stmt_backup); thd->current_arena= thd; if (!stmt->cursor->is_open()) { /* We're done with the fetch: reset PS for next execution */ cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); } DBUG_VOID_RETURN; } Loading Loading
mysql-test/r/select.result +17 −0 Original line number Diff line number Diff line Loading @@ -2682,3 +2682,20 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); INSERT INTO t2 VALUES (2), (4), (6); SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; a 2 4 EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where DROP TABLE t1,t2;
mysql-test/t/select.test +16 −0 Original line number Diff line number Diff line Loading @@ -2255,3 +2255,19 @@ AND FK_firma_id = 2; drop table t1; # # Test for bug #10084: STRAIGHT_JOIN with ON expression # CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); INSERT INTO t2 VALUES (2), (4), (6); SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; DROP TABLE t1,t2;
sql/mysql_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -844,7 +844,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length); void mysql_stmt_free(THD *thd, char *packet); void mysql_stmt_reset(THD *thd, char *packet); void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length); void reset_stmt_for_execute(THD *thd, LEX *lex); void reinit_stmt_before_use(THD *thd, LEX *lex); void init_stmt_after_parse(THD*, LEX*); /* sql_handler.cc */ Loading
sql/sp_head.cc +1 −1 Original line number Diff line number Diff line Loading @@ -1355,7 +1355,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, implemented at the same time as ability not to store LEX for instruction if it is not really used. */ reset_stmt_for_execute(thd, m_lex); reinit_stmt_before_use(thd, m_lex); /* If requested check whenever we have access to tables in LEX's table list Loading
sql/sql_prepare.cc +34 −24 Original line number Diff line number Diff line Loading @@ -1656,6 +1656,17 @@ static bool init_param_array(Prepared_statement *stmt) return FALSE; } /* Cleanup PS after execute/prepare and restore THD state */ static void cleanup_stmt_and_thd_after_use(Statement *stmt, THD *thd) { stmt->lex->unit.cleanup(); cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); thd->cleanup_after_query(); } /* Given a query string with parameter markers, create a Prepared Statement from it and send PS info back to the client. Loading Loading @@ -1760,12 +1771,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, thd->lex->sphead= NULL; } lex_end(lex); lex->unit.cleanup(); close_thread_tables(thd); cleanup_stmt_and_thd_after_use(stmt, thd); thd->restore_backup_statement(stmt, &thd->stmt_backup); cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); thd->cleanup_after_query(); thd->current_arena= thd; if (error) Loading Loading @@ -1808,10 +1816,10 @@ void init_stmt_after_parse(THD *thd, LEX *lex) /* Reinit prepared statement/stored procedure before execution */ void reset_stmt_for_execute(THD *thd, LEX *lex) void reinit_stmt_before_use(THD *thd, LEX *lex) { SELECT_LEX *sl= lex->all_selects_list; DBUG_ENTER("reset_stmt_for_execute"); DBUG_ENTER("reinit_stmt_before_use"); if (lex->empty_field_list_on_rset) { Loading Loading @@ -2007,7 +2015,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) thd->stmt_backup.set_statement(thd); thd->set_statement(stmt); thd->current_arena= stmt; reset_stmt_for_execute(thd, stmt->lex); reinit_stmt_before_use(thd, stmt->lex); /* From now cursors assume that thd->mem_root is clean */ if (expanded_query.length() && alloc_query(thd, (char *)expanded_query.ptr(), Loading @@ -2031,17 +2039,18 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) if (cursor && cursor->is_open()) { /* It's safer if we grab THD state after mysql_execute_command is finished and not in Cursor::open(), because currently the call to Cursor::open is buried deep in JOIN::exec of the top level join. */ cursor->init_from_thd(thd); cursor->state= stmt->state; } else { thd->lex->unit.cleanup(); cleanup_items(stmt->free_list); close_thread_tables(thd); cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); close_thread_tables(thd); /* to close derived tables */ thd->rollback_item_tree_changes(); thd->cleanup_after_query(); } thd->set_statement(&thd->stmt_backup); Loading Loading @@ -2119,7 +2128,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, { DBUG_ENTER("execute_stmt"); reset_stmt_for_execute(thd, stmt->lex); reinit_stmt_before_use(thd, stmt->lex); if (expanded_query->length() && alloc_query(thd, (char *)expanded_query->ptr(), Loading @@ -2141,14 +2150,11 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); thd->lex->unit.cleanup(); thd->current_arena= thd; cleanup_items(stmt->free_list); thd->rollback_item_tree_changes(); reset_stmt_params(stmt); close_thread_tables(thd); // to close derived tables cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); thd->set_statement(&thd->stmt_backup); thd->cleanup_after_query(); thd->current_arena= thd; if (stmt->state == Item_arena::PREPARED) stmt->state= Item_arena::EXECUTED; Loading @@ -2171,7 +2177,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) /* assume there is always place for 8-16 bytes */ ulong stmt_id= uint4korr(packet); ulong num_rows= uint4korr(packet+4); Statement *stmt; Prepared_statement *stmt; DBUG_ENTER("mysql_stmt_fetch"); if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch"))) Loading @@ -2185,7 +2191,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) thd->current_arena= stmt; thd->set_n_backup_statement(stmt, &thd->stmt_backup); stmt->cursor->init_thd(thd); if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), QUERY_PRIOR); Loading @@ -2197,11 +2202,16 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); /* Restore THD state */ stmt->cursor->reset_thd(thd); thd->restore_backup_statement(stmt, &thd->stmt_backup); thd->current_arena= thd; if (!stmt->cursor->is_open()) { /* We're done with the fetch: reset PS for next execution */ cleanup_stmt_and_thd_after_use(stmt, thd); reset_stmt_params(stmt); } DBUG_VOID_RETURN; } Loading