Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 00ade1d

Browse files
committed
Pass modern COPY syntax to backend, since copy (query) does not accept old syntax. Per complaint from Michael Fuhr.
1 parent 23c4978 commit 00ade1d

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/bin/psql/copy.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.72 2007/01/05 22:19:49 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.73 2007/02/05 15:22:18 adunstan Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "copy.h"
@@ -268,7 +268,7 @@ parse_slash_copy(const char *args)
268268
0, false, false, pset.encoding);
269269

270270
/*
271-
* Allows old COPY syntax for backward compatibility 2002-06-19
271+
* Allows old COPY syntax for backward compatibility.
272272
*/
273273
if (token && pg_strcasecmp(token, "using") == 0)
274274
{
@@ -480,32 +480,28 @@ do_copy(const char *args)
480480

481481
printfPQExpBuffer(&query, "COPY ");
482482

483-
/* Uses old COPY syntax for backward compatibility 2002-06-19 */
484-
if (options->binary)
485-
appendPQExpBuffer(&query, "BINARY ");
486-
487483
appendPQExpBuffer(&query, "%s ", options->table);
488484

489485
if (options->column_list)
490486
appendPQExpBuffer(&query, "%s ", options->column_list);
491487

492-
/* Uses old COPY syntax for backward compatibility 2002-06-19 */
493-
if (options->oids)
494-
appendPQExpBuffer(&query, "WITH OIDS ");
495-
496488
if (options->from)
497489
appendPQExpBuffer(&query, "FROM STDIN");
498490
else
499491
appendPQExpBuffer(&query, "TO STDOUT");
500492

501493

502-
/* Uses old COPY syntax for backward compatibility 2002-06-19 */
494+
if (options->binary)
495+
appendPQExpBuffer(&query, " BINARY ");
496+
497+
if (options->oids)
498+
appendPQExpBuffer(&query, " OIDS ");
499+
503500
if (options->delim)
504-
emit_copy_option(&query, " USING DELIMITERS ", options->delim);
501+
emit_copy_option(&query, " DELIMITER ", options->delim);
505502

506-
/* There is no backward-compatible CSV syntax */
507503
if (options->null)
508-
emit_copy_option(&query, " WITH NULL AS ", options->null);
504+
emit_copy_option(&query, " NULL AS ", options->null);
509505

510506
if (options->csv_mode)
511507
appendPQExpBuffer(&query, " CSV");

0 commit comments

Comments
 (0)