Assert(RelationSyncCache != NULL);
- /* Find cached function info, creating if not found */
- oldctx = MemoryContextSwitchTo(CacheMemoryContext);
+ /* Find cached relation info, creating if not found */
entry = (RelationSyncEntry *) hash_search(RelationSyncCache,
(void *) &relid,
HASH_ENTER, &found);
- MemoryContextSwitchTo(oldctx);
Assert(entry != NULL);
/* Not found means schema wasn't sent */
- if (!found || !entry->replicate_valid)
+ if (!found)
+ {
+ /* immediately make a new entry valid enough to satisfy callbacks */
+ entry->schema_sent = false;
+ entry->streamed_txns = NIL;
+ entry->replicate_valid = false;
+ entry->pubactions.pubinsert = entry->pubactions.pubupdate =
+ entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false;
+ entry->publish_as_relid = InvalidOid;
+ }
+
+ /* Validate the entry */
+ if (!entry->replicate_valid)
{
List *pubids = GetRelationPublications(relid);
ListCell *lc;
* relcache considers all publications given relation is in, but here
* we only need to consider ones that the subscriber requested.
*/
- entry->pubactions.pubinsert = entry->pubactions.pubupdate =
- entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false;
-
foreach(lc, data->publications)
{
Publication *pub = lfirst(lc);
entry->replicate_valid = true;
}
- if (!found)
- {
- entry->schema_sent = false;
- entry->streamed_txns = NULL;
- }
-
return entry;
}
{
entry->schema_sent = false;
list_free(entry->streamed_txns);
- entry->streamed_txns = NULL;
+ entry->streamed_txns = NIL;
}
}