From 789c95503751b3d6e02589208d8c5c7350cc2119 Mon Sep 17 00:00:00 2001 From: VaibhaveS Date: Wed, 31 Jul 2024 16:08:46 +0530 Subject: [PATCH] Use copy with binary. --- src/bin/pgcopydb/pgsql.c | 6 +++--- src/bin/pgcopydb/table-data.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/pgcopydb/pgsql.c b/src/bin/pgcopydb/pgsql.c index 80864267..b9382303 100644 --- a/src/bin/pgcopydb/pgsql.c +++ b/src/bin/pgcopydb/pgsql.c @@ -2926,7 +2926,7 @@ pg_copy_from_stdin(PGSQL *pgsql, const char *qname) { char sql[BUFSIZE] = { 0 }; - sformat(sql, sizeof(sql), "COPY %s FROM stdin", qname); + sformat(sql, sizeof(sql), "COPY %s FROM stdin WITH (format binary)", qname); char *endpoint = pgsql->connectionType == PGSQL_CONN_SOURCE ? "SOURCE" : "TARGET"; @@ -3070,7 +3070,7 @@ pg_copy_send_query(PGSQL *pgsql, CopyArgs *args, ExecStatusType status) args->srcAttrList, args->srcQname); } - appendPQExpBuffer(sql, "to stdout"); + appendPQExpBuffer(sql, "to stdout with (format binary);"); } else if (status == PGRES_COPY_IN) { @@ -3087,7 +3087,7 @@ pg_copy_send_query(PGSQL *pgsql, CopyArgs *args, ExecStatusType status) if (args->freeze) { - appendPQExpBuffer(sql, " with (freeze)"); + appendPQExpBuffer(sql, " with (freeze, format binary)"); } } else diff --git a/src/bin/pgcopydb/table-data.c b/src/bin/pgcopydb/table-data.c index 208be4ff..54daf36c 100644 --- a/src/bin/pgcopydb/table-data.c +++ b/src/bin/pgcopydb/table-data.c @@ -1440,6 +1440,8 @@ copydb_prepare_copy_query(CopyTableDataSpec *tableSpecs, CopyArgs *args) } } + appendPQExpBuffer(srcWhereClause, " WITH (FORMAT BINARY)"); + if (PQExpBufferBroken(srcWhereClause)) { log_error("Failed to create where clause for %s: out of memory",