[HACKERS] PartitionSchemaData & partcollation (Re: [COMMITTERS] pgsql:Associate partitioning information with each RelOptInfo.) - Mailing list pgsql-hackers

From Amit Langote
Subject [HACKERS] PartitionSchemaData & partcollation (Re: [COMMITTERS] pgsql:Associate partitioning information with each RelOptInfo.)
Date
Msg-id 571d159d-ca5e-ab0a-1bbf-2cef66ba0e42@lab.ntt.co.jp
Whole thread Raw
Responses Re: [HACKERS] PartitionSchemaData & partcollation (Re: [COMMITTERS]pgsql: Associate partitioning information with each RelOptInfo.)  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Re: [HACKERS] PartitionSchemaData & partcollation (Re: [COMMITTERS]pgsql: Associate partitioning information with each RelOptInfo.)  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
List pgsql-hackers
On 2017/09/21 12:42, Robert Haas wrote:
> Associate partitioning information with each RelOptInfo.
> 
> This is not used for anything yet, but it is necessary infrastructure
> for partition-wise join and for partition pruning without constraint
> exclusion.
> 
> Ashutosh Bapat, reviewed by Amit Langote and with quite a few changes,
> mostly cosmetic, by me.  Additional review and testing of this patch
> series by Antonin Houska, Amit Khandekar, Rafia Sabih, Rajkumar
> Raghuwanshi, Thomas Munro, and Dilip Kumar.

I noticed that this commit does not add partcollation field to
PartitionSchemeData, while it adds parttypcoll.  I think it'd be necessary
to have partcollation too, because partitioning would have used the same,
not parttypcoll.  For, example see the following code in
partition_rbound_datum_cmp:

        cmpval = DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[i],
                                                 key->partcollation[i],
                                                 rb_datums[i],
                                                 tuple_datums[i]));

So, it would be wrong to use parttypcoll, if we are to use the collation
to match a clause with the partition bounds when doing partition-pruning.
Concretely, a clause's inputcollid should match partcollation for the
corresponding column, not the column's parttypcoll.

Attached is a patch that adds the same.  I first thought of including it
in the partition-pruning patch set [1], but thought we could independently
fix this.

Thoughts?

Thanks,
Amit

[1] https://commitfest.postgresql.org/14/1272/

-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Attachment

pgsql-hackers by date:

Previous
From: tushar
Date:
Subject: Re: [HACKERS] Binary search in fmgr_isbuiltin() is a bottleneck.
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] PartitionSchemaData & partcollation (Re: [COMMITTERS]pgsql: Associate partitioning information with each RelOptInfo.)