forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc399248
committed
Fix deparsing of Consts in postgres_fdw ORDER BY
For UNION ALL queries where a union child query contained a foreigntable, if the targetlist of that query contained a constant, and thetop-level query performed an ORDER BY which contained the column for theconstant value, then postgres_fdw would find the EquivalenceMember withthe Const and then try to produce an ORDER BY containing that Const.This caused problems with INT typed Consts as these could appear to berequests to order by an ordinal column position rather than the constantvalue. This could lead to either an error such as:ERROR: ORDER BY position <int const> is not in select listor worse, if the constant value is a valid column, then we could justsort by the wrong column altogether.Here we fix this issue by just not including these Consts in the ORDERBY clause.In passing, add a new section for testing ORDER BY in the postgres_fdwtests and move two existing tests which were misplaced in the WHEREclause testing section into it.Reported-by: Michał KłeczekReviewed-by: Ashutosh Bapat, Richard GuoBug: #18381Discussion:https://postgr.es/m/0714C8B8-8D82-4ABB-9F8D-A0C3657E7B6E%40kleczek.orgDiscussion:https://postgr.es/m/18381-137456acd168bf93%40postgresql.orgBackpatch-through: 12, oldest supported version1 parent7b8e2ae commitc399248
File tree
3 files changed
+114
-36
lines changed- contrib/postgres_fdw
- expected
- sql
3 files changed
+114
-36
lines changedLines changed: 21 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3912 | 3912 |
| |
3913 | 3913 |
| |
3914 | 3914 |
| |
3915 |
| - | |
3916 | 3915 |
| |
| 3916 | + | |
3917 | 3917 |
| |
3918 | 3918 |
| |
3919 | 3919 |
| |
3920 | 3920 |
| |
3921 |
| - | |
3922 | 3921 |
| |
3923 | 3922 |
| |
3924 | 3923 |
| |
| |||
3951 | 3950 |
| |
3952 | 3951 |
| |
3953 | 3952 |
| |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
3954 | 3973 |
| |
3955 | 3974 |
| |
3956 | 3975 |
| |
| |||
3965 | 3984 |
| |
3966 | 3985 |
| |
3967 | 3986 |
| |
3968 |
| - | |
3969 | 3987 |
| |
3970 | 3988 |
| |
3971 | 3989 |
| |
| |||
3975 | 3993 |
| |
3976 | 3994 |
| |
3977 | 3995 |
| |
3978 |
| - | |
3979 | 3996 |
| |
3980 | 3997 |
| |
3981 | 3998 |
| |
|
Lines changed: 67 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
893 | 893 |
| |
894 | 894 |
| |
895 | 895 |
| |
896 |
| - | |
897 |
| - | |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
906 |
| - | |
907 |
| - | |
908 |
| - | |
909 |
| - | |
910 |
| - | |
911 |
| - | |
912 |
| - | |
913 |
| - | |
914 |
| - | |
915 |
| - | |
916 |
| - | |
917 |
| - | |
918 |
| - | |
919 |
| - | |
920 |
| - | |
921 |
| - | |
922 | 896 |
| |
923 | 897 |
| |
924 | 898 |
| |
| |||
1206 | 1180 |
| |
1207 | 1181 |
| |
1208 | 1182 |
| |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1209 | 1250 |
| |
1210 | 1251 |
| |
1211 | 1252 |
| |
|
Lines changed: 26 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 | 358 |
| |
365 | 359 |
| |
366 | 360 |
| |
| |||
462 | 456 |
| |
463 | 457 |
| |
464 | 458 |
| |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
465 | 485 |
| |
466 | 486 |
| |
467 | 487 |
| |
|
0 commit comments
Comments
(0)