forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6ea364e
committed
Prevent overly-aggressive collapsing of joins to RTE_RESULT relations.
The RTE_RESULT simplification logic added by commit4be058f had aflaw: it would collapse out a RTE_RESULT that is due to compute aPlaceHolderVar, and reassign the PHV to the parent join level, even ifanother input relation of the join contained a lateral reference tothe PHV. That can't work because the PHV would be computed too late.In practice it led to failures of internal sanity checks later inplanning (either assertion failures or errors such as "failed toconstruct the join relation").To fix, add code to check for the presence of such PHVs in relevantportions of the query tree. Notably, this required refactoringrange_table_walker so that a caller could ask to walk individual RTEsnot the whole list. (It might be a good idea to refactorrange_table_mutator in the same way, if only to keep those functionslooking similar; but I didn't do so here as it wasn't necessary forthe bug fix.)This exercise also taught me that find_dependent_phvs(), as it stood,could only safely be used on the entire Query, not on subtrees.Adjust its API to reflect that; which in passing allows it to havea fast path for the common case of no PHVs anywhere.Per report from Will Leinweber. Back-patch to v12 where the bugwas introduced.Discussion:https://postgr.es/m/CALLb-4xJMd4GZt2YCecMC95H-PafuWNKcmps4HLRx2NHNBfB4g@mail.gmail.com1 parente0e569e commit6ea364e
File tree
5 files changed
+193
-66
lines changed- src
- backend
- nodes
- optimizer/prep
- include/nodes
- test/regress
- expected
- sql
5 files changed
+193
-66
lines changedLines changed: 61 additions & 46 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2378 | 2378 |
| |
2379 | 2379 |
| |
2380 | 2380 |
| |
2381 |
| - | |
| 2381 | + | |
2382 | 2382 |
| |
2383 |
| - | |
2384 |
| - | |
2385 |
| - | |
2386 |
| - | |
2387 |
| - | |
2388 |
| - | |
2389 |
| - | |
2390 |
| - | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
2391 | 2388 |
| |
2392 |
| - | |
2393 |
| - | |
2394 |
| - | |
2395 |
| - | |
2396 |
| - | |
2397 |
| - | |
2398 |
| - | |
2399 |
| - | |
2400 |
| - | |
2401 |
| - | |
2402 |
| - | |
2403 |
| - | |
2404 |
| - | |
2405 |
| - | |
2406 |
| - | |
2407 |
| - | |
2408 |
| - | |
2409 |
| - | |
2410 |
| - | |
2411 |
| - | |
2412 |
| - | |
2413 |
| - | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
2414 | 2416 |
| |
2415 |
| - | |
2416 |
| - | |
2417 |
| - | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
2418 | 2421 |
| |
2419 |
| - | |
2420 |
| - | |
2421 |
| - | |
2422 |
| - | |
2423 |
| - | |
2424 |
| - | |
2425 |
| - | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
2426 | 2441 |
| |
2427 |
| - | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
2428 | 2447 |
| |
2429 | 2448 |
| |
2430 |
| - | |
2431 |
| - | |
2432 |
| - | |
2433 |
| - | |
2434 | 2449 |
| |
2435 | 2450 |
| |
2436 | 2451 |
| |
|
Lines changed: 93 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
123 |
| - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
124 | 126 |
| |
125 | 127 |
| |
126 | 128 |
| |
| |||
2957 | 2959 |
| |
2958 | 2960 |
| |
2959 | 2961 |
| |
2960 |
| - | |
2961 |
| - | |
2962 |
| - | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
2963 | 2968 |
| |
2964 | 2969 |
| |
2965 | 2970 |
| |
| |||
3021 | 3026 |
| |
3022 | 3027 |
| |
3023 | 3028 |
| |
3024 |
| - | |
3025 |
| - | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
3026 | 3034 |
| |
3027 | 3035 |
| |
3028 | 3036 |
| |
| |||
3035 | 3043 |
| |
3036 | 3044 |
| |
3037 | 3045 |
| |
3038 |
| - | |
3039 |
| - | |
3040 |
| - | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
3041 | 3050 |
| |
3042 | 3051 |
| |
3043 |
| - | |
| 3052 | + | |
| 3053 | + | |
3044 | 3054 |
| |
3045 | 3055 |
| |
3046 | 3056 |
| |
| |||
3091 | 3101 |
| |
3092 | 3102 |
| |
3093 | 3103 |
| |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
3094 | 3113 |
| |
3095 |
| - | |
| 3114 | + | |
| 3115 | + | |
3096 | 3116 |
| |
3097 | 3117 |
| |
3098 | 3118 |
| |
| |||
3121 | 3141 |
| |
3122 | 3142 |
| |
3123 | 3143 |
| |
| 3144 | + | |
| 3145 | + | |
3124 | 3146 |
| |
3125 | 3147 |
| |
3126 | 3148 |
| |
| |||
3131 | 3153 |
| |
3132 | 3154 |
| |
3133 | 3155 |
| |
3134 |
| - | |
| 3156 | + | |
3135 | 3157 |
| |
3136 | 3158 |
| |
3137 | 3159 |
| |
| |||
3141 | 3163 |
| |
3142 | 3164 |
| |
3143 | 3165 |
| |
3144 |
| - | |
| 3166 | + | |
3145 | 3167 |
| |
3146 | 3168 |
| |
3147 | 3169 |
| |
| |||
3162 | 3184 |
| |
3163 | 3185 |
| |
3164 | 3186 |
| |
3165 |
| - | |
| 3187 | + | |
3166 | 3188 |
| |
3167 | 3189 |
| |
3168 | 3190 |
| |
| |||
3246 | 3268 |
| |
3247 | 3269 |
| |
3248 | 3270 |
| |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
3249 | 3277 |
| |
3250 | 3278 |
| |
3251 | 3279 |
| |
| |||
3292 | 3320 |
| |
3293 | 3321 |
| |
3294 | 3322 |
| |
3295 |
| - | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
3296 | 3342 |
| |
3297 | 3343 |
| |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
3298 | 3350 |
| |
3299 | 3351 |
| |
3300 | 3352 |
| |
3301 | 3353 |
| |
3302 | 3354 |
| |
3303 |
| - | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
3304 | 3366 |
| |
3305 |
| - | |
3306 |
| - | |
3307 |
| - | |
3308 |
| - | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
3309 | 3382 |
| |
3310 | 3383 |
| |
3311 | 3384 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
141 | 141 |
| |
142 | 142 |
| |
143 | 143 |
| |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 |
| |
145 | 148 |
| |
146 | 149 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3242 | 3242 |
| |
3243 | 3243 |
| |
3244 | 3244 |
| |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
3245 | 3271 |
| |
3246 | 3272 |
| |
3247 | 3273 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1018 | 1018 |
| |
1019 | 1019 |
| |
1020 | 1020 |
| |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
1021 | 1031 |
| |
1022 | 1032 |
| |
1023 | 1033 |
| |
|
0 commit comments
Comments
(0)