Commit f6e3313f authored by Andrew Dunstan's avatar Andrew Dunstan

Remove undocumented support for copy syntax from before 7.3. Update comments to
reflect syntax actually supported, e.g. by including CSV params.
parent 348b6218
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.74 2007/02/08 11:10:27 petere Exp $ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.75 2007/03/16 13:41:21 adunstan Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "copy.h" #include "copy.h"
...@@ -35,21 +35,19 @@ ...@@ -35,21 +35,19 @@
* parse_slash_copy * parse_slash_copy
* -- parses \copy command line * -- parses \copy command line
* *
* The documented preferred syntax is: * The documented syntax is:
* \copy tablename [(columnlist)] from|to filename * \copy tablename [(columnlist)] from|to filename
* [ with ] [ binary ] [ oids ] [ delimiter [as] char ] [ null [as] string ] * [ with ] [ binary ] [ oids ] [ delimiter [as] char ] [ null [as] string ]
* [ csv [ header ] [ quote [ AS ] string ] escape [as] string
* [ force not null column [, ...] | force quote column [, ...] ] ]
* *
* \copy ( select stmt ) to filename * \copy ( select stmt ) to filename
* [ with ] [ binary ] [ delimiter [as] char ] [ null [as] string ] * [ with ] [ binary ] [ delimiter [as] char ] [ null [as] string ]
* [ csv [ header ] [ quote [ AS ] string ] escape [as] string
* [ force quote column [, ...] ] ]
* *
* The pre-7.3 syntax was: * Force quote only applies for copy to; force not null only applies for
* \copy [ binary ] tablename [(columnlist)] [with oids] from|to filename * copy from.
* [ [using] delimiters char ] [ with null as string ]
*
* The actual accepted syntax is a rather unholy combination of these,
* plus some undocumented flexibility (for instance, the clauses after
* WITH can appear in any order). The accepted syntax matches what
* the backend grammar actually accepts (see backend/parser/gram.y).
* *
* table name can be double-quoted and can have a schema part. * table name can be double-quoted and can have a schema part.
* column names can be double-quoted. * column names can be double-quoted.
...@@ -216,23 +214,6 @@ parse_slash_copy(const char *args) ...@@ -216,23 +214,6 @@ parse_slash_copy(const char *args)
goto error; goto error;
} }
/*
* Allows old COPY syntax for backward compatibility 2002-06-19
*/
if (pg_strcasecmp(token, "with") == 0)
{
token = strtokx(NULL, whitespace, NULL, NULL,
0, false, false, pset.encoding);
if (!token || pg_strcasecmp(token, "oids") != 0)
goto error;
result->oids = true;
token = strtokx(NULL, whitespace, NULL, NULL,
0, false, false, pset.encoding);
if (!token)
goto error;
}
if (pg_strcasecmp(token, "from") == 0) if (pg_strcasecmp(token, "from") == 0)
result->from = true; result->from = true;
else if (pg_strcasecmp(token, "to") == 0) else if (pg_strcasecmp(token, "to") == 0)
...@@ -267,27 +248,6 @@ parse_slash_copy(const char *args) ...@@ -267,27 +248,6 @@ parse_slash_copy(const char *args)
token = strtokx(NULL, whitespace, NULL, NULL, token = strtokx(NULL, whitespace, NULL, NULL,
0, false, false, pset.encoding); 0, false, false, pset.encoding);
/*
* Allows old COPY syntax for backward compatibility.
*/
if (token && pg_strcasecmp(token, "using") == 0)
{
token = strtokx(NULL, whitespace, NULL, NULL,
0, false, false, pset.encoding);
if (!(token && pg_strcasecmp(token, "delimiters") == 0))
goto error;
}
if (token && pg_strcasecmp(token, "delimiters") == 0)
{
token = strtokx(NULL, whitespace, NULL, "'",
nonstd_backslash, true, false, pset.encoding);
if (!token)
goto error;
result->delim = pg_strdup(token);
token = strtokx(NULL, whitespace, NULL, NULL,
0, false, false, pset.encoding);
}
if (token) if (token)
{ {
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment