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 3cd2c07
Show file tree
Hide file tree
Showing 2 changed files with 7 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
4 changes: 4 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 Expand Up @@ -1474,6 +1476,8 @@ copydb_prepare_summary_command(CopyTableDataSpec *tableSpecs)
appendPQExpBuffer(command, " %s", tableSpecs->copyArgs.srcWhereClause);
}

appendPQExpBuffer(command, "WITH (FORMAT BINARY)");

tableSummary->command =
command->data != NULL ? strdup(command->data) : NULL;

Expand Down

0 comments on commit 3cd2c07

Please sign in to comment.