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

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed.
Date: 2016-11-03 04:27:03
Message-ID: CAJrrPGcNnO8jS7ZThypFYAb=KTM1PeByiKXGh73DpWGbBheAcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, Nov 1, 2016 at 8:05 PM, Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:

> On Tue, Nov 1, 2016 at 12:40 PM, Haribabu Kommi
> <kommi(dot)haribabu(at)gmail(dot)com> wrote:
> > 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.
>
> I agree it will be complex..
> >
> > Attached is the updated patch with doc changes.
>
> Now since we are adding support for INSTEAD OF TRIGGER in COPY FROM
> command, It will be good that we provide a HINT to user if INSTEAD of
> trigger does not exist, like we do in case of insert ?
>
> INSERT case:
> postgres=# insert into ttt_v values(7);
> 2016-11-01 14:31:39.845 IST [72343] ERROR: cannot insert into view "ttt_v"
> 2016-11-01 14:31:39.845 IST [72343] DETAIL: Views that do not select
> from a single table or view are not automatically updatable.
> 2016-11-01 14:31:39.845 IST [72343] HINT: To enable inserting into
> the view, provide an INSTEAD OF INSERT trigger or an unconditional ON
> INSERT DO INSTEAD rule.
>
> COPY case:
> postgres=# COPY ttt_v FROM stdin;
> 2016-11-01 14:31:52.235 IST [72343] ERROR: cannot copy to view "ttt_v"
> 2016-11-01 14:31:52.235 IST [72343] STATEMENT: COPY ttt_v FROM stdin;

Thanks for your suggestion. Yes, I agree that adding a hint is good.
Updated patch is attached with addition of hint message.

2016-11-03 14:56:28.685 AEDT [7822] ERROR: cannot copy to view "ttt_v"
2016-11-03 14:56:28.685 AEDT [7822] HINT: To enable copy to view, provide
an INSTEAD OF INSERT trigger
2016-11-03 14:56:28.685 AEDT [7822] STATEMENT: COPY ttt_v FROM stdin;

Regards,
Hari Babu
Fujitsu Australia

Attachment Content-Type Size
copy_to_view_2.patch application/octet-stream 5.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dilip Kumar 2016-11-03 06:23:50 Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed.
Previous Message Tom Lane 2016-11-02 19:53:10 Re: BUG #14404: High row estimates when query uses master inherited tables

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2016-11-03 05:19:47 Re: WIP: [[Parallel] Shared] Hash
Previous Message Chapman Flack 2016-11-03 03:10:15 who calls InitializeTimeouts() ?