diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 57d5d2939e1..5bd94f0ca7f 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3267,12 +3267,6 @@ drop procedure bug8762| # # BUG#5240: Stored procedure crash if function has cursor declaration # -# The following test case fails in --ps-protocol mode due to some bugs -# in algorithm which calculates list of tables to be locked for queries -# using Stored Functions. It is disabled until Dmitri fixes this. -# ---disable_ps_protocol - --disable_warnings drop function if exists bug5240| --enable_warnings @@ -3292,8 +3286,6 @@ insert into t1 values ("answer", 42)| select id, bug5240() from t1| drop function bug5240| ---enable_ps_protocol - # # BUG#5278: Stored procedure packets out of order if SET PASSWORD. # diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 07c0ce2b6e3..7a72b78b6f4 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -601,7 +601,7 @@ void Item_exists_subselect::fix_length_and_dec() max_length= 1; max_columns= engine->cols(); /* We need only 1 row to determine existence */ - unit->global_parameters->select_limit= new Item_int(1); + unit->global_parameters->select_limit= new Item_int((int32) 1); } double Item_exists_subselect::val_real() diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index c5753a7f114..fa42bdb25b1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -340,6 +340,8 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define UNCACHEABLE_SIDEEFFECT 4 // forcing to save JOIN for explain #define UNCACHEABLE_EXPLAIN 8 +/* Don't evaluate subqueries in prepare even if they're not correlated */ +#define UNCACHEABLE_PREPARE 16 #ifdef EXTRA_DEBUG /* diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2a168e079ff..3344abfbb2d 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1760,6 +1760,7 @@ void st_select_lex_unit::set_limit(SELECT_LEX *sl) { ulonglong select_limit_val; + DBUG_ASSERT(! thd->current_arena->is_stmt_prepare()); select_limit_val= sl->select_limit ? sl->select_limit->val_uint() : HA_POS_ERROR; offset_limit_cnt= sl->offset_limit ? sl->offset_limit->val_uint() : ULL(0); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 521581bb07a..9aa17077a80 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -304,6 +304,7 @@ public: UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT UNCACHEABLE_EXPLAIN + UNCACHEABLE_PREPARE */ uint8 uncacheable; enum sub_select_type linkage; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b76524521af..2b8b1035498 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5173,26 +5173,28 @@ bool mysql_new_select(LEX *lex, bool move_down) { SELECT_LEX *select_lex; - THD *thd; + THD *thd= lex->thd; DBUG_ENTER("mysql_new_select"); - if (!(select_lex= new(lex->thd->mem_root) SELECT_LEX())) + if (!(select_lex= new (thd->mem_root) SELECT_LEX())) DBUG_RETURN(1); - select_lex->select_number= ++lex->thd->select_number; + select_lex->select_number= ++thd->select_number; select_lex->init_query(); select_lex->init_select(); select_lex->parent_lex= lex; + if (thd->current_arena->is_stmt_prepare()) + select_lex->uncacheable|= UNCACHEABLE_PREPARE; if (move_down) { SELECT_LEX_UNIT *unit; lex->subqueries= TRUE; /* first select_lex of subselect or derived table */ - if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT())) + if (!(unit= new (thd->mem_root) SELECT_LEX_UNIT())) DBUG_RETURN(1); unit->init_query(); unit->init_select(); - unit->thd= lex->thd; + unit->thd= thd; unit->include_down(lex->current_select); unit->link_next= 0; unit->link_prev= 0; @@ -5216,7 +5218,7 @@ mysql_new_select(LEX *lex, bool move_down) as far as we included SELECT_LEX for UNION unit should have fake SELECT_LEX for UNION processing */ - if (!(fake= unit->fake_select_lex= new(lex->thd->mem_root) SELECT_LEX())) + if (!(fake= unit->fake_select_lex= new (thd->mem_root) SELECT_LEX())) DBUG_RETURN(1); fake->include_standalone(unit, (SELECT_LEX_NODE**)&unit->fake_select_lex); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1521b206e0d..4440e542434 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1838,7 +1838,10 @@ void init_stmt_after_parse(THD *thd, LEX *lex) optimisation. */ for (; sl; sl= sl->next_select_in_list()) + { sl->prep_where= sl->where; + sl->uncacheable&= ~UNCACHEABLE_PREPARE; + } for (TABLE_LIST *table= lex->query_tables; table; table= table->next_global) table->prep_on_expr= table->on_expr; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c3efc34dae5..9f6b93f0a96 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7985,7 +7985,7 @@ handler: LEX *lex=Lex; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ - lex->current_select->select_limit= new Item_int(1); + lex->current_select->select_limit= new Item_int((int32) 1); lex->current_select->offset_limit= 0; if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0)) YYABORT; diff --git a/storage/ndb/src/common/mgmcommon/IPCConfig.cpp b/storage/ndb/src/common/mgmcommon/IPCConfig.cpp index f188a433f1b..f45bc6ead54 100644 --- a/storage/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/storage/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -188,7 +188,7 @@ IPCConfig::configureTransporters(Uint32 nodeId, if(iter.get(CFG_NODE_HOST, &hostname)) continue; if( strlen(hostname) == 0 ) continue; if(iter.get(CFG_MGM_PORT, &port)) continue; - connect_string.appfmt("%s%s:port",separator,hostname,port); + connect_string.appfmt("%s%s:%u",separator,hostname,port); separator= ","; } NdbMgmHandle h= ndb_mgm_create_handle();