Fix issues in binary_upgrade_logical_slot_has_caught_up().
authorAmit Kapila <[email protected]>
Thu, 7 Dec 2023 03:12:48 +0000 (08:42 +0530)
committerAmit Kapila <[email protected]>
Thu, 7 Dec 2023 03:12:48 +0000 (08:42 +0530)
The commit 29d0a77fa6 labelled binary_upgrade_logical_slot_has_caught_up()
as a non-strict function to allow providing a better error message to callers
in case the passed slot_name is NULL. On further discussion, it seems that
it is not helpful to have a different error message for NULL input in this
function, so this patch marks the function as strict.

This patch also removes the explicit permission check to use replication
slots as this function is invoked only by superusers and instead adds an
Assert.

Reported-by: Masahiko Sawada
Author: Hayato Kuroda
Reviewed-by: Vignesh C
Discussion: https://postgr.es/m/CAD21AoDSyiBKkMXBxN_gUayZZUCOgyHnG8Ge8rcPXNP3Tf6B4g@mail.gmail.com

src/backend/utils/adt/pg_upgrade_support.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat

index 2f6fc86c3df3c14bec7fdd7728aba9ca45036d10..92921b0239d976b4a013a29552e16f01fed16beb 100644 (file)
@@ -281,11 +281,11 @@ binary_upgrade_logical_slot_has_caught_up(PG_FUNCTION_ARGS)
 
    CHECK_IS_BINARY_UPGRADE;
 
-   /* We must check before dereferencing the argument */
-   if (PG_ARGISNULL(0))
-       elog(ERROR, "null argument to binary_upgrade_validate_wal_records is not allowed");
-
-   CheckSlotPermissions();
+   /*
+    * Binary upgrades only allowed super-user connections so we must have
+    * permission to use replication slots.
+    */
+   Assert(has_rolreplication(GetUserId()));
 
    slot_name = PG_GETARG_NAME(0);
 
index c4c59bfe6f9e2a02d779a69abf1bb450d9e0559a..a06a8f0b23be924e55c8634e98a17d4bd62d62a0 100644 (file)
@@ -57,6 +57,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202311271
+#define CATALOG_VERSION_NO 202312071
 
 #endif
index fb58dee3bcdf6460a71e40a0b3423c1ec39e55c9..77e8b13764924595c8a7248df168d55a4723dbe4 100644 (file)
   proparallel => 'u', prorettype => 'void', proargtypes => 'oid',
   prosrc => 'binary_upgrade_set_next_pg_tablespace_oid' },
 { oid => '8046', descr => 'for use by pg_upgrade',
-  proname => 'binary_upgrade_logical_slot_has_caught_up', proisstrict => 'f',
-  provolatile => 'v', proparallel => 'u', prorettype => 'bool',
-  proargtypes => 'name',
+  proname => 'binary_upgrade_logical_slot_has_caught_up', provolatile => 'v',
+  proparallel => 'u', prorettype => 'bool', proargtypes => 'name',
   prosrc => 'binary_upgrade_logical_slot_has_caught_up' },
 
 # conversion functions