Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxSmh-0012Vu-Gc for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Oct 2023 13:58:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qxSmf-00ETuD-RB for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Oct 2023 13:58:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxSmf-00ETu3-F4 for pgsql-hackers@lists.postgresql.org; Mon, 30 Oct 2023 13:58:25 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxSmc-003pmE-Jm for pgsql-hackers@postgresql.org; Mon, 30 Oct 2023 13:58:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=CCKi0hu4zpGEMBIFbgAKT16G2rGqQvj2/6ND6fwHReA=; b=QNMt9 L5kUPxuYVHial5Zd8HbLt2UmYciQh6X1xXb/FEDHwFDyjbB8tkaiKlXULHLnflzOsolaqa81UU5Vp JxZvgTXZI4Ensl6KzAUk+hdHjVUoCxYodhCpzU5Px8cIfR1ZuH01kL41Y+OcIj6q690vShdwe4NKx Vk0s8kvRmI4NMik9mXNzgBOlkLAOdLwgewugoc7ED3GCWiz0eJWDWxCjjXSzS/GOz6IcmG/WJgo1h DZBg5tdw1fc7tnEdOOm8a3CaxBUE08QR4CD85BbtFF5DEqVyKs20fv1XnizfrmHyHx0VtQ5b2ih0l aCqju0UWpaQB0lPsWbJmjyBCrCb2w==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qxSma-00EnBD-1f; Mon, 30 Oct 2023 09:58:20 -0400 Date: Mon, 30 Oct 2023 09:58:20 -0400 From: Bruce Momjian To: Kyotaro Horiguchi Cc: zmlpostgres@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org, rjuju123@gmail.com Subject: Re: COPY TO (FREEZE)? Message-ID: References: <20231030.151658.744161460517379332.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yookP34fCGbAERMJ" Content-Disposition: inline In-Reply-To: <20231030.151658.744161460517379332.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yookP34fCGbAERMJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 30, 2023 at 03:16:58PM +0900, Kyotaro Horiguchi wrote: > At Sun, 29 Oct 2023 15:35:02 -0400, Bruce Momjian wrote in > > You are 100% correct. Updated patch attached. > > - errmsg("COPY force not null only available using COPY FROM"))); > + errmsg("COPY force not null cannot be used with COPY TO"))); > > I find the term "force not null" hard to translate, especially into > Japaese, as its literal translation doesn't align with the entire > message. The most recent translation for it is the literal rendition > of "FORCE_NOT_NULL option of COPY can only be used with COPY FROM". > > In short, for translation convenience, I would prefer if "force not > null" were "FORCE_NOT_NULL". That is a good point. I reviewed more of the messages and added capitalization where appropriate, patch attached. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --yookP34fCGbAERMJ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="freeze.diff" diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index d12ba96497..18ecc69c33 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -224,6 +224,7 @@ COPY { table_name [ ( COPY FREEZE on a partitioned table. + This option is only allowed in COPY FROM. 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..145315debe 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -671,7 +671,7 @@ ProcessCopyOptions(ParseState *pstate, if (!opts_out->csv_mode && opts_out->quote != NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY quote available only in CSV mode"))); + errmsg("COPY QUOTE available only in CSV mode"))); if (opts_out->csv_mode && strlen(opts_out->quote) != 1) ereport(ERROR, @@ -687,7 +687,7 @@ ProcessCopyOptions(ParseState *pstate, if (!opts_out->csv_mode && opts_out->escape != NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY escape available only in CSV mode"))); + errmsg("COPY ESCAPE available only in CSV mode"))); if (opts_out->csv_mode && strlen(opts_out->escape) != 1) ereport(ERROR, @@ -698,46 +698,52 @@ ProcessCopyOptions(ParseState *pstate, if (!opts_out->csv_mode && (opts_out->force_quote || opts_out->force_quote_all)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force quote available only in CSV mode"))); + errmsg("COPY FORCE_QUOTE available only in CSV mode"))); if ((opts_out->force_quote || opts_out->force_quote_all) && is_from) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force quote only available using COPY TO"))); + errmsg("COPY FORCE_QUOTE cannot be used with COPY FROM"))); /* Check force_notnull */ if (!opts_out->csv_mode && opts_out->force_notnull != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force not null available only in CSV mode"))); + 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) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force null available only in CSV mode"))); + errmsg("COPY FORCE_NULL available only in CSV mode"))); 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), - errmsg("COPY delimiter must not appear in the NULL specification"))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("COPY delimiter character 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 cannot be used with COPY TO"))); + 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..6d2fc21518 100644 --- a/src/test/regress/expected/copy2.out +++ b/src/test/regress/expected/copy2.out @@ -83,17 +83,17 @@ ERROR: cannot specify DELIMITER in BINARY mode COPY x to stdin (format BINARY, null 'x'); ERROR: cannot specify NULL in BINARY mode COPY x to stdin (format TEXT, force_quote(a)); -ERROR: COPY force quote available only in CSV mode +ERROR: COPY FORCE_QUOTE available only in CSV mode COPY x from stdin (format CSV, force_quote(a)); -ERROR: COPY force quote only available using COPY TO +ERROR: COPY FORCE_QUOTE cannot be used with COPY FROM COPY x to stdout (format TEXT, force_not_null(a)); -ERROR: COPY force not null available only in CSV mode +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 +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 --yookP34fCGbAERMJ--