mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix NULL input behaviour of pg_stat_get_replication_slot().
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
This commit is contained in:
@ -2315,7 +2315,7 @@ Datum
|
|||||||
pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
|
pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
#define PG_STAT_GET_REPLICATION_SLOT_COLS 10
|
#define PG_STAT_GET_REPLICATION_SLOT_COLS 10
|
||||||
text *slotname_text = PG_GETARG_TEXT_P(0);
|
text *slotname_text;
|
||||||
NameData slotname;
|
NameData slotname;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
Datum values[PG_STAT_GET_REPLICATION_SLOT_COLS];
|
Datum values[PG_STAT_GET_REPLICATION_SLOT_COLS];
|
||||||
@ -2323,6 +2323,15 @@ pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
|
|||||||
PgStat_StatReplSlotEntry *slotent;
|
PgStat_StatReplSlotEntry *slotent;
|
||||||
PgStat_StatReplSlotEntry allzero;
|
PgStat_StatReplSlotEntry allzero;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function was accidentally marked as non-strict, can't change that post
|
||||||
|
* release.
|
||||||
|
*/
|
||||||
|
if (PG_ARGISNULL(0))
|
||||||
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
|
slotname_text = PG_GETARG_TEXT_P(0);
|
||||||
|
|
||||||
/* Initialise values and NULL flags arrays */
|
/* Initialise values and NULL flags arrays */
|
||||||
MemSet(values, 0, sizeof(values));
|
MemSet(values, 0, sizeof(values));
|
||||||
MemSet(nulls, 0, sizeof(nulls));
|
MemSet(nulls, 0, sizeof(nulls));
|
||||||
|
@ -201,4 +201,11 @@ FROM prevstats AS pr;
|
|||||||
|
|
||||||
DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
|
DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
|
||||||
DROP TABLE prevstats;
|
DROP TABLE prevstats;
|
||||||
|
-- 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
|
-- End of Stats Test
|
||||||
|
@ -176,4 +176,10 @@ FROM prevstats AS pr;
|
|||||||
|
|
||||||
DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
|
DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
|
||||||
DROP TABLE prevstats;
|
DROP TABLE prevstats;
|
||||||
|
|
||||||
|
|
||||||
|
-- ensure that stats accessors handle NULL input correctly
|
||||||
|
SELECT pg_stat_get_replication_slot(NULL);
|
||||||
|
|
||||||
|
|
||||||
-- End of Stats Test
|
-- End of Stats Test
|
||||||
|
Reference in New Issue
Block a user