Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed. - Mailing list pgsql-hackers

From Haribabu Kommi
Subject Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed.
Date
Msg-id CAJrrPGc2CFTvswkE_JCvq-5M7L83T5N4uOVEWy7XJXRLFBUEVA@mail.gmail.com
Whole thread Raw
Responses Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed.  (Dilip Kumar <dilipbalaut@gmail.com>)
List pgsql-hackers


On Tue, Nov 1, 2016 at 3:54 PM, Dilip Kumar <dilipbalaut@gmail.com> wrote:
On Tue, Oct 4, 2016 at 1:07 PM, Haribabu Kommi <kommi.haribabu@gmail.com> wrote:
> I think currently there is no handling of INSTEAD of triggers in the copy
> functionality.
>
> It didn't seem difficult to the support the same, until unless there are any
> problems for complext queries, so after adding the INSTEAD of triggers
> check and calling the ExecIRInsertTriggers function, the Copy is also
> working for the view.
>
> Attached is a POC patch of the same. I didn't checked all the possible
> scenarios.

We support insert into view in below 2 cases..

1. INSTEAD OF INSERT trigger
2. or an unconditional ON INSERT DO INSTEAD rule

Yes, I agree that the above are the two cases where the insert is possible
on a view other than updatable views.

 
In your patch we are supporting first one in COPY command, Will it not
be good to support second one also in COPY command ?


COPY command is treated as an UTILITY command, During the query
processing, the rules are not applied on the COPY command, and in the
execution of COPY command, it just inserts the data into the heap and 
indexes with direct calls.

I feel supporting the COPY command for the case-2 is little bit complex
and may not be that much worth.

Attached is the updated patch with doc changes.

Regards,
Hari Babu
Fujitsu Australia
Attachment

pgsql-hackers by date:

Previous
From: Mithun Cy
Date:
Subject: Re: Patch: Implement failover on libpq connect level.
Next
From: Rafia Sabih
Date:
Subject: Re: pgbench - allow backslash continuations in \set expressions