From 2c05d4a955058526a130a5306e792d6e24ad32e3 Mon Sep 17 00:00:00 2001 From: Joel Jacobson Date: Tue, 15 Oct 2024 02:29:11 +0200 Subject: [PATCH 09/16] Separate HEADER option validation into its own section. --- src/backend/commands/copy.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index cd80548324..025a4da15d 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -845,18 +845,25 @@ ProcessCopyOptions(ParseState *pstate, /* No default for default_print; remains NULL */ } + /* --- HEADER option --- */ + if (header_specified) + { + if (opts_out->format == COPY_FORMAT_BINARY) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + /*- translator: %s is the name of a COPY option, e.g. ON_ERROR */ + errmsg("cannot specify %s in BINARY mode", "HEADER"))); + } + else + { + /* Default is no header; no action needed */ + } + /* * Check for incompatible options (must do these three before inserting * defaults) */ - /* Check header */ - if (opts_out->format == COPY_FORMAT_BINARY && opts_out->header_line) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /*- translator: %s is the name of a COPY option, e.g. ON_ERROR */ - errmsg("cannot specify %s in BINARY mode", "HEADER"))); - /* Check force_quote */ if (opts_out->format != COPY_FORMAT_CSV && (opts_out->force_quote || opts_out->force_quote_all)) -- 2.45.1