diff options
| author | Tom Lane | 2020-11-16 21:39:59 +0000 |
|---|---|---|
| committer | Tom Lane | 2020-11-16 21:39:59 +0000 |
| commit | 4025e6c46620048804467d2ad29d31aa9ba50387 (patch) | |
| tree | ca0d049f6f3cd9e3bcda355279ceeb649d036c9b /src/test | |
| parent | ad84ecc98d7e2ad81567094b8a6910b5078927a7 (diff) | |
Do not return NULL for error cases in satisfies_hash_partition().
Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea. It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.
For the checks for NULL input values, I just switched it to returning
false. There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.
For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.
Back-patch to v11 where this code came in.
Discussion: https://postgr.es/m/24067.1605134819@sss.pgh.pa.us
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/hash_part.out | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/test/regress/expected/hash_part.out b/src/test/regress/expected/hash_part.out index 91ec7c6f589..4c74e4b7069 100644 --- a/src/test/regress/expected/hash_part.out +++ b/src/test/regress/expected/hash_part.out @@ -10,11 +10,7 @@ CREATE TABLE mchash1 PARTITION OF mchash FOR VALUES WITH (MODULUS 4, REMAINDER 0); -- invalid OID, no such table SELECT satisfies_hash_partition(0, 4, 0, NULL); - satisfies_hash_partition --------------------------- - -(1 row) - +ERROR: could not open relation with OID 0 -- not partitioned SELECT satisfies_hash_partition('tenk1'::regclass, 4, 0, NULL); ERROR: "tenk1" is not a hash partitioned table @@ -34,14 +30,14 @@ ERROR: remainder for hash partition must be less than modulus SELECT satisfies_hash_partition('mchash'::regclass, NULL, 0, NULL); satisfies_hash_partition -------------------------- - + f (1 row) -- remainder is null SELECT satisfies_hash_partition('mchash'::regclass, 4, NULL, NULL); satisfies_hash_partition -------------------------- - + f (1 row) -- too many arguments |
