- Notifications
You must be signed in to change notification settings - Fork5
Commit1dffabe
committed
Further fix pg_trgm's extraction of trigrams from regular expressions.
Commit9e43e87 turns out to have been insufficient: not only is itnecessary to track tentative parent links while considering a set ofarc removals, but it's necessary to track tentative flag additionsas well. This is because we always merge arc target states intoarc source states; therefore, when considering a merge of the finalstate with some other, it is the other state that will acquire a newTSTATE_FIN bit. If there's another arc for the same color trigramthat would cause merging of that state with the initial state, wefailed to recognize the problem. The test cases for the prior commitevidently only exercised situations where a tentative merge with theinitial state occurs before one with the final state. If it goes theother way around, we'll happily merge the initial and final states,either producing a broken final graph that would never match anything,or triggering the Assert added by the prior commit.It's tempting to consider switching the merge direction when the mergeinvolves the final state, but I lack the time to analyze that idea indetail. Instead just keep track of the flag changes that would resultfrom proposed merges, in the same way that the prior commit trackedproposed parent links.Along the way, add some more debugging support, because I'm not entirelyconfident that this is the last bug here. And tweak matters so thatthe transformed.dot file uses small integers rather than pointer valuesto identify states; that makes it more readable if you're just eyeballingit rather than fooling with Graphviz. And rename a couple of identicallynamed struct fields to reduce confusion.Per report from Corey Csuhta. Add a test case based on his example.(Note: this case does not trigger the bug under 9.3, apparently becauseits different measurement of costs causes it to stop merging states beforeit hits the failure. I spent some time trying to find a variant that wouldfail in 9.3, without success; but I'm sure such cases exist.)Like the previous patch, back-patch to 9.3 where this code was added.Report:https://postgr.es/m/E2B01A4B-4530-406B-8D17-2F67CF9A16BA@csuhta.com1 parent139eb96 commit1dffabe
File tree
3 files changed
+136
-42
lines changed- contrib/pg_trgm
- expected
- sql
3 files changed
+136
-42
lines changedLines changed: 17 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3497 | 3497 |
| |
3498 | 3498 |
| |
3499 | 3499 |
| |
| 3500 | + | |
3500 | 3501 |
| |
3501 | 3502 |
| |
3502 | 3503 |
| |
| |||
3598 | 3599 |
| |
3599 | 3600 |
| |
3600 | 3601 |
| |
3601 |
| - | |
| 3602 | + | |
| 3603 | + | |
3602 | 3604 |
| |
3603 | 3605 |
| |
3604 | 3606 |
| |
| |||
3690 | 3692 |
| |
3691 | 3693 |
| |
3692 | 3694 |
| |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
3693 | 3701 |
| |
3694 | 3702 |
| |
3695 | 3703 |
| |
| |||
3784 | 3792 |
| |
3785 | 3793 |
| |
3786 | 3794 |
| |
3787 |
| - | |
| 3795 | + | |
| 3796 | + | |
3788 | 3797 |
| |
3789 | 3798 |
| |
3790 | 3799 |
| |
| |||
3876 | 3885 |
| |
3877 | 3886 |
| |
3878 | 3887 |
| |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
3879 | 3894 |
| |
3880 | 3895 |
| |
3881 | 3896 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
| 55 | + | |
55 | 56 |
| |
56 | 57 |
| |
57 | 58 |
| |
| |||
87 | 88 |
| |
88 | 89 |
| |
89 | 90 |
| |
| 91 | + | |
90 | 92 |
| |
91 | 93 |
| |
92 | 94 |
| |
| |||
124 | 126 |
| |
125 | 127 |
| |
126 | 128 |
| |
| 129 | + | |
127 | 130 |
| |
128 | 131 |
| |
129 | 132 |
| |
|
0 commit comments
Comments
(0)