diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index bf4e81f..b5616ba 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -5560,6 +5560,9 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
 	 * likely that varno is OUTER_VAR or INNER_VAR, in which case we must dig
 	 * down into the subplans, or INDEX_VAR, which is resolved similarly. Also
 	 * find the aliases previously assigned for this RTE.
+	 * In case when these special verno is assigned by custom-scan provider,
+	 * it has to be resolved by querying the provider because only extension
+	 * knows the mapping of the special var-node.
 	 */
 	if (var->varno >= 1 && var->varno <= list_length(dpns->rtable))
 	{
@@ -5575,6 +5578,8 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
 	{
 		deparse_namespace	save_dpns;
 
+		Assert(netlevelsup == 0);
+
 		if (child_ps)
 			push_child_plan(dpns, child_ps, &save_dpns);
 		/*
