Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD9zu-0003Ov-He for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 17:23:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kD9zt-0000yh-B6 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 17:23:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD9zt-0000ya-4I for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 17:23:05 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD9zq-0007x4-Dp for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 17:23:04 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kD9zo-0008Vg-9E; Tue, 01 Sep 2020 13:23:00 -0400 Date: Tue, 1 Sep 2020 13:23:00 -0400 From: Bruce Momjian To: Junfeng Yang Cc: "pgsql-hackers@postgresql.org" Subject: Re: Is it possible to set end-of-data marker for COPY statement. Message-ID: <20200901172300.GX13613@momjian.us> References: <20200901160502.GW13613@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901160502.GW13613@momjian.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Sep 1, 2020 at 12:05:02PM -0400, Bruce Momjian wrote: > > copy test from '/tmp/data' DELIMITER ','; > > > > An end-of-copy marker corrupt error will be raised. > > > > This requires users to escape the end-of-data marker manually in their data. > > Why we don't have a mechanism to define other characters as end-of-data marker? > > Or there are other ways to avoid escape the end-of-data in data? > > This is the first I am hearing of this. The problem is that the system > can't decide if \. is escaping a delimiter, or the end-of-copy marker. > I think we need to just disable period as a delimiter. I don't think > there is enough demand to allow the end-of-data marker to be > configurable. > > Interestingly, you can use period as s delimiter if you are copying from > a file that doesn't need an end-of-data marker and you never need to > escape the delimiter, but that seems like too rare a use case to allow > period to be supported as a delimiter. I am sorry I mis-read this email. The example uses _comma_ for the delimiter, rather than period. Let me reply again. We already disallow period for delimiters: COPY test TO '/u/postgres/tmp/x' WITH (DELIMITER '.'); ERROR: COPY delimiter cannot be "." COPY test TO STDOUT WITH (DELIMITER '.'); ERROR: COPY delimiter cannot be "." -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee