diff options
author | Amit Kapila | 2025-01-23 09:58:37 +0000 |
---|---|---|
committer | Amit Kapila | 2025-01-23 09:58:37 +0000 |
commit | e65dbc9927fb86aa3c8a914ede6a6ae934384f5a (patch) | |
tree | baf5c64867d7376c40135fc115860c1339087204 /src/include | |
parent | eef4a33f62f7300765b5ffa8c966fa2fba50d176 (diff) |
Change publication's publish_generated_columns option type to enum.
The current boolean publish_generated_columns option only supports a
binary choice, which is insufficient for future enhancements where
generated columns can be of different types (e.g., stored or virtual). The
supported values for the publish_generated_columns option are 'none' and
'stored'.
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/d718d219-dd47-4a33-bb97-56e8fc4da994@eisentraut.org
Discussion: https://postgr.es/m/B80D17B2-2C8E-4C7D-87F2-E5B4BE3C069E@gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/pg_publication.h | 26 | ||||
-rw-r--r-- | src/include/commands/publicationcmds.h | 2 | ||||
-rw-r--r-- | src/include/replication/logicalproto.h | 11 |
4 files changed, 30 insertions, 11 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 28de0c83342..586b83f2f4d 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -57,6 +57,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202501171 +#define CATALOG_VERSION_NO 202501231 #endif diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h index 3c2ae2a960c..9e6cddcac4c 100644 --- a/src/include/catalog/pg_publication.h +++ b/src/include/catalog/pg_publication.h @@ -55,8 +55,11 @@ CATALOG(pg_publication,6104,PublicationRelationId) /* true if partition changes are published using root schema */ bool pubviaroot; - /* true if generated columns data should be published */ - bool pubgencols; + /* + * 'n'(none) if generated column data should not be published. 's'(stored) + * if stored generated column data should be published. + */ + char pubgencols_type; } FormData_pg_publication; /* ---------------- @@ -107,13 +110,27 @@ typedef struct PublicationDesc bool gencols_valid_for_delete; } PublicationDesc; +#ifdef EXPOSE_TO_CLIENT_CODE + +typedef enum PublishGencolsType +{ + /* Generated columns present should not be replicated. */ + PUBLISH_GENCOLS_NONE = 'n', + + /* Generated columns present should be replicated. */ + PUBLISH_GENCOLS_STORED = 's', + +} PublishGencolsType; + +#endif /* EXPOSE_TO_CLIENT_CODE */ + typedef struct Publication { Oid oid; char *name; bool alltables; bool pubviaroot; - bool pubgencols; + PublishGencolsType pubgencols_type; PublicationActions pubactions; } Publication; @@ -171,6 +188,7 @@ extern ObjectAddress publication_add_schema(Oid pubid, Oid schemaid, extern Bitmapset *pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols, MemoryContext mcxt); -extern Bitmapset *pub_form_cols_map(Relation relation, bool include_gencols); +extern Bitmapset *pub_form_cols_map(Relation relation, + PublishGencolsType include_gencols_type); #endif /* PG_PUBLICATION_H */ diff --git a/src/include/commands/publicationcmds.h b/src/include/commands/publicationcmds.h index 170c5ce00f0..e11a942ea0f 100644 --- a/src/include/commands/publicationcmds.h +++ b/src/include/commands/publicationcmds.h @@ -35,7 +35,7 @@ extern bool pub_rf_contains_invalid_column(Oid pubid, Relation relation, List *ancestors, bool pubviaroot); extern bool pub_contains_invalid_column(Oid pubid, Relation relation, List *ancestors, bool pubviaroot, - bool pubgencols, + char pubgencols_type, bool *invalid_column_list, bool *invalid_gen_col); diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h index 7012247825d..b261c60d3fa 100644 --- a/src/include/replication/logicalproto.h +++ b/src/include/replication/logicalproto.h @@ -225,19 +225,20 @@ extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn); extern void logicalrep_write_insert(StringInfo out, TransactionId xid, Relation rel, TupleTableSlot *newslot, bool binary, Bitmapset *columns, - bool include_gencols); + PublishGencolsType include_gencols_type); extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup); extern void logicalrep_write_update(StringInfo out, TransactionId xid, Relation rel, TupleTableSlot *oldslot, TupleTableSlot *newslot, bool binary, - Bitmapset *columns, bool include_gencols); + Bitmapset *columns, + PublishGencolsType include_gencols_type); extern LogicalRepRelId logicalrep_read_update(StringInfo in, bool *has_oldtuple, LogicalRepTupleData *oldtup, LogicalRepTupleData *newtup); extern void logicalrep_write_delete(StringInfo out, TransactionId xid, Relation rel, TupleTableSlot *oldslot, bool binary, Bitmapset *columns, - bool include_gencols); + PublishGencolsType include_gencols_type); extern LogicalRepRelId logicalrep_read_delete(StringInfo in, LogicalRepTupleData *oldtup); extern void logicalrep_write_truncate(StringInfo out, TransactionId xid, @@ -249,7 +250,7 @@ extern void logicalrep_write_message(StringInfo out, TransactionId xid, XLogRecP bool transactional, const char *prefix, Size sz, const char *message); extern void logicalrep_write_rel(StringInfo out, TransactionId xid, Relation rel, Bitmapset *columns, - bool include_gencols); + PublishGencolsType include_gencols_type); extern LogicalRepRelation *logicalrep_read_rel(StringInfo in); extern void logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid); @@ -274,6 +275,6 @@ extern void logicalrep_read_stream_abort(StringInfo in, extern const char *logicalrep_message_type(LogicalRepMsgType action); extern bool logicalrep_should_publish_column(Form_pg_attribute att, Bitmapset *columns, - bool include_gencols); + PublishGencolsType include_gencols_type); #endif /* LOGICAL_PROTO_H */ |