Skip to content

Commit

Permalink
Use copy with binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhaveS committed Jul 31, 2024
1 parent 792c554 commit 9216022
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bin/pgcopydb/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,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";
Expand Down Expand Up @@ -3073,7 +3073,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)
{
Expand All @@ -3090,7 +3090,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
Expand Down
2 changes: 2 additions & 0 deletions src/bin/pgcopydb/table-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9216022

Please sign in to comment.