1/*-------------------------------------------------------------------------
2 *
3 * logicalrelation.h
4 * Relation definitions for logical replication relation mapping.
5 *
6 * Portions Copyright (c) 2016-2019, 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 "replication/logicalproto.h"
16
17typedef struct LogicalRepRelMapEntry
18{
19 LogicalRepRelation remoterel; /* key is remoterel.remoteid */
20
21 /* Mapping to local relation, filled as needed. */
22 Oid localreloid; /* local relation id */
23 Relation localrel; /* relcache entry */
24 AttrNumber *attrmap; /* map of local attributes to remote ones */
25 bool updatable; /* Can apply updates/deletes? */
26
27 /* Sync state. */
28 char state;
29 XLogRecPtr statelsn;
30} LogicalRepRelMapEntry;
31
32extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
33
34extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
35 LOCKMODE lockmode);
36extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
37 LOCKMODE lockmode);
38
39extern void logicalrep_typmap_update(LogicalRepTyp *remotetyp);
40extern char *logicalrep_typmap_gettypname(Oid remoteid);
41
42#endif /* LOGICALRELATION_H */
43