Re: Extend COPY FROM with HEADER <integer> to skip multiple lines

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extend COPY FROM with HEADER <integer> to skip multiple lines
Date: 2025-06-27 04:09:42
Message-ID: 20250627130942.f48ab7f5032e176f6af44775@sraoss.co.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 27 Jun 2025 12:22:17 +0900
Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:

> > However, your patch is clear, and it seems we don't need to worry about this concern.
> > Your patch looks good to me.
>
> Thanks for reviewing the patch! I've marked it as ready for committer.

I have a few minor comment on the patch.

+ if (ival < 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("%s requires a Boolean value, a non-negative "
+ "integer, or the string \"match\"",
+ def->defname)));

ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("%s requires a Boolean value or \"match\"",
+ errmsg("%s requires a Boolean value, a non-negative integer, "
+ "or the string \"match\"",
def->defname)));

These two pieces of code raise the same error, but with different error codes:
one returns ERRCODE_INVALID_PARAMETER_VALUE, while the other returns ERRCODE_SYNTAX_ERROR.

I believe the former is more appropriate, although the existing code uses the
latter. In any case, the error codes should be consistent.

Regarding the documentation, how about explicitly stating that when MATCH is specified, only
the first line is skipped? While this may seem obvious, it’s worth clarifying, as the semantics
of the HEADER option have become a bit more complex with this change.

Regards,
Yugo Nagata

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-06-27 04:17:19 Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Previous Message jian he 2025-06-27 04:08:35 pg_restore --no-policies should not restore policies' comment