diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 1c480cfaaf7..1a6db244c94 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -5309,6 +5309,20 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
 	/* Save the exposed type of the expression */
 	vardata->vartype = exprType(node);
 
+	/*
+	 * It's possible to get here during SubLink planning, before we have
+	 * constructed any RelOptInfos for the parent query level.  In that case
+	 * we have to punt by pretending the node is variable-free, since we
+	 * cannot satisfy the API expectation of passing back a RelOptInfo.
+	 */
+	if (root->simple_rel_array == NULL)
+	{
+		vardata->var = node;
+		vardata->atttype = vardata->vartype;
+		vardata->atttypmod = exprTypmod(node);
+		return;
+	}
+
 	/* Look inside any binary-compatible relabeling */
 
 	if (IsA(node, RelabelType))
