codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * logicalrelation.h4 * Relation definitions for logical replication relation mapping.5 *6 * Portions Copyright (c) 2016-2023, PostgreSQL Global Development Group7 *8 * src/include/replication/logicalrelation.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef LOGICALRELATION_H13#define LOGICALRELATION_H14 15#include "access/attmap.h"16#include "catalog/index.h"17#include "replication/logicalproto.h"18 19typedef struct LogicalRepRelMapEntry20{21 LogicalRepRelation remoterel; /* key is remoterel.remoteid */22 23 /*24 * Validity flag -- when false, revalidate all derived info at next25 * logicalrep_rel_open. (While the localrel is open, we assume our lock26 * on that rel ensures the info remains good.)27 */28 bool localrelvalid;29 30 /* Mapping to local relation. */31 Oid localreloid; /* local relation id */32 Relation localrel; /* relcache entry (NULL when closed) */33 AttrMap *attrmap; /* map of local attributes to remote ones */34 bool updatable; /* Can apply updates/deletes? */35 Oid localindexoid; /* which index to use, or InvalidOid if none */36 37 /* Sync state. */38 char state;39 XLogRecPtr statelsn;40} LogicalRepRelMapEntry;41 42extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);43extern void logicalrep_partmap_reset_relmap(LogicalRepRelation *remoterel);44 45extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,46 LOCKMODE lockmode);47extern LogicalRepRelMapEntry *logicalrep_partition_open(LogicalRepRelMapEntry *root,48 Relation partrel, AttrMap *map);49extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,50 LOCKMODE lockmode);51extern bool IsIndexUsableForReplicaIdentityFull(IndexInfo *indexInfo, AttrMap *attrmap);52extern Oid GetRelationIdentityOrPK(Relation rel);53 54#endif /* LOGICALRELATION_H */55 