diff options
Diffstat (limited to 'src/backend/partitioning/partbounds.c')
-rw-r--r-- | src/backend/partitioning/partbounds.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c index 3d2d3f4c3da..19d055493ed 100644 --- a/src/backend/partitioning/partbounds.c +++ b/src/backend/partitioning/partbounds.c @@ -4653,6 +4653,8 @@ compute_partition_hash_value(int partnatts, FmgrInfo *partsupfunc, Oid *partcoll * * Returns true if remainder produced when this computed single hash value is * divided by the given modulus is equal to given remainder, otherwise false. + * NB: it's important that this never return null, as the constraint machinery + * would consider that to be a "pass". * * See get_qual_for_hash() for usage. */ @@ -4677,9 +4679,9 @@ satisfies_hash_partition(PG_FUNCTION_ARGS) ColumnsHashData *my_extra; uint64 rowHash = 0; - /* Return null if the parent OID, modulus, or remainder is NULL. */ + /* Return false if the parent OID, modulus, or remainder is NULL. */ if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2)) - PG_RETURN_NULL(); + PG_RETURN_BOOL(false); parentId = PG_GETARG_OID(0); modulus = PG_GETARG_INT32(1); remainder = PG_GETARG_INT32(2); @@ -4709,14 +4711,11 @@ satisfies_hash_partition(PG_FUNCTION_ARGS) int j; /* Open parent relation and fetch partition key info */ - parent = try_relation_open(parentId, AccessShareLock); - if (parent == NULL) - PG_RETURN_NULL(); + parent = relation_open(parentId, AccessShareLock); key = RelationGetPartitionKey(parent); /* Reject parent table that is not hash-partitioned. */ - if (parent->rd_rel->relkind != RELKIND_PARTITIONED_TABLE || - key->strategy != PARTITION_STRATEGY_HASH) + if (key == NULL || key->strategy != PARTITION_STRATEGY_HASH) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("\"%s\" is not a hash partitioned table", |