PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, 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"
22#include "catalog/pg_publication_d.h" /* IWYU pragma: export */
23
24/* ----------------
25 * pg_publication definition. cpp turns this into
26 * typedef struct FormData_pg_publication
27 * ----------------
28 */
29CATALOG(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 /*
44 * indicates that this is special publication which should encompass all
45 * sequences in the database (except for the unlogged and temp ones)
46 */
47 bool puballsequences;
48
49 /* true if inserts are published */
50 bool pubinsert;
51
52 /* true if updates are published */
53 bool pubupdate;
54
55 /* true if deletes are published */
56 bool pubdelete;
57
58 /* true if truncates are published */
59 bool pubtruncate;
60
61 /* true if partition changes are published using root schema */
62 bool pubviaroot;
63
64 /*
65 * 'n'(none) if generated column data should not be published. 's'(stored)
66 * if stored generated column data should be published.
67 */
68 char pubgencols;
70
71/* ----------------
72 * Form_pg_publication corresponds to a pointer to a tuple with
73 * the format of pg_publication relation.
74 * ----------------
75 */
77
78DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, pg_publication, btree(oid oid_ops));
79DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, pg_publication, btree(pubname name_ops));
80
81MAKE_SYSCACHE(PUBLICATIONOID, pg_publication_oid_index, 8);
82MAKE_SYSCACHE(PUBLICATIONNAME, pg_publication_pubname_index, 8);
83
84typedef struct PublicationActions
85{
91
92typedef struct PublicationDesc
93{
95
96 /*
97 * true if the columns referenced in row filters which are used for UPDATE
98 * or DELETE are part of the replica identity or the publication actions
99 * do not include UPDATE or DELETE.
100 */
103
104 /*
105 * true if the columns are part of the replica identity or the publication
106 * actions do not include UPDATE or DELETE.
107 */
110
111 /*
112 * true if all generated columns that are part of replica identity are
113 * published or the publication actions do not include UPDATE or DELETE.
114 */
118
119#ifdef EXPOSE_TO_CLIENT_CODE
120
121typedef enum PublishGencolsType
122{
123 /* Generated columns present should not be replicated. */
124 PUBLISH_GENCOLS_NONE = 'n',
125
126 /* Generated columns present should be replicated. */
127 PUBLISH_GENCOLS_STORED = 's',
128
129} PublishGencolsType;
130
131#endif /* EXPOSE_TO_CLIENT_CODE */
132
133typedef struct Publication
134{
136 char *name;
140 PublishGencolsType pubgencols_type;
143
144typedef struct PublicationRelInfo
145{
150
151extern Publication *GetPublication(Oid pubid);
152extern Publication *GetPublicationByName(const char *pubname, bool missing_ok);
153extern List *GetRelationPublications(Oid relid);
154
155/*---------
156 * Expected values for pub_partopt parameter of GetPublicationRelations(),
157 * which allows callers to specify which partitions of partitioned tables
158 * mentioned in the publication they expect to see.
159 *
160 * ROOT: only the table explicitly mentioned in the publication
161 * LEAF: only leaf partitions in given tree
162 * ALL: all partitions in given tree
163 */
165{
170
171extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt);
172extern List *GetAllTablesPublications(void);
173extern List *GetAllPublicationRelations(char relkind, bool pubviaroot);
174extern List *GetPublicationSchemas(Oid pubid);
175extern List *GetSchemaPublications(Oid schemaid);
176extern List *GetSchemaPublicationRelations(Oid schemaid,
177 PublicationPartOpt pub_partopt);
179 PublicationPartOpt pub_partopt);
181 PublicationPartOpt pub_partopt,
182 Oid relid);
183extern Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors,
184 int *ancestor_level);
185
186extern bool is_publishable_relation(Relation rel);
187extern bool is_schema_publication(Oid pubid);
188extern bool check_and_fetch_column_list(Publication *pub, Oid relid,
189 MemoryContext mcxt, Bitmapset **cols);
191 bool if_not_exists);
192extern Bitmapset *pub_collist_validate(Relation targetrel, List *columns);
193extern ObjectAddress publication_add_schema(Oid pubid, Oid schemaid,
194 bool if_not_exists);
195
196extern Bitmapset *pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols,
197 MemoryContext mcxt);
198extern Bitmapset *pub_form_cols_map(Relation relation,
199 PublishGencolsType include_gencols_type);
200
201#endif /* PG_PUBLICATION_H */
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
MAKE_SYSCACHE(PUBLICATIONOID, pg_publication_oid_index, 8)
Bitmapset * pub_collist_validate(Relation targetrel, List *columns)
List * GetPubPartitionOptionRelations(List *result, PublicationPartOpt pub_partopt, Oid relid)
List * GetRelationPublications(Oid relid)
bool is_schema_publication(Oid pubid)
ObjectAddress publication_add_schema(Oid pubid, Oid schemaid, bool if_not_exists)
CATALOG(pg_publication, 6104, PublicationRelationId)
struct PublicationRelInfo PublicationRelInfo
List * GetPublicationSchemas(Oid pubid)
FormData_pg_publication
ObjectAddress publication_add_relation(Oid pubid, PublicationRelInfo *pri, bool if_not_exists)
List * GetAllTablesPublications(void)
DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, pg_publication, btree(pubname name_ops))
List * GetAllSchemaPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
struct PublicationActions PublicationActions
Publication * GetPublicationByName(const char *pubname, bool missing_ok)
List * GetSchemaPublications(Oid schemaid)
DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, pg_publication, btree(oid oid_ops))
Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors, int *ancestor_level)
List * GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
FormData_pg_publication * Form_pg_publication
struct PublicationDesc PublicationDesc
Bitmapset * pub_form_cols_map(Relation relation, PublishGencolsType include_gencols_type)
Publication * GetPublication(Oid pubid)
List * GetAllPublicationRelations(char relkind, bool pubviaroot)
bool check_and_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt, Bitmapset **cols)
Bitmapset * pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols, MemoryContext mcxt)
struct Publication Publication
bool is_publishable_relation(Relation rel)
List * GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
PublicationPartOpt
@ PUBLICATION_PART_LEAF
@ PUBLICATION_PART_ROOT
@ PUBLICATION_PART_ALL
uint64_t Datum
Definition: postgres.h:70
unsigned int Oid
Definition: postgres_ext.h:32
Definition: pg_list.h:54
Definition: nodes.h:135
PublicationActions pubactions
bool gencols_valid_for_update
bool gencols_valid_for_delete
PublishGencolsType pubgencols_type
PublicationActions pubactions
Definition: c.h:750