forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitae4867e
committed
Avoid divide-by-zero in regex_selectivity() with long fixed prefix.
Given a regex pattern with a very long fixed prefix (approaching 500characters), the result of pow(FIXED_CHAR_SEL, fixed_prefix_len) canunderflow to zero. Typically the preceding selectivity calculationwould have underflowed as well, so that we compute 0/0 and get NaN.In released branches this leads to an assertion failure later on.That doesn't happen in HEAD, for reasons I've not explored yet,but it's surely still a bug.To fix, just skip the division when the pow() result is zero, sothat we'll (most likely) return a zero selectivity estimate. Inthe edge cases where "sel" didn't yet underflow, perhaps thisisn't desirable, but I'm not sure that the case is worth spendinga lot of effort on. The results of regex_selectivity_sub() arebarely worth the electrons they're written on anyway :-(Per report from Alexander Lakhin. Back-patch to all supported versions.Discussion:https://postgr.es/m/6de0a0c3-ada9-cd0c-3e4e-2fa9964b41e3@gmail.com1 parent993bdb9 commitae4867e
1 file changed
+11
-2
lines changedLines changed: 11 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1442 | 1442 |
| |
1443 | 1443 |
| |
1444 | 1444 |
| |
1445 |
| - | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1446 | 1450 |
| |
1447 |
| - | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
1448 | 1457 |
| |
1449 | 1458 |
| |
1450 | 1459 |
| |
|
0 commit comments
Comments
(0)