1 /*-------------------------------------------------------------------------
2  *
3  * logicalrelation.h
4  *	  Relation definitions for logical replication relation mapping.
5  *
6  * Portions Copyright (c) 2016-2020, PostgreSQL Global Development Group
7  *
8  * src/include/replication/logicalrelation.h
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef LOGICALRELATION_H
13 #define LOGICALRELATION_H
14 
15 #include "access/attmap.h"
16 #include "replication/logicalproto.h"
17 
18 typedef struct LogicalRepRelMapEntry
19 {
20 	LogicalRepRelation remoterel;	/* key is remoterel.remoteid */
21 
22 	/* Mapping to local relation. */
23 	Oid			localreloid;	/* local relation id */
24 	Relation	localrel;		/* relcache entry (NULL when closed) */
25 	AttrMap    *attrmap;		/* map of local attributes to remote ones */
26 	bool		updatable;		/* Can apply updates/deletes? */
27 
28 	/* Sync state. */
29 	char		state;
30 	/* Validity flag ... inserted here to avoid ABI break in back branches. */
31 	bool		localrelvalid;
32 	XLogRecPtr	statelsn;
33 } LogicalRepRelMapEntry;
34 
35 extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
36 
37 extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
38 												  LOCKMODE lockmode);
39 extern LogicalRepRelMapEntry *logicalrep_partition_open(LogicalRepRelMapEntry *root,
40 														Relation partrel, AttrMap *map);
41 extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
42 								 LOCKMODE lockmode);
43 
44 #endif							/* LOGICALRELATION_H */
45