forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit393430f
committed
Print the correct aliases for DML target tables in ruleutils.
ruleutils.c blindly printed the user-given alias (or nothing if therehadn't been one) for the target table of INSERT/UPDATE/DELETE queries.That works a large percentage of the time, but not always: for queriesappearing in WITH, it's possible that we chose a different alias toavoid conflict with outer-scope names. Since the chosen alias wouldbe used in any Var references to the target table, this'd lead to aninconsistent printout with consequences such as dump/restore failures.The correct logic for printing (or not) a relation alias was embeddedin get_from_clause_item. Factor it out to a separate function so thatwe don't need a jointree node to use it. (Only a limited part of thatfunction can be reached from these new call sites, but this seems likethe cleanest non-duplicative factorization.)In passing, I got rid of a redundant "\d+ rules_src" step in rules.sql.Initial report from Jonathan Katz; thanks to Vignesh C for analysis.This has been broken for a long time, so back-patch to all supportedbranches.Discussion:https://postgr.es/m/e947fa21-24b2-f922-375a-d4f763ef3e4b@postgresql.orgDiscussion:https://postgr.es/m/CALDaNm1MMntjmT_NJGp-Z=xbF02qHGAyuSHfYHias3TqQbPF2w@mail.gmail.com1 parent881a917 commit393430f
File tree
3 files changed
+130
-84
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+130
-84
lines changedLines changed: 88 additions & 66 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
475 | 475 |
| |
476 | 476 |
| |
477 | 477 |
| |
| 478 | + | |
| 479 | + | |
478 | 480 |
| |
479 | 481 |
| |
480 | 482 |
| |
| |||
6648 | 6650 |
| |
6649 | 6651 |
| |
6650 | 6652 |
| |
6651 |
| - | |
| 6653 | + | |
6652 | 6654 |
| |
6653 |
| - | |
6654 |
| - | |
6655 |
| - | |
6656 |
| - | |
| 6655 | + | |
| 6656 | + | |
| 6657 | + | |
| 6658 | + | |
| 6659 | + | |
| 6660 | + | |
6657 | 6661 |
| |
6658 | 6662 |
| |
6659 | 6663 |
| |
| |||
6835 | 6839 |
| |
6836 | 6840 |
| |
6837 | 6841 |
| |
6838 |
| - | |
6839 |
| - | |
6840 |
| - | |
| 6842 | + | |
| 6843 | + | |
| 6844 | + | |
| 6845 | + | |
6841 | 6846 |
| |
6842 | 6847 |
| |
6843 | 6848 |
| |
| |||
7043 | 7048 |
| |
7044 | 7049 |
| |
7045 | 7050 |
| |
7046 |
| - | |
7047 |
| - | |
7048 |
| - | |
| 7051 | + | |
| 7052 | + | |
| 7053 | + | |
7049 | 7054 |
| |
7050 | 7055 |
| |
7051 | 7056 |
| |
| |||
10887 | 10892 |
| |
10888 | 10893 |
| |
10889 | 10894 |
| |
10890 |
| - | |
10891 | 10895 |
| |
10892 | 10896 |
| |
10893 |
| - | |
10894 | 10897 |
| |
10895 | 10898 |
| |
10896 | 10899 |
| |
| |||
11027 | 11030 |
| |
11028 | 11031 |
| |
11029 | 11032 |
| |
11030 |
| - | |
11031 |
| - | |
11032 |
| - | |
11033 |
| - | |
11034 |
| - | |
11035 |
| - | |
11036 |
| - | |
11037 |
| - | |
11038 |
| - | |
11039 |
| - | |
11040 |
| - | |
11041 |
| - | |
11042 |
| - | |
11043 |
| - | |
11044 |
| - | |
11045 |
| - | |
11046 |
| - | |
11047 |
| - | |
11048 |
| - | |
11049 |
| - | |
11050 |
| - | |
11051 |
| - | |
11052 |
| - | |
11053 |
| - | |
11054 |
| - | |
11055 |
| - | |
11056 |
| - | |
11057 |
| - | |
11058 |
| - | |
11059 |
| - | |
11060 |
| - | |
11061 |
| - | |
11062 |
| - | |
11063 |
| - | |
11064 |
| - | |
11065 |
| - | |
11066 |
| - | |
11067 |
| - | |
11068 |
| - | |
11069 |
| - | |
11070 |
| - | |
11071 |
| - | |
11072 |
| - | |
11073 |
| - | |
11074 |
| - | |
11075 |
| - | |
11076 |
| - | |
11077 |
| - | |
11078 |
| - | |
11079 |
| - | |
11080 |
| - | |
11081 |
| - | |
11082 |
| - | |
| 11033 | + | |
11083 | 11034 |
| |
11084 | 11035 |
| |
11085 | 11036 |
| |
| |||
11217 | 11168 |
| |
11218 | 11169 |
| |
11219 | 11170 |
| |
| 11171 | + | |
| 11172 | + | |
| 11173 | + | |
| 11174 | + | |
| 11175 | + | |
| 11176 | + | |
| 11177 | + | |
| 11178 | + | |
| 11179 | + | |
| 11180 | + | |
| 11181 | + | |
| 11182 | + | |
| 11183 | + | |
| 11184 | + | |
| 11185 | + | |
| 11186 | + | |
| 11187 | + | |
| 11188 | + | |
| 11189 | + | |
| 11190 | + | |
| 11191 | + | |
| 11192 | + | |
| 11193 | + | |
| 11194 | + | |
| 11195 | + | |
| 11196 | + | |
| 11197 | + | |
| 11198 | + | |
| 11199 | + | |
| 11200 | + | |
| 11201 | + | |
| 11202 | + | |
| 11203 | + | |
| 11204 | + | |
| 11205 | + | |
| 11206 | + | |
| 11207 | + | |
| 11208 | + | |
| 11209 | + | |
| 11210 | + | |
| 11211 | + | |
| 11212 | + | |
| 11213 | + | |
| 11214 | + | |
| 11215 | + | |
| 11216 | + | |
| 11217 | + | |
| 11218 | + | |
| 11219 | + | |
| 11220 | + | |
| 11221 | + | |
| 11222 | + | |
| 11223 | + | |
| 11224 | + | |
| 11225 | + | |
| 11226 | + | |
| 11227 | + | |
| 11228 | + | |
| 11229 | + | |
| 11230 | + | |
| 11231 | + | |
| 11232 | + | |
| 11233 | + | |
| 11234 | + | |
| 11235 | + | |
| 11236 | + | |
| 11237 | + | |
| 11238 | + | |
| 11239 | + | |
| 11240 | + | |
| 11241 | + | |
11220 | 11242 |
| |
11221 | 11243 |
| |
11222 | 11244 |
| |
|
Lines changed: 30 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2998 | 2998 |
| |
2999 | 2999 |
| |
3000 | 3000 |
| |
3001 |
| - | |
3002 |
| - | |
3003 |
| - | |
3004 |
| - | |
3005 |
| - | |
3006 |
| - | |
3007 |
| - | |
3008 |
| - | |
3009 |
| - | |
3010 |
| - | |
3011 |
| - | |
3012 |
| - | |
3013 |
| - | |
3014 |
| - | |
3015 |
| - | |
3016 |
| - | |
3017 |
| - | |
3018 | 3001 |
| |
3019 | 3002 |
| |
3020 | 3003 |
| |
3021 | 3004 |
| |
3022 | 3005 |
| |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
3023 | 3016 |
| |
3024 | 3017 |
| |
3025 | 3018 |
| |
| |||
3044 | 3037 |
| |
3045 | 3038 |
| |
3046 | 3039 |
| |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
3047 | 3060 |
| |
3048 | 3061 |
| |
3049 | 3062 |
| |
|
Lines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1015 | 1015 |
| |
1016 | 1016 |
| |
1017 | 1017 |
| |
1018 |
| - | |
1019 | 1018 |
| |
1020 | 1019 |
| |
1021 | 1020 |
| |
1022 | 1021 |
| |
1023 | 1022 |
| |
1024 | 1023 |
| |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1025 | 1036 |
| |
1026 | 1037 |
| |
1027 | 1038 |
| |
|
0 commit comments
Comments
(0)