diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 918b58242f..a15d76a0e9 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -7620,7 +7620,9 @@ SCRAM-SHA-256$<iteration count>:&l
srsublsn pg_lsn
- End LSN for s and r states.
+ Remote LSN of the state change used for synchronization coordination
+ when in s or r states,
+ otherwise null
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index cb15731115..0d23b20d62 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -451,13 +451,20 @@ GetSubscriptionRelations(Oid subid)
{
Form_pg_subscription_rel subrel;
SubscriptionRelState *relstate;
+ Datum d;
+ bool isnull;
subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
- relstate->lsn = subrel->srsublsn;
+ d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
+ Anum_pg_subscription_rel_srsublsn, &isnull);
+ if (isnull)
+ relstate->lsn = InvalidXLogRecPtr;
+ else
+ relstate->lsn = DatumGetLSN(d);
res = lappend(res, relstate);
}
@@ -503,13 +510,20 @@ GetSubscriptionNotReadyRelations(Oid subid)
{
Form_pg_subscription_rel subrel;
SubscriptionRelState *relstate;
+ Datum d;
+ bool isnull;
subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
- relstate->lsn = subrel->srsublsn;
+ d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
+ Anum_pg_subscription_rel_srsublsn, &isnull);
+ if (isnull)
+ relstate->lsn = InvalidXLogRecPtr;
+ else
+ relstate->lsn = DatumGetLSN(d);
res = lappend(res, relstate);
}
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 9d9334272e..282019c49d 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202007191
+#define CATALOG_VERSION_NO 202007201
#endif
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index c44df04c72..f384f4e7fa 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -33,8 +33,18 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
Oid srsubid; /* Oid of subscription */
Oid srrelid; /* Oid of relation */
char srsubstate; /* state of the relation in subscription */
- XLogRecPtr srsublsn; /* remote lsn of the state change used for
- * synchronization coordination */
+
+ /*
+ * Although srsublsn is a fixed-width type, it is allowed to be NULL, so
+ * we prevent direct C code access to it just as for a varlena field.
+ */
+#ifdef CATALOG_VARLEN /* variable-length fields start here */
+
+ XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the state change
+ * used for synchronization
+ * coordination, or NULL if not
+ * valid */
+#endif
} FormData_pg_subscription_rel;
typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;