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 1kDAam-00055y-4I for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 18:01:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDAal-0002lM-0a for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 18:01:11 +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 1kDAak-0002lE-Q2 for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 18:01:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDAai-0008PY-NU for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 18:01:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 081I16ba141883; Tue, 1 Sep 2020 14:01:06 -0400 From: Tom Lane To: Bruce Momjian cc: Junfeng Yang , "pgsql-hackers@postgresql.org" Subject: Re: Is it possible to set end-of-data marker for COPY statement. In-reply-to: <20200901172550.GY13613@momjian.us> References: <20200901172550.GY13613@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Tue, 01 Sep 2020 13:25:50 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <141881.1598983266.1@sss.pgh.pa.us> Date: Tue, 01 Sep 2020 14:01:06 -0400 Message-ID: <141882.1598983266@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce Momjian writes: > On Tue, Sep 1, 2020 at 06:14:45AM +0000, Junfeng Yang wrote: >> Data in file "/tmp/data". >> >> 122,as\.d,adad >> 133,sa dad,adadad > So, you are using comma as the delimiter, but have \. (backslash-period) > as a data value. You need to double-up backslashes in your input data, > no matter what is after the backslash. You just happen to hit backslash > period, but other things like \N could cause problems --- literal > backslashes have to be doubled. As mentioned upthread, using CSV format might work better. In CSV you aren't necessarily stuck with backslash being treated as an escape character. regards, tom lane