Skip to content

Commit 99ee43c

Browse files
committed
Make EXPLAIN show the function call expression of a FunctionScan plan node,
but only in VERBOSE mode. Per discussion.
1 parent 5c788e7 commit 99ee43c

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

src/backend/commands/explain.c

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.207 2010/07/13 20:57:19 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.208 2010/08/24 21:20:36 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -59,6 +59,9 @@ static void ExplainNode(PlanState *planstate, List *ancestors,
5959
ExplainState *es);
6060
static void show_plan_tlist(PlanState *planstate, List *ancestors,
6161
ExplainState *es);
62+
static void show_expression(Node *node, const char *qlabel,
63+
PlanState *planstate, List *ancestors,
64+
bool useprefix, ExplainState *es);
6265
static void show_qual(List *qual, const char *qlabel,
6366
PlanState *planstate, List *ancestors,
6467
bool useprefix, ExplainState *es);
@@ -1017,13 +1020,19 @@ ExplainNode(PlanState *planstate, List *ancestors,
10171020
"Recheck Cond", planstate, ancestors, es);
10181021
/* FALL THRU */
10191022
case T_SeqScan:
1020-
case T_FunctionScan:
10211023
case T_ValuesScan:
10221024
case T_CteScan:
10231025
case T_WorkTableScan:
10241026
case T_SubqueryScan:
10251027
show_scan_qual(plan->qual, "Filter", planstate, ancestors, es);
10261028
break;
1029+
case T_FunctionScan:
1030+
if (es->verbose)
1031+
show_expression(((FunctionScan *) plan)->funcexpr,
1032+
"Function Call", planstate, ancestors,
1033+
es->verbose, es);
1034+
show_scan_qual(plan->qual, "Filter", planstate, ancestors, es);
1035+
break;
10271036
case T_TidScan:
10281037
{
10291038
/*
@@ -1282,24 +1291,16 @@ show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
12821291
}
12831292

12841293
/*
1285-
* Show a qualifier expression
1294+
* Show a generic expression
12861295
*/
12871296
static void
1288-
show_qual(List *qual, const char *qlabel,
1289-
PlanState *planstate, List *ancestors,
1290-
bool useprefix, ExplainState *es)
1297+
show_expression(Node *node, const char *qlabel,
1298+
PlanState *planstate, List *ancestors,
1299+
bool useprefix, ExplainState *es)
12911300
{
12921301
List *context;
1293-
Node *node;
12941302
char *exprstr;
12951303

1296-
/* No work if empty qual */
1297-
if (qual == NIL)
1298-
return;
1299-
1300-
/* Convert AND list to explicit AND */
1301-
node = (Node *) make_ands_explicit(qual);
1302-
13031304
/* Set up deparsing context */
13041305
context = deparse_context_for_planstate((Node *) planstate,
13051306
ancestors,
@@ -1312,6 +1313,27 @@ show_qual(List *qual, const char *qlabel,
13121313
ExplainPropertyText(qlabel, exprstr, es);
13131314
}
13141315

1316+
/*
1317+
* Show a qualifier expression (which is a List with implicit AND semantics)
1318+
*/
1319+
static void
1320+
show_qual(List *qual, const char *qlabel,
1321+
PlanState *planstate, List *ancestors,
1322+
bool useprefix, ExplainState *es)
1323+
{
1324+
Node *node;
1325+
1326+
/* No work if empty qual */
1327+
if (qual == NIL)
1328+
return;
1329+
1330+
/* Convert AND list to explicit AND */
1331+
node = (Node *) make_ands_explicit(qual);
1332+
1333+
/* And show it */
1334+
show_expression(node, qlabel, planstate, ancestors, useprefix, es);
1335+
}
1336+
13151337
/*
13161338
* Show a qualifier expression for a scan plan node
13171339
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy