summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/copy.c15
-rw-r--r--src/backend/commands/explain.c35
2 files changed, 38 insertions, 12 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 4825bca363f..4eb94a43add 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2121,17 +2121,10 @@ CopyFrom(CopyState cstate)
* here that basically duplicated execUtils.c ...)
*/
resultRelInfo = makeNode(ResultRelInfo);
- resultRelInfo->ri_RangeTableIndex = 1; /* dummy */
- resultRelInfo->ri_RelationDesc = cstate->rel;
- resultRelInfo->ri_TrigDesc = CopyTriggerDesc(cstate->rel->trigdesc);
- if (resultRelInfo->ri_TrigDesc)
- {
- resultRelInfo->ri_TrigFunctions = (FmgrInfo *)
- palloc0(resultRelInfo->ri_TrigDesc->numtriggers * sizeof(FmgrInfo));
- resultRelInfo->ri_TrigWhenExprs = (List **)
- palloc0(resultRelInfo->ri_TrigDesc->numtriggers * sizeof(List *));
- }
- resultRelInfo->ri_TrigInstrument = NULL;
+ InitResultRelInfo(resultRelInfo,
+ cstate->rel,
+ 1, /* dummy rangetable index */
+ 0);
ExecOpenIndices(resultRelInfo);
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 989b52da9d4..9799e9ecb41 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -90,6 +90,7 @@ static void ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir,
static void ExplainScanTarget(Scan *plan, ExplainState *es);
static void ExplainModifyTarget(ModifyTable *plan, ExplainState *es);
static void ExplainTargetRel(Plan *plan, Index rti, ExplainState *es);
+static void show_modifytable_info(ModifyTableState *mtstate, ExplainState *es);
static void ExplainMemberNodes(List *plans, PlanState **planstates,
List *ancestors, ExplainState *es);
static void ExplainSubPlans(List *plans, List *ancestors,
@@ -1341,6 +1342,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
break;
+ case T_ModifyTable:
+ show_modifytable_info((ModifyTableState *) planstate, es);
+ break;
case T_Hash:
show_hash_info((HashState *) planstate, es);
break;
@@ -1840,7 +1844,8 @@ show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es)
FdwRoutine *fdwroutine = fsstate->fdwroutine;
/* Let the FDW emit whatever fields it wants */
- fdwroutine->ExplainForeignScan(fsstate, es);
+ if (fdwroutine->ExplainForeignScan != NULL)
+ fdwroutine->ExplainForeignScan(fsstate, es);
}
/*
@@ -2037,6 +2042,34 @@ ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
}
/*
+ * Show extra information for a ModifyTable node
+ */
+static void
+show_modifytable_info(ModifyTableState *mtstate, ExplainState *es)
+{
+ FdwRoutine *fdwroutine = mtstate->resultRelInfo->ri_FdwRoutine;
+
+ /*
+ * If the first target relation is a foreign table, call its FDW to
+ * display whatever additional fields it wants to. For now, we ignore the
+ * possibility of other targets being foreign tables, although the API for
+ * ExplainForeignModify is designed to allow them to be processed.
+ */
+ if (fdwroutine != NULL &&
+ fdwroutine->ExplainForeignModify != NULL)
+ {
+ ModifyTable *node = (ModifyTable *) mtstate->ps.plan;
+ List *fdw_private = (List *) linitial(node->fdwPrivLists);
+
+ fdwroutine->ExplainForeignModify(mtstate,
+ mtstate->resultRelInfo,
+ fdw_private,
+ 0,
+ es);
+ }
+}
+
+/*
* Explain the constituent plans of a ModifyTable, Append, MergeAppend,
* BitmapAnd, or BitmapOr node.
*