|
3 | 3 | * |
4 | 4 | * Copyright (c) 2000-2007, PostgreSQL Global Development Group |
5 | 5 | * |
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 $ |
7 | 7 | */ |
8 | 8 | #include "postgres_fe.h" |
9 | 9 | #include "copy.h" |
|
35 | 35 | * parse_slash_copy |
36 | 36 | * -- parses \copy command line |
37 | 37 | * |
38 | | - * The documented preferred syntax is: |
| 38 | + * The documented syntax is: |
39 | 39 | * \copy tablename [(columnlist)] from|to filename |
40 | 40 | * [ 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 [, ...] ] ] |
41 | 43 | * |
42 | 44 | * \copy ( select stmt ) to filename |
43 | 45 | * [ with ] [ binary ] [ delimiter [as] char ] [ null [as] string ] |
| 46 | + * [ csv [ header ] [ quote [ AS ] string ] escape [as] string |
| 47 | + * [ force quote column [, ...] ] ] |
44 | 48 | * |
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. |
53 | 51 | * |
54 | 52 | * table name can be double-quoted and can have a schema part. |
55 | 53 | * column names can be double-quoted. |
@@ -216,23 +214,6 @@ parse_slash_copy(const char *args) |
216 | 214 | goto error; |
217 | 215 | } |
218 | 216 |
|
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 | | - |
236 | 217 | if (pg_strcasecmp(token, "from") == 0) |
237 | 218 | result->from = true; |
238 | 219 | else if (pg_strcasecmp(token, "to") == 0) |
@@ -267,27 +248,6 @@ parse_slash_copy(const char *args) |
267 | 248 | token = strtokx(NULL, whitespace, NULL, NULL, |
268 | 249 | 0, false, false, pset.encoding); |
269 | 250 |
|
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 | | - |
291 | 251 | if (token) |
292 | 252 | { |
293 | 253 | /* |
|
0 commit comments