*/
if (OidIsValid(defaultPartOid))
{
- check_default_allows_bound(parent, defaultRel, bound);
+ check_default_partition_contents(parent, defaultRel, bound);
/* Keep the lock until commit. */
heap_close(defaultRel, NoLock);
}
int part_index = -1;
PartitionKey key = RelationGetPartitionKey(relation);
PartitionDesc partdesc = RelationGetPartitionDesc(relation);
+ PartitionBoundInfo boundinfo = partdesc->boundinfo;
/* Route as appropriate based on partitioning strategy. */
switch (key->strategy)
{
case PARTITION_STRATEGY_HASH:
{
- PartitionBoundInfo boundinfo = partdesc->boundinfo;
- int greatest_modulus = get_hash_partition_greatest_modulus(boundinfo);
- uint64 rowHash = compute_hash_value(key->partnatts,
- key->partsupfunc,
- values, isnull);
+ int greatest_modulus;
+ uint64 rowHash;
+
+ greatest_modulus = get_hash_partition_greatest_modulus(boundinfo);
+ rowHash = compute_partition_hash_value(key->partnatts,
+ key->partsupfunc,
+ values, isnull);
part_index = boundinfo->indexes[rowHash % greatest_modulus];
}
case PARTITION_STRATEGY_LIST:
if (isnull[0])
{
- if (partition_bound_accepts_nulls(partdesc->boundinfo))
- part_index = partdesc->boundinfo->null_index;
+ if (partition_bound_accepts_nulls(boundinfo))
+ part_index = boundinfo->null_index;
}
else
{
bound_offset = partition_list_bsearch(key->partsupfunc,
key->partcollation,
- partdesc->boundinfo,
+ boundinfo,
values[0], &equal);
if (bound_offset >= 0 && equal)
- part_index = partdesc->boundinfo->indexes[bound_offset];
+ part_index = boundinfo->indexes[bound_offset];
}
break;
{
bound_offset = partition_range_datum_bsearch(key->partsupfunc,
key->partcollation,
- partdesc->boundinfo,
+ boundinfo,
key->partnatts,
values,
&equal);
* bound of the partition we're looking for, if there
* actually exists one.
*/
- part_index = partdesc->boundinfo->indexes[bound_offset + 1];
+ part_index = boundinfo->indexes[bound_offset + 1];
}
}
break;
* the default partition, if there is one.
*/
if (part_index < 0)
- part_index = partdesc->boundinfo->default_index;
+ part_index = boundinfo->default_index;
return part_index;
}
*upper;
Assert(spec->strategy == PARTITION_STRATEGY_RANGE);
- lower = make_one_range_bound(key, -1, spec->lowerdatums, true);
- upper = make_one_range_bound(key, -1, spec->upperdatums, false);
+ lower = make_one_partition_rbound(key, -1, spec->lowerdatums, true);
+ upper = make_one_partition_rbound(key, -1, spec->upperdatums, false);
/*
* First check if the resulting range would be empty with
}
/*
- * check_default_allows_bound
+ * check_default_partition_contents
*
* This function checks if there exists a row in the default partition that
* would properly belong to the new partition being added. If it finds one,
* it throws an error.
*/
void
-check_default_allows_bound(Relation parent, Relation default_rel,
- PartitionBoundSpec *new_spec)
+check_default_partition_contents(Relation parent, Relation default_rel,
+ PartitionBoundSpec *new_spec)
{
List *new_part_constraints;
List *def_part_constraints;
}
/*
- * make_one_range_bound
+ * make_one_partition_rbound
*
* Return a PartitionRangeBound given a list of PartitionRangeDatum elements
* and a flag telling whether the bound is lower or not. Made into a function
* because there are multiple sites that want to use this facility.
*/
PartitionRangeBound *
-make_one_range_bound(PartitionKey key, int index, List *datums, bool lower)
+make_one_partition_rbound(PartitionKey key, int index, List *datums, bool lower)
{
PartitionRangeBound *bound;
ListCell *lc;
}
/*
- * compute_hash_value
+ * compute_partition_hash_value
*
- * Compute the hash value for given not null partition key values.
+ * Compute the hash value for given partition key values.
*/
uint64
-compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
- Datum *values, bool *isnull)
+compute_partition_hash_value(int partnatts, FmgrInfo *partsupfunc,
+ Datum *values, bool *isnull)
{
int i;
uint64 rowHash = 0;
for (i = 0; i < partnatts; i++)
{
+ /* Nulls are just ignored */
if (!isnull[i])
{
Datum hash;
isnull[i] = bms_is_member(i, nullkeys);
greatest_modulus = get_hash_partition_greatest_modulus(boundinfo);
- rowHash = compute_hash_value(partnatts, partsupfunc, values, isnull);
+ rowHash = compute_partition_hash_value(partnatts, partsupfunc,
+ values, isnull);
if (partindices[rowHash % greatest_modulus] >= 0)
result->bound_offsets =
continue;
}
- lower = make_one_range_bound(key, i, spec->lowerdatums,
- true);
- upper = make_one_range_bound(key, i, spec->upperdatums,
- false);
+ lower = make_one_partition_rbound(key, i, spec->lowerdatums,
+ true);
+ upper = make_one_partition_rbound(key, i, spec->upperdatums,
+ false);
all_bounds[ndatums++] = lower;
all_bounds[ndatums++] = upper;
i++;
} PartitionRangeBound;
extern int get_hash_partition_greatest_modulus(PartitionBoundInfo b);
-extern uint64 compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
- Datum *values, bool *isnull);
+extern uint64 compute_partition_hash_value(int partnatts, FmgrInfo *partsupfunc,
+ Datum *values, bool *isnull);
extern List *get_qual_from_partbound(Relation rel, Relation parent,
PartitionBoundSpec *spec);
extern bool partition_bounds_equal(int partnatts, int16 *parttyplen,
PartitionKey key);
extern void check_new_partition_bound(char *relname, Relation parent,
PartitionBoundSpec *spec);
-extern void check_default_allows_bound(Relation parent, Relation defaultRel,
- PartitionBoundSpec *new_spec);
+extern void check_default_partition_contents(Relation parent,
+ Relation defaultRel,
+ PartitionBoundSpec *new_spec);
-extern PartitionRangeBound *make_one_range_bound(PartitionKey key, int index,
- List *datums, bool lower);
+extern PartitionRangeBound *make_one_partition_rbound(PartitionKey key, int index,
+ List *datums, bool lower);
extern int32 partition_hbound_cmp(int modulus1, int remainder1, int modulus2,
int remainder2);
extern int32 partition_rbound_cmp(int partnatts, FmgrInfo *partsupfunc,