@@ -73,6 +73,11 @@ static void show_upper_qual(List *qual, const char *qlabel,
73
73
ExplainState * es );
74
74
static void show_sort_keys (SortState * sortstate , List * ancestors ,
75
75
ExplainState * es );
76
+ static void show_merge_append_keys (MergeAppendState * mstate , List * ancestors ,
77
+ ExplainState * es );
78
+ static void show_sort_keys_common (PlanState * planstate ,
79
+ int nkeys , AttrNumber * keycols ,
80
+ List * ancestors , ExplainState * es );
76
81
static void show_sort_info (SortState * sortstate , ExplainState * es );
77
82
static void show_hash_info (HashState * hashstate , ExplainState * es );
78
83
static const char * explain_get_index_name (Oid indexId );
@@ -647,6 +652,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
647
652
case T_Append :
648
653
pname = sname = "Append" ;
649
654
break ;
655
+ case T_MergeAppend :
656
+ pname = sname = "Merge Append" ;
657
+ break ;
650
658
case T_RecursiveUnion :
651
659
pname = sname = "Recursive Union" ;
652
660
break ;
@@ -1074,6 +1082,10 @@ ExplainNode(PlanState *planstate, List *ancestors,
1074
1082
show_sort_keys ((SortState * ) planstate , ancestors , es );
1075
1083
show_sort_info ((SortState * ) planstate , es );
1076
1084
break ;
1085
+ case T_MergeAppend :
1086
+ show_merge_append_keys ((MergeAppendState * ) planstate ,
1087
+ ancestors , es );
1088
+ break ;
1077
1089
case T_Result :
1078
1090
show_upper_qual ((List * ) ((Result * ) plan )-> resconstantqual ,
1079
1091
"One-Time Filter" , planstate , ancestors , es );
@@ -1170,6 +1182,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
1170
1182
innerPlanState (planstate ) ||
1171
1183
IsA (plan , ModifyTable ) ||
1172
1184
IsA (plan , Append ) ||
1185
+ IsA (plan , MergeAppend ) ||
1173
1186
IsA (plan , BitmapAnd ) ||
1174
1187
IsA (plan , BitmapOr ) ||
1175
1188
IsA (plan , SubqueryScan ) ||
@@ -1208,6 +1221,11 @@ ExplainNode(PlanState *planstate, List *ancestors,
1208
1221
((AppendState * ) planstate )-> appendplans ,
1209
1222
ancestors , es );
1210
1223
break ;
1224
+ case T_MergeAppend :
1225
+ ExplainMemberNodes (((MergeAppend * ) plan )-> mergeplans ,
1226
+ ((MergeAppendState * ) planstate )-> mergeplans ,
1227
+ ancestors , es );
1228
+ break ;
1211
1229
case T_BitmapAnd :
1212
1230
ExplainMemberNodes (((BitmapAnd * ) plan )-> bitmapplans ,
1213
1231
((BitmapAndState * ) planstate )-> bitmapplans ,
@@ -1265,7 +1283,9 @@ show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
1265
1283
/* The tlist of an Append isn't real helpful, so suppress it */
1266
1284
if (IsA (plan , Append ))
1267
1285
return ;
1268
- /* Likewise for RecursiveUnion */
1286
+ /* Likewise for MergeAppend and RecursiveUnion */
1287
+ if (IsA (plan , MergeAppend ))
1288
+ return ;
1269
1289
if (IsA (plan , RecursiveUnion ))
1270
1290
return ;
1271
1291
@@ -1369,8 +1389,31 @@ static void
1369
1389
show_sort_keys (SortState * sortstate , List * ancestors , ExplainState * es )
1370
1390
{
1371
1391
Sort * plan = (Sort * ) sortstate -> ss .ps .plan ;
1372
- int nkeys = plan -> numCols ;
1373
- AttrNumber * keycols = plan -> sortColIdx ;
1392
+
1393
+ show_sort_keys_common ((PlanState * ) sortstate ,
1394
+ plan -> numCols , plan -> sortColIdx ,
1395
+ ancestors , es );
1396
+ }
1397
+
1398
+ /*
1399
+ * Likewise, for a MergeAppend node.
1400
+ */
1401
+ static void
1402
+ show_merge_append_keys (MergeAppendState * mstate , List * ancestors ,
1403
+ ExplainState * es )
1404
+ {
1405
+ MergeAppend * plan = (MergeAppend * ) mstate -> ps .plan ;
1406
+
1407
+ show_sort_keys_common ((PlanState * ) mstate ,
1408
+ plan -> numCols , plan -> sortColIdx ,
1409
+ ancestors , es );
1410
+ }
1411
+
1412
+ static void
1413
+ show_sort_keys_common (PlanState * planstate , int nkeys , AttrNumber * keycols ,
1414
+ List * ancestors , ExplainState * es )
1415
+ {
1416
+ Plan * plan = planstate -> plan ;
1374
1417
List * context ;
1375
1418
List * result = NIL ;
1376
1419
bool useprefix ;
@@ -1381,7 +1424,7 @@ show_sort_keys(SortState *sortstate, List *ancestors, ExplainState *es)
1381
1424
return ;
1382
1425
1383
1426
/* Set up deparsing context */
1384
- context = deparse_context_for_planstate ((Node * ) sortstate ,
1427
+ context = deparse_context_for_planstate ((Node * ) planstate ,
1385
1428
ancestors ,
1386
1429
es -> rtable );
1387
1430
useprefix = (list_length (es -> rtable ) > 1 || es -> verbose );
@@ -1390,7 +1433,7 @@ show_sort_keys(SortState *sortstate, List *ancestors, ExplainState *es)
1390
1433
{
1391
1434
/* find key expression in tlist */
1392
1435
AttrNumber keyresno = keycols [keyno ];
1393
- TargetEntry * target = get_tle_by_resno (plan -> plan . targetlist ,
1436
+ TargetEntry * target = get_tle_by_resno (plan -> targetlist ,
1394
1437
keyresno );
1395
1438
1396
1439
if (!target )
@@ -1603,8 +1646,8 @@ ExplainScanTarget(Scan *plan, ExplainState *es)
1603
1646
}
1604
1647
1605
1648
/*
1606
- * Explain the constituent plans of a ModifyTable, Append, BitmapAnd ,
1607
- * or BitmapOr node.
1649
+ * Explain the constituent plans of a ModifyTable, Append, MergeAppend ,
1650
+ * BitmapAnd, or BitmapOr node.
1608
1651
*
1609
1652
* The ancestors list should already contain the immediate parent of these
1610
1653
* plans.
0 commit comments