forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb69bdce
committed
Avoid assertion due to disconnected NFA sub-graphs in regex parsing.
In commit08c0d6a which introduced "rainbow" arcs in regex NFAs,I didn't think terribly hard about what to do when creating the colorcomplement of a rainbow arc. Clearly, the complement cannot match anycharacters, and I took the easy way out by just not building any arcsat all in the complement arc set. That mostly works, but NikolayShaplov found a case where it doesn't: if we decide to delete thatsub-NFA later because it's inside a "{0}" quantifier, delsub()suffered an assertion failure. That's because delsub() relies onthe target sub-NFA being fully connected. That was always truebefore, and the best fix seems to be to restore that property.Hence, invent a new arc type CANTMATCH that can be generated inplace of an empty color complement, and drop it again later when westart NFA optimization. (At that point we don't need to do delsub()any more, and besides there are other cases where NFA optimization canlead to disconnected subgraphs.)It appears that this bug has no consequences in a non-assert-enabledbuild: there will be some transiently leaked NFA states/arcs, butthey'll get cleaned up eventually. Still, we don't like assertionfailures, so back-patch to v14 where rainbow arcs were introduced.Per bug #18708 from Nikolay Shaplov.Discussion:https://postgr.es/m/18708-f94f2599c9d2c005@postgresql.org1 parent9a70f67 commitb69bdce
File tree
6 files changed
+79
-1
lines changed- src
- backend/regex
- include/regex
- test/modules/test_regex
- expected
- sql
6 files changed
+79
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1075 | 1075 | | |
1076 | 1076 | | |
1077 | 1077 | | |
1078 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1079 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1080 | 1089 | | |
| 1090 | + | |
1081 | 1091 | | |
1082 | 1092 | | |
1083 | 1093 | | |
| |||
1089 | 1099 | | |
1090 | 1100 | | |
1091 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1092 | 1108 | | |
1093 | 1109 | | |
1094 | 1110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1462 | 1462 | | |
1463 | 1463 | | |
1464 | 1464 | | |
| 1465 | + | |
1465 | 1466 | | |
1466 | 1467 | | |
1467 | 1468 | | |
| |||
1599 | 1600 | | |
1600 | 1601 | | |
1601 | 1602 | | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
1602 | 1609 | | |
1603 | 1610 | | |
1604 | 1611 | | |
| |||
2922 | 2929 | | |
2923 | 2930 | | |
2924 | 2931 | | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
2925 | 2960 | | |
2926 | 2961 | | |
2927 | 2962 | | |
| |||
3627 | 3662 | | |
3628 | 3663 | | |
3629 | 3664 | | |
| 3665 | + | |
| 3666 | + | |
3630 | 3667 | | |
3631 | 3668 | | |
3632 | 3669 | | |
| |||
3749 | 3786 | | |
3750 | 3787 | | |
3751 | 3788 | | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
3752 | 3792 | | |
3753 | 3793 | | |
3754 | 3794 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| 346 | + | |
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
| |||
2368 | 2370 | | |
2369 | 2371 | | |
2370 | 2372 | | |
| 2373 | + | |
2371 | 2374 | | |
2372 | 2375 | | |
2373 | 2376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
| 414 | + | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2071 | 2071 | | |
2072 | 2072 | | |
2073 | 2073 | | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
2074 | 2088 | | |
2075 | 2089 | | |
2076 | 2090 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
622 | 625 | | |
623 | 626 | | |
624 | 627 | | |
| |||
0 commit comments
Comments
(0)