forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfacce1d
committed
Fix performance bug in regexp's citerdissect/creviterdissect.
After detecting a sub-match "dissect" failure (i.e., a backref matchfailure) in the i'th sub-match of an iteration node, we should proceedby adjusting the attempted length of the i'th submatch. As coded,though, these functions changed the attempted length of the *last*sub-match, and only after exhausting all possibilities for that wouldthey back up to adjust the next-to-last sub-match, and then thesecond-from-last, etc; all of which is wasted effort, since onlychanging the start or length of the i'th sub-match can possibly makeit succeed. This oversight creates the possibility for exponentiallybad performance. Fortunately the problem is masked in most cases byoptimizations or constraints applied elsewhere; which explains whywe'd not noticed it before. But it is possible to reach the problemwith fairly simple, if contrived, regexps.Oversight in my commit173e29a. That's pretty ancient now,so back-patch to all supported branches.Discussion:https://postgr.es/m/1808998.1629412269@sss.pgh.pa.us1 parent9a9c8b9 commitfacce1d
1 file changed
+10
-8
lines changedLines changed: 10 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1147 | 1147 |
| |
1148 | 1148 |
| |
1149 | 1149 |
| |
1150 |
| - | |
1151 |
| - | |
| 1150 | + | |
| 1151 | + | |
1152 | 1152 |
| |
1153 | 1153 |
| |
1154 | 1154 |
| |
| |||
1236 | 1236 |
| |
1237 | 1237 |
| |
1238 | 1238 |
| |
1239 |
| - | |
| 1239 | + | |
| 1240 | + | |
1240 | 1241 |
| |
1241 | 1242 |
| |
1242 | 1243 |
| |
1243 | 1244 |
| |
1244 |
| - | |
| 1245 | + | |
1245 | 1246 |
| |
1246 | 1247 |
| |
1247 | 1248 |
| |
| |||
1352 | 1353 |
| |
1353 | 1354 |
| |
1354 | 1355 |
| |
1355 |
| - | |
1356 |
| - | |
| 1356 | + | |
| 1357 | + | |
1357 | 1358 |
| |
1358 | 1359 |
| |
1359 | 1360 |
| |
| |||
1447 | 1448 |
| |
1448 | 1449 |
| |
1449 | 1450 |
| |
1450 |
| - | |
| 1451 | + | |
| 1452 | + | |
1451 | 1453 |
| |
1452 | 1454 |
| |
1453 | 1455 |
| |
1454 | 1456 |
| |
1455 |
| - | |
| 1457 | + | |
1456 | 1458 |
| |
1457 | 1459 |
| |
1458 | 1460 |
| |
|
0 commit comments
Comments
(0)