From cd20b02064e6e41c8bc24043c41dbb6efa57dbf2 Mon Sep 17 00:00:00 2001
From: soumyadeep2007 <sochakraborty@pivotal.io>
Date: Fri, 27 Sep 2019 22:46:14 -0700
Subject: [PATCH v2 3/3] Some minor cosmetic changes

1. Renamed ExecComputeSlotInfo to eliminate the need for the assert.
2. Extracted return value to a bool variable for slightly better
readability.
3. Taking the opportunity to use TTS_IS_VIRTUAL.
---
 src/backend/executor/execExpr.c       | 25 ++++++++++++++-----------
 src/backend/executor/execExprInterp.c |  4 ++--
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 1ff13d1079..aef4ac657e 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -65,7 +65,7 @@ static void ExecInitFunc(ExprEvalStep *scratch, Expr *node, List *args,
 static void ExecInitExprSlots(ExprState *state, Node *node);
 static void ExecPushExprSlots(ExprState *state, LastAttnumInfo *info);
 static bool get_last_attnums_walker(Node *node, LastAttnumInfo *info);
-static bool ExecComputeSlotInfo(ExprState *state, ExprEvalStep *op);
+static bool ExecComputeFetchOpInfo(ExprState *state, ExprEvalStep *op);
 static void ExecInitWholeRowVar(ExprEvalStep *scratch, Var *variable,
 								ExprState *state);
 static void ExecInitSubscriptingRef(ExprEvalStep *scratch,
@@ -2273,6 +2273,7 @@ static void
 ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
 {
 	ExprEvalStep scratch = {0};
+	bool		 deform_step_required;
 
 	scratch.resvalue = NULL;
 	scratch.resnull = NULL;
@@ -2285,7 +2286,8 @@ ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
 		scratch.d.fetch.fixed = false;
 		scratch.d.fetch.kind = NULL;
 		scratch.d.fetch.known_desc = NULL;
-		if (ExecComputeSlotInfo(state, &scratch))
+		deform_step_required = ExecComputeFetchOpInfo(state, &scratch);
+		if (deform_step_required)
 			ExprEvalPushStep(state, &scratch);
 	}
 	if (info->last_outer > 0)
@@ -2295,7 +2297,8 @@ ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
 		scratch.d.fetch.fixed = false;
 		scratch.d.fetch.kind = NULL;
 		scratch.d.fetch.known_desc = NULL;
-		if (ExecComputeSlotInfo(state, &scratch))
+		deform_step_required = ExecComputeFetchOpInfo(state, &scratch);
+		if (deform_step_required)
 			ExprEvalPushStep(state, &scratch);
 	}
 	if (info->last_scan > 0)
@@ -2305,7 +2308,8 @@ ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
 		scratch.d.fetch.fixed = false;
 		scratch.d.fetch.kind = NULL;
 		scratch.d.fetch.known_desc = NULL;
-		if (ExecComputeSlotInfo(state, &scratch))
+		deform_step_required = ExecComputeFetchOpInfo(state, &scratch);
+		if (deform_step_required)
 			ExprEvalPushStep(state, &scratch);
 	}
 }
@@ -2368,7 +2372,7 @@ get_last_attnums_walker(Node *node, LastAttnumInfo *info)
  * Returns true if the the deforming step is required, false otherwise.
  */
 static bool
-ExecComputeSlotInfo(ExprState *state, ExprEvalStep *op)
+ExecComputeFetchOpInfo(ExprState *state, ExprEvalStep *op)
 {
 	PlanState  *parent = state->parent;
 	TupleDesc	desc = NULL;
@@ -2376,10 +2380,6 @@ ExecComputeSlotInfo(ExprState *state, ExprEvalStep *op)
 	bool		isfixed = false;
 	ExprEvalOp	opcode = op->opcode;
 
-	Assert(opcode == EEOP_INNER_FETCHSOME ||
-		   opcode == EEOP_OUTER_FETCHSOME ||
-		   opcode == EEOP_SCAN_FETCHSOME);
-
 	if (op->d.fetch.known_desc != NULL)
 	{
 		desc = op->d.fetch.known_desc;
@@ -3340,6 +3340,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
 	int			maxatt = -1;
 	List	   *adjust_jumps = NIL;
 	ListCell   *lc;
+	bool		deform_step_required;
 
 	/*
 	 * When no columns are actually compared, the result's always true. See
@@ -3371,7 +3372,8 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
 	scratch.d.fetch.fixed = false;
 	scratch.d.fetch.known_desc = ldesc;
 	scratch.d.fetch.kind = lops;
-	if (ExecComputeSlotInfo(state, &scratch))
+	deform_step_required = ExecComputeFetchOpInfo(state, &scratch);
+	if (deform_step_required)
 		ExprEvalPushStep(state, &scratch);
 
 	scratch.opcode = EEOP_OUTER_FETCHSOME;
@@ -3379,7 +3381,8 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
 	scratch.d.fetch.fixed = false;
 	scratch.d.fetch.known_desc = rdesc;
 	scratch.d.fetch.kind = rops;
-	if (ExecComputeSlotInfo(state, &scratch))
+	deform_step_required = ExecComputeFetchOpInfo(state, &scratch);
+	if (deform_step_required)
 		ExprEvalPushStep(state, &scratch);
 
 	/*
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index ccea030cd7..3c1288c5b9 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -2149,7 +2149,7 @@ ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 	 * execExpr.c has not emitted a EEOP_*_FETCHSOME step. Verify, as much as
 	 * possible, that that determination was accurate.
 	 */
-	Assert(slot->tts_ops == &TTSOpsVirtual);
+	Assert(TTS_IS_VIRTUAL(slot));
 	Assert(TTS_FIXED(slot));
 	Assert(attnum >= 0 && attnum < slot->tts_nvalid);
 
@@ -2190,7 +2190,7 @@ ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull
 
 	/* see ExecJustVarVirtImpl for comments */
 
-	Assert(inslot->tts_ops == &TTSOpsVirtual);
+	Assert(TTS_IS_VIRTUAL(inslot));
 	Assert(TTS_FIXED(inslot));
 	Assert(attnum >= 0 && attnum < inslot->tts_nvalid);
 
-- 
2.23.0

