3
3
*
4
4
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "copy.h"
@@ -274,6 +274,8 @@ parse_slash_copy(const char *args)
274
274
result -> header = true;
275
275
else if (pg_strcasecmp (token ,"delimiter" )== 0 )
276
276
{
277
+ if (result -> delim )
278
+ gotoerror ;
277
279
token = strtokx (NULL ,whitespace ,NULL ,"'" ,
278
280
nonstd_backslash , true, false,pset .encoding );
279
281
if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -286,6 +288,8 @@ parse_slash_copy(const char *args)
286
288
}
287
289
else if (pg_strcasecmp (token ,"null" )== 0 )
288
290
{
291
+ if (result -> null )
292
+ gotoerror ;
289
293
token = strtokx (NULL ,whitespace ,NULL ,"'" ,
290
294
nonstd_backslash , true, false,pset .encoding );
291
295
if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -298,6 +302,8 @@ parse_slash_copy(const char *args)
298
302
}
299
303
else if (pg_strcasecmp (token ,"quote" )== 0 )
300
304
{
305
+ if (result -> quote )
306
+ gotoerror ;
301
307
token = strtokx (NULL ,whitespace ,NULL ,"'" ,
302
308
nonstd_backslash , true, false,pset .encoding );
303
309
if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -310,6 +316,8 @@ parse_slash_copy(const char *args)
310
316
}
311
317
else if (pg_strcasecmp (token ,"escape" )== 0 )
312
318
{
319
+ if (result -> escape )
320
+ gotoerror ;
313
321
token = strtokx (NULL ,whitespace ,NULL ,"'" ,
314
322
nonstd_backslash , true, false,pset .encoding );
315
323
if (token && pg_strcasecmp (token ,"as" )== 0 )
@@ -326,6 +334,8 @@ parse_slash_copy(const char *args)
326
334
0 , false, false,pset .encoding );
327
335
if (pg_strcasecmp (token ,"quote" )== 0 )
328
336
{
337
+ if (result -> force_quote_list )
338
+ gotoerror ;
329
339
/* handle column list */
330
340
fetch_next = false;
331
341
for (;;)
@@ -347,6 +357,8 @@ parse_slash_copy(const char *args)
347
357
}
348
358
else if (pg_strcasecmp (token ,"not" )== 0 )
349
359
{
360
+ if (result -> force_notnull_list )
361
+ gotoerror ;
350
362
token = strtokx (NULL ,whitespace ,"," ,"\"" ,
351
363
0 , false, false,pset .encoding );
352
364
if (pg_strcasecmp (token ,"null" )!= 0 )