- Notifications
You must be signed in to change notification settings - Fork5
Commit76f965f
committed
Improve handling of collations in contrib/postgres_fdw.
If we have a local Var of say varchar type with default collation, andwe apply a RelabelType to convert that to text with default collation, wedon't want to consider that as creating an FDW_COLLATE_UNSAFE situation.It should be okay to compare that to a remote Var, so long as the remoteVar determines the comparison collation. (When we actually ship such anexpression to the remote side, the local Var would become a Param withdefault collation, meaning the remote Var would in fact control thecomparison collation, because non-default implicit collation overridesdefault implicit collation in parse_collate.c.) To fix, be more preciseabout what FDW_COLLATE_NONE means: it applies either to a noncollatabledata type or to a collatable type with default collation, if that collationcan't be traced to a remote Var. (When it can, FDW_COLLATE_SAFE isappropriate.) We were essentially using that interpretation already atthe Var/Const/Param level, but we weren't bubbling it up properly.An alternative fix would be to introduce a separate FDW_COLLATE_DEFAULTvalue to describe the second situation, but that would add more codewithout changing the actual behavior, so it didn't seem worthwhile.Also, since we're clarifying the rule to be that we care about whetheroperator/function input collations match, there seems no need to failimmediately upon seeing a Const/Param/non-foreign-Var with nondefaultcollation. We only have to reject if it appears in a collation-sensitivecontext (for example, "var IS NOT NULL" is perfectly safe from a collationstandpoint, whatever collation the var has). So just set the state toUNSAFE rather than failing immediately.Per report from Jeevan Chalke. This essentially corrects some sloppythinking in commited3ddf9, so back-patchto 9.3 where that logic appeared.1 parent9f1255a commit76f965f
File tree
3 files changed
+135
-66
lines changed- contrib/postgres_fdw
- expected
- sql
3 files changed
+135
-66
lines changedLines changed: 57 additions & 32 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
21 |
| - | |
22 |
| - | |
23 |
| - | |
24 |
| - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 |
| |
26 | 27 |
| |
27 | 28 |
| |
| |||
69 | 70 |
| |
70 | 71 |
| |
71 | 72 |
| |
72 |
| - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 |
| |
74 |
| - | |
| 77 | + | |
| 78 | + | |
75 | 79 |
| |
76 | 80 |
| |
77 | 81 |
| |
| |||
272 | 276 |
| |
273 | 277 |
| |
274 | 278 |
| |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 |
| - | |
281 |
| - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
282 | 297 |
| |
283 | 298 |
| |
284 | 299 |
| |
| |||
288 | 303 |
| |
289 | 304 |
| |
290 | 305 |
| |
291 |
| - | |
292 |
| - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
293 | 309 |
| |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
301 | 316 |
| |
302 | 317 |
| |
303 | 318 |
| |
304 | 319 |
| |
305 | 320 |
| |
306 | 321 |
| |
307 | 322 |
| |
308 |
| - | |
| 323 | + | |
309 | 324 |
| |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
314 |
| - | |
315 |
| - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
316 | 331 |
| |
317 | 332 |
| |
318 | 333 |
| |
| |||
348 | 363 |
| |
349 | 364 |
| |
350 | 365 |
| |
| 366 | + | |
| 367 | + | |
351 | 368 |
| |
352 | 369 |
| |
353 | 370 |
| |
| |||
393 | 410 |
| |
394 | 411 |
| |
395 | 412 |
| |
| 413 | + | |
| 414 | + | |
396 | 415 |
| |
397 | 416 |
| |
398 | 417 |
| |
| |||
434 | 453 |
| |
435 | 454 |
| |
436 | 455 |
| |
| 456 | + | |
| 457 | + | |
437 | 458 |
| |
438 | 459 |
| |
439 | 460 |
| |
| |||
483 | 504 |
| |
484 | 505 |
| |
485 | 506 |
| |
486 |
| - | |
| 507 | + | |
487 | 508 |
| |
488 | 509 |
| |
489 | 510 |
| |
490 | 511 |
| |
491 | 512 |
| |
492 | 513 |
| |
493 | 514 |
| |
| 515 | + | |
| 516 | + | |
494 | 517 |
| |
495 | 518 |
| |
496 | 519 |
| |
| |||
540 | 563 |
| |
541 | 564 |
| |
542 | 565 |
| |
543 |
| - | |
| 566 | + | |
544 | 567 |
| |
545 | 568 |
| |
546 | 569 |
| |
547 | 570 |
| |
548 | 571 |
| |
549 | 572 |
| |
550 | 573 |
| |
| 574 | + | |
| 575 | + | |
551 | 576 |
| |
552 | 577 |
| |
553 | 578 |
| |
|
Lines changed: 70 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1005 | 1005 |
| |
1006 | 1006 |
| |
1007 | 1007 |
| |
1008 |
| - | |
1009 |
| - | |
1010 |
| - | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
1011 | 1011 |
| |
1012 | 1012 |
| |
1013 |
| - | |
1014 |
| - | |
| 1013 | + | |
| 1014 | + | |
1015 | 1015 |
| |
1016 |
| - | |
1017 |
| - | |
| 1016 | + | |
| 1017 | + | |
1018 | 1018 |
| |
1019 | 1019 |
| |
1020 | 1020 |
| |
1021 |
| - | |
1022 |
| - | |
| 1021 | + | |
| 1022 | + | |
1023 | 1023 |
| |
1024 |
| - | |
1025 |
| - | |
| 1024 | + | |
| 1025 | + | |
1026 | 1026 |
| |
1027 | 1027 |
| |
1028 | 1028 |
| |
1029 |
| - | |
1030 |
| - | |
| 1029 | + | |
| 1030 | + | |
1031 | 1031 |
| |
1032 |
| - | |
1033 |
| - | |
| 1032 | + | |
| 1033 | + | |
1034 | 1034 |
| |
1035 | 1035 |
| |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
1036 | 1058 |
| |
1037 | 1059 |
| |
1038 |
| - | |
1039 |
| - | |
| 1060 | + | |
| 1061 | + | |
1040 | 1062 |
| |
1041 |
| - | |
| 1063 | + | |
1042 | 1064 |
| |
1043 |
| - | |
| 1065 | + | |
1044 | 1066 |
| |
1045 | 1067 |
| |
1046 | 1068 |
| |
1047 |
| - | |
1048 |
| - | |
| 1069 | + | |
| 1070 | + | |
1049 | 1071 |
| |
1050 |
| - | |
| 1072 | + | |
1051 | 1073 |
| |
1052 |
| - | |
| 1074 | + | |
1053 | 1075 |
| |
1054 | 1076 |
| |
1055 | 1077 |
| |
1056 |
| - | |
1057 |
| - | |
| 1078 | + | |
| 1079 | + | |
1058 | 1080 |
| |
1059 |
| - | |
| 1081 | + | |
1060 | 1082 |
| |
1061 |
| - | |
| 1083 | + | |
1062 | 1084 |
| |
1063 | 1085 |
| |
1064 | 1086 |
| |
1065 |
| - | |
1066 |
| - | |
| 1087 | + | |
| 1088 | + | |
1067 | 1089 |
| |
1068 |
| - | |
| 1090 | + | |
1069 | 1091 |
| |
1070 |
| - | |
| 1092 | + | |
1071 | 1093 |
| |
1072 | 1094 |
| |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1073 | 1112 |
| |
1074 | 1113 |
| |
1075 | 1114 |
| |
|
Lines changed: 8 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
316 | 316 |
| |
317 | 317 |
| |
318 | 318 |
| |
319 |
| - | |
320 |
| - | |
321 |
| - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
322 | 322 |
| |
323 | 323 |
| |
324 | 324 |
| |
325 | 325 |
| |
326 | 326 |
| |
| 327 | + | |
| 328 | + | |
| 329 | + | |
327 | 330 |
| |
328 | 331 |
| |
329 | 332 |
| |
330 | 333 |
| |
331 | 334 |
| |
| 335 | + | |
| 336 | + | |
332 | 337 |
| |
333 | 338 |
| |
334 | 339 |
| |
|
0 commit comments
Comments
(0)