From 551aeed43e1ff80e1e4b45bfd0d435e8cd36a9b7 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 26 Nov 2024 02:08:18 +0500 Subject: [PATCH] Improved COPY OUT format extraction --- lib/PgSQL_Protocol.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/PgSQL_Protocol.cpp b/lib/PgSQL_Protocol.cpp index 0e2c38987..2ee026c88 100644 --- a/lib/PgSQL_Protocol.cpp +++ b/lib/PgSQL_Protocol.cpp @@ -1438,7 +1438,7 @@ unsigned int PgSQL_Protocol::copy_row_description_to_PgSQL_Query_Result(bool sen unsigned int PgSQL_Protocol::copy_row_to_PgSQL_Query_Result(bool send, PgSQL_Query_Result* pg_query_result, const PGresult* result) { assert(pg_query_result); assert(result); - assert(pg_query_result->num_fields); + //assert(pg_query_result->num_fields); const unsigned int numRows = PQntuples(result); unsigned int total_size = 0; @@ -1825,25 +1825,16 @@ unsigned int PgSQL_Protocol::copy_out_response_start_to_PgSQL_Query_Result(bool } PG_pkt pgpkt(_ptr, size); - uint8_t format = 0; // Format: Text pgpkt.put_char('H'); pgpkt.put_uint32(size - 1); - pgpkt.put_char(format); + pgpkt.put_char(PQbinaryTuples(result) ? 1 : 0); pgpkt.put_uint16(fields_cnt); for (int i = 0; i < fields_cnt; i++) { int format_code = PQfformat(result, i); pgpkt.put_uint16(format_code); - - if (format_code != 0) - format = format_code; } - if (format != 0) { - _ptr[1 + 4] = format; - } - - if (send == true) { // not supported //(*myds)->PSarrayOUT->add((void*)_ptr, size);