Fix NULL input behaviour of pg_stat_get_replication_slot().
authorAndres Freund <andres@anarazel.de>
Mon, 28 Mar 2022 04:39:43 +0000 (21:39 -0700)
committerAndres Freund <andres@anarazel.de>
Mon, 28 Mar 2022 04:46:23 +0000 (21:46 -0700)
pg_stat_get_replication_slot() accidentally was marked as non-strict, crashing
when called with NULL input. As it's already released, introduce an explicit
NULL check in 14, fix the catalog in HEAD.

Bumps catversion in HEAD.

Discussion: https://postgr.es/m/20220326212432.s5n2maw6kugnpyxw@alap3.anarazel.de
Backpatch: 14-, where replication slot stats were introduced

src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/regress/expected/stats.out
src/test/regress/sql/stats.sql

index a3a49d39386f45f17968591f32f3e0d638955b7e..706475dfa807e2714c83a031ad0a5f6b3b4ce07f 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202203241
+#define CATALOG_VERSION_NO 202203271
 
 #endif
index 5e612a6b67ea3f6b6a9bcbbe1529e465372e435d..a26625f8233e2d64070bbe78d9531ee5eabb6a63 100644 (file)
   proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
   prosrc => 'pg_stat_get_wal_receiver' },
 { oid => '6169', descr => 'statistics: information about replication slot',
-  proname => 'pg_stat_get_replication_slot', proisstrict => 'f', provolatile => 's',
+  proname => 'pg_stat_get_replication_slot', provolatile => 's',
   proparallel => 'r', prorettype => 'record', proargtypes => 'text',
   proallargtypes => '{text,text,int8,int8,int8,int8,int8,int8,int8,int8,timestamptz}',
   proargmodes => '{i,o,o,o,o,o,o,o,o,o,o}',
index b7416c8f8fbe05c7a8b60f43314f32a88f58ddca..dcf48112f649fc841ba4ed881a9c3954c2fdc95a 100644 (file)
@@ -255,4 +255,11 @@ SELECT pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid);
 
 DROP TABLE brin_hot;
 DROP FUNCTION wait_for_hot_stats();
+-- ensure that stats accessors handle NULL input correctly
+SELECT pg_stat_get_replication_slot(NULL);
+ pg_stat_get_replication_slot 
+------------------------------
+(1 row)
+
 -- End of Stats Test
index dbc2dd28b6ba2bcd8d52f2c84c19f629996145e1..076c763451a5d3b7795fe2c4dce9b7a060110050 100644 (file)
@@ -229,4 +229,8 @@ DROP TABLE brin_hot;
 DROP FUNCTION wait_for_hot_stats();
 
 
+-- ensure that stats accessors handle NULL input correctly
+SELECT pg_stat_get_replication_slot(NULL);
+
+
 -- End of Stats Test