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 1ocnmw-0007W4-70 for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Sep 2022 13:04:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ocnmv-0000O1-1I for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Sep 2022 13:04:45 +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 1ocnmu-0000Ni-Nu for pgsql-hackers@lists.postgresql.org; Mon, 26 Sep 2022 13:04:44 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocnmr-0007sv-Tx for pgsql-hackers@postgresql.org; Mon, 26 Sep 2022 13:04:44 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id BE8D960172; Mon, 26 Sep 2022 22:04:36 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.7 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 26 Sep 2022 22:04:36 +0900 From: torikoshia To: Damir Belyalov Cc: PostgreSQL Hackers , a.lepikhov@postgrespro.ru Subject: Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features) In-Reply-To: References: <1197371508.4255.1327.camel@ebony.site> <1197660423.1536.8.camel@dell.linuxdev.us.dell.com> <15007.1197674561@sss.pgh.pa.us> <200712141830.16877.trent_shipley@qwest.net> <87k31ftoe0.fsf_-_@commandprompt.com> <686e46d6718f9535bc39fac7cad7408b@oss.nttdata.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <769423519e16d18a1e7611c6931da58b@oss.nttdata.com> X-Sender: torikoshia@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-09-21 21:11, Damir Belyalov wrote: Thanks for updating patch. > In the previous patch there was an error when processing constraints. > The patch was fixed, but the code grew up and became more complicated > (0005-COPY_IGNORE_ERRORS). I also simplified the logic of > safeNextCopyFrom(). > You asked why we need subtransactions, so the answer is in this patch. > When processing a row that does not satisfy constraints or INSTEAD OF > triggers, it is necessary to rollback the subtransaction and return > the table to its original state. > Cause of complexity, I had to abandon the constraints, triggers > processing in and handle only errors that occur when reading the file. > Attaching simplified patch (0006-COPY_IGNORE_ERRORS). Do you mean you stop dealing with errors concerned with constraints and triggers and we should review 0006-COPY_IGNORE_ERRORS? > Tried to implement your error and could not. The result was the same > as COPY FROM implements. Hmm, I applied v6 patch and when canceled COPY by sending SIGINT(ctrl + C), I faced the same situation as below. I tested it on CentOS 8.4. =# COPY test FROM '/home/tori/pgsql/master/10000000.data' WITH (IGNORE_ERRORS); ^CCancel request sent ERROR: canceling statement due to user request CONTEXT: COPY test, line 628000: "628000 xxx" =# SELECT 1; ERROR: current transaction is aborted, commands ignored until end of transaction block =# ABORT; FATAL: UserAbortTransactionBlock: unexpected state STARTED server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded. I did the same procedure on COPY FROM without IGNORE_ERRORS and didn't face this situation. -- Regards, -- Atsushi Torikoshi NTT DATA CORPORATION