- Notifications
You must be signed in to change notification settings - Fork4.9k
Commite276b58
committed
Fix parse_cte.c's failure to examine sub-WITHs in DML statements.
makeDependencyGraphWalker thought that only SelectStmt nodes couldcontain a WithClause. Which was true in our original implementationof WITH, but astonishingly we missed updating this code when we addedthe ability to attach WITH to INSERT/UPDATE/DELETE (and later MERGE).Moreover, since it was coded to deliberately block recursion to aWithClause, even updating raw_expression_tree_walker didn't save it.The upshot of this was that we didn't see references to outer CTEnames appearing within an inner WITH, and would neither complain aboutdisallowed recursion nor account for such references when sorting CTEsinto a usable order. The lack of complaints about this is perhaps notso surprising, because typical usage of WITH wouldn't hit either case.Still, it's pretty broken; failing to detect recursion here leads toassert failures or worse later on.Fix by factoring out the processing of sub-WITHs into a new functionWalkInnerWith, and invoking that for all the statement types thatcan have WITH.Bug: #18878Reported-by: Yu Liang <luy70@psu.edu>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/18878-a26fa5ab6be2f2cf@postgresql.orgBackpatch-through: 131 parentb92482d commite276b58
File tree
3 files changed
+111
-43
lines changed- src
- backend/parser
- test/regress
- expected
- sql
3 files changed
+111
-43
lines changedLines changed: 96 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
87 | 88 |
| |
88 | 89 |
| |
89 | 90 |
| |
| |||
507 | 508 |
| |
508 | 509 |
| |
509 | 510 |
| |
510 |
| - | |
511 | 511 |
| |
512 | 512 |
| |
513 | 513 |
| |
514 |
| - | |
515 |
| - | |
516 |
| - | |
517 |
| - | |
518 |
| - | |
519 |
| - | |
520 |
| - | |
521 |
| - | |
522 |
| - | |
523 |
| - | |
524 |
| - | |
525 |
| - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
526 | 524 |
| |
527 |
| - | |
528 |
| - | |
529 |
| - | |
530 |
| - | |
531 |
| - | |
532 |
| - | |
533 |
| - | |
534 |
| - | |
535 |
| - | |
536 |
| - | |
537 |
| - | |
538 |
| - | |
539 |
| - | |
540 |
| - | |
541 |
| - | |
542 |
| - | |
543 |
| - | |
544 |
| - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
545 | 537 |
| |
546 |
| - | |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 |
| - | |
553 |
| - | |
554 |
| - | |
555 |
| - | |
556 |
| - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
557 | 543 |
| |
558 | 544 |
| |
559 | 545 |
| |
560 | 546 |
| |
561 |
| - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
562 | 561 |
| |
563 | 562 |
| |
564 | 563 |
| |
| |||
572 | 571 |
| |
573 | 572 |
| |
574 | 573 |
| |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 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 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
575 | 628 |
| |
576 | 629 |
| |
577 | 630 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1109 | 1109 |
| |
1110 | 1110 |
| |
1111 | 1111 |
| |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1112 | 1120 |
| |
1113 | 1121 |
| |
1114 | 1122 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
520 | 520 |
| |
521 | 521 |
| |
522 | 522 |
| |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
523 | 530 |
| |
524 | 531 |
| |
525 | 532 |
| |
|
0 commit comments
Comments
(0)