Skip to content

Commit f6e3313

Browse files
committed
Remove undocumented support for copy syntax from before 7.3. Update comments to reflect syntax actually supported, e.g. by including CSV params.
1 parent 348b621 commit f6e3313

File tree

1 file changed

+8
-48
lines changed

1 file changed

+8
-48
lines changed

src/bin/psql/copy.c

Lines changed: 8 additions & 48 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.74 2007/02/08 11:10:27 petere Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.75 2007/03/16 13:41:21 adunstan Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "copy.h"
@@ -35,21 +35,19 @@
3535
* parse_slash_copy
3636
* -- parses \copy command line
3737
*
38-
* The documented preferred syntax is:
38+
* The documented syntax is:
3939
* \copy tablename [(columnlist)] from|to filename
4040
* [ with ] [ binary ] [ oids ] [ delimiter [as] char ] [ null [as] string ]
41+
* [ csv [ header ] [ quote [ AS ] string ] escape [as] string
42+
* [ force not null column [, ...] | force quote column [, ...] ] ]
4143
*
4244
* \copy ( select stmt ) to filename
4345
* [ with ] [ binary ] [ delimiter [as] char ] [ null [as] string ]
46+
* [ csv [ header ] [ quote [ AS ] string ] escape [as] string
47+
* [ force quote column [, ...] ] ]
4448
*
45-
* The pre-7.3 syntax was:
46-
* \copy [ binary ] tablename [(columnlist)] [with oids] from|to filename
47-
* [ [using] delimiters char ] [ with null as string ]
48-
*
49-
* The actual accepted syntax is a rather unholy combination of these,
50-
* plus some undocumented flexibility (for instance, the clauses after
51-
* WITH can appear in any order). The accepted syntax matches what
52-
* the backend grammar actually accepts (see backend/parser/gram.y).
49+
* Force quote only applies for copy to; force not null only applies for
50+
* copy from.
5351
*
5452
* table name can be double-quoted and can have a schema part.
5553
* column names can be double-quoted.
@@ -216,23 +214,6 @@ parse_slash_copy(const char *args)
216214
goto error;
217215
}
218216

219-
/*
220-
* Allows old COPY syntax for backward compatibility 2002-06-19
221-
*/
222-
if (pg_strcasecmp(token, "with") == 0)
223-
{
224-
token = strtokx(NULL, whitespace, NULL, NULL,
225-
0, false, false, pset.encoding);
226-
if (!token || pg_strcasecmp(token, "oids") != 0)
227-
goto error;
228-
result->oids = true;
229-
230-
token = strtokx(NULL, whitespace, NULL, NULL,
231-
0, false, false, pset.encoding);
232-
if (!token)
233-
goto error;
234-
}
235-
236217
if (pg_strcasecmp(token, "from") == 0)
237218
result->from = true;
238219
else if (pg_strcasecmp(token, "to") == 0)
@@ -267,27 +248,6 @@ parse_slash_copy(const char *args)
267248
token = strtokx(NULL, whitespace, NULL, NULL,
268249
0, false, false, pset.encoding);
269250

270-
/*
271-
* Allows old COPY syntax for backward compatibility.
272-
*/
273-
if (token && pg_strcasecmp(token, "using") == 0)
274-
{
275-
token = strtokx(NULL, whitespace, NULL, NULL,
276-
0, false, false, pset.encoding);
277-
if (!(token && pg_strcasecmp(token, "delimiters") == 0))
278-
goto error;
279-
}
280-
if (token && pg_strcasecmp(token, "delimiters") == 0)
281-
{
282-
token = strtokx(NULL, whitespace, NULL, "'",
283-
nonstd_backslash, true, false, pset.encoding);
284-
if (!token)
285-
goto error;
286-
result->delim = pg_strdup(token);
287-
token = strtokx(NULL, whitespace, NULL, NULL,
288-
0, false, false, pset.encoding);
289-
}
290-
291251
if (token)
292252
{
293253
/*

0 commit comments

Comments
 (0)