Commit 4526951
committed
Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN.
The relation aliases shown in the "Relations" line for a foreign scan
didn't always agree with those used in the rest of EXPLAIN's output.
The regression test result changes appearing here provide examples.
It's really impossible for postgres_fdw to duplicate EXPLAIN's alias
assignment logic during postgresGetForeignRelSize(), because of the
de-duplication that EXPLAIN does on a global basis --- and anyway,
trying to duplicate that would be unmaintainable. Instead, just put
numeric rangetable indexes into the string, and convert those to
table names/aliases in postgresExplainForeignScan, which does have
access to the results of ruleutils.c's alias assignment logic.
Aside from being more reliable, this shifts some work from planning
to EXPLAIN, which is a good tradeoff for performance. (I also
changed from using StringInfo to using psprintf, which makes the
code slightly simpler and reduces its memory consumption.)
A kluge required by this solution is that we have to reverse-engineer
the rtoffset applied by setrefs.c. If that logic ever fails
(presumably because the member tables of a join got offset by
different amounts), we'll need some more cooperation with setrefs.c
to keep things straight. But for now, there's no need for that.
Arguably this is a back-patchable bug fix, but since this is a mostly
cosmetic issue and there have been no field complaints, I'll refrain
for now.
Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us1 parent 1d468b9 commit 4526951
File tree
3 files changed
+117
-56
lines changed- contrib/postgres_fdw
- expected
3 files changed
+117
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1348 | 1348 | | |
1349 | 1349 | | |
1350 | 1350 | | |
1351 | | - | |
| 1351 | + | |
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
| |||
2084 | 2084 | | |
2085 | 2085 | | |
2086 | 2086 | | |
2087 | | - | |
| 2087 | + | |
2088 | 2088 | | |
2089 | 2089 | | |
2090 | 2090 | | |
| |||
3230 | 3230 | | |
3231 | 3231 | | |
3232 | 3232 | | |
3233 | | - | |
| 3233 | + | |
3234 | 3234 | | |
3235 | 3235 | | |
3236 | 3236 | | |
| |||
8480 | 8480 | | |
8481 | 8481 | | |
8482 | 8482 | | |
8483 | | - | |
8484 | | - | |
| 8483 | + | |
| 8484 | + | |
8485 | 8485 | | |
8486 | 8486 | | |
8487 | 8487 | | |
8488 | 8488 | | |
8489 | 8489 | | |
8490 | 8490 | | |
8491 | | - | |
| 8491 | + | |
8492 | 8492 | | |
8493 | 8493 | | |
8494 | 8494 | | |
| |||
8507 | 8507 | | |
8508 | 8508 | | |
8509 | 8509 | | |
8510 | | - | |
| 8510 | + | |
8511 | 8511 | | |
8512 | 8512 | | |
8513 | 8513 | | |
| |||
8561 | 8561 | | |
8562 | 8562 | | |
8563 | 8563 | | |
8564 | | - | |
8565 | | - | |
| 8564 | + | |
| 8565 | + | |
8566 | 8566 | | |
8567 | 8567 | | |
8568 | 8568 | | |
8569 | 8569 | | |
8570 | 8570 | | |
8571 | 8571 | | |
8572 | | - | |
| 8572 | + | |
8573 | 8573 | | |
8574 | 8574 | | |
8575 | 8575 | | |
| |||
8689 | 8689 | | |
8690 | 8690 | | |
8691 | 8691 | | |
8692 | | - | |
8693 | | - | |
| 8692 | + | |
| 8693 | + | |
8694 | 8694 | | |
8695 | 8695 | | |
8696 | 8696 | | |
8697 | 8697 | | |
8698 | | - | |
| 8698 | + | |
8699 | 8699 | | |
8700 | | - | |
| 8700 | + | |
8701 | 8701 | | |
8702 | | - | |
| 8702 | + | |
8703 | 8703 | | |
8704 | 8704 | | |
8705 | 8705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
574 | 576 | | |
575 | 577 | | |
576 | 578 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | 579 | | |
581 | 580 | | |
582 | 581 | | |
| |||
719 | 718 | | |
720 | 719 | | |
721 | 720 | | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
726 | 724 | | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
| 725 | + | |
737 | 726 | | |
738 | 727 | | |
739 | 728 | | |
| |||
1376 | 1365 | | |
1377 | 1366 | | |
1378 | 1367 | | |
1379 | | - | |
| 1368 | + | |
1380 | 1369 | | |
1381 | 1370 | | |
1382 | 1371 | | |
| |||
2528 | 2517 | | |
2529 | 2518 | | |
2530 | 2519 | | |
2531 | | - | |
2532 | | - | |
2533 | | - | |
2534 | | - | |
2535 | | - | |
| 2520 | + | |
| 2521 | + | |
2536 | 2522 | | |
2537 | 2523 | | |
2538 | | - | |
2539 | | - | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
2540 | 2529 | | |
2541 | 2530 | | |
2542 | 2531 | | |
2543 | | - | |
2544 | | - | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
2545 | 2599 | | |
2546 | 2600 | | |
2547 | 2601 | | |
2548 | 2602 | | |
2549 | 2603 | | |
2550 | 2604 | | |
2551 | 2605 | | |
| 2606 | + | |
| 2607 | + | |
2552 | 2608 | | |
2553 | 2609 | | |
2554 | 2610 | | |
| |||
5171 | 5227 | | |
5172 | 5228 | | |
5173 | 5229 | | |
5174 | | - | |
| 5230 | + | |
| 5231 | + | |
| 5232 | + | |
5175 | 5233 | | |
5176 | | - | |
5177 | | - | |
5178 | | - | |
5179 | | - | |
5180 | | - | |
| 5234 | + | |
| 5235 | + | |
| 5236 | + | |
| 5237 | + | |
5181 | 5238 | | |
5182 | 5239 | | |
5183 | 5240 | | |
| |||
5723 | 5780 | | |
5724 | 5781 | | |
5725 | 5782 | | |
5726 | | - | |
| 5783 | + | |
| 5784 | + | |
| 5785 | + | |
5727 | 5786 | | |
5728 | | - | |
5729 | | - | |
5730 | | - | |
| 5787 | + | |
| 5788 | + | |
5731 | 5789 | | |
5732 | 5790 | | |
5733 | 5791 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
93 | 96 | | |
94 | | - | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
0 commit comments