forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7d2c7f0
committed
Fix query pullup issue with WindowClause runCondition
94985c2 added code to detect when WindowFuncs were monotonic andallowed additional quals to be "pushed down" into the subquery to beused as WindowClause runConditions in order to short-circuit executionin nodeWindowAgg.c.The Node representation of runConditions wasn't well selected andbecause we do qual pushdown before planning the subquery, the planningof the subquery could perform subquery pull-up of nested subqueries.For WindowFuncs with args, the arguments could be changed after pushingthe qual down to the subquery.This was made more difficult by the fact that the code duplicated theWindowFunc inside an OpExpr to include in the WindowClauses runConditionfield. This could result in duplication of subqueries and a pull-up ofsuch a subquery could result in another initplan parameter being issuedfor the 2nd version of the subplan. This could result in errors such as:ERROR: WindowFunc not found in subplan target listsTo fix this, we change the node representation of these run conditionsand instead of storing an OpExpr containing the WindowFunc in a listinside WindowClause, we now store a new node type namedWindowFuncRunCondition within a new field in the WindowFunc. These gettransformed into OpExprs later in planning once subquery pull-up has beenperformed.This problem did exist in v15 and v16, but that was fixed by9d36b88and e5d20bbd.Cat version bump due to new node type and modifying WindowFunc struct.Bug: #18305Reported-by: Zuming JiangDiscussion:https://postgr.es/m/18305-33c49b4c830b37b3%40postgresql.org1 parent01df147 commit7d2c7f0
File tree
18 files changed
+143
-53
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- prep
- util
- parser
- include
- catalog
- nodes
- optimizer
- test/regress
- expected
- sql
- tools/pgindent
18 files changed
+143
-53
lines changedLines changed: 20 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2163 | 2163 |
| |
2164 | 2164 |
| |
2165 | 2165 |
| |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2166 | 2176 |
| |
2167 | 2177 |
| |
2168 | 2178 |
| |
| |||
2400 | 2410 |
| |
2401 | 2411 |
| |
2402 | 2412 |
| |
2403 |
| - | |
2404 |
| - | |
2405 | 2413 |
| |
2406 | 2414 |
| |
2407 | 2415 |
| |
| |||
2752 | 2760 |
| |
2753 | 2761 |
| |
2754 | 2762 |
| |
2755 |
| - | |
2756 |
| - | |
2757 | 2763 |
| |
2758 | 2764 |
| |
2759 | 2765 |
| |
| |||
3053 | 3059 |
| |
3054 | 3060 |
| |
3055 | 3061 |
| |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
3056 | 3072 |
| |
3057 | 3073 |
| |
3058 | 3074 |
| |
| |||
3466 | 3482 |
| |
3467 | 3483 |
| |
3468 | 3484 |
| |
3469 |
| - | |
3470 | 3485 |
| |
3471 | 3486 |
| |
3472 | 3487 |
| |
| |||
3799 | 3814 |
| |
3800 | 3815 |
| |
3801 | 3816 |
| |
3802 |
| - | |
3803 | 3817 |
| |
3804 | 3818 |
| |
3805 | 3819 |
| |
|
Lines changed: 12 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2205 | 2205 |
| |
2206 | 2206 |
| |
2207 | 2207 |
| |
2208 |
| - | |
| 2208 | + | |
2209 | 2209 |
| |
2210 | 2210 |
| |
2211 | 2211 |
| |
| |||
2358 | 2358 |
| |
2359 | 2359 |
| |
2360 | 2360 |
| |
2361 |
| - | |
| 2361 | + | |
2362 | 2362 |
| |
2363 | 2363 |
| |
2364 | 2364 |
| |
| |||
2369 | 2369 |
| |
2370 | 2370 |
| |
2371 | 2371 |
| |
2372 |
| - | |
| 2372 | + | |
2373 | 2373 |
| |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
2378 |
| - | |
2379 |
| - | |
2380 |
| - | |
2381 |
| - | |
2382 |
| - | |
2383 |
| - | |
2384 |
| - | |
2385 |
| - | |
2386 |
| - | |
2387 |
| - | |
2388 |
| - | |
2389 |
| - | |
2390 |
| - | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
2391 | 2379 |
| |
2392 |
| - | |
| 2380 | + | |
2393 | 2381 |
| |
2394 | 2382 |
| |
2395 | 2383 |
| |
| |||
2403 | 2391 |
| |
2404 | 2392 |
| |
2405 | 2393 |
| |
2406 |
| - | |
2407 |
| - | |
2408 |
| - | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
2409 | 2397 |
| |
2410 | 2398 |
| |
2411 | 2399 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2699 | 2699 |
| |
2700 | 2700 |
| |
2701 | 2701 |
| |
2702 |
| - | |
| 2702 | + | |
2703 | 2703 |
| |
2704 | 2704 |
| |
2705 | 2705 |
| |
|
Lines changed: 44 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
870 | 870 |
| |
871 | 871 |
| |
872 | 872 |
| |
873 |
| - | |
874 |
| - | |
875 |
| - | |
876 | 873 |
| |
877 | 874 |
| |
878 | 875 |
| |
| |||
4527 | 4524 |
| |
4528 | 4525 |
| |
4529 | 4526 |
| |
| 4527 | + | |
4530 | 4528 |
| |
4531 | 4529 |
| |
4532 | 4530 |
| |
| 4531 | + | |
4533 | 4532 |
| |
4534 | 4533 |
| |
4535 | 4534 |
| |
| |||
4577 | 4576 |
| |
4578 | 4577 |
| |
4579 | 4578 |
| |
4580 |
| - | |
4581 | 4579 |
| |
4582 | 4580 |
| |
4583 | 4581 |
| |
| |||
4599 | 4597 |
| |
4600 | 4598 |
| |
4601 | 4599 |
| |
4602 |
| - | |
4603 |
| - | |
4604 |
| - | |
| 4600 | + | |
| 4601 | + | |
4605 | 4602 |
| |
4606 |
| - | |
4607 |
| - | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
| 4628 | + | |
| 4629 | + | |
| 4630 | + | |
| 4631 | + | |
| 4632 | + | |
| 4633 | + | |
| 4634 | + | |
| 4635 | + | |
| 4636 | + | |
| 4637 | + | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
4608 | 4641 |
| |
4609 | 4642 |
| |
4610 | 4643 |
| |
4611 | 4644 |
| |
4612 |
| - | |
| 4645 | + | |
| 4646 | + | |
4613 | 4647 |
| |
4614 | 4648 |
| |
4615 | 4649 |
| |
|
Lines changed: 0 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2175 | 2175 |
| |
2176 | 2176 |
| |
2177 | 2177 |
| |
2178 |
| - | |
2179 |
| - | |
2180 |
| - | |
2181 |
| - | |
2182 |
| - | |
2183 |
| - | |
2184 |
| - | |
2185 |
| - | |
2186 | 2178 |
| |
2187 | 2179 |
| |
2188 | 2180 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2566 | 2566 |
| |
2567 | 2567 |
| |
2568 | 2568 |
| |
| 2569 | + | |
2569 | 2570 |
| |
2570 | 2571 |
| |
2571 | 2572 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3471 | 3471 |
| |
3472 | 3472 |
| |
3473 | 3473 |
| |
| 3474 | + | |
3474 | 3475 |
| |
3475 | 3476 |
| |
3476 | 3477 |
| |
| |||
3486 | 3487 |
| |
3487 | 3488 |
| |
3488 | 3489 |
| |
| 3490 | + | |
3489 | 3491 |
| |
3490 | 3492 |
| |
3491 | 3493 |
| |
| |||
3510 | 3512 |
| |
3511 | 3513 |
| |
3512 | 3514 |
| |
| 3515 | + | |
3513 | 3516 |
| |
3514 | 3517 |
| |
3515 | 3518 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2956 | 2956 |
| |
2957 | 2957 |
| |
2958 | 2958 |
| |
2959 |
| - | |
2960 | 2959 |
| |
2961 | 2960 |
| |
2962 | 2961 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3826 | 3826 |
| |
3827 | 3827 |
| |
3828 | 3828 |
| |
| 3829 | + | |
3829 | 3830 |
| |
3830 | 3831 |
| |
3831 | 3832 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
834 | 834 |
| |
835 | 835 |
| |
836 | 836 |
| |
| 837 | + | |
837 | 838 |
| |
838 | 839 |
| |
839 | 840 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 |
| - | |
| 60 | + | |
61 | 61 |
| |
62 | 62 |
|
Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1549 | 1549 |
| |
1550 | 1550 |
| |
1551 | 1551 |
| |
1552 |
| - | |
1553 |
| - | |
1554 | 1552 |
| |
1555 | 1553 |
| |
1556 | 1554 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2308 | 2308 |
| |
2309 | 2309 |
| |
2310 | 2310 |
| |
| 2311 | + | |
2311 | 2312 |
| |
2312 | 2313 |
| |
2313 | 2314 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
575 | 575 |
| |
576 | 576 |
| |
577 | 577 |
| |
| 578 | + | |
| 579 | + | |
578 | 580 |
| |
579 | 581 |
| |
580 | 582 |
| |
| |||
585 | 587 |
| |
586 | 588 |
| |
587 | 589 |
| |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
588 | 618 |
| |
589 | 619 |
| |
590 | 620 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
250 | 250 |
| |
251 | 251 |
| |
252 | 252 |
| |
| 253 | + | |
253 | 254 |
| |
254 | 255 |
| |
255 | 256 |
| |
|
0 commit comments
Comments
(0)