forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7421f4b
committed
Fix incorrect handling of CTEs and ENRs as DML target relations.
setTargetTable threw an error if the proposed target RangeVar's relnamematched any visible CTE or ENR. This breaks backwards compatibility inthe CTE case, since pre-v10 we never looked for a CTE here at all, so thatCTE names did not mask regular tables. It does seem like a good idea tothrow an error for the ENR case, though, thus causing ENRs to mask tablesfor this purpose; ENRs are new in v10 so we're not breaking existing code,and we may someday want to allow them to be the targets of DML.To fix that, replace use of getRTEForSpecialRelationTypes, which wasoverkill anyway, with use of scanNameSpaceForENR.A second problem was that the check neglected to verify null schemaname,so that a CTE or ENR could incorrectly be thought to match a qualifiedRangeVar. That happened because getRTEForSpecialRelationTypes reliedon its caller to have checked for null schemaname. Even though the oneremaining caller got it right, this is obviously bug-prone, so movethe check inside getRTEForSpecialRelationTypes.Also, revert commit18ce3a4's extremely poorly thought out decision toadd a NULL return case to parserOpenTable --- without either documentingthat or adjusting any of the callers to check for it. The current bugseems to have arisen in part due to working around that bad idea.In passing, remove the one-line shim functions transformCTEReference andtransformENRReference --- they don't seem to be adding any clarity orfunctionality.Per report from Hugo Mercier (via Julien Rouhaud). Back-patch to v10where the bug was introduced.Thomas Munro, with minor editing by meDiscussion:https://postgr.es/m/CAOBaU_YdPVH+PTtiKSSLOiiW3mVDYsnNUekK+XPbHXiP=wrFLA@mail.gmail.com1 parent4211673 commit7421f4b
File tree
6 files changed
+59
-63
lines changed- src
- backend/parser
- test/regress
- expected
- sql
6 files changed
+59
-63
lines changedLines changed: 27 additions & 47 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 | 65 |
| |
69 | 66 |
| |
70 | 67 |
| |
| |||
184 | 181 |
| |
185 | 182 |
| |
186 | 183 |
| |
187 |
| - | |
188 |
| - | |
189 |
| - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
190 | 190 |
| |
191 | 191 |
| |
192 | 192 |
| |
| |||
430 | 430 |
| |
431 | 431 |
| |
432 | 432 |
| |
433 |
| - | |
434 |
| - | |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
439 |
| - | |
440 |
| - | |
441 |
| - | |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
448 |
| - | |
449 |
| - | |
450 |
| - | |
451 |
| - | |
452 |
| - | |
453 |
| - | |
454 |
| - | |
455 |
| - | |
456 |
| - | |
457 |
| - | |
458 |
| - | |
459 |
| - | |
460 |
| - | |
461 |
| - | |
462 | 433 |
| |
463 | 434 |
| |
464 | 435 |
| |
| |||
1071 | 1042 |
| |
1072 | 1043 |
| |
1073 | 1044 |
| |
1074 |
| - | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1075 | 1051 |
| |
1076 | 1052 |
| |
1077 | 1053 |
| |
1078 | 1054 |
| |
1079 | 1055 |
| |
1080 |
| - | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1081 | 1063 |
| |
1082 | 1064 |
| |
1083 | 1065 |
| |
1084 |
| - | |
1085 |
| - | |
1086 |
| - | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1087 | 1071 |
| |
1088 | 1072 |
| |
1089 | 1073 |
| |
| |||
1119 | 1103 |
| |
1120 | 1104 |
| |
1121 | 1105 |
| |
1122 |
| - | |
| 1106 | + | |
1123 | 1107 |
| |
1124 | 1108 |
| |
1125 |
| - | |
1126 |
| - | |
1127 |
| - | |
1128 |
| - | |
1129 |
| - | |
1130 |
| - | |
| 1109 | + | |
| 1110 | + | |
1131 | 1111 |
| |
1132 | 1112 |
| |
1133 | 1113 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1159 | 1159 |
| |
1160 | 1160 |
| |
1161 | 1161 |
| |
1162 |
| - | |
1163 |
| - | |
1164 |
| - | |
1165 |
| - | |
1166 |
| - | |
1167 |
| - | |
1168 | 1162 |
| |
1169 | 1163 |
| |
1170 | 1164 |
| |
1171 | 1165 |
| |
1172 | 1166 |
| |
1173 | 1167 |
| |
1174 |
| - | |
| 1168 | + | |
1175 | 1169 |
| |
1176 | 1170 |
| |
1177 | 1171 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5879 | 5879 |
| |
5880 | 5880 |
| |
5881 | 5881 |
| |
5882 |
| - | |
| 5882 | + | |
5883 | 5883 |
| |
5884 | 5884 |
| |
5885 | 5885 |
| |
5886 | 5886 |
| |
5887 | 5887 |
| |
5888 |
| - | |
| 5888 | + | |
5889 | 5889 |
| |
5890 | 5890 |
| |
5891 | 5891 |
| |
5892 | 5892 |
| |
5893 |
| - | |
5894 |
| - | |
| 5893 | + | |
| 5894 | + | |
5895 | 5895 |
| |
5896 | 5896 |
| |
5897 | 5897 |
| |
|
Lines changed: 16 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2273 | 2273 |
| |
2274 | 2274 |
| |
2275 | 2275 |
| |
2276 |
| - | |
2277 |
| - | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + |
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4678 | 4678 |
| |
4679 | 4679 |
| |
4680 | 4680 |
| |
4681 |
| - | |
| 4681 | + | |
4682 | 4682 |
| |
4683 | 4683 |
| |
4684 | 4684 |
| |
4685 | 4685 |
| |
4686 | 4686 |
| |
4687 | 4687 |
| |
4688 |
| - | |
| 4688 | + | |
4689 | 4689 |
| |
4690 | 4690 |
| |
4691 | 4691 |
| |
|
Lines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1030 | 1030 |
| |
1031 | 1031 |
| |
1032 | 1032 |
| |
1033 |
| - | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + |
0 commit comments
Comments
(0)