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-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 /* 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;
57
58 /*
59 * 'n'(none) if generated column data should not be published. 's'(stored)
60 * if stored generated column data should be published.
61 */
62 char pubgencols;
64
65/* ----------------
66 * Form_pg_publication corresponds to a pointer to a tuple with
67 * the format of pg_publication relation.
68 * ----------------
69 */
71
72DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, pg_publication, btree(oid oid_ops));
73DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, pg_publication, btree(pubname name_ops));
74
75MAKE_SYSCACHE(PUBLICATIONOID, pg_publication_oid_index, 8);
76MAKE_SYSCACHE(PUBLICATIONNAME, pg_publication_pubname_index, 8);
77
78typedef struct PublicationActions
79{
85
86typedef struct PublicationDesc
87{
89
90 /*
91 * true if the columns referenced in row filters which are used for UPDATE
92 * or DELETE are part of the replica identity or the publication actions
93 * do not include UPDATE or DELETE.
94 */
97
98 /*
99 * true if the columns are part of the replica identity or the publication
100 * actions do not include UPDATE or DELETE.
101 */
104
105 /*
106 * true if all generated columns that are part of replica identity are
107 * published or the publication actions do not include UPDATE or DELETE.
108 */
112
113#ifdef EXPOSE_TO_CLIENT_CODE
114
115typedef enum PublishGencolsType
116{
117 /* Generated columns present should not be replicated. */
118 PUBLISH_GENCOLS_NONE = 'n',
119
120 /* Generated columns present should be replicated. */
121 PUBLISH_GENCOLS_STORED = 's',
122
123} PublishGencolsType;
124
125#endif /* EXPOSE_TO_CLIENT_CODE */
126
127typedef struct Publication
128{
130 char *name;
133 PublishGencolsType pubgencols_type;
136
137typedef struct PublicationRelInfo
138{
143
144extern Publication *GetPublication(Oid pubid);
145extern Publication *GetPublicationByName(const char *pubname, bool missing_ok);
146extern List *GetRelationPublications(Oid relid);
147
148/*---------
149 * Expected values for pub_partopt parameter of GetRelationPublications(),
150 * which allows callers to specify which partitions of partitioned tables
151 * mentioned in the publication they expect to see.
152 *
153 * ROOT: only the table explicitly mentioned in the publication
154 * LEAF: only leaf partitions in given tree
155 * ALL: all partitions in given tree
156 */
158{
163
164extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt);
165extern List *GetAllTablesPublications(void);
166extern List *GetAllTablesPublicationRelations(bool pubviaroot);
167extern List *GetPublicationSchemas(Oid pubid);
168extern List *GetSchemaPublications(Oid schemaid);
169extern List *GetSchemaPublicationRelations(Oid schemaid,
170 PublicationPartOpt pub_partopt);
172 PublicationPartOpt pub_partopt);
174 PublicationPartOpt pub_partopt,
175 Oid relid);
176extern Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors,
177 int *ancestor_level);
178
179extern bool is_publishable_relation(Relation rel);
180extern bool is_schema_publication(Oid pubid);
181extern bool check_and_fetch_column_list(Publication *pub, Oid relid,
182 MemoryContext mcxt, Bitmapset **cols);
184 bool if_not_exists);
185extern Bitmapset *pub_collist_validate(Relation targetrel, List *columns);
186extern ObjectAddress publication_add_schema(Oid pubid, Oid schemaid,
187 bool if_not_exists);
188
189extern Bitmapset *pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols,
190 MemoryContext mcxt);
191extern Bitmapset *pub_form_cols_map(Relation relation,
192 PublishGencolsType include_gencols_type);
193
194#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 * GetAllTablesPublicationRelations(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
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:32
Definition: pg_list.h:54
Definition: nodes.h:131
PublicationActions pubactions
bool gencols_valid_for_update
bool gencols_valid_for_delete
PublishGencolsType pubgencols_type
PublicationActions pubactions
Definition: c.h:712