Re: transition table behavior with inheritance appears broken (was: Declarative partitioning - another take)

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Kevin Grittner <kgrittn(at)gmail(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, David Fetter <david(at)fetter(dot)org>, Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: transition table behavior with inheritance appears broken (was: Declarative partitioning - another take)
Date: 2017-05-19 05:01:38
Message-ID: CAEepm=3gn3=gXRi94k1OQxSUKzqF_h+3K6XfFRheNXBLJ=aOdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 19, 2017 at 1:38 AM, Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
> On Thu, May 18, 2017 at 5:16 AM, Amit Langote
> <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>
>> Do we need to update documentation? Perhaps, some clarification on the
>> inheritance/partitioning behavior somewhere.
>
> Yeah, I think so.

Here is an attempt at documenting the situation in the CREATE TRIGGER
notes section.

>> - Assert((enrmd->reliddesc == InvalidOid) != (enrmd->tupdesc == NULL));
>> + Assert((enrmd->reliddesc == InvalidOid) !=
>> + (enrmd->tupdesc == NULL));
>>
>> Perhaps, unintentional change?
>
> Agreed; line is not long enough to need to wrap.

Fixed.

>> I'm not sure if it's significant for transition tables, but what if a
>> partition's BR trigger modified the tuple? Would we want to include the
>> modified version of the tuple in the transition table or the original as
>> the patch does? Same for the code in CopyFrom().
>
> Good spot! If the BR trigger on the child table modifies or
> suppresses the action, I strongly feel that must be reflected in the
> transition table. This needs to be fixed.

Gah. Right. In the attached version, there is a still an 'original
tuple' optimisation for insertions (avoiding parent -> child -> parent
conversion), but it's disabled if there are any BEFORE INSERT or
INSTEAD OF INSERT row-level triggers.

That's demonstrated by this part of the regression test, which
modifies the value inserted into the 'CCC' partition (and similar case
for COPY):

insert into parent values ('AAA', 42), ('BBB', 42), ('CCC', 66);
NOTICE: trigger = parent_stmt_trig, old table = <NULL>, new table =
(AAA,42), (BBB,42), (CCC,1066)

On Thu, May 18, 2017 at 10:16 PM, Amit Langote
<Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> +typedef struct TriggerTransitionState
> +{
> ...
> + bool ttf_delete_old_table;
>
> Just curious: why ttf_? TriggerTransition field?

Oops. Changed to "tts_". I had renamed this struct but not the members.

--
Thomas Munro
http://www.enterprisedb.com

Attachment Content-Type Size
transition-tuples-from-child-tables-v7.patch application/octet-stream 59.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-05-19 05:01:39 Re: [POC] hash partitioning
Previous Message Michael Paquier 2017-05-19 04:51:35 Re: [Bug fix]If recovery.conf has target_session_attrs=read-write, the standby fails to start.