Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pg_subscription.h171 linesDownload Raw Back to catalog
1/* -------------------------------------------------------------------------2 *3 * pg_subscription.h4 *	  definition of the "subscription" system catalog (pg_subscription)5 *6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group7 * Portions Copyright (c) 1994, Regents of the University of California8 *9 * src/include/catalog/pg_subscription.h10 *11 * NOTES12 *	  The Catalog.pm module reads this file and derives schema13 *	  information.14 *15 * -------------------------------------------------------------------------16 */17#ifndef PG_SUBSCRIPTION_H18#define PG_SUBSCRIPTION_H19 20#include "access/xlogdefs.h"21#include "catalog/genbki.h"22#include "catalog/pg_subscription_d.h"23 24#include "nodes/pg_list.h"25 26/*27 * two_phase tri-state values. See comments atop worker.c to know more about28 * these states.29 */30#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'31#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'32#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'33 34/*35 * The subscription will request the publisher to only send changes that do not36 * have any origin.37 */38#define LOGICALREP_ORIGIN_NONE "none"39 40/*41 * The subscription will request the publisher to send changes regardless42 * of their origin.43 */44#define LOGICALREP_ORIGIN_ANY "any"45 46/* ----------------47 *		pg_subscription definition. cpp turns this into48 *		typedef struct FormData_pg_subscription49 * ----------------50 */51 52/*53 * Technically, the subscriptions live inside the database, so a shared catalog54 * seems weird, but the replication launcher process needs to access all of55 * them to be able to start the workers, so we have to put them in a shared,56 * nailed catalog.57 *58 * CAUTION:  There is a GRANT in system_views.sql to grant public select59 * access on all columns except subconninfo.  When you add a new column60 * here, be sure to update that (or, if the new column is not to be publicly61 * readable, update associated comments and catalogs.sgml instead).62 */63CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO64{65	Oid			oid;			/* oid */66 67	Oid			subdbid BKI_LOOKUP(pg_database);	/* Database the68													 * subscription is in. */69 70	XLogRecPtr	subskiplsn;		/* All changes finished at this LSN are71								 * skipped */72 73	NameData	subname;		/* Name of the subscription */74 75	Oid			subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */76 77	bool		subenabled;		/* True if the subscription is enabled (the78								 * worker should be running) */79 80	bool		subbinary;		/* True if the subscription wants the81								 * publisher to send data in binary */82 83	char		substream;		/* Stream in-progress transactions. See84								 * LOGICALREP_STREAM_xxx constants. */85 86	char		subtwophasestate;	/* Stream two-phase transactions */87 88	bool		subdisableonerr;	/* True if a worker error should cause the89									 * subscription to be disabled */90 91	bool		subpasswordrequired;	/* Must connection use a password? */92 93	bool		subrunasowner;	/* True if replication should execute as the94								 * subscription owner */95 96#ifdef CATALOG_VARLEN			/* variable-length fields start here */97	/* Connection string to the publisher */98	text		subconninfo BKI_FORCE_NOT_NULL;99 100	/* Slot name on publisher */101	NameData	subslotname BKI_FORCE_NULL;102 103	/* Synchronous commit setting for worker */104	text		subsynccommit BKI_FORCE_NOT_NULL;105 106	/* List of publications subscribed to */107	text		subpublications[1] BKI_FORCE_NOT_NULL;108 109	/* Only publish data originating from the specified origin */110	text		suborigin BKI_DEFAULT(LOGICALREP_ORIGIN_ANY);111#endif112} FormData_pg_subscription;113 114typedef FormData_pg_subscription *Form_pg_subscription;115 116DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex);117 118DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, on pg_subscription using btree(oid oid_ops));119DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, SubscriptionNameIndexId, on pg_subscription using btree(subdbid oid_ops, subname name_ops));120 121typedef struct Subscription122{123	Oid			oid;			/* Oid of the subscription */124	Oid			dbid;			/* Oid of the database which subscription is125								 * in */126	XLogRecPtr	skiplsn;		/* All changes finished at this LSN are127								 * skipped */128	char	   *name;			/* Name of the subscription */129	Oid			owner;			/* Oid of the subscription owner */130	bool		enabled;		/* Indicates if the subscription is enabled */131	bool		binary;			/* Indicates if the subscription wants data in132								 * binary format */133	char		stream;			/* Allow streaming in-progress transactions.134								 * See LOGICALREP_STREAM_xxx constants. */135	char		twophasestate;	/* Allow streaming two-phase transactions */136	bool		disableonerr;	/* Indicates if the subscription should be137								 * automatically disabled if a worker error138								 * occurs */139	bool		passwordrequired;	/* Must connection use a password? */140	bool		runasowner;		/* Run replication as subscription owner */141	char	   *conninfo;		/* Connection string to the publisher */142	char	   *slotname;		/* Name of the replication slot */143	char	   *synccommit;		/* Synchronous commit setting for worker */144	List	   *publications;	/* List of publication names to subscribe to */145	char	   *origin;			/* Only publish data originating from the146								 * specified origin */147} Subscription;148 149/* Disallow streaming in-progress transactions. */150#define LOGICALREP_STREAM_OFF 'f'151 152/*153 * Streaming in-progress transactions are written to a temporary file and154 * applied only after the transaction is committed on upstream.155 */156#define LOGICALREP_STREAM_ON 't'157 158/*159 * Streaming in-progress transactions are applied immediately via a parallel160 * apply worker.161 */162#define LOGICALREP_STREAM_PARALLEL 'p'163 164extern Subscription *GetSubscription(Oid subid, bool missing_ok);165extern void FreeSubscription(Subscription *sub);166extern void DisableSubscription(Oid subid);167 168extern int	CountDBSubscriptions(Oid dbid);169 170#endif							/* PG_SUBSCRIPTION_H */171