segfault with contrib lo

Lists: pgsql-hackers
From: Marc Cousin <cousinmarc(at)gmail(dot)com>
To: 'PostgreSQL Hackers' <pgsql-hackers(at)postgresql(dot)org>
Subject: segfault with contrib lo
Date: 2013-10-07 16:32:01
Message-ID: 2078938.ATyKPy5RM4@marco-dalibo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I was using the lo contrib a few days ago and wasn't paying attention, and
forgot the "for each row" in the create trigger command... PostgreSQL
segfaulted, when the trigger tried to access the row's attributes.

Please find attached a patch to control that the trigger is correctly defined
(as in the example): a before trigger, for each row, and a parameter (if the
parameter was omitted, it segfaulted too). I hope I did this correctly.

Regards,

Marc.

Attachment Content-Type Size
diff_lo text/x-patch 995 bytes

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Marc Cousin <cousinmarc(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: segfault with contrib lo
Date: 2013-10-08 16:28:46
Message-ID: CA+TgmoZxg9M68abs-Fst5q76b+RtBxbD2TZsoE7zNWmAWbRapA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Oct 7, 2013 at 12:32 PM, Marc Cousin <cousinmarc(at)gmail(dot)com> wrote:
> I was using the lo contrib a few days ago and wasn't paying attention, and
> forgot the "for each row" in the create trigger command... PostgreSQL
> segfaulted, when the trigger tried to access the row's attributes.
>
> Please find attached a patch to control that the trigger is correctly defined
> (as in the example): a before trigger, for each row, and a parameter (if the
> parameter was omitted, it segfaulted too). I hope I did this correctly.

Thanks for the patch. Please add it to the next CommitFest.

https://commitfest.postgresql.org/action/commitfest_view/open

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Marc Cousin <cousinmarc(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: segfault with contrib lo
Date: 2013-10-08 17:12:49
Message-ID: 3588560.iRHyKAKEcf@marco
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday 08 October 2013 12:28:46 Robert Haas wrote:
> On Mon, Oct 7, 2013 at 12:32 PM, Marc Cousin <cousinmarc(at)gmail(dot)com> wrote:
> > I was using the lo contrib a few days ago and wasn't paying attention, and
> > forgot the "for each row" in the create trigger command... PostgreSQL
> > segfaulted, when the trigger tried to access the row's attributes.
> >
> > Please find attached a patch to control that the trigger is correctly
> > defined (as in the example): a before trigger, for each row, and a
> > parameter (if the parameter was omitted, it segfaulted too). I hope I did
> > this correctly.
> Thanks for the patch. Please add it to the next CommitFest.
>
> https://commitfest.postgresql.org/action/commitfest_view/open
Done.


From: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>
To: Marc Cousin <cousinmarc(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: segfault with contrib lo
Date: 2013-11-23 11:50:49
Message-ID: CAD21AoB-kuW8JgRmqjEd7jiSkbdDWMnYTRHD9ychU3=s9Sxw0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 9, 2013 at 2:12 AM, Marc Cousin <cousinmarc(at)gmail(dot)com> wrote:
> On Tuesday 08 October 2013 12:28:46 Robert Haas wrote:
>> On Mon, Oct 7, 2013 at 12:32 PM, Marc Cousin <cousinmarc(at)gmail(dot)com> wrote:
>> > I was using the lo contrib a few days ago and wasn't paying attention, and
>> > forgot the "for each row" in the create trigger command... PostgreSQL
>> > segfaulted, when the trigger tried to access the row's attributes.
>> >
>> > Please find attached a patch to control that the trigger is correctly
>> > defined (as in the example): a before trigger, for each row, and a
>> > parameter (if the parameter was omitted, it segfaulted too). I hope I did
>> > this correctly.
>> Thanks for the patch. Please add it to the next CommitFest.
>>
>> https://commitfest.postgresql.org/action/commitfest_view/open
> Done.
>

Sorry for late response.
I tried the patch you attached.

It is simple patch, and works fine.
It is just my suggestion that error message shows name of trigger.

Regards,

-------
Sawada Masahiko


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>
Cc: Marc Cousin <cousinmarc(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: segfault with contrib lo
Date: 2013-11-24 03:51:25
Message-ID: 6436.1385265085@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> writes:
> On Mon, Oct 7, 2013 at 12:32 PM, Marc Cousin <cousinmarc(at)gmail(dot)com> wrote:
>>> I was using the lo contrib a few days ago and wasn't paying attention, and
>>> forgot the "for each row" in the create trigger command... PostgreSQL
>>> segfaulted, when the trigger tried to access the row's attributes.
>>>
>>> Please find attached a patch to control that the trigger is correctly
>>> defined (as in the example): a before trigger, for each row, and a
>>> parameter (if the parameter was omitted, it segfaulted too). I hope I did
>>> this correctly.

This looks good to me, except I see no reason for the trigger to refuse to
run as an AFTER trigger. It works fine like that (I checked), and in some
scenarios people might prefer to do it that way to be sure they're seeing
the final version of the update.

> Sorry for late response.
> I tried the patch you attached.
> It is simple patch, and works fine.
> It is just my suggestion that error message shows name of trigger.

That seemed like a good idea to me, so I made all the errors (not
just the new ones) do it.

Committed and back-patched.

regards, tom lane