forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0e6aa87
committed
Avoid determining regexp subexpression matches, when possible.
Identifying the precise match locations for parenthesized subexpressionsis a fairly expensive task given the way our regexp engine works, bothat regexp compile time (where we must create an optimized NFA for eachparenthesized subexpression) and at runtime (where determining exactmatch locations requires laborious search).Up to now we've made little attempt to optimize this situation. Thispatch identifies cases where we know at compile time that we won'tneed to know subexpression match locations, and teaches the regexpcompiler to not bother creating per-subexpression regexps forparenthesis pairs that are not referenced by backrefs elsewhere inthe regexp. (To preserve semantics, we obviously still have topin down the match locations of backref references.) Users couldhave obtained the same results before this by being careful towrite "non capturing" parentheses wherever possible, but few peoplebother with that.Discussion:https://postgr.es/m/2219936.1628115334@sss.pgh.pa.us1 parent76ad244 commit0e6aa87
File tree
10 files changed
+154
-45
lines changed- contrib/pg_trgm
- src
- backend
- regex
- utils/adt
- include/regex
- test/modules/test_regex
- expected
- sql
10 files changed
+154
-45
lines changedLines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
541 | 541 |
| |
542 | 542 |
| |
543 | 543 |
| |
544 |
| - | |
| 544 | + | |
| 545 | + | |
545 | 546 |
| |
546 |
| - | |
| 547 | + | |
| 548 | + | |
547 | 549 |
| |
548 | 550 |
| |
549 | 551 |
| |
|
Lines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
528 | 528 |
| |
529 | 529 |
| |
530 | 530 |
| |
531 |
| - | |
532 |
| - | |
533 |
| - | |
534 |
| - | |
| 531 | + | |
535 | 532 |
| |
536 | 533 |
| |
537 | 534 |
| |
|
Lines changed: 54 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
68 |
| - | |
| 68 | + | |
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
| |||
431 | 431 |
| |
432 | 432 |
| |
433 | 433 |
| |
434 |
| - | |
| 434 | + | |
| 435 | + | |
435 | 436 |
| |
436 | 437 |
| |
437 | 438 |
| |
| |||
1013 | 1014 |
| |
1014 | 1015 |
| |
1015 | 1016 |
| |
1016 |
| - | |
1017 |
| - | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
1018 | 1022 |
| |
1019 |
| - | |
1020 | 1023 |
| |
1021 | 1024 |
| |
1022 |
| - | |
1023 | 1025 |
| |
| 1026 | + | |
1024 | 1027 |
| |
1025 | 1028 |
| |
1026 | 1029 |
| |
| |||
2141 | 2144 |
| |
2142 | 2145 |
| |
2143 | 2146 |
| |
2144 |
| - | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
2145 | 2153 |
| |
2146 | 2154 |
| |
2147 |
| - | |
2148 |
| - | |
| 2155 | + | |
| 2156 | + | |
2149 | 2157 |
| |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
2150 | 2181 |
| |
2151 |
| - | |
2152 |
| - | |
2153 |
| - | |
2154 |
| - | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2155 | 2186 |
| |
2156 |
| - | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
2157 | 2195 |
| |
2158 | 2196 |
| |
2159 | 2197 |
| |
| |||
2501 | 2539 |
| |
2502 | 2540 |
| |
2503 | 2541 |
| |
| 2542 | + | |
| 2543 | + | |
2504 | 2544 |
| |
2505 | 2545 |
| |
2506 | 2546 |
| |
|
Lines changed: 25 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
213 | 213 |
| |
214 | 214 |
| |
215 | 215 |
| |
216 |
| - | |
217 |
| - | |
218 |
| - | |
219 |
| - | |
| 216 | + | |
220 | 217 |
| |
221 |
| - | |
| 218 | + | |
222 | 219 |
| |
223 | 220 |
| |
224 | 221 |
| |
| |||
229 | 226 |
| |
230 | 227 |
| |
231 | 228 |
| |
| 229 | + | |
| 230 | + | |
232 | 231 |
| |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
233 | 240 |
| |
234 | 241 |
| |
235 | 242 |
| |
| |||
290 | 297 |
| |
291 | 298 |
| |
292 | 299 |
| |
293 |
| - | |
294 |
| - | |
| 300 | + | |
| 301 | + | |
295 | 302 |
| |
296 |
| - | |
297 |
| - | |
298 |
| - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
299 | 314 |
| |
300 | 315 |
| |
301 | 316 |
| |
| |||
752 | 767 |
| |
753 | 768 |
| |
754 | 769 |
| |
755 |
| - | |
756 | 770 |
| |
757 | 771 |
| |
758 | 772 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
583 | 583 |
| |
584 | 584 |
| |
585 | 585 |
| |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
586 | 594 |
| |
587 | 595 |
| |
588 | 596 |
| |
|
Lines changed: 10 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
347 | 347 |
| |
348 | 348 |
| |
349 | 349 |
| |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
350 | 354 |
| |
351 | 355 |
| |
352 | 356 |
| |
| |||
1412 | 1416 |
| |
1413 | 1417 |
| |
1414 | 1418 |
| |
| 1419 | + | |
1415 | 1420 |
| |
1416 | 1421 |
| |
1417 | 1422 |
| |
| |||
1430 | 1435 |
| |
1431 | 1436 |
| |
1432 | 1437 |
| |
1433 |
| - | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
1434 | 1442 |
| |
1435 | 1443 |
| |
1436 | 1444 |
| |
| |||
1952 | 1960 |
| |
1953 | 1961 |
| |
1954 | 1962 |
| |
1955 |
| - | |
| 1963 | + | |
1956 | 1964 |
| |
1957 | 1965 |
| |
1958 | 1966 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
109 |
| - | |
| 109 | + | |
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
477 | 477 |
| |
478 | 478 |
| |
479 | 479 |
| |
| 480 | + | |
480 | 481 |
| |
481 |
| - | |
| 482 | + | |
482 | 483 |
| |
483 | 484 |
| |
484 |
| - | |
| 485 | + | |
485 | 486 |
| |
486 |
| - | |
| 487 | + | |
487 | 488 |
| |
488 | 489 |
| |
489 | 490 |
| |
|
Lines changed: 36 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
146 | 146 |
| |
147 | 147 |
| |
148 | 148 |
| |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
155 | 155 |
| |
156 | 156 |
| |
157 | 157 |
| |
| |||
2658 | 2658 |
| |
2659 | 2659 |
| |
2660 | 2660 |
| |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
2661 | 2675 |
| |
2662 | 2676 |
| |
2663 | 2677 |
| |
| |||
3476 | 3490 |
| |
3477 | 3491 |
| |
3478 | 3492 |
| |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
3479 | 3509 |
| |
3480 | 3510 |
| |
3481 | 3511 |
| |
|
Lines changed: 11 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
66 |
| - | |
67 |
| - | |
| 66 | + | |
| 67 | + | |
68 | 68 |
| |
69 | 69 |
| |
70 | 70 |
| |
| |||
775 | 775 |
| |
776 | 776 |
| |
777 | 777 |
| |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
778 | 783 |
| |
779 | 784 |
| |
780 | 785 |
| |
| |||
1011 | 1016 |
| |
1012 | 1017 |
| |
1013 | 1018 |
| |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1014 | 1023 |
| |
1015 | 1024 |
| |
1016 | 1025 |
| |
|
0 commit comments
Comments
(0)