Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*-------------------------------------------------------------------------
 *
 * logicalrelation.h
 *    Relation definitions for logical replication relation mapping.
 *
 * Portions Copyright (c) 2016-2026, PostgreSQL Global Development Group
 *
 * src/include/replication/logicalrelation.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef LOGICALRELATION_H
#define LOGICALRELATION_H
 
#include "access/attmap.h"
#include "catalog/index.h"
#include "replication/logicalproto.h"
 
typedef struct LogicalRepRelMapEntry
{
    LogicalRepRelation remoterel;   /* key is remoterel.remoteid */
 
    /*
     * Validity flag -- when false, revalidate all derived info at next
     * logicalrep_rel_open.  (While the localrel is open, we assume our lock
     * on that rel ensures the info remains good.)
     */
    bool        localrelvalid;
 
    /* Mapping to local relation. */
    Oid         localreloid;    /* local relation id */
    Relation    localrel;       /* relcache entry (NULL when closed) */
    AttrMap    *attrmap;        /* map of local attributes to remote ones */
    bool        updatable;      /* Can apply updates/deletes? */
    Oid         localindexoid;  /* which index to use, or InvalidOid if none */
    bool        idxisreplident; /* is it the relation's replica identity or
                                 * primary key, rather than an index usable
                                 * for a REPLICA IDENTITY FULL remote
                                 * relation? */
 
    /* Sync state. */
    char        state;
    XLogRecPtr  statelsn;
} LogicalRepRelMapEntry;
 
extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
extern void logicalrep_partmap_reset_relmap(LogicalRepRelation *remoterel);
 
extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
                                                  LOCKMODE lockmode);
extern LogicalRepRelMapEntry *logicalrep_partition_open(LogicalRepRelMapEntry *root,
                                                        Relation partrel, AttrMap *map);
extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
                                 LOCKMODE lockmode);
extern bool IsIndexUsableForReplicaIdentityFull(Relation idxrel, AttrMap *attrmap);
extern Oid  GetRelationIdentityOrPK(Relation rel);
 
#endif                          /* LOGICALRELATION_H */