Commit bf39b3af authored by Tom Lane's avatar Tom Lane

Further sync postgres_fdw's "Relations" output with the rest of EXPLAIN.

EXPLAIN generally only adds schema qualifications to table names when
VERBOSE is specified.  In postgres_fdw's "Relations" output, table
names were always so qualified, but that was an implementation
restriction: in the original coding, we didn't have access to the
verbose flag at the time the string was generated.  After the code
rearrangement of commit 4526951d, we do have that info available
at the right time, so make this output follow the normal rule.

Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us
parent 68ab9829
...@@ -8481,14 +8481,14 @@ ANALYZE fprt2_p2; ...@@ -8481,14 +8481,14 @@ ANALYZE fprt2_p2;
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT t1.a,t2.b,t3.c FROM fprt1 t1 INNER JOIN fprt2 t2 ON (t1.a = t2.b) INNER JOIN fprt1 t3 ON (t2.b = t3.a) WHERE t1.a % 25 =0 ORDER BY 1,2,3; SELECT t1.a,t2.b,t3.c FROM fprt1 t1 INNER JOIN fprt2 t2 ON (t1.a = t2.b) INNER JOIN fprt1 t3 ON (t2.b = t3.a) WHERE t1.a % 25 =0 ORDER BY 1,2,3;
QUERY PLAN QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------
Sort Sort
Sort Key: t1.a, t3.c Sort Key: t1.a, t3.c
-> Append -> Append
-> Foreign Scan -> Foreign Scan
Relations: ((public.ftprt1_p1 t1) INNER JOIN (public.ftprt2_p1 t2)) INNER JOIN (public.ftprt1_p1 t3) Relations: ((ftprt1_p1 t1) INNER JOIN (ftprt2_p1 t2)) INNER JOIN (ftprt1_p1 t3)
-> Foreign Scan -> Foreign Scan
Relations: ((public.ftprt1_p2 t1_1) INNER JOIN (public.ftprt2_p2 t2_1)) INNER JOIN (public.ftprt1_p2 t3_1) Relations: ((ftprt1_p2 t1_1) INNER JOIN (ftprt2_p2 t2_1)) INNER JOIN (ftprt1_p2 t3_1)
(7 rows) (7 rows)
SELECT t1.a,t2.b,t3.c FROM fprt1 t1 INNER JOIN fprt2 t2 ON (t1.a = t2.b) INNER JOIN fprt1 t3 ON (t2.b = t3.a) WHERE t1.a % 25 =0 ORDER BY 1,2,3; SELECT t1.a,t2.b,t3.c FROM fprt1 t1 INNER JOIN fprt2 t2 ON (t1.a = t2.b) INNER JOIN fprt1 t3 ON (t2.b = t3.a) WHERE t1.a % 25 =0 ORDER BY 1,2,3;
...@@ -8562,14 +8562,14 @@ SELECT t1.wr, t2.wr FROM (SELECT t1 wr, a FROM fprt1 t1 WHERE t1.a % 25 = 0) t1 ...@@ -8562,14 +8562,14 @@ SELECT t1.wr, t2.wr FROM (SELECT t1 wr, a FROM fprt1 t1 WHERE t1.a % 25 = 0) t1
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2; SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------------------- -----------------------------------------------------------------------
Sort Sort
Sort Key: t1.a, t1.b Sort Key: t1.a, t1.b
-> Append -> Append
-> Foreign Scan -> Foreign Scan
Relations: (public.ftprt1_p1 t1) INNER JOIN (public.ftprt2_p1 t2) Relations: (ftprt1_p1 t1) INNER JOIN (ftprt2_p1 t2)
-> Foreign Scan -> Foreign Scan
Relations: (public.ftprt1_p2 t1_1) INNER JOIN (public.ftprt2_p2 t2_1) Relations: (ftprt1_p2 t1_1) INNER JOIN (ftprt2_p2 t2_1)
(7 rows) (7 rows)
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2; SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
...@@ -8690,16 +8690,16 @@ SET enable_partitionwise_aggregate TO true; ...@@ -8690,16 +8690,16 @@ SET enable_partitionwise_aggregate TO true;
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT a, sum(b), min(b), count(*) FROM pagg_tab GROUP BY a HAVING avg(b) < 22 ORDER BY 1; SELECT a, sum(b), min(b), count(*) FROM pagg_tab GROUP BY a HAVING avg(b) < 22 ORDER BY 1;
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------ -----------------------------------------------------------------
Sort Sort
Sort Key: pagg_tab.a Sort Key: pagg_tab.a
-> Append -> Append
-> Foreign Scan -> Foreign Scan
Relations: Aggregate on (public.fpagg_tab_p1 pagg_tab) Relations: Aggregate on (fpagg_tab_p1 pagg_tab)
-> Foreign Scan -> Foreign Scan
Relations: Aggregate on (public.fpagg_tab_p2 pagg_tab_1) Relations: Aggregate on (fpagg_tab_p2 pagg_tab_1)
-> Foreign Scan -> Foreign Scan
Relations: Aggregate on (public.fpagg_tab_p3 pagg_tab_2) Relations: Aggregate on (fpagg_tab_p3 pagg_tab_2)
(9 rows) (9 rows)
SELECT a, sum(b), min(b), count(*) FROM pagg_tab GROUP BY a HAVING avg(b) < 22 ORDER BY 1; SELECT a, sum(b), min(b), count(*) FROM pagg_tab GROUP BY a HAVING avg(b) < 22 ORDER BY 1;
......
...@@ -2571,7 +2571,6 @@ postgresExplainForeignScan(ForeignScanState *node, ExplainState *es) ...@@ -2571,7 +2571,6 @@ postgresExplainForeignScan(ForeignScanState *node, ExplainState *es)
{ {
int rti = strtol(ptr, &ptr, 10); int rti = strtol(ptr, &ptr, 10);
RangeTblEntry *rte; RangeTblEntry *rte;
char *namespace;
char *relname; char *relname;
char *refname; char *refname;
...@@ -2580,11 +2579,19 @@ postgresExplainForeignScan(ForeignScanState *node, ExplainState *es) ...@@ -2580,11 +2579,19 @@ postgresExplainForeignScan(ForeignScanState *node, ExplainState *es)
rte = rt_fetch(rti, es->rtable); rte = rt_fetch(rti, es->rtable);
Assert(rte->rtekind == RTE_RELATION); Assert(rte->rtekind == RTE_RELATION);
/* This logic should agree with explain.c's ExplainTargetRel */ /* This logic should agree with explain.c's ExplainTargetRel */
namespace = get_namespace_name(get_rel_namespace(rte->relid));
relname = get_rel_name(rte->relid); relname = get_rel_name(rte->relid);
if (es->verbose)
{
char *namespace;
namespace = get_namespace_name(get_rel_namespace(rte->relid));
appendStringInfo(relations, "%s.%s", appendStringInfo(relations, "%s.%s",
quote_identifier(namespace), quote_identifier(namespace),
quote_identifier(relname)); quote_identifier(relname));
}
else
appendStringInfo(relations, "%s",
quote_identifier(relname));
refname = (char *) list_nth(es->rtable_names, rti - 1); refname = (char *) list_nth(es->rtable_names, rti - 1);
if (refname == NULL) if (refname == NULL)
refname = rte->eref->aliasname; refname = rte->eref->aliasname;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment