Re: Partition-wise join for join between (declaratively) partitioned tables

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Partition-wise join for join between (declaratively) partitioned tables
Date: 2017-03-14 00:58:28
Message-ID: a2ec8003-4591-1295-df7e-d04506ae295a@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/03/14 9:17, Robert Haas wrote:
> On Mon, Mar 13, 2017 at 3:24 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Haven't looked at 0007 yet.
>
> Overall this one looks pretty good and straightforward.

In the following code of find_partition_scheme():

+ /* Did not find matching partition scheme. Create one. */
+ part_scheme = (PartitionScheme) palloc0(sizeof(PartitionSchemeData));
+
+ /* Copy partition bounds/lists. */
+ part_scheme->nparts = part_desc->nparts;
+ part_scheme->strategy = part_key->strategy;
+ part_scheme->boundinfo = part_desc->boundinfo;
+
+ /* Store partition key information. */
+ part_scheme->partnatts = part_key->partnatts;
+
+ part_scheme->partopfamily = (Oid *) palloc(sizeof(Oid) * partnatts);
+ memcpy(part_scheme->partopfamily, part_key->partopfamily,
+ sizeof(Oid) * partnatts);
+
+ part_scheme->partopcintype = (Oid *) palloc(sizeof(Oid) * partnatts);
+ memcpy(part_scheme->partopcintype, part_key->partopcintype,
+ sizeof(Oid) * partnatts);
+
+ part_scheme->key_types = (Oid *) palloc(sizeof(Oid) * partnatts);
+ memcpy(part_scheme->key_types, part_key->parttypid,
+ sizeof(Oid) * partnatts);
+
+ part_scheme->key_typmods = (int32 *) palloc(sizeof(int32) * partnatts);
+ memcpy(part_scheme->key_typmods, part_key->parttypmod,
+ sizeof(int32) * partnatts);
+
+ part_scheme->key_collations = (Oid *) palloc(sizeof(Oid) * partnatts);
+ memcpy(part_scheme->key_collations, part_key->parttypcoll,
+ sizeof(Oid) * partnatts);

Couldn't we avoid the memcpy() on individual members of part_key? After
all, RelationData.rd_partkey is guarded just like rd_partdesc by
relcache.c in face of invalidations (see keep_partkey logic in
RelationClearRelation).

Thanks,
Amit

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-03-14 01:00:54 Re: scram and \password
Previous Message Joe Conway 2017-03-14 00:54:48 Re: scram and \password