From 1362d0740311a9194a35b418e788b693efd3dc4c Mon Sep 17 00:00:00 2001
From: "houzj.fnst" <houzj.fnst@cn.fujitsu.com>
Date: Fri, 7 May 2021 20:19:19 +0800
Subject: [PATCH] fix explain info about fdw batch insert

---
 contrib/postgres_fdw/postgres_fdw.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 9a31bbb86b..1a4b9b1c95 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -3680,7 +3680,11 @@ create_foreign_modify(EState *estate,
 	/* Set up remote query information. */
 	fmstate->query = query;
 	if (operation == CMD_INSERT)
-		fmstate->orig_query = pstrdup(fmstate->query);
+	{
+		fmstate->query = pstrdup(fmstate->query);
+		fmstate->orig_query = query;
+	}
+
 	fmstate->target_attrs = target_attrs;
 	fmstate->values_end = values_end;
 	fmstate->has_returning = has_returning;
-- 
2.18.4

