Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix some ill-chosen names for globally-visible partition support functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Jun 2018 17:18:02 +0000 (13:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Jun 2018 17:18:02 +0000 (13:18 -0400)
"compute_hash_value" is particularly gratuitously generic, but IMO
all of these ought to have names clearly related to partitioning.

src/backend/commands/tablecmds.c
src/backend/executor/execPartition.c
src/backend/partitioning/partbounds.c
src/backend/partitioning/partprune.c
src/backend/utils/cache/partcache.c
src/include/partitioning/partbounds.h

index d20991a1e56f70d561e486eab28e01c4892e69bf..8b848f91a7c7baeffb024b127afa61ccef6a9162 100644 (file)
@@ -855,7 +855,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
         */
        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);
        }
index 4eeee7c5e7f531ca74797cbd03b9699f9d61e351..7a4665cc4ee39a7078ee41f95a9092f5abe89a04 100644 (file)
@@ -1085,17 +1085,20 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
    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];
            }
@@ -1104,8 +1107,8 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
        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
            {
@@ -1113,10 +1116,10 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
 
                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;
 
@@ -1143,7 +1146,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
                {
                    bound_offset = partition_range_datum_bsearch(key->partsupfunc,
                                                                 key->partcollation,
-                                                                partdesc->boundinfo,
+                                                                boundinfo,
                                                                 key->partnatts,
                                                                 values,
                                                                 &equal);
@@ -1154,7 +1157,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
                     * 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;
@@ -1169,7 +1172,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
     * 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;
 }
index 09c7c3e2522a548083e83fb5ab02b000be4b227d..b19c76acc8a298324d7f08210be62ce22dcbbf8f 100644 (file)
@@ -470,8 +470,8 @@ check_new_partition_bound(char *relname, Relation parent,
                           *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
@@ -589,15 +589,15 @@ check_new_partition_bound(char *relname, Relation parent,
 }
 
 /*
- * 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;
@@ -757,14 +757,14 @@ get_hash_partition_greatest_modulus(PartitionBoundInfo bound)
 }
 
 /*
- * 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;
@@ -2052,13 +2052,13 @@ get_range_nulltest(PartitionKey key)
 }
 
 /*
- * 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;
@@ -2066,6 +2066,7 @@ compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
 
    for (i = 0; i < partnatts; i++)
    {
+       /* Nulls are just ignored */
        if (!isnull[i])
        {
            Datum       hash;
index 480b22e043ec51d619b03226e5370507ba9da644..c31cd4f945f03c070d3898999e57d634f4fbc07a 100644 (file)
@@ -2018,7 +2018,8 @@ get_matching_hash_bounds(PartitionPruneContext *context,
            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 =
index 833246ee87f1eba9a759257d0cafe21e62de507b..115a9fe78ff2ae42878a7ed11a82d296e4d448d8 100644 (file)
@@ -499,10 +499,10 @@ RelationBuildPartitionDesc(Relation rel)
                    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++;
index 71c04aa446d9eba6036c855282862b0b458693a2..c7535e32fc861d191c2c7fdba9cdc86197dd3639 100644 (file)
@@ -105,8 +105,8 @@ typedef struct PartitionRangeBound
 } 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,
@@ -116,11 +116,12 @@ extern PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src,
                      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,