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 1qwutS-00F4hq-79 for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Oct 2023 01:47:10 +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 1qwutQ-006Chp-T0 for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Oct 2023 01:47:08 +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 1qwutQ-006Chg-At for pgsql-hackers@lists.postgresql.org; Sun, 29 Oct 2023 01:47:08 +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 1qwutN-003T9v-74 for pgsql-hackers@postgresql.org; Sun, 29 Oct 2023 01:47:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description; bh=ny3LXud4CNHZeTi+te0imLFqUHNXh4raj8pPdU+//+o=; b=0pCylZ9i8JA8MjJxpeIfRcb+ZE huES1+hSCnXWcfkhx4+H5VC0CPJJyJZBnERtki2rRlrwOOkOvv0bCyMd61LD7/pMpKHA+qi6D9/r2 x1O5suAMwqW+4PSI8zf0oto6/BeRTRQaCnMmuVvncssWzLRuq2OUJ3uK/feB230E+5hwdAajtbx+S 2IND4++4AACB0XsaRW4f4J3bVMumFXUHvGfiwo8GBAASL0rXd4JeObhCY992mqri45zkRQhGlDPh8 ynYUyIUMTXxkM9hd0RAmEl/o9cMK3tJ+ZNmE1nJeVRTUq10mFGNBuZKi3qBVRq0/5qbypo4hfuURE KFFgoMJQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qwutL-009nKj-18; Sat, 28 Oct 2023 21:47:03 -0400 Date: Sat, 28 Oct 2023 21:47:03 -0400 From: Bruce Momjian To: Tom Lane Cc: Kyotaro Horiguchi , rjuju123@gmail.com, pgsql-hackers@postgresql.org Subject: Re: COPY TO (FREEZE)? Message-ID: References: <20220802.133046.1941977979333284049.horikyota.ntt@gmail.com> <20220802061746.4jjwudlkszpaqhbg@jrouhaud> <20220802.171735.1109220976200931645.horikyota.ntt@gmail.com> <2027931.1698543593@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Ms5XzAE17TYmUgrg" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2027931.1698543593@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Ms5XzAE17TYmUgrg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Oct 28, 2023 at 09:39:53PM -0400, Tom Lane wrote: > Bruce Momjian 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. Agreed, my mistake. > + 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 think it is modeled after: errmsg("COPY force null only available using COPY FROM"))); > 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"))); I now have: errmsg("COPY FREEZE mode only available using COPY FROM"))); Updated patch attached. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --Ms5XzAE17TYmUgrg 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..82b65543c3 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 allowed only 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..92558b6bb0 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -728,16 +728,22 @@ ProcessCopyOptions(ParseState *pstate, /* 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 only available using COPY FROM"))); + if (opts_out->default_print) { if (!is_from) --Ms5XzAE17TYmUgrg--