Commit 1925ac2
committed
Fix misbehavior in contrib/pg_trgm with an unsatisfiable regex.
If the regex compiler can see that a regex is unsatisfiable
(for example, '$foo') then it may emit an NFA having no arcs.
pg_trgm's packGraph function did the wrong thing in this case;
it would access off the end of a work array, and with bad luck
could produce a corrupted output data structure causing more
problems later. This could end with wrong answers or crashes
in queries using a pg_trgm GIN or GiST index with such a regex.
Fix by not trying to de-duplicate if there aren't at least 2 arcs.
Per bug #17830 from Alexander Lakhin. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/17830-57ff5f89bdb02b09@postgresql.org1 parent d66bb04 commit 1925ac2
File tree
3 files changed
+25
-10
lines changed- contrib/pg_trgm
- expected
- sql
3 files changed
+25
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1947 | 1947 | | |
1948 | 1948 | | |
1949 | 1949 | | |
1950 | | - | |
1951 | | - | |
1952 | | - | |
| 1950 | + | |
1953 | 1951 | | |
1954 | 1952 | | |
1955 | 1953 | | |
| |||
2021 | 2019 | | |
2022 | 2020 | | |
2023 | 2021 | | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
| 2022 | + | |
2027 | 2023 | | |
2028 | | - | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
2029 | 2030 | | |
2030 | | - | |
2031 | | - | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
2032 | 2036 | | |
| 2037 | + | |
2033 | 2038 | | |
2034 | | - | |
| 2039 | + | |
| 2040 | + | |
2035 | 2041 | | |
2036 | 2042 | | |
2037 | 2043 | | |
| |||
0 commit comments