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)
274274result -> header = true;
275275else if (pg_strcasecmp (token ,"delimiter" )== 0 )
276276{
277+ if (result -> delim )
278+ gotoerror ;
277279token = strtokx (NULL ,whitespace ,NULL ,"'" ,
278280nonstd_backslash , true, false,pset .encoding );
279281if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -286,6 +288,8 @@ parse_slash_copy(const char *args)
286288}
287289else if (pg_strcasecmp (token ,"null" )== 0 )
288290{
291+ if (result -> null )
292+ gotoerror ;
289293token = strtokx (NULL ,whitespace ,NULL ,"'" ,
290294nonstd_backslash , true, false,pset .encoding );
291295if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -298,6 +302,8 @@ parse_slash_copy(const char *args)
298302}
299303else if (pg_strcasecmp (token ,"quote" )== 0 )
300304{
305+ if (result -> quote )
306+ gotoerror ;
301307token = strtokx (NULL ,whitespace ,NULL ,"'" ,
302308nonstd_backslash , true, false,pset .encoding );
303309if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -310,6 +316,8 @@ parse_slash_copy(const char *args)
310316}
311317else if (pg_strcasecmp (token ,"escape" )== 0 )
312318{
319+ if (result -> escape )
320+ gotoerror ;
313321token = strtokx (NULL ,whitespace ,NULL ,"'" ,
314322nonstd_backslash , true, false,pset .encoding );
315323if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -326,6 +334,8 @@ parse_slash_copy(const char *args)
3263340 , false, false,pset .encoding );
327335if (pg_strcasecmp (token ,"quote" )== 0 )
328336{
337+ if (result -> force_quote_list )
338+ gotoerror ;
329339/* handle column list */
330340fetch_next = false;
331341for (;;)
@@ -347,6 +357,8 @@ parse_slash_copy(const char *args)
347357}
348358else if (pg_strcasecmp (token ,"not" )== 0 )
349359{
360+ if (result -> force_notnull_list )
361+ gotoerror ;
350362token = strtokx (NULL ,whitespace ,"," ,"\"" ,
3513630 , false, false,pset .encoding );
352364if (pg_strcasecmp (token ,"null" )!= 0 )