--- mysql-5.1-5.1.49_old/sql/sql_prepare.cc 2011-05-23 10:27:56.000000000 +0200 +++ mysql-5.1-5.1.49/sql/sql_prepare.cc 2011-05-23 12:08:27.000000000 +0200 @@ -264,7 +264,9 @@ Protocol::SEND_EOF); } /* Flag that a response has already been sent */ - thd->main_da.disable_status(); + if (!error) + thd->main_da.disable_status(); + DBUG_RETURN(error); } #else @@ -836,7 +838,7 @@ type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ @@ -2358,12 +2360,14 @@ { sl->where= sl->prep_where->copy_andor_structure(thd); sl->where->cleanup(); - } + } else + sl->where= NULL; if (sl->prep_having) { sl->having= sl->prep_having->copy_andor_structure(thd); sl->having->cleanup(); - } + } else + sl->having= NULL; DBUG_ASSERT(sl->join == 0); ORDER *order; /* Fix GROUP list */ @@ -3265,6 +3269,13 @@ if (set_parameters(expanded_query, packet, packet_end)) return TRUE; + /* Check if we got an error when sending long data */ + if (state == Query_arena::ERROR) + { + my_message(last_errno, last_error, MYF(0)); + return TRUE; + } + reexecute: reprepare_observer.reset_reprepare_observer(); @@ -3502,12 +3513,6 @@ status_var_increment(thd->status_var.com_stmt_execute); - /* Check if we got an error when sending long data */ - if (state == Query_arena::ERROR) - { - my_message(last_errno, last_error, MYF(0)); - return TRUE; - } if (flags & (uint) IS_IN_USE) { my_error(ER_PS_NO_RECURSION, MYF(0));