Correctly mark pg_subscription.subslotname as nullable.
authorTom Lane
Sun, 19 Jul 2020 16:37:23 +0000 (12:37 -0400)
committerTom Lane
Sun, 19 Jul 2020 16:37:23 +0000 (12:37 -0400)
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

doc/src/sgml/catalogs.sgml
src/include/catalog/catversion.h
src/include/catalog/pg_subscription.h
src/test/regress/expected/subscription.out
src/test/regress/sql/subscription.sql

index 8ff17d9b4e0bc19a90e41aafb1ecd3ff82bcbe0c..6cb9e8e29ad0849585c19acc27f35834439a8f92 100644 (file)
@@ -7517,8 +7517,9 @@ SCRAM-SHA-256$<iteration count>:&l
        subslotname name
       
       
-       Name of the replication slot in the upstream database. Also used
-       for local replication origin name.
+       Name of the replication slot in the upstream database (also used
+       for the local replication origin name);
+       null represents NONE
       
      
 
index 6b3aa7c0063e28eef06bd76701cab8453e41e540..9d9334272e85eb97e5c29c95da64f596498ecc2b 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202007131
+#define CATALOG_VERSION_NO 202007191
 
 #endif
index 0a756d42d8453fad1f2c9e24be72936d73b67e97..e3288ad76e96c25f21fcfaead36a62286520c393 100644 (file)
@@ -53,7 +53,7 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
    text        subconninfo BKI_FORCE_NOT_NULL;
 
    /* Slot name on publisher */
-   NameData    subslotname;
+   NameData    subslotname BKI_FORCE_NULL;
 
    /* Synchronous commit setting for worker */
    text        subsynccommit BKI_FORCE_NOT_NULL;
index e7add9d2b81be9b9c1d2e7634fcec1596613c781..3ba1e5dcdd5a299115750f9be6fefbce544bf41c 100644 (file)
@@ -147,6 +147,13 @@ DROP SUBSCRIPTION regress_testsub;
 ERROR:  DROP SUBSCRIPTION cannot run inside a transaction block
 COMMIT;
 ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE);
+\dRs+
+                                                      List of subscriptions
+      Name       |           Owner            | Enabled |     Publication     | Synchronous commit |           Conninfo           
+-----------------+----------------------------+---------+---------------------+--------------------+------------------------------
+ regress_testsub | regress_subscription_user2 | f       | {testpub2,testpub3} | local              | dbname=regress_doesnotexist2
+(1 row)
+
 -- now it works
 BEGIN;
 DROP SUBSCRIPTION regress_testsub;
index 9e234ab8b3f7be6a20daa747a34742fd0977ec20..1bc58887f7ed50af809810754aab3f217ad75097 100644 (file)
@@ -109,6 +109,8 @@ COMMIT;
 
 ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE);
 
+\dRs+
+
 -- now it works
 BEGIN;
 DROP SUBSCRIPTION regress_testsub;