PostgreSQL Source Code  git master
pg_publication.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_publication.h
4  * definition of the "publication" system catalog (pg_publication)
5  *
6  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/catalog/pg_publication.h
10  *
11  * NOTES
12  * The Catalog.pm module reads this file and derives schema
13  * information.
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef PG_PUBLICATION_H
18 #define PG_PUBLICATION_H
19 
20 #include "catalog/genbki.h"
21 #include "catalog/objectaddress.h"
22 #include "catalog/pg_publication_d.h"
23 
24 /* ----------------
25  * pg_publication definition. cpp turns this into
26  * typedef struct FormData_pg_publication
27  * ----------------
28  */
29 CATALOG(pg_publication,6104,PublicationRelationId)
30 {
31  Oid oid; /* oid */
32 
33  NameData pubname; /* name of the publication */
34 
35  Oid pubowner BKI_LOOKUP(pg_authid); /* publication owner */
36 
37  /*
38  * indicates that this is special publication which should encompass all
39  * tables in the database (except for the unlogged and temp ones)
40  */
41  bool puballtables;
42 
43  /* true if inserts are published */
44  bool pubinsert;
45 
46  /* true if updates are published */
47  bool pubupdate;
48 
49  /* true if deletes are published */
50  bool pubdelete;
51 
52  /* true if truncates are published */
53  bool pubtruncate;
54 
55  /* true if partition changes are published using root schema */
56  bool pubviaroot;
58 
59 /* ----------------
60  * Form_pg_publication corresponds to a pointer to a tuple with
61  * the format of pg_publication relation.
62  * ----------------
63  */
65 
66 DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, pg_publication, btree(oid oid_ops));
67 DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, pg_publication, btree(pubname name_ops));
68 
69 MAKE_SYSCACHE(PUBLICATIONOID, pg_publication_oid_index, 8);
70 MAKE_SYSCACHE(PUBLICATIONNAME, pg_publication_pubname_index, 8);
71 
72 typedef struct PublicationActions
73 {
74  bool pubinsert;
75  bool pubupdate;
76  bool pubdelete;
79 
80 typedef struct PublicationDesc
81 {
83 
84  /*
85  * true if the columns referenced in row filters which are used for UPDATE
86  * or DELETE are part of the replica identity or the publication actions
87  * do not include UPDATE or DELETE.
88  */
91 
92  /*
93  * true if the columns are part of the replica identity or the publication
94  * actions do not include UPDATE or DELETE.
95  */
99 
100 typedef struct Publication
101 {
103  char *name;
104  bool alltables;
108 
109 typedef struct PublicationRelInfo
110 {
115 
116 extern Publication *GetPublication(Oid pubid);
117 extern Publication *GetPublicationByName(const char *pubname, bool missing_ok);
118 extern List *GetRelationPublications(Oid relid);
119 
120 /*---------
121  * Expected values for pub_partopt parameter of GetRelationPublications(),
122  * which allows callers to specify which partitions of partitioned tables
123  * mentioned in the publication they expect to see.
124  *
125  * ROOT: only the table explicitly mentioned in the publication
126  * LEAF: only leaf partitions in given tree
127  * ALL: all partitions in given tree
128  */
129 typedef enum PublicationPartOpt
130 {
135 
136 extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt);
137 extern List *GetAllTablesPublications(void);
138 extern List *GetAllTablesPublicationRelations(bool pubviaroot);
139 extern List *GetPublicationSchemas(Oid pubid);
140 extern List *GetSchemaPublications(Oid schemaid);
141 extern List *GetSchemaPublicationRelations(Oid schemaid,
142  PublicationPartOpt pub_partopt);
144  PublicationPartOpt pub_partopt);
146  PublicationPartOpt pub_partopt,
147  Oid relid);
148 extern Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors,
149  int *ancestor_level);
150 
151 extern bool is_publishable_relation(Relation rel);
152 extern bool is_schema_publication(Oid pubid);
154  bool if_not_exists);
155 extern ObjectAddress publication_add_schema(Oid pubid, Oid schemaid,
156  bool if_not_exists);
157 
158 extern Bitmapset *pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols,
159  MemoryContext mcxt);
160 
161 #endif /* PG_PUBLICATION_H */
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
MAKE_SYSCACHE(PUBLICATIONOID, pg_publication_oid_index, 8)
bool is_schema_publication(Oid pubid)
List * GetPublicationSchemas(Oid pubid)
Publication * GetPublicationByName(const char *pubname, bool missing_ok)
List * GetSchemaPublications(Oid schemaid)
Publication * GetPublication(Oid pubid)
List * GetRelationPublications(Oid relid)
ObjectAddress publication_add_schema(Oid pubid, Oid schemaid, bool if_not_exists)
CATALOG(pg_publication, 6104, PublicationRelationId)
struct PublicationRelInfo PublicationRelInfo
FormData_pg_publication
ObjectAddress publication_add_relation(Oid pubid, PublicationRelInfo *pri, bool if_not_exists)
List * GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, pg_publication, btree(pubname name_ops))
struct PublicationActions PublicationActions
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, pg_publication, btree(oid oid_ops))
List * GetAllTablesPublications(void)
List * GetAllTablesPublicationRelations(bool pubviaroot)
Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors, int *ancestor_level)
List * GetPubPartitionOptionRelations(List *result, PublicationPartOpt pub_partopt, Oid relid)
FormData_pg_publication * Form_pg_publication
struct PublicationDesc PublicationDesc
List * GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
struct Publication Publication
Bitmapset * pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols, MemoryContext mcxt)
bool is_publishable_relation(Relation rel)
List * GetAllSchemaPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
PublicationPartOpt
@ PUBLICATION_PART_LEAF
@ PUBLICATION_PART_ROOT
@ PUBLICATION_PART_ALL
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
Definition: pg_list.h:54
Definition: nodes.h:129
PublicationActions pubactions
bool cols_valid_for_delete
bool cols_valid_for_update
PublicationActions pubactions
Definition: c.h:728