Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1a0d7d

Browse files
committed
Fix NULL input behaviour of pg_stat_get_replication_slot().
pg_stat_get_replication_slot() accidentally was marked as non-strict, crashingwhen called with NULL input. As it's already released, introduce an explicitNULL check in 14, fix the catalog in HEAD.Bumps catversion in HEAD.Discussion:https://postgr.es/m/20220326212432.s5n2maw6kugnpyxw@alap3.anarazel.deBackpatch: 14-, where replication slot stats were introduced
1 parent6839aa7 commitc1a0d7d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2315,14 +2315,23 @@ Datum
23152315
pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
23162316
{
23172317
#definePG_STAT_GET_REPLICATION_SLOT_COLS 10
2318-
text*slotname_text=PG_GETARG_TEXT_P(0);
2318+
text*slotname_text;
23192319
NameDataslotname;
23202320
TupleDesctupdesc;
23212321
Datumvalues[PG_STAT_GET_REPLICATION_SLOT_COLS];
23222322
boolnulls[PG_STAT_GET_REPLICATION_SLOT_COLS];
23232323
PgStat_StatReplSlotEntry*slotent;
23242324
PgStat_StatReplSlotEntryallzero;
23252325

2326+
/*
2327+
* Function was accidentally marked as non-strict, can't change that post
2328+
* release.
2329+
*/
2330+
if (PG_ARGISNULL(0))
2331+
PG_RETURN_NULL();
2332+
2333+
slotname_text=PG_GETARG_TEXT_P(0);
2334+
23262335
/* Initialise values and NULL flags arrays */
23272336
MemSet(values,0,sizeof(values));
23282337
MemSet(nulls,0,sizeof(nulls));

‎src/test/regress/expected/stats.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,11 @@ FROM prevstats AS pr;
201201

202202
DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
203203
DROP TABLE prevstats;
204+
-- ensure that stats accessors handle NULL input correctly
205+
SELECT pg_stat_get_replication_slot(NULL);
206+
pg_stat_get_replication_slot
207+
------------------------------
208+
209+
(1 row)
210+
204211
-- End of Stats Test

‎src/test/regress/sql/stats.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,10 @@ FROM prevstats AS pr;
176176

177177
DROPTABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4;
178178
DROPTABLE prevstats;
179+
180+
181+
-- ensure that stats accessors handle NULL input correctly
182+
SELECT pg_stat_get_replication_slot(NULL);
183+
184+
179185
-- End of Stats Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp