pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: Etsuro Fujita <etsuro.fujita@gmail.com>
Cc: PostgreSQL-Dev <pgsql-hackers@postgresql.org>
Subject: Re: [POC] Fast COPY FROM command for the table with foreign partitions
Date: Mon, 21 Sep 2020 14:20:16 +0300
Message-ID: <2a33a068-749c-4c18-ba74-bd6fbf37abce@postgrespro.ru> (raw)
In-Reply-To: <CA+HiwqF7TH0AuJ11L41StEzNeoOnYd6COGHMakM=kZWZLa-ELA@mail.gmail.com>
References: <ae25e79e-6122-720e-1349-fb832c6021df@postgrespro.ru>
	<CA+HiwqHtQaZp_t5M3z1+M0T9zd=0s3r_oOmi9TxHDdyW0_cxvg@mail.gmail.com>
	<ab62d228-cf9a-e517-8667-7df1184adf2a@postgrespro.ru>
	<CA+HiwqG1o5BDi0Hx6Uoxteyra2FbiSvaN4Fzs-i0pfKo1Zp_fg@mail.gmail.com>
	<CA+HiwqHT9UFhVHyKsavL5u=iVdW9k92pHHN=FYL0sEysGtvYsw@mail.gmail.com>
	<20200907072651.GF4867@paquier.xyz>
	<19ba27e7-ee1e-9117-68ad-fd609b5763ca@postgrespro.ru>
	<CA+HiwqEoSMpzMhzz1Dv7qFsFtzG71t5Wrgy4F+MoVUVR_5HdDQ@mail.gmail.com>
	<0c67618c2e43b1dccb260dd6f90eeac2@postgrespro.ru>
	<CA+HiwqHhdBcYRxhUUK7FRSWoQxe8met8fDvN=fhooH9x5dU35A@mail.gmail.com>
	<d3fbf3bc93b7bcd99ff7fa9ee41e0e20@postgrespro.ru>
	<27e119ab-70a4-a08a-deb2-d882e2ce9435@postgrespro.ru>
	<21741c8e5df397d88e9eff3e741baf91@postgrespro.ru>
	<CA+HiwqHeEOB0wgUhM85fqjC-_=Pj3ystvFHvxKvtuA0_4sp2tA@mail.gmail.com>
	<da7ed3f5-b596-2549-3710-4cc2a602ec17@postgrespro.ru>
	<CA+HiwqF7TH0AuJ11L41StEzNeoOnYd6COGHMakM=kZWZLa-ELA@mail.gmail.com>

This patch currently looks very ready for use. And I'm taking a close 
look at the error reporting. Here we have difference in behavior of 
local and foreign table:

regression test in postgres_fdw.sql:
copy rem2 from stdin;
-1	xyzzy
\.

reports error (1):
=================
ERROR:  new row for relation "loc2" violates check constraint...
DETAIL:  Failing row contains (-1, xyzzy).
CONTEXT:  COPY loc2, line 1: "-1	xyzzy"
remote SQL command: COPY public.loc2(f1, f2) FROM STDIN
COPY rem2, line 2

But local COPY into loc2 reports another error (2):
===================================================
copy loc2 from stdin;
ERROR:  new row for relation "loc2" violates check constraint...
DETAIL:  Failing row contains (-1, xyzzy).
CONTEXT:  COPY loc2, line 1: "-1	xyzzy"

Report (2) is shorter and more specific.
Report (1) contains meaningless information.

Maybe we need to improve error report? For example like this:
ERROR: Failed COPY into foreign table "rem2":
new row for relation "loc2" violates check constraint...
DETAIL:  Failing row contains (-1, xyzzy).
remote SQL command: COPY public.loc2(f1, f2) FROM STDIN
COPY rem2, line 1

The problem here is that we run into an error after the COPY FROM 
command completes. And we need to translate lineno from foreign server 
to lineno of overall COPY command.

-- 
regards,
Andrey Lepikhov
Postgres Professional





view thread (84+ messages)  latest in thread

Message-ID: <2a33a068-749c-4c18-ba74-bd6fbf37abce@postgrespro.ru>
Permalink:  ../2a33a068-749c-4c18-ba74-bd6fbf37abce@postgrespro.ru/
Also on:    postgresql.org/message-id/2a33a068-749c-4c18-ba74-bd6fbf37abce@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.lepikhov@postgrespro.ru, amitlangote09@gmail.com, a.kondratov@postgrespro.ru, michael@paquier.xyz, ashutosh.bapat@2ndquadrant.com, ashutosh.bapat.oss@gmail.com, etsuro.fujita@gmail.com
  Subject: Re: [POC] Fast COPY FROM command for the table with foreign partitions
  In-Reply-To: <2a33a068-749c-4c18-ba74-bd6fbf37abce@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox