On Sun, Mar 27, 2022 at 2:54 AM Andres Freund <and...@anarazel.de> wrote: > > Hi, > > I'm working to increase the test coverage of pgstat related stuff higher (for > the shared memory stats patch, of course). > > "Accidentally" noticed that > SELECT * FROM pg_stat_get_replication_slot(NULL); > crashes. This is present in HEAD and 14. > > I guess we'll have to add a code-level check in 14 to deal with this?
This problem is reproducible in both PG14 & Head, changing isstrict solves the problem. In PG14 should we also add a check in pg_stat_get_replication_slot so that it can solve the problem for the existing users who have already installed PG14 or will this be handled automatically when upgrading to the new version. Regards, Vignesh
From 578f8f51e7213b22152db7447d94f7fd48bf3893 Mon Sep 17 00:00:00 2001 From: Vigneshwaran C <vignes...@gmail.com> Date: Sun, 27 Mar 2022 11:30:09 +0530 Subject: [PATCH] pg_stat_get_replication_slot NULL handling. Set isstrict to true for pg_stat_get_replication_slot function. --- src/include/catalog/pg_proc.dat | 2 +- src/test/regress/expected/misc_functions.out | 9 +++++++++ src/test/regress/sql/misc_functions.sql | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 699bd0aa3e..c14ccccdf5 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5370,7 +5370,7 @@ 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', proisstrict => 't', 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}', diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index 01d1ad0b9a..900e89342c 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -466,6 +466,15 @@ SELECT has_function_privilege('regress_slot_dir_funcs', (1 row) DROP ROLE regress_slot_dir_funcs; +-- +-- Test NULL handling of pg_stat_get_replication_slot +-- +SELECT pg_stat_get_replication_slot(NULL); + pg_stat_get_replication_slot +------------------------------ + +(1 row) + -- -- Test adding a support function to a subject function -- diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql index 072fc36a1f..34895a58c1 100644 --- a/src/test/regress/sql/misc_functions.sql +++ b/src/test/regress/sql/misc_functions.sql @@ -161,6 +161,11 @@ SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_replslotdir(text)', 'EXECUTE'); DROP ROLE regress_slot_dir_funcs; +-- +-- Test NULL handling of pg_stat_get_replication_slot +-- +SELECT pg_stat_get_replication_slot(NULL); + -- -- Test adding a support function to a subject function -- -- 2.32.0
From a5ff5cadf5bb386bc3b32b7c8340718ce44fdc74 Mon Sep 17 00:00:00 2001 From: Vigneshwaran C <vignes...@gmail.com> Date: Sun, 27 Mar 2022 11:47:05 +0530 Subject: [PATCH] pg_stat_get_replication_slot NULL handling. Passing NULL to pg_stat_get_replication_slot crashes. Set isstrict to true for pg_stat_get_replication_slot function to handle it. --- src/include/catalog/pg_proc.dat | 2 +- src/test/regress/expected/misc_functions.out | 8 ++++++++ src/test/regress/sql/misc_functions.sql | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 79669bf5a2..4a1f0fe0ef 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5310,7 +5310,7 @@ 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', prorows => '1', proisstrict => 'f', + proname => 'pg_stat_get_replication_slot', prorows => '1', proisstrict => 't', proretset => 't', provolatile => 's', proparallel => 'r', prorettype => 'record', proargtypes => 'text', proallargtypes => '{text,text,int8,int8,int8,int8,int8,int8,int8,int8,timestamptz}', diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index e845042d38..3883aebdfe 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -214,6 +214,14 @@ select count(*) > 0 from t (1 row) +-- +-- Test NULL handling of pg_stat_get_replication_slot +-- +SELECT pg_stat_get_replication_slot(NULL); + pg_stat_get_replication_slot +------------------------------ +(0 rows) + -- -- Test adding a support function to a subject function -- diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql index a398349afc..5029f5d931 100644 --- a/src/test/regress/sql/misc_functions.sql +++ b/src/test/regress/sql/misc_functions.sql @@ -69,6 +69,11 @@ select count(*) > 0 from where spcname = 'pg_default') pts join pg_database db on pts.pts = db.oid; +-- +-- Test NULL handling of pg_stat_get_replication_slot +-- +SELECT pg_stat_get_replication_slot(NULL); + -- -- Test adding a support function to a subject function -- -- 2.32.0