#At file:///mnt/raid/alik/MySQL/bzr/bug39519/6.0-rt-bug39519/
2728 Alexander Nozdrin 2008-11-12
Bug #34481 A typo in HugeTLB error Message.
modified:
include/mysql.h
include/mysql.h.pp
libmysql/libmysql.c
sql-common/client.c
tests/mysql_client_test.c
per-file messages:
include/mysql.h.pp
Add a new flag into MYSQL.
=== modified file 'include/mysql.h'
--- a/include/mysql.h 2008-08-07 17:52:43 +0000
+++ b/include/mysql.h 2008-11-12 11:15:32 +0000
@@ -257,6 +257,7 @@ typedef struct st_mysql
enum mysql_status status;
my_bool free_me; /* If free in mysql_close */
my_bool reconnect; /* set to 1 if automatic reconnect */
+ my_bool flush_all_results;
/* session-wide random string */
char scramble[SCRAMBLE_LENGTH+1];
=== modified file 'include/mysql.h.pp'
--- a/include/mysql.h.pp 2008-09-12 08:38:48 +0000
+++ b/include/mysql.h.pp 2008-11-12 11:15:32 +0000
@@ -336,6 +336,7 @@ typedef struct st_mysql
enum mysql_status status;
my_bool free_me;
my_bool reconnect;
+ my_bool flush_all_results;
char scramble[20 +1];
my_bool unused1;
void *unused2, *unused3, *unused4, *unused5;
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2008-08-07 17:52:43 +0000
+++ b/libmysql/libmysql.c 2008-11-12 11:15:32 +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;
=== modified file 'sql-common/client.c'
--- a/sql-common/client.c 2008-05-08 16:01:15 +0000
+++ b/sql-common/client.c 2008-11-12 11:15:32 +0000
@@ -833,22 +833,160 @@ static void cli_flush_use_result(MYSQL *
/* Clear the current execution status */
DBUG_ENTER("cli_flush_use_result");
DBUG_PRINT("warning",("Not all packets read, clearing them"));
- for (;;)
+
+ /*
+ If MYSQL::flush_all_results is FALSE, then we just read through the
+ first EOF packet.
+
+ MYSQL_STATUS_READY means, we're in front of a ResultSet packet, or an
+ Ok-packet.
+
+ MYSQL_STATUS_GET_RESULT or MYSQL_STATUS_USE_RESULT means we're in the
+ beginning (or in the middle) of data-part of ResultSet-packet.
+ */
+
+ if (!mysql->flush_all_results ||
+ mysql->status == MYSQL_STATUS_GET_RESULT ||
+ mysql->status == MYSQL_STATUS_USE_RESULT)
{
- ulong pkt_len;
- if ((pkt_len=cli_safe_read(mysql)) == packet_error)
- break;
- if (pkt_len <= 8 && mysql->net.read_pos[0] == 254)
+ /* Waiting for EOF-packet (it will be PT_RS_DATA_EOF). */
+
+ while (1)
{
+ ulong packet_length= cli_safe_read(mysql);
+
+ if (packet_length == packet_error)
+ DBUG_VOID_RETURN;
+
+ if (packet_length <= 8 && mysql->net.read_pos[0] == 254)
+ break;
+ }
+
+ /* Analyze received EOF-packet (PT_RS_DATA_EOF). */
+
+ my_bool more_results_exist;
+
+ 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;
+
+ more_results_exist= mysql->server_status & SERVER_MORE_RESULTS_EXISTS;
+ }
+ else
+ {
+ /*
+ This is the 4.0 protocol, which does not support multi result sets.
+ */
+ more_results_exist= FALSE;
+ }
+
+ if (!mysql->flush_all_results)
+ DBUG_VOID_RETURN;
+
+ mysql->status = MYSQL_STATUS_READY;
+
+ if (!more_results_exist)
+ DBUG_VOID_RETURN;
+ }
+
+ DBUG_ASSERT(mysql->status == MYSQL_STATUS_READY);
+ DBUG_ASSERT(mysql->flush_all_results);
+
+ /*
+ Here we can get two types of packets:
+ - OK-packet.
+ - ResultSet-packet.
+ */
+
+ while (1)
+ {
+ ulong packet_length= cli_safe_read(mysql);
+
+ if (packet_length == packet_error)
+ DBUG_VOID_RETURN;
+
+ if (packet_length > 0 && mysql->net.read_pos[0] == 0)
+ {
+ /* 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;
+
+ DBUG_VOID_RETURN;
+ }
+
+ /* This is a ResultSet-packet. */
+
+ packet_length= cli_safe_read(mysql); /* Field count. */
+ if (packet_length == packet_error)
+ DBUG_VOID_RETURN;
+
+ /* Reading metadata (until EOF). */
+
+ while (1)
+ {
+ packet_length= cli_safe_read(mysql); /* Metadata row or EOF. */
+ if (packet_length == packet_error)
+ DBUG_VOID_RETURN;
+
+ if (packet_length > 0 && mysql->net.read_pos[0] == 0xfe)
+ break;
+ }
+
+ /* Reading data (until EOF). */
+
+ while (1)
+ {
+ packet_length= cli_safe_read(mysql); /* Data row or EOF. */
+ if (packet_length == packet_error)
+ DBUG_VOID_RETURN;
+
+ if (packet_length > 0 && mysql->net.read_pos[0] == 0xfe)
+ break;
+ }
+
+ /* Analyze received EOF-packet (PT_RS_DATA_EOF). */
+
+ my_bool more_results_exist;
+
+ 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;
+
+ more_results_exist= mysql->server_status & SERVER_MORE_RESULTS_EXISTS;
+ }
+ else
+ {
+ /*
+ This is the 4.0 protocol, which does not support multi result sets.
+ */
+ more_results_exist= FALSE;
}
+
+ if (!more_results_exist)
+ DBUG_VOID_RETURN;
}
+
DBUG_VOID_RETURN;
}
=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c 2008-09-15 20:37:25 +0000
+++ b/tests/mysql_client_test.c 2008-11-12 11:15:32 +0000
@@ -2039,6 +2039,43 @@ static void test_wl4435()
}
}
+static void test_wl4435_2()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+ char query[MAX_TEST_QUERY_LENGTH];
+
+ myheader("test_wl4435_2");
+ mct_start_logging("test_wl4435_2");
+
+ rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
+ myquery(rc);
+
+ rc= mysql_query(mysql,
+ "CREATE PROCEDURE p1()"
+ "BEGIN "
+ " SELECT 1; "
+ " SELECT 2, 3 UNION SELECT 4, 5; "
+ " SELECT 6, 7, 8; "
+ "END");
+ myquery(rc);
+
+ strmov(query, "CALL p1()");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ /* Execute! */
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ mysql_stmt_close(stmt);
+
+ rc= mysql_commit(mysql);
+ myquery(rc);
+}
+
+
/* Test simple prepare field results */
static void test_prepare_field_result()
@@ -18769,6 +18806,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug36004", test_bug36004 },
{ "test_wl4284_1", test_wl4284_1 },
{ "test_wl4435", test_wl4435 },
+ { "test_wl4435_2", test_wl4435_2 },
{ "test_bug38486", test_bug38486 },
{ 0, 0 }
};
| Thread |
|---|
| • bzr commit into mysql-6.0 branch (alik:2728) Bug#34481 | Alexander Nozdrin | 12 Nov |