Re: Constraint merge and not valid status - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: Constraint merge and not valid status
Date
Msg-id 20160726.110527.172830280.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: Constraint merge and not valid status  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: Constraint merge and not valid status  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
Hello,

At Mon, 25 Jul 2016 18:21:27 +0900, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote in
<96fb8bca-57f5-e5a8-9630-79d4fc5b213e@lab.ntt.co.jp>
> 
> Hello,
> 
> On 2016/07/25 17:18, Kyotaro HORIGUCHI wrote:
> > 
> >  - Remove ccvalid condition from equalTupleDescs() to reduce
> >    unnecessary cache invalidation or tuple rebuilding.
> 
> The following commit introduced the ccvalid check:
> 
> """
> commit c31305de5f5a4880b0ba2f5983025ef0210a3b2a
> Author: Noah Misch <noah@leadboat.com>
> Date:   Sun Mar 23 02:13:43 2014 -0400
> 
> Address ccvalid/ccnoinherit in TupleDesc support functions.
> 
> equalTupleDescs() neglected both of these ConstrCheck fields, and
> CreateTupleDescCopyConstr() neglected ccnoinherit.  At this time, the
> only known behavior defect resulting from these omissions is constraint
> exclusion disregarding a CHECK constraint validated by an ALTER TABLE
> VALIDATE CONSTRAINT statement issued earlier in the same transaction.
> Back-patch to 9.2, where these fields were introduced.
> """

Wow.. Missed the obvious thing. Certainly relation cache must be
invalidated by a change of ccvalidated as the commit message.

> So, apparently RelationClearRelation() does intend to discard a cached
> TupleDesc if ccvalid changed in a transaction.  Whereas,
> acquire_inherited_sample_rows() does not seem to depend on ccvalid being
> equal or not (or any member of TupleConstr for that matter).  So maybe,
> instead of simply discarding the check (which does serve a purpose), we
> could make equalTupleDescs() parameterized on whether we want TupleConstr
> equality check to be performed or not.  RelationClearRelation() can ask
> for the check to be performed by passing true for the parameter whereas
> acquire_inherited_sample_rows() and other callers can pass false.  Perhaps
> something like the attached.

Hmm. It should resolve the problem. But the two comparisons seem
to be separate things. Constraints is not a part of tuple
description. relcache seems to be making misusage of the equality
of tuple descriptors.

So, how about splitting the original equalTupleDescs into
equalTupleDescs and equalTupleConstraints ?

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH v12] GSSAPI encryption support
Next
From: Michael Paquier
Date:
Subject: Re: AdvanceXLInsertBuffer vs. WAL segment compressibility