Re: BUG #15552: Unexpected error in COPY to a foreign table in a transaction

Luis Carril <luis.carril@swarm64.com>

From: Luis Carril <luis.carril@swarm64.com>
To: Michael Paquier <michael@paquier.xyz>, Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>, PG Bug reporting form <noreply@postgresql.org>, Michael Paquier <michael.paquier@gmail.com>
Date: 2018-12-19T10:15:56Z
Lists: pgsql-bugs
Hi,

   I was not able to reproduce the error reported by Etsuro, for me on HEAD:


psql (12devel)
Type "help" for help.

postgres=# create table instead_of_insert_tbl(id serial, name text);
ERROR:  relation "instead_of_insert_tbl" already exists
postgres=#
postgres=# begin;
BEGIN
postgres=#
postgres=# create view instead_of_insert_tbl_view as select ''::text as str;
CREATE VIEW
postgres=#
postgres=# create function fun_instead_of_insert_tbl() returns trigger
postgres-# as $$ begin insert into instead_of_insert_tbl (name) values (new.str); return
postgres$# null; end;
postgres$# $$ language plpgsql;
CREATE FUNCTION
postgres=#
postgres=# create trigger trig_instead_of_insert_tbl_view instead of
postgres-# insert on instead_of_insert_tbl_view for each row execute procedure
postgres-# fun_instead_of_insert_tbl();
CREATE TRIGGER
postgres=#
postgres=# copy instead_of_insert_tbl_view from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> test1
>> \.
COPY 1



   Also, I created the CF entry with Michael's patch, following Amit's indications.


Cheers
Luis M Carril

Commits

  1. Disable WAL-skipping optimization for COPY on views

  2. Disable WAL-skipping optimization for COPY on views and foreign tables