* Alexander Nozdrin <alik@stripped> [08/11/12 14:51]:
> per-file messages:
> include/mysql.h
> Add a new flag into MYSQL structure (flush_all_delete).
> This flag determines if all results should be flushed
> or only the first one:
>
> - if MYSQL::flush_all_delete is TRUE, then
> cli_flush_use_result() will read/flush all pending
> results. I.e. it will read all packets while server
> status attribute indicates that there are more results.
> This is a new semantic, required to fix the bug.
>
> - if MYSQL::flush_all_results is FALSE, the old sematic
> is preserved -- i.e. cli_flush_use_result() reads data
> untile first EOF-packet.
Can't extend MYSQL with more members, this breaks the ABI.
And this is not necessary, see below.
> === modified file 'libmysql/libmysql.c'
> --- a/libmysql/libmysql.c 2008-08-07 17:52:43 +0000
> +++ b/libmysql/libmysql.c 2008-11-12 11:22:58 +0000
> @@ -4692,7 +4692,9 @@ my_bool STDCALL mysql_stmt_close(MYSQL_S
> Flush result set of the connection. If it does not belong
> to this statement, set a warning.
> */
> + mysql->flush_all_results= TRUE;
> (*mysql->methods->flush_use_result)(mysql);
> + mysql->flush_all_results= FALSE;
> if (mysql->unbuffered_fetch_owner)
> *mysql->unbuffered_fetch_owner= TRUE;
> mysql->status= MYSQL_STATUS_READY;
This is the only place where you use this flag.
Why not use an own function instead of the flag?
> + {
> + /* Analyze OK-packet. */
> +
> + uchar *pos= mysql->net.read_pos + 1;
> +
> + net_field_length_ll(&pos); /* affected rows */
> + net_field_length_ll(&pos); /* insert id */
> +
> + mysql->server_status=uint2korr(pos);
> + pos+=2;
> +
> if (protocol_41(mysql))
> {
> - char *pos= (char*) mysql->net.read_pos + 1;
> - mysql->warning_count=uint2korr(pos); pos+=2;
> - mysql->server_status=uint2korr(pos); pos+=2;
> + mysql->warning_count=uint2korr(pos);
> + pos+=2;
> }
> - break; /* End of data */
> +
> + /* message is ignored. */
> +
> + if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
> + continue;
In prepared statements, you can't get server_status &
SERVER_MORE_RESULTS_EXISTS after an OK packet.
When does this code work?
--