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 1oNSfa-00070P-EL for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2022 05:29:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oNSfZ-0007mt-4X for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2022 05:29: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 1oNSfY-0007mk-Lh for pgsql-hackers@lists.postgresql.org; Mon, 15 Aug 2022 05:29:44 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oNSfT-0001cJ-7a for pgsql-hackers@postgresql.org; Mon, 15 Aug 2022 05:29:44 +0000 Received: from [192.168.129.213] (unknown [91.205.25.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id BD32121C04FE; Mon, 15 Aug 2022 08:29:37 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1660541378; bh=wl6Wzi3ZtUV3Nb9UDSmzF10R8suZsKIU2hJhdgK8dr0=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=M4bCGLIa2wvk6QTiC+XpiukuLqA8gS5372P8GYUCcxpEqxBuqpEMnxkRT8jvF/pEf +bziSTfeE1GhGKpkhWItCu3kg3GePmmqJ/62KnKokuu9waAvU4GGwDOA39uTjnOCdy Od6yzPKvWgGuuAvKydU7JWmJlIofWkzYaVv4lnZw= Message-ID: <9b293a07-c822-a326-6ff2-4a9e0e9e5549@postgrespro.ru> Date: Mon, 15 Aug 2022 10:29:22 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Fast COPY FROM based on batch insert Content-Language: en-US To: Etsuro Fujita Cc: Justin Pryzby , Zhihong Yu , Amit Langote , tanghy.fnst@fujitsu.com, Ashutosh Bapat , Pg Hackers , Tomas Vondra , houzj.fnst@fujitsu.com References: <20210409004956.GN6592@telsasoft.com> <45ad1b94-339b-a841-8885-67ebe6fc5bc1@postgrespro.ru> <57733596-5fd6-07ec-d65c-67411411f10e@postgrespro.ru> <05bc8819-3e53-d884-a0d0-a17ffa5febef@postgrespro.ru> <09ff35ff-291f-d9e9-a0ed-55e6bb9732fc@postgrespro.ru> From: Andrey Lepikhov Organization: Postgres Professional In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/9/22 16:44, Etsuro Fujita wrote: >>> -1 foo >>> 1 bar >>> \. > ERROR: new row for relation "t1" violates check constraint "t1_f1positive" > DETAIL: Failing row contains (-1, foo). > CONTEXT: remote SQL command: INSERT INTO public.t1(f1, f2) VALUES > ($1, $2), ($3, $4) > COPY ft1, line 3 > > In single-insert mode the error context information is correct, but in > batch-insert mode it isn’t (i.e., the line number isn’t correct). > > The error occurs on the remote side, so I'm not sure if there is a > simple fix. What I came up with is to just suppress error context > information other than the relation name, like the attached. What do > you think about that? I've spent many efforts to this problem too. Your solution have a rationale and looks fine. I only think, we should add a bit of info into an error report to simplify comprehension why don't point specific line here. For example: 'COPY %s (buffered)' or 'COPY FOREIGN TABLE %s' or, if instead of relname_only field to save a MultiInsertBuffer pointer, we might add min/max linenos into the report: 'COPY %s, line between %llu and %llu' -- Regards Andrey Lepikhov Postgres Professional