- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit1b47a11
committed
Fix GIN's shimTriConsistentFn to not corrupt its input.
Commit0f21db3 made an assumption that GIN triConsistentFnswould not modify their input entryRes[] arrays. But in fact,the "shim" triConsistentFn that we use for opclasses that don'tsupply their own did exactly that, potentially leading to wronganswers from a GIN index search. Through bad luck, none of thetest cases that we have for such opclasses exposed the bug.One response to this could be that the assumption of consistency checkfunctions not modifying entryRes[] arrays is a bad one, but it stillseems reasonable to me. Notably, shimTriConsistentFn is itselfassuming that with respect to the underlying boolean consistentFn,so it's sure being self-centered in supposing that it gets to do so.Fortunately, it's quite simple to fix shimTriConsistentFn to restorethe entry-time state of entryRes[], so let's do that instead.This issue doesn't affect any core GIN opclasses, since they allsupply their own triConsistentFns. It does affect contrib modulesbtree_gin, hstore, and intarray.Along the way, I (tgl) noticed that shimTriConsistentFn failed topick up on a "recheck" flag returned by its first call to the booleanconsistentFn. This may be only a latent problem, since it would beunlikely for a consistentFn to set recheck for the all-false caseand not any other cases. (Indeed, none of our contrib modules dothat.) Nonetheless, it's formally wrong.Reported-by: Vinod Sridharan <vsridh90@gmail.com>Author: Vinod Sridharan <vsridh90@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CAFMdLD7XzsXfi1+DpTqTgrD8XU0i2C99KuF=5VHLWjx4C1pkcg@mail.gmail.comBackpatch-through: 131 parent873aff9 commit1b47a11
File tree
3 files changed
+64
-5
lines changed- contrib/intarray
- expected
- sql
- src/backend/access/gin
3 files changed
+64
-5
lines changedLines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
473 | 473 |
| |
474 | 474 |
| |
475 | 475 |
| |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
476 | 482 |
| |
477 | 483 |
| |
478 | 484 |
| |
| |||
547 | 553 |
| |
548 | 554 |
| |
549 | 555 |
| |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
550 | 562 |
| |
551 | 563 |
| |
552 | 564 |
| |
| |||
629 | 641 |
| |
630 | 642 |
| |
631 | 643 |
| |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
632 | 650 |
| |
633 | 651 |
| |
634 | 652 |
| |
| |||
709 | 727 |
| |
710 | 728 |
| |
711 | 729 |
| |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
712 | 736 |
| |
713 | 737 |
| |
714 | 738 |
| |
| |||
783 | 807 |
| |
784 | 808 |
| |
785 | 809 |
| |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
786 | 816 |
| |
787 | 817 |
| |
788 | 818 |
| |
| |||
857 | 887 |
| |
858 | 888 |
| |
859 | 889 |
| |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
860 | 896 |
| |
861 | 897 |
| |
862 | 898 |
| |
| |||
949 | 985 |
| |
950 | 986 |
| |
951 | 987 |
| |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
952 | 994 |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
| 95 | + | |
95 | 96 |
| |
96 | 97 |
| |
97 | 98 |
| |
| |||
109 | 110 |
| |
110 | 111 |
| |
111 | 112 |
| |
| 113 | + | |
112 | 114 |
| |
113 | 115 |
| |
114 | 116 |
| |
| |||
129 | 131 |
| |
130 | 132 |
| |
131 | 133 |
| |
| 134 | + | |
132 | 135 |
| |
133 | 136 |
| |
134 | 137 |
| |
| |||
147 | 150 |
| |
148 | 151 |
| |
149 | 152 |
| |
| 153 | + | |
150 | 154 |
| |
151 | 155 |
| |
152 | 156 |
| |
| |||
163 | 167 |
| |
164 | 168 |
| |
165 | 169 |
| |
| 170 | + | |
166 | 171 |
| |
167 | 172 |
| |
168 | 173 |
| |
| |||
179 | 184 |
| |
180 | 185 |
| |
181 | 186 |
| |
| 187 | + | |
182 | 188 |
| |
183 | 189 |
| |
184 | 190 |
| |
| |||
214 | 220 |
| |
215 | 221 |
| |
216 | 222 |
| |
| 223 | + | |
217 | 224 |
| |
218 | 225 |
| |
219 | 226 |
|
Lines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
146 | 146 |
| |
147 | 147 |
| |
148 | 148 |
| |
149 |
| - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
150 | 152 |
| |
151 | 153 |
| |
152 | 154 |
| |
| |||
155 | 157 |
| |
156 | 158 |
| |
157 | 159 |
| |
158 |
| - | |
| 160 | + | |
159 | 161 |
| |
160 | 162 |
| |
161 | 163 |
| |
| |||
175 | 177 |
| |
176 | 178 |
| |
177 | 179 |
| |
178 |
| - | |
179 |
| - | |
| 180 | + | |
| 181 | + | |
180 | 182 |
| |
181 | 183 |
| |
182 | 184 |
| |
| |||
185 | 187 |
| |
186 | 188 |
| |
187 | 189 |
| |
| 190 | + | |
188 | 191 |
| |
189 | 192 |
| |
190 | 193 |
| |
| |||
206 | 209 |
| |
207 | 210 |
| |
208 | 211 |
| |
209 |
| - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
210 | 216 |
| |
211 | 217 |
| |
212 | 218 |
| |
213 | 219 |
| |
214 | 220 |
| |
215 | 221 |
| |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
216 | 226 |
| |
217 | 227 |
| |
218 | 228 |
| |
|
0 commit comments
Comments
(0)