aboutsummaryrefslogtreecommitdiff
path: root/src/include/replication/logicalrelation.h
blob: f2b104aa6898b5e944e6573909d44ab303f401c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*-------------------------------------------------------------------------
 *
 * logicalrelation.h
 *	  Relation definitions for logical replication relation mapping.
 *
 * Portions Copyright (c) 2016-2017, PostgreSQL Global Development Group
 *
 * src/include/replication/logicalrelation.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef LOGICALRELATION_H
#define LOGICALRELATION_H

#include "replication/logicalproto.h"

typedef struct LogicalRepRelMapEntry
{
	LogicalRepRelation	remoterel;		/* key is remoterel.remoteid */

	/* Mapping to local relation, filled as needed. */
	Oid					localreloid;	/* local relation id */
	Relation			localrel;		/* relcache entry */
	AttrNumber         *attrmap;		/* map of local attributes to
										 * remote ones */
	bool				updatable;		/* Can apply updates/detetes? */

	/* Sync state. */
	char				state;
	XLogRecPtr			statelsn;
} LogicalRepRelMapEntry;

extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);

extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
												  LOCKMODE lockmode);
extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
								 LOCKMODE lockmode);

extern void logicalrep_typmap_update(LogicalRepTyp *remotetyp);
extern Oid logicalrep_typmap_getid(Oid remoteid);

#endif   /* LOGICALRELATION_H */