logicalrelation.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*-------------------------------------------------------------------------
  2. *
  3. * logicalrelation.h
  4. * Relation definitions for logical replication relation mapping.
  5. *
  6. * Portions Copyright (c) 2016-2022, PostgreSQL Global Development Group
  7. *
  8. * src/include/replication/logicalrelation.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef LOGICALRELATION_H
  13. #define LOGICALRELATION_H
  14. #include "access/attmap.h"
  15. #include "replication/logicalproto.h"
  16. typedef struct LogicalRepRelMapEntry
  17. {
  18. LogicalRepRelation remoterel; /* key is remoterel.remoteid */
  19. /*
  20. * Validity flag -- when false, revalidate all derived info at next
  21. * logicalrep_rel_open. (While the localrel is open, we assume our lock
  22. * on that rel ensures the info remains good.)
  23. */
  24. bool localrelvalid;
  25. /* Mapping to local relation. */
  26. Oid localreloid; /* local relation id */
  27. Relation localrel; /* relcache entry (NULL when closed) */
  28. AttrMap *attrmap; /* map of local attributes to remote ones */
  29. bool updatable; /* Can apply updates/deletes? */
  30. /* Sync state. */
  31. char state;
  32. XLogRecPtr statelsn;
  33. } LogicalRepRelMapEntry;
  34. extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
  35. extern void logicalrep_partmap_reset_relmap(LogicalRepRelation *remoterel);
  36. extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
  37. LOCKMODE lockmode);
  38. extern LogicalRepRelMapEntry *logicalrep_partition_open(LogicalRepRelMapEntry *root,
  39. Relation partrel, AttrMap *map);
  40. extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
  41. LOCKMODE lockmode);
  42. #endif /* LOGICALRELATION_H */