forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb30f7f3
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 parent7fa367d commitb30f7f3
1 file changed
+10
-8
lines changedLines changed: 10 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1098 | 1098 |
| |
1099 | 1099 |
| |
1100 | 1100 |
| |
1101 |
| - | |
1102 |
| - | |
| 1101 | + | |
| 1102 | + | |
1103 | 1103 |
| |
1104 | 1104 |
| |
1105 | 1105 |
| |
| |||
1187 | 1187 |
| |
1188 | 1188 |
| |
1189 | 1189 |
| |
1190 |
| - | |
| 1190 | + | |
| 1191 | + | |
1191 | 1192 |
| |
1192 | 1193 |
| |
1193 | 1194 |
| |
1194 | 1195 |
| |
1195 |
| - | |
| 1196 | + | |
1196 | 1197 |
| |
1197 | 1198 |
| |
1198 | 1199 |
| |
| |||
1299 | 1300 |
| |
1300 | 1301 |
| |
1301 | 1302 |
| |
1302 |
| - | |
1303 |
| - | |
| 1303 | + | |
| 1304 | + | |
1304 | 1305 |
| |
1305 | 1306 |
| |
1306 | 1307 |
| |
| |||
1394 | 1395 |
| |
1395 | 1396 |
| |
1396 | 1397 |
| |
1397 |
| - | |
| 1398 | + | |
| 1399 | + | |
1398 | 1400 |
| |
1399 | 1401 |
| |
1400 | 1402 |
| |
1401 | 1403 |
| |
1402 |
| - | |
| 1404 | + | |
1403 | 1405 |
| |
1404 | 1406 |
| |
1405 | 1407 |
| |
|
0 commit comments
Comments
(0)