ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate)
{
/*
- * The columns are stored in the range table entry. If this ResultRelInfo
- * doesn't have an entry in the range table (i.e. if it represents a
- * partition routing target), fetch the parent's RTE and map the columns
- * to the order they are in the partition.
+ * The columns are stored in the range table entry. If this ResultRelInfo
+ * represents a partition routing target, and doesn't have an entry of its
+ * own in the range table, fetch the parent's RTE and map the columns to
+ * the order they are in the partition.
*/
if (relinfo->ri_RangeTableIndex != 0)
{
return rte->insertedCols;
}
- else
+ else if (relinfo->ri_RootResultRelInfo)
{
ResultRelInfo *rootRelInfo = relinfo->ri_RootResultRelInfo;
RangeTblEntry *rte = rt_fetch(rootRelInfo->ri_RangeTableIndex,
else
return rte->insertedCols;
}
+ else
+ {
+ /*
+ * The relation isn't in the range table and it isn't a partition
+ * routing target. This ResultRelInfo must've been created only for
+ * firing triggers and the relation is not being inserted into. (See
+ * ExecGetTriggerResultRel.)
+ */
+ return NULL;
+ }
}
/* Return a bitmap representing columns being updated */
return rte->updatedCols;
}
- else
+ else if (relinfo->ri_RootResultRelInfo)
{
ResultRelInfo *rootRelInfo = relinfo->ri_RootResultRelInfo;
RangeTblEntry *rte = rt_fetch(rootRelInfo->ri_RangeTableIndex,
else
return rte->updatedCols;
}
+ else
+ return NULL;
}