MemoryContext old;
RelationSyncEntry *relentry;
TransactionId xid = InvalidTransactionId;
+ Relation ancestor = NULL;
if (!is_publishable_relation(relation))
return;
if (relentry->publish_as_relid != RelationGetRelid(relation))
{
Assert(relation->rd_rel->relispartition);
- relation = RelationIdGetRelation(relentry->publish_as_relid);
+ ancestor = RelationIdGetRelation(relentry->publish_as_relid);
+ relation = ancestor;
/* Convert tuple if needed. */
if (relentry->map)
tuple = execute_attr_map_tuple(tuple, relentry->map);
if (relentry->publish_as_relid != RelationGetRelid(relation))
{
Assert(relation->rd_rel->relispartition);
- relation = RelationIdGetRelation(relentry->publish_as_relid);
+ ancestor = RelationIdGetRelation(relentry->publish_as_relid);
+ relation = ancestor;
/* Convert tuples if needed. */
if (relentry->map)
{
if (relentry->publish_as_relid != RelationGetRelid(relation))
{
Assert(relation->rd_rel->relispartition);
- relation = RelationIdGetRelation(relentry->publish_as_relid);
+ ancestor = RelationIdGetRelation(relentry->publish_as_relid);
+ relation = ancestor;
/* Convert tuple if needed. */
if (relentry->map)
oldtuple = execute_attr_map_tuple(oldtuple, relentry->map);
Assert(false);
}
+ if (RelationIsValid(ancestor))
+ {
+ RelationClose(ancestor);
+ ancestor = NULL;
+ }
+
/* Cleanup */
MemoryContextSwitchTo(old);
MemoryContextReset(data->context);