File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 523523 else
524524 {
525525 // The underlying vector<char> will be freed by `free_result` from Python side.
526- query_result_memory = new std::vector<char >(4096 );
526+ // When the input query contains multiple statements, such as "SELECT 1; SELECT 2". When executing "SELECT 2",
527+ // the query_result_memory corresponding to SELECT 1 has not been "stolen" by function stealQueryOutputVector,
528+ // so it remains non-empty.
529+ if (query_result_memory)
530+ query_result_memory->resize (4096 );
531+ else
532+ query_result_memory = new std::vector<char >(4096 );
533+
527534 query_result_buf = std::make_shared<WriteBufferFromVector<std::vector<char >>>(*query_result_memory);
528535
529536 out_buf = query_result_buf.get ();
Original file line number Diff line number Diff line change @@ -107,13 +107,13 @@ class ClientBase
107107 return query_result_memory;
108108 }
109109
110- // / Steals and returns the query output vector, replacing it with a new one
110+ // / Steals and returns the query output vector.
111+ // / Afterward, the content of query_result_memory is released by the Python side.
111112 std::vector<char > * stealQueryOutputVector ()
112113 {
113114 auto * result = query_result_memory;
114- query_result_memory = new std::vector<char >(4096 );
115- // WriteBufferFromVector takes a reference to the vector but doesn't own it
116- query_result_buf = std::make_shared<WriteBufferFromVector<std::vector<char >>>(*query_result_memory);
115+ query_result_memory = nullptr ;
116+ query_result_buf.reset ();
117117 return result;
118118 }
119119
You can’t perform that action at this time.
0 commit comments