postgresql/src/include/catalog/pg_subscription.h
Tom Lane 914d2383ae Correctly mark pg_subscription.subslotname as nullable.
Due to the layout of this catalog, subslotname has to be explicitly
marked BKI_FORCE_NULL, else initdb will default to the assumption
that it's non-nullable.  Since, in fact, CREATE/ALTER SUBSCRIPTION
will store null values there, the existing marking is just wrong,
and has been since this catalog was invented.

We haven't noticed because not much in the system actually depends
on attnotnull being truthful.  However, JIT'ed tuple deconstruction
does depend on that in some cases, allowing crashes or wrong answers
in queries that inspect pg_subscription.  Commit 9de77b545 quite
accidentally exposed this on the buildfarm members that force JIT
activation.

Back-patch to v13.  The problem goes further back, but we cannot
force initdb in released branches, so some klugier solution will
be needed there.  Before working on that, push this simple fix
to try to get the buildfarm back to green.

Discussion: https://postgr.es/m/4118109.1595096139@sss.pgh.pa.us
2020-07-19 12:37:23 -04:00

89 lines
2.9 KiB
C

/* -------------------------------------------------------------------------
*
* pg_subscription.h
* definition of the "subscription" system catalog (pg_subscription)
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/catalog/pg_subscription.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
* information.
*
* -------------------------------------------------------------------------
*/
#ifndef PG_SUBSCRIPTION_H
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
#include "catalog/pg_subscription_d.h"
#include "nodes/pg_list.h"
/* ----------------
* pg_subscription definition. cpp turns this into
* typedef struct FormData_pg_subscription
* ----------------
*/
/*
* Technically, the subscriptions live inside the database, so a shared catalog
* seems weird, but the replication launcher process needs to access all of
* them to be able to start the workers, so we have to put them in a shared,
* nailed catalog.
*
* NOTE: When adding a column, also update system_views.sql.
*/
CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
Oid subdbid; /* Database the subscription is in. */
NameData subname; /* Name of the subscription */
Oid subowner; /* Owner of the subscription */
bool subenabled; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
text subconninfo BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname BKI_FORCE_NULL;
/* Synchronous commit setting for worker */
text subsynccommit BKI_FORCE_NOT_NULL;
/* List of publications subscribed to */
text subpublications[1] BKI_FORCE_NOT_NULL;
#endif
} FormData_pg_subscription;
typedef FormData_pg_subscription *Form_pg_subscription;
typedef struct Subscription
{
Oid oid; /* Oid of the subscription */
Oid dbid; /* Oid of the database which subscription is
* in */
char *name; /* Name of the subscription */
Oid owner; /* Oid of the subscription owner */
bool enabled; /* Indicates if the subscription is enabled */
char *conninfo; /* Connection string to the publisher */
char *slotname; /* Name of the replication slot */
char *synccommit; /* Synchronous commit setting for worker */
List *publications; /* List of publication names to subscribe to */
} Subscription;
extern Subscription *GetSubscription(Oid subid, bool missing_ok);
extern void FreeSubscription(Subscription *sub);
extern Oid get_subscription_oid(const char *subname, bool missing_ok);
extern char *get_subscription_name(Oid subid, bool missing_ok);
extern int CountDBSubscriptions(Oid dbid);
#endif /* PG_SUBSCRIPTION_H */