Re: inserts into partitioned table may cause crash

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: inserts into partitioned table may cause crash
Date: 2018-03-09 11:18:08
Message-ID: 5AA26D70.2010007@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

(2018/03/06 21:26), Etsuro Fujita wrote:
> One thing I notice while working on this is this in ExecInsert/CopyFrom,
> which I moved to ExecPrepareTupleRouting as-is for the former:
>
> /*
> * If we're capturing transition tuples, we might need to convert from the
> * partition rowtype to parent rowtype.
> */
> if (mtstate->mt_transition_capture != NULL)
> {
> if (resultRelInfo->ri_TrigDesc &&
> (resultRelInfo->ri_TrigDesc->trig_insert_before_row ||
> resultRelInfo->ri_TrigDesc->trig_insert_instead_row))
> {
> /*
> * If there are any BEFORE or INSTEAD triggers on the partition,
> * we'll have to be ready to convert their result back to
> * tuplestore format.
> */
> mtstate->mt_transition_capture->tcs_original_insert_tuple = NULL;
> mtstate->mt_transition_capture->tcs_map =
> TupConvMapForLeaf(proute, rootRelInfo, leaf_part_index);
> }
>
> Do we need to consider INSTEAD triggers here? The partition is either a
> plain table or a foreign table, so I don't think it can have those
> triggers. Am I missing something?

There seems to be no objections, so I removed the INSTEAD-trigger
condition from this. Here are updated patches for PG10 and HEAD.

Other changes:
* Add regression tests based on your test cases shown upthread
* Adjust code/comments a little bit

Best regards,
Etsuro Fujita

Attachment Content-Type Size
ExecInsert-reset-estate-result-rel-HEAD-v2.patch text/x-diff 15.7 KB
ExecInsert-reset-estate-result-rel-10backpatch-v2.patch text/x-diff 13.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2018-03-09 11:55:46 Re: [HACKERS] Another oddity in handling of WCO constraints in postgres_fdw
Previous Message Ashutosh Bapat 2018-03-09 10:51:09 Re: [HACKERS] Partition-wise aggregation/grouping