File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -176,16 +176,17 @@ void db_copy_thread_t::thread_t::start_copy(
176176{
177177 assert (!m_inflight);
178178
179- std::string copystr = " COPY " ;
180- copystr .reserve (target->name .size () + target->rows .size () + 14 );
181- copystr += target->name ;
182- if (! target->rows . empty ()) {
183- copystr += ' ( ' ;
184- copystr += target->rows ;
185- copystr += ' ) ' ;
179+ fmt::memory_buffer sql ;
180+ sql .reserve (target->name .size () + target->rows .size () + 14 );
181+ if ( target->rows . empty ()) {
182+ fmt::format_to (sql, FMT_STRING ( " COPY {} FROM STDIN " ), target->name );
183+ } else {
184+ fmt::format_to (sql, FMT_STRING ( " COPY {} ({}) FROM STDIN " ), target->name ,
185+ target-> rows ) ;
186186 }
187- copystr += " FROM STDIN" ;
188- m_conn->query (PGRES_COPY_IN, copystr);
187+
188+ sql.push_back (' \0 ' );
189+ m_conn->query (PGRES_COPY_IN, sql.data ());
189190
190191 m_inflight = target;
191192}
You can’t perform that action at this time.
0 commit comments