@@ -357,10 +357,7 @@ ProcessCopyOptions(ParseState *pstate,
357
357
char * fmt = defGetString (defel );
358
358
359
359
if (format_specified )
360
- ereport (ERROR ,
361
- (errcode (ERRCODE_SYNTAX_ERROR ),
362
- errmsg ("conflicting or redundant options" ),
363
- parser_errposition (pstate , defel -> location )));
360
+ errorConflictingDefElem (defel , pstate );
364
361
format_specified = true;
365
362
if (strcmp (fmt , "text" ) == 0 )
366
363
/* default format */ ;
@@ -377,66 +374,45 @@ ProcessCopyOptions(ParseState *pstate,
377
374
else if (strcmp (defel -> defname , "freeze" ) == 0 )
378
375
{
379
376
if (freeze_specified )
380
- ereport (ERROR ,
381
- (errcode (ERRCODE_SYNTAX_ERROR ),
382
- errmsg ("conflicting or redundant options" ),
383
- parser_errposition (pstate , defel -> location )));
377
+ errorConflictingDefElem (defel , pstate );
384
378
freeze_specified = true;
385
379
opts_out -> freeze = defGetBoolean (defel );
386
380
}
387
381
else if (strcmp (defel -> defname , "delimiter" ) == 0 )
388
382
{
389
383
if (opts_out -> delim )
390
- ereport (ERROR ,
391
- (errcode (ERRCODE_SYNTAX_ERROR ),
392
- errmsg ("conflicting or redundant options" ),
393
- parser_errposition (pstate , defel -> location )));
384
+ errorConflictingDefElem (defel , pstate );
394
385
opts_out -> delim = defGetString (defel );
395
386
}
396
387
else if (strcmp (defel -> defname , "null" ) == 0 )
397
388
{
398
389
if (opts_out -> null_print )
399
- ereport (ERROR ,
400
- (errcode (ERRCODE_SYNTAX_ERROR ),
401
- errmsg ("conflicting or redundant options" ),
402
- parser_errposition (pstate , defel -> location )));
390
+ errorConflictingDefElem (defel , pstate );
403
391
opts_out -> null_print = defGetString (defel );
404
392
}
405
393
else if (strcmp (defel -> defname , "header" ) == 0 )
406
394
{
407
395
if (header_specified )
408
- ereport (ERROR ,
409
- (errcode (ERRCODE_SYNTAX_ERROR ),
410
- errmsg ("conflicting or redundant options" ),
411
- parser_errposition (pstate , defel -> location )));
396
+ errorConflictingDefElem (defel , pstate );
412
397
header_specified = true;
413
398
opts_out -> header_line = defGetBoolean (defel );
414
399
}
415
400
else if (strcmp (defel -> defname , "quote" ) == 0 )
416
401
{
417
402
if (opts_out -> quote )
418
- ereport (ERROR ,
419
- (errcode (ERRCODE_SYNTAX_ERROR ),
420
- errmsg ("conflicting or redundant options" ),
421
- parser_errposition (pstate , defel -> location )));
403
+ errorConflictingDefElem (defel , pstate );
422
404
opts_out -> quote = defGetString (defel );
423
405
}
424
406
else if (strcmp (defel -> defname , "escape" ) == 0 )
425
407
{
426
408
if (opts_out -> escape )
427
- ereport (ERROR ,
428
- (errcode (ERRCODE_SYNTAX_ERROR ),
429
- errmsg ("conflicting or redundant options" ),
430
- parser_errposition (pstate , defel -> location )));
409
+ errorConflictingDefElem (defel , pstate );
431
410
opts_out -> escape = defGetString (defel );
432
411
}
433
412
else if (strcmp (defel -> defname , "force_quote" ) == 0 )
434
413
{
435
414
if (opts_out -> force_quote || opts_out -> force_quote_all )
436
- ereport (ERROR ,
437
- (errcode (ERRCODE_SYNTAX_ERROR ),
438
- errmsg ("conflicting or redundant options" ),
439
- parser_errposition (pstate , defel -> location )));
415
+ errorConflictingDefElem (defel , pstate );
440
416
if (defel -> arg && IsA (defel -> arg , A_Star ))
441
417
opts_out -> force_quote_all = true;
442
418
else if (defel -> arg && IsA (defel -> arg , List ))
@@ -451,10 +427,7 @@ ProcessCopyOptions(ParseState *pstate,
451
427
else if (strcmp (defel -> defname , "force_not_null" ) == 0 )
452
428
{
453
429
if (opts_out -> force_notnull )
454
- ereport (ERROR ,
455
- (errcode (ERRCODE_SYNTAX_ERROR ),
456
- errmsg ("conflicting or redundant options" ),
457
- parser_errposition (pstate , defel -> location )));
430
+ errorConflictingDefElem (defel , pstate );
458
431
if (defel -> arg && IsA (defel -> arg , List ))
459
432
opts_out -> force_notnull = castNode (List , defel -> arg );
460
433
else
@@ -467,9 +440,7 @@ ProcessCopyOptions(ParseState *pstate,
467
440
else if (strcmp (defel -> defname , "force_null" ) == 0 )
468
441
{
469
442
if (opts_out -> force_null )
470
- ereport (ERROR ,
471
- (errcode (ERRCODE_SYNTAX_ERROR ),
472
- errmsg ("conflicting or redundant options" )));
443
+ errorConflictingDefElem (defel , pstate );
473
444
if (defel -> arg && IsA (defel -> arg , List ))
474
445
opts_out -> force_null = castNode (List , defel -> arg );
475
446
else
@@ -487,10 +458,7 @@ ProcessCopyOptions(ParseState *pstate,
487
458
* allowed for the column list to be NIL.
488
459
*/
489
460
if (opts_out -> convert_selectively )
490
- ereport (ERROR ,
491
- (errcode (ERRCODE_SYNTAX_ERROR ),
492
- errmsg ("conflicting or redundant options" ),
493
- parser_errposition (pstate , defel -> location )));
461
+ errorConflictingDefElem (defel , pstate );
494
462
opts_out -> convert_selectively = true;
495
463
if (defel -> arg == NULL || IsA (defel -> arg , List ))
496
464
opts_out -> convert_select = castNode (List , defel -> arg );
@@ -504,10 +472,7 @@ ProcessCopyOptions(ParseState *pstate,
504
472
else if (strcmp (defel -> defname , "encoding" ) == 0 )
505
473
{
506
474
if (opts_out -> file_encoding >= 0 )
507
- ereport (ERROR ,
508
- (errcode (ERRCODE_SYNTAX_ERROR ),
509
- errmsg ("conflicting or redundant options" ),
510
- parser_errposition (pstate , defel -> location )));
475
+ errorConflictingDefElem (defel , pstate );
511
476
opts_out -> file_encoding = pg_char_to_encoding (defGetString (defel ));
512
477
if (opts_out -> file_encoding < 0 )
513
478
ereport (ERROR ,
0 commit comments