diff options
author | Bruce Momjian | 2008-03-11 23:30:56 +0000 |
---|---|---|
committer | Bruce Momjian | 2008-03-11 23:30:56 +0000 |
commit | ef5ee1ad344665a8ec0bea772ea799990872cecf (patch) | |
tree | 6007ec4888ecb5869d4c9962507593e750e61787 | |
parent | 4af56dfb1162815650b951eb9a2120eac91df4d1 (diff) |
Prevent psql \copy from accepting multiple string parameters, e.g.
test=> \copy billing_data from ../BillingSamplePricerFile.csv with csv
header quote as '"' null as 'abc' null as '123'
\copy: parse error at "null"
Per report from Stephen Frost
-rw-r--r-- | src/bin/psql/copy.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 092c2defbb..2ddc9d7cb3 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -274,6 +274,8 @@ parse_slash_copy(const char *args) result->header = true; else if (pg_strcasecmp(token, "delimiter") == 0) { + if (result->delim) + goto error; token = strtokx(NULL, whitespace, NULL, "'", nonstd_backslash, true, false, pset.encoding); if (token && pg_strcasecmp(token, "as") == 0) @@ -286,6 +288,8 @@ parse_slash_copy(const char *args) } else if (pg_strcasecmp(token, "null") == 0) { + if (result->null) + goto error; token = strtokx(NULL, whitespace, NULL, "'", nonstd_backslash, true, false, pset.encoding); if (token && pg_strcasecmp(token, "as") == 0) @@ -298,6 +302,8 @@ parse_slash_copy(const char *args) } else if (pg_strcasecmp(token, "quote") == 0) { + if (result->quote) + goto error; token = strtokx(NULL, whitespace, NULL, "'", nonstd_backslash, true, false, pset.encoding); if (token && pg_strcasecmp(token, "as") == 0) @@ -310,6 +316,8 @@ parse_slash_copy(const char *args) } else if (pg_strcasecmp(token, "escape") == 0) { + if (result->escape) + goto error; token = strtokx(NULL, whitespace, NULL, "'", nonstd_backslash, true, false, pset.encoding); if (token && pg_strcasecmp(token, "as") == 0) @@ -326,6 +334,8 @@ parse_slash_copy(const char *args) 0, false, false, pset.encoding); if (pg_strcasecmp(token, "quote") == 0) { + if (result->force_quote_list) + goto error; /* handle column list */ fetch_next = false; for (;;) @@ -347,6 +357,8 @@ parse_slash_copy(const char *args) } else if (pg_strcasecmp(token, "not") == 0) { + if (result->force_notnull_list) + goto error; token = strtokx(NULL, whitespace, ",", "\"", 0, false, false, pset.encoding); if (pg_strcasecmp(token, "null") != 0) |