Re: BUG #15437: Segfault during insert into declarative partitioned table with a trigger creating partition

From: Dmitry Shalashov <skaurus(at)gmail(dot)com>
To: Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15437: Segfault during insert into declarative partitioned table with a trigger creating partition
Date: 2018-10-19 09:38:09
Message-ID: CAKPeCUGE2VJD3Z7j7gTAZuEWW=z0hff-WNcwNNt=2KFt8ma+aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>> The problem here is with the server allowing to create a partition of the
>> table being inserted into, inside the table's BEFORE INSERT trigger.

That may be off-topic here, but I feel that *some* way of auto-creating
partitions would be useful though.
Maybe all partitioning setup could boil down to one table declaration, with
auto-created partitions of the same structure, including indices and stuff.

Dmitry Shalashov, relap.io & surfingbird.ru

--

Our news:

Relap is the Native advertisement network №1 in Russia
<https://adindex.ru/rating3/tech/172078/index.phtml#172106> and №3 by Video
<https://adindex.ru/rating3/tech/172078/index.phtml#172105>
We partnered with the Adblock Plus
<https://blog.relap.ru/2018/06/relap-adblock-plus/>
Weborama made quality audit
<https://adindex.ru/news/releases/2018/03/22/169924.phtml> of our inventory

пт, 19 окт. 2018 г. в 6:45, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>:

> On 2018/10/19 11:52, Tom Lane wrote:
> > Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> writes:
> >> On 2018/10/18 20:57, PG Bug reporting form wrote:
> >>> I tried to use declarative partitioning and, to avoid creating
> partitions by
> >>> hand, to make them in ON BEFORE STATEMENT trigger. Trigger executes
> >>> successfully (proved that with RAISE NOTICE), but server crashes.
> >
> >> The problem here is with the server allowing to create a partition of
> the
> >> table being inserted into, inside the table's BEFORE INSERT trigger.
> >> Generally speaking, the command that's run inside the trigger shouldn't
> >> have been allowed to proceed if it might change the table's properties
> >> that the execution of the ongoing command is depending upon.
> >
> > Check.
> >
> >> I propose the attached to fix that.
> >
> > Hmm ... I wonder if we shouldn't do CheckTableNotInUse for *both* cases,
> > is_partition or no?
>
> Yeah, that would be better robustness-wise, but I couldn't think of a case
> where not doing CheckTableNotInUse for the !is_partition case would be
> problematic. Adding an inheritance child doesn't change the relcache
> content of the parent table, but for partitioning it does. Maybe I'm
> missing something though.
>
> Attached updated patch adds the check for both cases, although I'm not
> sure what the error message text added by the patch should look like. Is
> the following OK?
>
> CheckTableNotInUse(relation, "CREATE TABLE INHERITS / PARTITION OF");
>
> Thanks,
> Amit
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dmitry Shalashov 2018-10-19 09:43:24 Re: BUG #15437: Segfault during insert into declarative partitioned table with a trigger creating partition
Previous Message PG Bug reporting form 2018-10-19 08:06:41 BUG #15442: Error in uninstalling PostgreSQL