forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit98edd61
committed
Fix datatype confusion with the new lossy GiST distance functions.
We can only support a lossy distance function when the distance function'sdatatype is comparable with the original ordering operator's datatype.The distance function always returns a float8, so we are limited to float8,and float4 (by a hard-coded cast of the float8 to float4).In light of this limitation, it seems like a good idea to have a separate'recheck' flag for the ORDER BY expressions, so that if you have a non-lossydistance function, it still works with lossy quals. There are cases likethat with the build-in or contrib opclasses, but it's plausible.There was a hidden assumption that the ORDER BY values returned by GiSTmatch the original ordering operator's return type, but there are plentyof examples where that's not true, e.g. in btree_gist and pg_trgm. As longas the distance function is not lossy, we can tolerate that and just notreturn the distance to the executor (or rather, always return NULL). Theexecutor doesn't need the distances if there are no lossy results.There was another little bug: the recheck variable was not initializedbefore calling the distance function. That revealed the bigger issue,as the executor tried to reorder tuples that didn't need reordering, andthat failed because of the datatype mismatch.1 parenta868931 commit98edd61
File tree
6 files changed
+78
-16
lines changed- doc/src/sgml
- src
- backend
- access/gist
- executor
- include/access
6 files changed
+78
-16
lines changedLines changed: 9 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
818 | 818 |
| |
819 | 819 |
| |
820 | 820 |
| |
821 |
| - | |
822 |
| - | |
823 |
| - | |
824 |
| - | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
825 | 830 |
| |
826 | 831 |
| |
827 | 832 |
| |
|
Lines changed: 44 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
| |||
31 | 32 |
| |
32 | 33 |
| |
33 | 34 |
| |
34 |
| - | |
| 35 | + | |
35 | 36 |
| |
36 | 37 |
| |
| 38 | + | |
| 39 | + | |
37 | 40 |
| |
38 | 41 |
| |
39 | 42 |
| |
| |||
50 | 53 |
| |
51 | 54 |
| |
52 | 55 |
| |
53 |
| - | |
| 56 | + | |
| 57 | + | |
54 | 58 |
| |
55 | 59 |
| |
56 | 60 |
| |
| |||
60 | 64 |
| |
61 | 65 |
| |
62 | 66 |
| |
| 67 | + | |
63 | 68 |
| |
64 | 69 |
| |
65 | 70 |
| |
| |||
194 | 199 |
| |
195 | 200 |
| |
196 | 201 |
| |
197 |
| - | |
198 |
| - | |
199 |
| - | |
200 |
| - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
201 | 208 |
| |
| 209 | + | |
202 | 210 |
| |
203 | 211 |
| |
204 | 212 |
| |
205 | 213 |
| |
206 | 214 |
| |
207 | 215 |
| |
208 | 216 |
| |
209 |
| - | |
210 |
| - | |
211 |
| - | |
| 217 | + | |
212 | 218 |
| |
213 | 219 |
| |
214 | 220 |
| |
| |||
310 | 316 |
| |
311 | 317 |
| |
312 | 318 |
| |
| 319 | + | |
313 | 320 |
| |
314 | 321 |
| |
315 | 322 |
| |
316 | 323 |
| |
317 | 324 |
| |
318 | 325 |
| |
319 | 326 |
| |
320 |
| - | |
| 327 | + | |
| 328 | + | |
321 | 329 |
| |
322 | 330 |
| |
323 | 331 |
| |
| |||
375 | 383 |
| |
376 | 384 |
| |
377 | 385 |
| |
| 386 | + | |
378 | 387 |
| |
379 | 388 |
| |
380 | 389 |
| |
| |||
461 | 470 |
| |
462 | 471 |
| |
463 | 472 |
| |
| 473 | + | |
464 | 474 |
| |
465 | 475 |
| |
466 |
| - | |
467 |
| - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
468 | 500 |
| |
469 | 501 |
| |
470 | 502 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
| 20 | + | |
20 | 21 |
| |
21 | 22 |
| |
22 | 23 |
| |
| |||
263 | 264 |
| |
264 | 265 |
| |
265 | 266 |
| |
| 267 | + | |
| 268 | + | |
266 | 269 |
| |
267 | 270 |
| |
268 | 271 |
| |
| |||
281 | 284 |
| |
282 | 285 |
| |
283 | 286 |
| |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
284 | 300 |
| |
285 | 301 |
| |
286 | 302 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
236 | 236 |
| |
237 | 237 |
| |
238 | 238 |
| |
| 239 | + | |
239 | 240 |
| |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
240 | 245 |
| |
241 | 246 |
| |
242 | 247 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
121 | 121 |
| |
122 | 122 |
| |
123 | 123 |
| |
| 124 | + | |
124 | 125 |
| |
125 | 126 |
| |
126 | 127 |
| |
| |||
150 | 151 |
| |
151 | 152 |
| |
152 | 153 |
| |
| 154 | + | |
| 155 | + | |
153 | 156 |
| |
154 | 157 |
| |
155 | 158 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
99 | 99 |
| |
100 | 100 |
| |
101 | 101 |
| |
| 102 | + | |
102 | 103 |
| |
103 | 104 |
| |
104 | 105 |
| |
|
0 commit comments
Comments
(0)