Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdef329d

Browse files
committed
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
1 parent288579c commitdef329d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎src/bin/psql/copy.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.77 2008/01/01 19:45:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.78 2008/03/11 23:30:56 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"copy.h"
@@ -274,6 +274,8 @@ parse_slash_copy(const char *args)
274274
result->header= true;
275275
elseif (pg_strcasecmp(token,"delimiter")==0)
276276
{
277+
if (result->delim)
278+
gotoerror;
277279
token=strtokx(NULL,whitespace,NULL,"'",
278280
nonstd_backslash, true, false,pset.encoding);
279281
if (token&&pg_strcasecmp(token,"as")==0)
@@ -286,6 +288,8 @@ parse_slash_copy(const char *args)
286288
}
287289
elseif (pg_strcasecmp(token,"null")==0)
288290
{
291+
if (result->null)
292+
gotoerror;
289293
token=strtokx(NULL,whitespace,NULL,"'",
290294
nonstd_backslash, true, false,pset.encoding);
291295
if (token&&pg_strcasecmp(token,"as")==0)
@@ -298,6 +302,8 @@ parse_slash_copy(const char *args)
298302
}
299303
elseif (pg_strcasecmp(token,"quote")==0)
300304
{
305+
if (result->quote)
306+
gotoerror;
301307
token=strtokx(NULL,whitespace,NULL,"'",
302308
nonstd_backslash, true, false,pset.encoding);
303309
if (token&&pg_strcasecmp(token,"as")==0)
@@ -310,6 +316,8 @@ parse_slash_copy(const char *args)
310316
}
311317
elseif (pg_strcasecmp(token,"escape")==0)
312318
{
319+
if (result->escape)
320+
gotoerror;
313321
token=strtokx(NULL,whitespace,NULL,"'",
314322
nonstd_backslash, true, false,pset.encoding);
315323
if (token&&pg_strcasecmp(token,"as")==0)
@@ -326,6 +334,8 @@ parse_slash_copy(const char *args)
326334
0, false, false,pset.encoding);
327335
if (pg_strcasecmp(token,"quote")==0)
328336
{
337+
if (result->force_quote_list)
338+
gotoerror;
329339
/* handle column list */
330340
fetch_next= false;
331341
for (;;)
@@ -347,6 +357,8 @@ parse_slash_copy(const char *args)
347357
}
348358
elseif (pg_strcasecmp(token,"not")==0)
349359
{
360+
if (result->force_notnull_list)
361+
gotoerror;
350362
token=strtokx(NULL,whitespace,",","\"",
351363
0, false, false,pset.encoding);
352364
if (pg_strcasecmp(token,"null")!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp