Re: [HACKERS] INSERT ON CONFLICT and partitioned tables

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] INSERT ON CONFLICT and partitioned tables
Date: 2017-12-01 07:44:33
Message-ID: 32dccd3d-bdd1-9120-5b6e-32a9296a3bb1@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/12/01 11:01, Amit Langote wrote:
> On 2017/12/01 1:02, Robert Haas wrote:
>> Second, this would be the first place where the second argument to
>> ExecOpenIndices() is passed simply as true. The only other caller
>> that doesn't pass constant false is in nodeModifyTable.c and looks
>> like this:
>>
>> ExecOpenIndices(resultRelInfo, mtstate->mt_onconflict != ONCONFLICT_NONE);
>>
>> The intention here appears to be to avoid the overhead of doing
>> BuildSpeculativeIndexInfo() when it isn't needed. I think we should
>> try to do the same thing here. As written, the patch will do that
>> work even when the query has no ON CONFLICT clause, which doesn't seem
>> like a good idea.
>
> Agreed. One thing though is that ExecSetupPartitionTupleRouting doesn't
> receive the mtstate today. I've a patch pending that will re-design that
> interface (for another project) that I will post in the near future, but
> meanwhile let's just add a new parameter mtstate so that this patch can
> move forward with its business. The future patch I'm talking about will
> keep the parameter intact, so it should be OK now to add the same.
>
> Attached two patches:
>
> 0001: refactoring to add the mtstate parameter
> 0002: the original patch updated to address the above comment

I forgot to consider the fact that mtstate could be NULL in
ExecSetupPartitionTupleRouting(), so would result in dereferencing NULL
pointer when called from CopyFrom(), which fixed in the attached updated
patch.

Thanks,
Amit

Attachment Content-Type Size
0001-Pass-mtstate-to-ExecSetupPartitionTupleRouting.patch text/plain 2.6 KB
0002-Allow-ON-CONFLICT-DO-NOTHING-form-on-partitioned-tab.patch text/plain 6.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2017-12-01 08:39:10 Re: [HACKERS] [PATCH] Incremental sort
Previous Message Rajkumar Raghuwanshi 2017-12-01 06:36:00 Re: [HACKERS] Partition-wise join for join between (declaratively) partitioned tables