diff --git a/connection.c b/connection.c
index af985f2..7f73296 100644
--- a/connection.c
+++ b/connection.c
@@ -2808,6 +2808,7 @@ CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UD
 	int			maxlen,
 				empty_reqs;
 	BOOL		ReadyToReturn = FALSE,
+			retDetermined = FALSE,
 				query_completed = FALSE,
 				beforeV2 = !(PROTOCOL_64(&self->connInfo) || PROTOCOL_74(&self->connInfo)),
 				aborted = FALSE,
@@ -3246,6 +3247,7 @@ inolog("Discarded the first SAVEPOINT\n");
 						else
 							retres = cmdres;
 						aborted = TRUE;
+						retDetermined = TRUE;
 					}
 					query_completed = TRUE;
 				}
@@ -3389,17 +3391,28 @@ mylog("!!! copydata len=%d\n", response_length);
 
 cleanup:
 	if (SOCK_get_errcode(self->sock) != 0)
-	{
-		if (0 == CC_get_errornumber(self))
-			CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, "Communication error while sending query", func);
 		kill_conn = TRUE;
-	}
 	if (kill_conn)
-	{
 		CC_on_abort(self, CONN_DEAD);
+
+	if (CONN_DOWN == self->status)
+	{
+		if (0 == CC_get_errornumber(self))
+			CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, "Communication error while sending query", func);
 		retres = NULL;
+		aborted = TRUE;
 	}
-	if (rollback_on_error && CC_is_in_trans(self) && !discard_next_savepoint)
+	/*
+	 * Break before being ready to return.
+	 */
+	else if (!ReadyToReturn &&
+		 !retDetermined)
+		retres = cmdres;
+	/* Issue rollback command if necessary */
+	if (CONN_CONNECTED == self->status &&
+	    rollback_on_error &&
+	    CC_is_in_trans(self) &&
+	    !discard_next_savepoint)
 	{
 		char	cmd[64];
 
@@ -3421,12 +3434,6 @@ cleanup:
 	CLEANUP_FUNC_CONN_CS(func_cs_count, self);
 #undef	return
 	/*
-	 * Break before being ready to return.
-	 */
-	if (!ReadyToReturn)
-		retres = cmdres;
-
-	/*
 	 * Cleanup garbage results before returning.
 	 */
 	if (cmdres && retres != cmdres && !used_passed_result_object)
diff --git a/statement.c b/statement.c
index da5abf5..98faadf 100644
--- a/statement.c
+++ b/statement.c
@@ -2077,12 +2077,17 @@ inolog("get_Result=%p %p %d\n", res, SC_get_Result(self), self->curr_param_resul
 			 */
 			if (appendq)
 			{
-				QResultClass	*qres, *nres;
+				QResultClass	*qres, *pres, *nres;
 
-				for (qres = res; qres;)
+				for (qres = res, pres = NULL; qres;)
 				{
 					if (qres->command && strnicmp(qres->command, fetch_cmd, 5) == 0)
 					{
+						if (NULL != pres)
+						{
+							pres->next = NULL;
+							QR_Destructor(res);
+						}
 						res = qres;
 						break;
 					}
@@ -2096,8 +2101,7 @@ inolog("get_Result=%p %p %d\n", res, SC_get_Result(self), self->curr_param_resul
 						}
 						QR_add_notice(nres, QR_get_notice(qres));
 					}
-					qres->next = NULL;
-					QR_Destructor(qres);
+					pres = qres;
 					qres = nres;
 				}
 			}
