On 7/1/09 6:01 PM, Kristofer Pettersson wrote:
> #At file:///Users/thek/Development/51-bug44521/ based on
> revid:pstoev@stripped
>
> 2935 Kristofer Pettersson 2009-07-01
> Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent'
> failed et.al.
>
> For discussion.
[..]
> modified:
> sql/sp_head.cc
> sql/sql_parse.cc
> === modified file 'sql/sp_head.cc'
> --- a/sql/sp_head.cc 2009-05-30 13:32:28 +0000
> +++ b/sql/sp_head.cc 2009-07-01 21:01:14 +0000
> @@ -1249,7 +1249,7 @@ sp_head::execute(THD *thd)
> */
> if (thd->prelocked_mode == NON_PRELOCKED)
> thd->user_var_events_alloc= thd->mem_root;
> -
> +
Please ensure that your patches don't have meaningless changes.
> err_status= i->execute(thd,&ip);
>
> if (i->free_list)
> @@ -2865,7 +2865,7 @@ sp_instr_stmt::execute(THD *thd, uint *n
> if (!thd->is_error())
> thd->main_da.reset_diagnostics_area();
> }
> - DBUG_RETURN(res);
> + DBUG_RETURN(res || thd->is_error());
> }
>
>
>
> === modified file 'sql/sql_parse.cc'
> --- a/sql/sql_parse.cc 2009-06-05 11:23:58 +0000
> +++ b/sql/sql_parse.cc 2009-07-01 21:01:14 +0000
> @@ -954,6 +954,7 @@ bool dispatch_command(enum enum_server_c
> char* packet, uint packet_length)
> {
> NET *net=&thd->net;
> + bool eof_has_been_sent= FALSE;
> bool error= 0;
> DBUG_ENTER("dispatch_command");
> DBUG_PRINT("info",("packet: '%*.s'; command: %d", packet_length, packet,
> command));
> @@ -1166,6 +1167,14 @@ bool dispatch_command(enum enum_server_c
> case COM_STMT_EXECUTE:
> {
> mysqld_stmt_execute(thd, packet, packet_length);
> + /*
> + When executing a stored routine a network error may occur
> + (ER_NET_ERROR_ON_WRITE) which causes the diagnositc area
> + to be set. To avoid setting the diagnositc area twice we
> + need to remember this exception.
> + */
> + if (thd->main_da.is_sent)
> + eof_has_been_sent= TRUE;
I tend to think that this sort of defeats the purpose of the DA
controlling and enforcing its own state. If there is a need for
maintaining a state inside and outside of the object, it demonstrates
that the state is not being properly defined.
I tend to think that this is demonstrated in the behavior of
net_end_statement, net_send_error, net_send_eof and net_send_ok, where
the return status of network operations is systematically ignored.
is_sent must only be set if the packets are successfully sent to the client.