public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bruce Momjian <[email protected]>
To: Mingli Zhang <[email protected]>
Cc: Kyotaro Horiguchi <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: COPY TO (FREEZE)?
Date: Sun, 29 Oct 2023 15:35:02 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CANG7CAKvcAeomd-M_FLsNjGTbuf=ovbw9nZGcd1hMcO7usZ6DQ@mail.gmail.com>
References: <20220802061746.4jjwudlkszpaqhbg@jrouhaud>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<CANG7CALFO7tVq=9tEyapAmPSwGBGThLqGJ63ZP12Ky-wBdupZQ@mail.gmail.com>
<CANG7CAKvcAeomd-M_FLsNjGTbuf=ovbw9nZGcd1hMcO7usZ6DQ@mail.gmail.com>
On Sun, Oct 29, 2023 at 02:50:37PM +0800, Mingli Zhang wrote:
> I guess you want to write “cannot be used with COPY TO”
You are 100% correct. Updated patch attached.
--
Bruce Momjian <[email protected]> https://momjian.us
EDB https://enterprisedb.com
Only you can decide what is important to you.
Attachments:
[text/x-diff] freeze.diff (3.4K, ../[email protected]/2-freeze.diff)
download | inline diff:
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
index d12ba96497..82b65543c3 100644
--- a/doc/src/sgml/ref/copy.sgml
+++ b/doc/src/sgml/ref/copy.sgml
@@ -224,6 +224,7 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
open and there are no older snapshots held by this transaction. It is
currently not possible to perform a <command>COPY FREEZE</command> on
a partitioned table.
+ This option is allowed only in <command>COPY FROM</command>.
</para>
<para>
Note that all other sessions will immediately be able to see the data
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index c5d7d78645..bb6d93627b 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -711,8 +711,8 @@ ProcessCopyOptions(ParseState *pstate,
errmsg("COPY force not null available only in CSV mode")));
if (opts_out->force_notnull != NIL && !is_from)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("COPY force not null only available using COPY FROM")));
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY force not null cannot be used with COPY TO")));
/* Check force_null */
if (!opts_out->csv_mode && opts_out->force_null != NIL)
@@ -722,22 +722,28 @@ ProcessCopyOptions(ParseState *pstate,
if (opts_out->force_null != NIL && !is_from)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("COPY force null only available using COPY FROM")));
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY force null cannot be used with COPY TO")));
/* Don't allow the delimiter to appear in the null string. */
if (strchr(opts_out->null_print, opts_out->delim[0]) != NULL)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("COPY delimiter must not appear in the NULL specification")));
/* Don't allow the CSV quote char to appear in the null string. */
if (opts_out->csv_mode &&
strchr(opts_out->null_print, opts_out->quote[0]) != NULL)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CSV quote character must not appear in the NULL specification")));
+ /* Check freeze */
+ if (opts_out->freeze && !is_from)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY FREEZE mode cannot be used with COPY FROM")));
+
if (opts_out->default_print)
{
if (!is_from)
diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out
index 95ec7363af..98ef2ef140 100644
--- a/src/test/regress/expected/copy2.out
+++ b/src/test/regress/expected/copy2.out
@@ -89,11 +89,11 @@ ERROR: COPY force quote only available using COPY TO
COPY x to stdout (format TEXT, force_not_null(a));
ERROR: COPY force not null available only in CSV mode
COPY x to stdin (format CSV, force_not_null(a));
-ERROR: COPY force not null only available using COPY FROM
+ERROR: COPY force not null cannot be used with COPY TO
COPY x to stdout (format TEXT, force_null(a));
ERROR: COPY force null available only in CSV mode
COPY x to stdin (format CSV, force_null(a));
-ERROR: COPY force null only available using COPY FROM
+ERROR: COPY force null cannot be used with COPY TO
-- too many columns in column list: should fail
COPY x (a, b, c, d, e, d, c) from stdin;
ERROR: column "d" specified more than once
view thread (11+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: COPY TO (FREEZE)?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox