Re: COPY TO (FREEZE)?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, rjuju123(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY TO (FREEZE)?
Date: 2023-10-29 01:39:53
Message-ID: 2027931.1698543593@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> My apologies, wrong patch attached, right one attached now.

I think this one is fine as-is:

/* Only single-byte delimiter strings are supported. */
if (strlen(opts_out->delim) != 1)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("COPY delimiter must be a single one-byte character")));

While we have good implementation reasons for this restriction,
there's nothing illogical about wanting the delimiter to be more
general. It's particularly silly, from an end-user's standpoint,
that for example 'é' is an allowed delimiter in LATIN1 encoding
but not when the server is using UTF8. So I don't see how the
distinction you presented justifies this change.

+ if (opts_out->freeze && !is_from)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY freeze only available using COPY FROM")));

Not thrilled by the wording here. I don't like the fact that the
keyword FREEZE isn't capitalized, and I think you omitted too many
words for intelligibility to be preserved. Notably, all the adjacent
examples use "must" or "must not", and this decides that that can be
omitted.

I realize that you probably modeled the non-capitalization on nearby
messages like "COPY delimiter", but there's a difference IMO:
"delimiter" can be read as an English noun, but it's hard to read
"freeze" as a noun.

How about, say,

errmsg("COPY FREEZE must not be used in COPY TO")));

or perhaps that's redundant and we could write

errmsg("FREEZE option must not be used in COPY TO")));

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2023-10-29 01:47:03 Re: COPY TO (FREEZE)?
Previous Message Bruce Momjian 2023-10-29 00:41:14 Re: COPY TO (FREEZE)?