diff --git a/include/PgSQL_Connection.h b/include/PgSQL_Connection.h index 5e36f9a77..abc84ac88 100644 --- a/include/PgSQL_Connection.h +++ b/include/PgSQL_Connection.h @@ -526,6 +526,12 @@ public: bool unknown_transaction_status; private: + // Set end state for the fetch result to indicate that it originates from a simple query or statement execution. + ASYNC_ST fetch_result_end_st = ASYNC_QUERY_END; + inline void set_fetch_result_end_state(ASYNC_ST st) { + assert(st == ASYNC_QUERY_END || st == ASYNC_STMT_EXECUTE_END); + fetch_result_end_st = st; + } // Handles the COPY OUT response from the server. // Returns true if it consumes all buffer data, or false if the threshold for result size is reached bool handle_copy_out(const PGresult* result, uint64_t* processed_bytes); diff --git a/lib/PgSQL_Connection.cpp b/lib/PgSQL_Connection.cpp index 12553e895..a77da1f67 100644 --- a/lib/PgSQL_Connection.cpp +++ b/lib/PgSQL_Connection.cpp @@ -278,7 +278,6 @@ PG_ASYNC_ST PgSQL_Connection::handler(short event) { #if ENABLE_TIMER Timer timer(myds->sess->thread->Timers.Connections_Handlers); #endif // ENABLE_TIMER - ASYNC_ST USE_RESULT_END = ASYNC_QUERY_END; uint64_t processed_bytes = 0; // issue #527 : this variable will store the amount of bytes processed during this event if (pgsql_conn == NULL) { // it is the first time handler() is being called @@ -404,7 +403,7 @@ handler_again: !set_single_row_mode()) { NEXT_IMMEDIATE(ASYNC_QUERY_END); } - USE_RESULT_END = ASYNC_QUERY_END; + set_fetch_result_end_state(ASYNC_QUERY_END); NEXT_IMMEDIATE(ASYNC_USE_RESULT_START); } break; @@ -412,7 +411,7 @@ handler_again: fetch_result_start(); if (async_exit_status == PG_EVENT_NONE) { if (is_error_present()) { - NEXT_IMMEDIATE(USE_RESULT_END); + NEXT_IMMEDIATE(fetch_result_end_st); } new_result = true; if (myds->sess->mirror == false) { @@ -505,7 +504,7 @@ handler_again: proxy_warning("Unable to process the 'COPY' command. Please report a bug for future enhancements.\n"); } set_error(PGSQL_ERROR_CODES::ERRCODE_RAISE_EXCEPTION, "Unable to process 'COPY' command", true); - NEXT_IMMEDIATE(USE_RESULT_END); + NEXT_IMMEDIATE(fetch_result_end_st); break; case PGRES_BAD_RESPONSE: case PGRES_NONFATAL_ERROR: @@ -618,7 +617,7 @@ handler_again: query_result->add_ready_status(PQtransactionStatus(pgsql_conn)); update_bytes_recv(6); //processing_multi_statement = false; - NEXT_IMMEDIATE(USE_RESULT_END); + NEXT_IMMEDIATE(fetch_result_end_st); } break; case ASYNC_QUERY_END: @@ -808,7 +807,7 @@ handler_again: !set_single_row_mode()) { NEXT_IMMEDIATE(ASYNC_STMT_EXECUTE_END); } - USE_RESULT_END = ASYNC_STMT_EXECUTE_END; + set_fetch_result_end_state(ASYNC_STMT_EXECUTE_END); NEXT_IMMEDIATE(ASYNC_USE_RESULT_START); } break;