@ -260,6 +260,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
bool is_init )
bool is_init )
{
{
PGOutputData * data = palloc0 ( sizeof ( PGOutputData ) ) ;
PGOutputData * data = palloc0 ( sizeof ( PGOutputData ) ) ;
static bool publication_callback_registered = false ;
/* Create our memory context for private allocations. */
/* Create our memory context for private allocations. */
data - > context = AllocSetContextCreate ( ctx - > context ,
data - > context = AllocSetContextCreate ( ctx - > context ,
@ -323,9 +324,18 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
/* Init publication state. */
/* Init publication state. */
data - > publications = NIL ;
data - > publications = NIL ;
publications_valid = false ;
publications_valid = false ;
CacheRegisterSyscacheCallback ( PUBLICATIONOID ,
publication_invalidation_cb ,
/*
( Datum ) 0 ) ;
* Register callback for pg_publication if we didn ' t already do that
* during some previous call in this process .
*/
if ( ! publication_callback_registered )
{
CacheRegisterSyscacheCallback ( PUBLICATIONOID ,
publication_invalidation_cb ,
( Datum ) 0 ) ;
publication_callback_registered = true ;
}
/* Initialize relation schema cache. */
/* Initialize relation schema cache. */
init_rel_sync_cache ( CacheMemoryContext ) ;
init_rel_sync_cache ( CacheMemoryContext ) ;
@ -948,7 +958,9 @@ static void
init_rel_sync_cache ( MemoryContext cachectx )
init_rel_sync_cache ( MemoryContext cachectx )
{
{
HASHCTL ctl ;
HASHCTL ctl ;
static bool relation_callbacks_registered = false ;
/* Nothing to do if hash table already exists */
if ( RelationSyncCache ! = NULL )
if ( RelationSyncCache ! = NULL )
return ;
return ;
@ -963,10 +975,16 @@ init_rel_sync_cache(MemoryContext cachectx)
Assert ( RelationSyncCache ! = NULL ) ;
Assert ( RelationSyncCache ! = NULL ) ;
/* No more to do if we already registered callbacks */
if ( relation_callbacks_registered )
return ;
CacheRegisterRelcacheCallback ( rel_sync_cache_relation_cb , ( Datum ) 0 ) ;
CacheRegisterRelcacheCallback ( rel_sync_cache_relation_cb , ( Datum ) 0 ) ;
CacheRegisterSyscacheCallback ( PUBLICATIONRELMAP ,
CacheRegisterSyscacheCallback ( PUBLICATIONRELMAP ,
rel_sync_cache_publication_cb ,
rel_sync_cache_publication_cb ,
( Datum ) 0 ) ;
( Datum ) 0 ) ;
relation_callbacks_registered = true ;
}
}
/*
/*