summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2010-07-23 22:36:21 -0300
committerDavi Arnaut <davi.arnaut@oracle.com>2010-07-23 22:36:21 -0300
commitbba8d5ca9b3bcb4fd9685e8af6bae6de0c9b7be7 (patch)
tree1b0b99de278ce9cb5a458afc12e6cc2280a885b6
parent936217aac915f068deeef03544287411ddddba94 (diff)
parent32372a756f95c26f762c8a80ccfeaebb8d59e269 (diff)
downloadmariadb-git-bba8d5ca9b3bcb4fd9685e8af6bae6de0c9b7be7.tar.gz
Merge of mysql-5.1-bugteam into mysql-trunk-merge.
-rw-r--r--sql/protocol.cc16
-rw-r--r--sql/sql_cache.cc3
-rw-r--r--sql/sql_cursor.cc7
-rw-r--r--sql/sql_prepare.cc7
4 files changed, 24 insertions, 9 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 3f957dcc2de..6b7ab87aa62 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -658,7 +658,11 @@ void Protocol::end_partial_result_set(THD *thd_arg)
bool Protocol::flush()
{
#ifndef EMBEDDED_LIBRARY
- return net_flush(&thd->net);
+ bool error;
+ thd->stmt_da->can_overwrite_status= TRUE;
+ error= net_flush(&thd->net);
+ thd->stmt_da->can_overwrite_status= FALSE;
+ return error;
#else
return 0;
#endif
@@ -698,7 +702,8 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
if (flags & SEND_NUM_ROWS)
{ // Packet with number of elements
uchar *pos= net_store_length(buff, list->elements);
- (void) my_net_write(&thd->net, buff, (size_t) (pos-buff));
+ if (my_net_write(&thd->net, buff, (size_t) (pos-buff)))
+ DBUG_RETURN(1);
}
#ifndef DBUG_OFF
@@ -820,7 +825,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
if (flags & SEND_DEFAULTS)
item->send(&prot, &tmp); // Send default value
if (prot.write())
- break; /* purecov: inspected */
+ DBUG_RETURN(1);
#ifndef DBUG_OFF
field_types[count++]= field.type;
#endif
@@ -833,8 +838,9 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
to show that there is no cursor.
Send no warning information, as it will be sent at statement end.
*/
- write_eof_packet(thd, &thd->net, thd->server_status,
- thd->warning_info->statement_warn_count());
+ if (write_eof_packet(thd, &thd->net, thd->server_status,
+ thd->warning_info->statement_warn_count()))
+ DBUG_RETURN(1);
}
DBUG_RETURN(prepare_for_send(list->elements));
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index b73de320ef5..d6dc9edc502 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1673,7 +1673,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
thd->limit_found_rows = query->found_rows();
thd->status_var.last_query_cost= 0.0;
- thd->stmt_da->disable_status();
+ if (!thd->stmt_da->is_set())
+ thd->stmt_da->disable_status();
BLOCK_UNLOCK_RD(query_block);
MYSQL_QUERY_CACHE_HIT(thd->query(), (ulong) thd->limit_found_rows);
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index ca724ec262f..123b1cd1ec9 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -664,7 +664,12 @@ void Materialized_cursor::fetch(ulong num_rows)
if ((res= table->file->rnd_next(table->record[0])))
break;
/* Send data only if the read was successful. */
- result->send_data(item_list);
+ /*
+ If network write failed (i.e. due to a closed socked),
+ the error has already been set. Just return.
+ */
+ if (result->send_data(item_list))
+ return;
}
switch (res) {
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 089e751900e..a9c4f3f090d 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -352,8 +352,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
&stmt->lex->param_list,
Protocol::SEND_EOF);
}
- /* Flag that a response has already been sent */
- thd->stmt_da->disable_status();
+
+ if (!error)
+ /* Flag that a response has already been sent */
+ thd->stmt_da->disable_status();
+
DBUG_RETURN(error);
}
#else