diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 987bb73..e9b09dd 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -58,7 +58,8 @@ * In the case of range partitioning, ndatums will typically be far less than * 2 * nparts, because a partition's upper bound and the next partition's lower * bound are the same in most common cases, and we only store one of them. - * In case of hash partitioning, ndatums be same as the number of partitions. + * In case of hash partitioning, ndatums will be same as the number of + * partitions. * * For range and list partitioned tables, datums is an array of datum-tuples * with key->partnatts datums each. @@ -1504,12 +1505,12 @@ make_partition_op_expr(PartitionKey key, int keynum, /* * get_qual_for_hash * - * Given a list of partition columns, modulus and remainder this function - * returns an expression Node for the partition table's CHECK constraint. + * Given a list of partition columns, modulus and remainder corresponding to a + * partition, this function returns CHECK constraint expression Node for that + * partition. * - * For example, given a partition definition such as: - * CREATE TABLE simple_hash (a int, b char(10)) - * PARTITION BY HASH (a, b); + * For a partitioned table defined as: + * CREATE TABLE simple_hash (a int, b char(10)) PARTITION BY HASH (a, b); * * CREATE TABLE p_p1 PARTITION OF simple_hash * FOR VALUES WITH (modulus 2, remainder 1); @@ -1520,16 +1521,16 @@ make_partition_op_expr(PartitionKey key, int keynum, * CREATE TABLE p_p4 PARTITION OF simple_hash * FOR VALUES WITH (modulus 8, remainder 4); * - * This function will return one of the following in the form of a - * subexpression: + * This function will return one of the following in the form of an + * expression: * * for p_p1: satisfies_hash_partition(2, 1, hash_fn_1(a), hash_fn_2(b)) * for p_p2: satisfies_hash_partition(4, 2, hash_fn_1(a), hash_fn_2(b)) * for p_p3: satisfies_hash_partition(8, 0, hash_fn_1(a), hash_fn_2(b)) * for p_p4: satisfies_hash_partition(8, 4, hash_fn_1(a), hash_fn_2(b)) * - * hash_fn_1 and hash_fn_2 will be datatype-specific hash functions for - * column a and b respectively. + * where hash_fn_1 and hash_fn_2 are be datatype-specific hash functions for + * columns a and b respectively. */ static List * get_qual_for_hash(PartitionKey key, PartitionBoundSpec *spec) @@ -1568,7 +1569,6 @@ get_qual_for_hash(PartitionKey key, PartitionBoundSpec *spec) /* Left operand */ if (key->partattrs[i] != 0) - { keyCol = (Node *) makeVar(1, key->partattrs[i], key->parttypid[i], @@ -1576,7 +1576,6 @@ get_qual_for_hash(PartitionKey key, PartitionBoundSpec *spec) key->parttypcoll[i], 0); - } else { keyCol = (Node *) copyObject(lfirst(partexprs_item)); @@ -2684,7 +2683,7 @@ mix_hash_value(int nkeys, uint32 *hash_array, bool *isnull) /* * Rotate hash left 1 bit before mixing in the next column. This * prevents equal values in different keys from cancelling each other. - * */ + */ rowHash = (rowHash << 1) | ((rowHash & 0x80000000) ? 1 : 0); if (!isnull[i]) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 46344ee..8f8bbcd 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13231,8 +13231,9 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy) } /* - * Collation is irrelevant for hash partition key, because hash - * operator classes provide only equality, not ordering. + * Hash operator classes provide only equality, not ordering. + * Collation, which is relevant for ordering and not equality is + * irrelevant for hash partitioning. */ if (*strategy == PARTITION_STRATEGY_HASH && pelem->collation != NIL) { @@ -13404,9 +13405,10 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs, partcollation[attn] = attcollation; - /* Identify opclass to use. For list and range partitioning we use only - * btree operators, which seems enough for those. For hash partitioning, - * we use hash operators. */ + /* + * Identify opclass to use. For list and range partitioning we use only + * btree operator class, which seems enough for those. For hash partitioning, + * we use hash operator class. */ if (strategy == PARTITION_STRATEGY_HASH) { am_method = "hash";