- Notifications
You must be signed in to change notification settings - Fork5
Commit166d534
committed
Repair bugs in GiST page splitting code for multi-column indexes.
When considering a non-last column in a multi-column GiST index,gistsplit.c tries to improve on the split chosen by the opclass-specificpickSplit function by considering penalties for the next column. However,there were two bugs in this code: it failed to recompute the union keys forthe leftmost index columns, even though these might well change afterreassigning tuples; and it included the old union keys in the recomputationfor the columns it did recompute, so that those keys couldn't get smallereven if they should. The first problem could result in an invalid indexin which searches wouldn't find index entries that are in fact present;the second would make the index less efficient to search.Both of these errors were caused by misuse of gistMakeUnionItVec, whoseAPI was designed in a way that just begged such errors to be made. Thereis no situation in which it's safe or useful to compute the union keys fora subset of the index columns, and there is no caller that wants anyprevious union keys to be included in the computation; so the undocumentedchoice to treat the union keys as in/out rather than pure output parametersis a waste of code as well as being dangerous.Hence, rather than just making a minimal patch, I've changed the API ofgistMakeUnionItVec to remove the "startkey" parameter (it now alwaysprocesses all index columns) and treat the attr/isnull arrays as purelyoutput parameters.In passing, also get rid of a couple of unnecessary and dangerous usesof static variables in gistutil.c. It's remarkable that the one ingistMakeUnionKey hasn't given us portability troubles before now, becausein addition to posing a re-entrancy hazard, it was unsafely assuming thata static char[] array would have at least Datum alignment.Per investigation of a trouble report from Tomas Vondra. (There are alsosome bugs in contrib/btree_gist to be fixed, but that seems like materialfor a separate patch.) Back-patch to all supported branches.1 parentc5aad8d commit166d534
File tree
3 files changed
+46
-50
lines changed- src
- backend/access/gist
- include/access
3 files changed
+46
-50
lines changedLines changed: 20 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
23 |
| - | |
24 | 22 |
| |
| 23 | + | |
| 24 | + | |
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
32 |
| - | |
| 31 | + | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
| 36 | + | |
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 |
| - | |
| 52 | + | |
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
59 |
| - | |
| 59 | + | |
| 60 | + | |
60 | 61 |
| |
61 | 62 |
| |
62 |
| - | |
| 63 | + | |
63 | 64 |
| |
64 | 65 |
| |
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
68 |
| - | |
69 |
| - | |
70 | 69 |
| |
| 70 | + | |
| 71 | + | |
71 | 72 |
| |
72 | 73 |
| |
73 |
| - | |
| 74 | + | |
74 | 75 |
| |
75 |
| - | |
76 |
| - | |
77 | 76 |
| |
| 77 | + | |
| 78 | + | |
78 | 79 |
| |
79 | 80 |
| |
80 |
| - | |
| 81 | + | |
81 | 82 |
| |
82 | 83 |
| |
83 | 84 |
| |
| |||
443 | 444 |
| |
444 | 445 |
| |
445 | 446 |
| |
446 |
| - | |
| 447 | + | |
447 | 448 |
| |
448 | 449 |
| |
449 | 450 |
| |
450 | 451 |
| |
451 | 452 |
| |
452 | 453 |
| |
453 |
| - | |
| 454 | + | |
454 | 455 |
| |
455 | 456 |
| |
456 | 457 |
| |
| |||
471 | 472 |
| |
472 | 473 |
| |
473 | 474 |
| |
474 |
| - | |
| 475 | + | |
475 | 476 |
| |
476 | 477 |
| |
477 | 478 |
| |
| |||
562 | 563 |
| |
563 | 564 |
| |
564 | 565 |
| |
565 |
| - | |
| 566 | + | |
566 | 567 |
| |
567 | 568 |
| |
568 | 569 |
| |
| |||
617 | 618 |
| |
618 | 619 |
| |
619 | 620 |
| |
620 |
| - | |
| 621 | + | |
621 | 622 |
| |
622 | 623 |
| |
623 | 624 |
| |
|
Lines changed: 25 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
24 |
| - | |
25 |
| - | |
26 |
| - | |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 | 24 |
| |
31 | 25 |
| |
32 | 26 |
| |
| |||
148 | 142 |
| |
149 | 143 |
| |
150 | 144 |
| |
151 |
| - | |
| 145 | + | |
| 146 | + | |
152 | 147 |
| |
153 | 148 |
| |
154 |
| - | |
155 | 149 |
| |
156 |
| - | |
| 150 | + | |
157 | 151 |
| |
158 | 152 |
| |
159 | 153 |
| |
| |||
162 | 156 |
| |
163 | 157 |
| |
164 | 158 |
| |
165 |
| - | |
| 159 | + | |
166 | 160 |
| |
167 | 161 |
| |
168 | 162 |
| |
| 163 | + | |
169 | 164 |
| |
170 |
| - | |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 | 165 |
| |
179 | 166 |
| |
180 | 167 |
| |
| |||
192 | 179 |
| |
193 | 180 |
| |
194 | 181 |
| |
195 |
| - | |
| 182 | + | |
196 | 183 |
| |
197 | 184 |
| |
198 | 185 |
| |
| |||
202 | 189 |
| |
203 | 190 |
| |
204 | 191 |
| |
| 192 | + | |
205 | 193 |
| |
206 | 194 |
| |
207 | 195 |
| |
| |||
224 | 212 |
| |
225 | 213 |
| |
226 | 214 |
| |
227 |
| - | |
| 215 | + | |
| 216 | + | |
228 | 217 |
| |
229 |
| - | |
| 218 | + | |
230 | 219 |
| |
231 |
| - | |
| 220 | + | |
232 | 221 |
| |
233 | 222 |
| |
234 | 223 |
| |
| |||
240 | 229 |
| |
241 | 230 |
| |
242 | 231 |
| |
243 |
| - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
244 | 239 |
| |
245 | 240 |
| |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 | 241 |
| |
250 | 242 |
| |
251 | 243 |
| |
| |||
321 | 313 |
| |
322 | 314 |
| |
323 | 315 |
| |
| 316 | + | |
| 317 | + | |
324 | 318 |
| |
325 | 319 |
| |
326 | 320 |
| |
| |||
335 | 329 |
| |
336 | 330 |
| |
337 | 331 |
| |
338 |
| - | |
| 332 | + | |
339 | 333 |
| |
340 | 334 |
| |
341 | 335 |
| |
342 | 336 |
| |
343 | 337 |
| |
344 |
| - | |
| 338 | + | |
345 | 339 |
| |
346 | 340 |
| |
347 | 341 |
| |
348 | 342 |
| |
349 | 343 |
| |
350 |
| - | |
| 344 | + | |
| 345 | + | |
351 | 346 |
| |
352 | 347 |
| |
353 | 348 |
| |
354 | 349 |
| |
355 | 350 |
| |
356 | 351 |
| |
357 | 352 |
| |
358 |
| - | |
| 353 | + | |
359 | 354 |
| |
360 | 355 |
| |
361 | 356 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
500 | 500 |
| |
501 | 501 |
| |
502 | 502 |
| |
503 |
| - | |
| 503 | + | |
504 | 504 |
| |
505 | 505 |
| |
506 | 506 |
| |
|
0 commit comments
Comments
(0)