diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 27f0345..cf5585f 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -2874,6 +2874,8 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree)
 		}
 	}
 
+	estate->es_queryEnv = parentestate->es_queryEnv;
+
 	/*
 	 * Each EState must have its own es_epqScanDone state, but if we have
 	 * nested EPQ checks they should share es_epqTupleSlot arrays.  This
