- Notifications
You must be signed in to change notification settings - Fork5
Commit13cc7eb
committed
Clean up two rather nasty bugs in operator selection code.
1. If there is exactly one pg_operator entry of the right name and oprkind,oper() and related routines would return that entry whether its input typehad anything to do with the request or not. This is just prematureoptimization: we shouldn't return the single candidate until after we verifythat it really is a valid candidate, ie, is at least coercion-compatiblewith the given types.2. oper() and related routines only promise a coercion-compatible result.Unfortunately, there were quite a few callers that assumed the returnedoperator is binary-compatible with the given datatype; they would proceedto call it without making any datatype coercions. These callers includesorting, grouping, aggregation, and VACUUM ANALYZE. In general I thinkit is appropriate for these callers to require an exact or binary-compatiblematch, so I've added a new routine compatible_oper() that only succeeds ifit can find an operator that doesn't require any run-time conversions.Callers now call oper() or compatible_oper() depending on whether they areprepared to deal with type conversion or not.The upshot of these bugs is revealed by the following silliness in PL/Tcl'sselftest: it creates an operator @< on int4, and then tries to use it tosort a char(N) column. The system would let it do that :-( (and evidentlyhas done so since 6.3 :-( :-(). The result in this case was just a sillysort order, but the reverse combination would've provoked coredump fromtrying to dereference integers. With this fix you get more reasonablebehavior:pltcl_test=# select * from T_pkey1 order by key1, key2 using @<;ERROR: Unable to identify an operator '@<' for types 'bpchar' and 'bpchar' You will have to retype this query using an explicit cast1 parentb24b2a5 commit13cc7eb
File tree
9 files changed
+162
-90
lines changed- src
- backend
- commands
- executor
- optimizer
- path
- plan
- parser
- include/parser
9 files changed
+162
-90
lines changedLines changed: 16 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
152 | 152 |
| |
153 | 153 |
| |
154 | 154 |
| |
155 |
| - | |
156 | 155 |
| |
157 | 156 |
| |
158 | 157 |
| |
| |||
167 | 166 |
| |
168 | 167 |
| |
169 | 168 |
| |
170 |
| - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
171 | 173 |
| |
172 | 174 |
| |
173 |
| - | |
174 |
| - | |
| 175 | + | |
175 | 176 |
| |
176 | 177 |
| |
177 | 178 |
| |
178 | 179 |
| |
179 | 180 |
| |
180 |
| - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
181 | 185 |
| |
182 | 186 |
| |
183 |
| - | |
184 |
| - | |
| 187 | + | |
185 | 188 |
| |
186 | 189 |
| |
187 | 190 |
| |
| |||
191 | 194 |
| |
192 | 195 |
| |
193 | 196 |
| |
194 |
| - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
195 | 201 |
| |
196 | 202 |
| |
197 |
| - | |
198 |
| - | |
| 203 | + | |
199 | 204 |
| |
200 | 205 |
| |
201 | 206 |
| |
|
Lines changed: 6 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
| 49 | + | |
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| |||
909 | 909 |
| |
910 | 910 |
| |
911 | 911 |
| |
912 |
| - | |
913 |
| - | |
| 912 | + | |
914 | 913 |
| |
915 | 914 |
| |
916 | 915 |
| |
917 | 916 |
| |
918 | 917 |
| |
919 | 918 |
| |
920 |
| - | |
921 |
| - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
922 | 922 |
| |
923 | 923 |
| |
924 |
| - | |
925 |
| - | |
926 |
| - | |
| 924 | + | |
927 | 925 |
| |
928 | 926 |
| |
929 | 927 |
| |
|
Lines changed: 5 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
| 18 | + | |
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| |||
495 | 495 |
| |
496 | 496 |
| |
497 | 497 |
| |
498 |
| - | |
499 |
| - | |
| 498 | + | |
500 | 499 |
| |
501 |
| - | |
502 |
| - | |
| 500 | + | |
| 501 | + | |
503 | 502 |
| |
504 | 503 |
| |
505 |
| - | |
506 |
| - | |
507 |
| - | |
| 504 | + | |
508 | 505 |
| |
509 | 506 |
| |
510 | 507 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
| 12 | + | |
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| |||
878 | 878 |
| |
879 | 879 |
| |
880 | 880 |
| |
881 |
| - | |
| 881 | + | |
882 | 882 |
| |
883 | 883 |
| |
884 | 884 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
617 | 617 |
| |
618 | 618 |
| |
619 | 619 |
| |
620 |
| - | |
| 620 | + | |
621 | 621 |
| |
622 | 622 |
| |
623 | 623 |
| |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1155 | 1155 |
| |
1156 | 1156 |
| |
1157 | 1157 |
| |
1158 |
| - | |
1159 |
| - | |
1160 |
| - | |
1161 |
| - | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1162 | 1162 |
| |
1163 | 1163 |
| |
1164 | 1164 |
| |
|
Lines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
383 | 383 |
| |
384 | 384 |
| |
385 | 385 |
| |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
386 | 391 |
| |
387 | 392 |
| |
388 | 393 |
| |
|
0 commit comments
Comments
(0)