diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index a7d28407385..b188a6ed57d 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -484,6 +484,12 @@ set p = p+2; end; end while; end; +call ip(200); +select * from primes where i=45 or i=100 or i=199; +i p +45 211 +100 557 +199 1229 drop table primes; drop procedure opp; drop procedure ip; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index bcde9e5102c..0d6a84fa63b 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -564,11 +564,10 @@ end| # This isn't the fastest way in the world to compute prime numbers, so # don't be too ambition. ;-) -#QQ Something broke after the last merge. :-( /2003-03-19 -#QQ call ip(200)| +call ip(200)| # We don't want to select the entire table here, just pick a few # examples. -#QQ select * from primes where i=45 or i=100 or i=199| +select * from primes where i=45 or i=100 or i=199| drop table primes| drop procedure opp| drop procedure ip| diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 58ea7a7a873..0a232ea5b4a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -50,10 +50,15 @@ sp_map_result_type(enum enum_field_types type) static Item * eval_func_item(THD *thd, Item *it, enum enum_field_types type) { + DBUG_ENTER("eval_func_item"); it= it->this_item(); + DBUG_PRINT("info", ("type: %d", type)); if (it->fix_fields(thd, 0, NULL)) - return it; // Shouldn't happen? + { + DBUG_PRINT("info", ("fix_fields() failed")); + DBUG_RETURN(it); // Shouldn't happen? + } /* QQ How do we do this? Is there some better way? */ if (type == MYSQL_TYPE_NULL) @@ -62,9 +67,11 @@ eval_func_item(THD *thd, Item *it, enum enum_field_types type) { switch (sp_map_result_type(type)) { case INT_RESULT: + DBUG_PRINT("info", ("INT_RESULT: %d", it->val_int())); it= new Item_int(it->val_int()); break; case REAL_RESULT: + DBUG_PRINT("info", ("REAL_RESULT: %g", it->val())); it= new Item_real(it->val()); break; default: @@ -73,6 +80,7 @@ eval_func_item(THD *thd, Item *it, enum enum_field_types type) String tmp(buffer, sizeof(buffer), it->charset()); String *s= it->val_str(&tmp); + DBUG_PRINT("info", ("default result: %*s", s->length(), s->c_ptr_quick())) it= new Item_string(sql_strmake(s->c_ptr_quick(), s->length()), s->length(), it->charset()); break; @@ -80,7 +88,7 @@ eval_func_item(THD *thd, Item *it, enum enum_field_types type) } } - return it; + DBUG_RETURN(it); } sp_head::sp_head(LEX_STRING *name, LEX *lex) @@ -209,7 +217,7 @@ sp_head::execute_procedure(THD *thd, List *args) else { if (pvar->mode == sp_param_out) - nctx->push_item(it->this_item()); // OUT + nctx->push_item(NULL); // OUT else nctx->push_item(eval_func_item(thd, it, pvar->type)); // IN or INOUT // Note: If it's OUT or INOUT, it must be a variable. diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 9cf7a45b46b..9d22c6be62b 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -65,10 +65,14 @@ sp_pcontext::find_pvar(LEX_STRING *name) while (i-- > 0) { + uint len= m_pvar[i].name->const_string()->length(); + + if (name->length > len) + len= name->length; if (my_strncasecmp(system_charset_info, name->str, m_pvar[i].name->const_string()->ptr(), - name->length) == 0) + len) == 0) { return m_pvar + i; }