diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 9716697..d8afe02 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -6588,8 +6588,8 @@ exec_save_simple_expr(PLpgSQL_expr *expr, CachedPlan *cplan)
 	 * force_parallel_mode is on, the planner might've stuck a Gather node
 	 * atop that.  The simplest way to deal with this is to look through the
 	 * Gather node.  The Gather node's tlist would normally contain a Var
-	 * referencing the child node's output ... but setrefs.c might also have
-	 * copied a Const as-is.
+	 * referencing the child node's output or a Param... but setrefs.c might
+	 * also have copied a Const as-is.
 	 */
 	plan = stmt->planTree;
 	for (;;)
@@ -6616,6 +6616,12 @@ exec_save_simple_expr(PLpgSQL_expr *expr, CachedPlan *cplan)
 			/* If setrefs.c copied up a Const, no need to look further */
 			if (IsA(tle_expr, Const))
 				break;
+			if (IsA(tle_expr, Param))
+			{
+				/* Descend to the child node */
+				plan = plan->lefttree;
+				continue;
+			}
 			/* Otherwise, it better be an outer Var */
 			Assert(IsA(tle_expr, Var));
 			Assert(((Var *) tle_expr)->varno == OUTER_VAR);
