aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-11-08 14:06:42 +0900
committerMichael Paquier <michael@paquier.xyz>2023-11-08 14:06:42 +0900
commit59fc39c0d5d9237b4912b40fd781f605df1fb4b0 (patch)
tree3ffe3f118412e6c8e6df2a23b20e2cd2c9915c6d /src
parent33d5cf65f8c97d6bf085dffecb51c6a52d1f3f0d (diff)
downloadpostgresql-59fc39c0d5d9237b4912b40fd781f605df1fb4b0.tar.gz
postgresql-59fc39c0d5d9237b4912b40fd781f605df1fb4b0.zip
Enlarge assertion in bloom_init() for false_positive_rate
false_positive_rate is a parameter that can be set with the bloom opclass in BRIN, and setting it to a value of exactly 0.25 would trigger an assertion in the first INSERT done on the index with value set. The assertion changed here relied on BLOOM_{MIN|MAX}_FALSE_POSITIVE_RATE that are somewhat arbitrary values, and specifying an out-of-range value would also trigger a failure when defining such an index. So, as-is, the assertion was just doubling on the min-max check of the reloption. This is now enlarged to check that it is a correct percentage value, instead, based on a suggestion by Tom Lane. Author: Alexander Lakhin Reviewed-by: Tom Lane, Shihao Zhong Discussion: https://postgr.es/m/17969-a6c54de48026d694@postgresql.org Backpatch-through: 14
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/brin/brin_bloom.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index 2c8a20aaca6..72aabbcf50d 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -280,8 +280,7 @@ bloom_init(int ndistinct, double false_positive_rate)
double k; /* number of hash functions */
Assert(ndistinct > 0);
- Assert((false_positive_rate >= BLOOM_MIN_FALSE_POSITIVE_RATE) &&
- (false_positive_rate < BLOOM_MAX_FALSE_POSITIVE_RATE));
+ Assert(false_positive_rate > 0 && false_positive_rate < 1);
/* sizing bloom filter: -(n * ln(p)) / (ln(2))^2 */
nbits = ceil(-(ndistinct * log(false_positive_rate)) / pow(log(2.0), 2));