64
64
#include "storage/pg_shmem.h"
65
65
#include "storage/proc.h"
66
66
#include "storage/procsignal.h"
67
+ #include "utils/builtins.h"
67
68
#include "utils/guc.h"
68
69
#include "utils/memutils.h"
69
70
#include "utils/ps_status.h"
@@ -1539,7 +1540,7 @@ pgstat_reset_replslot_counter(const char *name)
1539
1540
if (SlotIsPhysical (slot ))
1540
1541
return ;
1541
1542
1542
- strlcpy ( msg .m_slotname , name , NAMEDATALEN );
1543
+ namestrcpy ( & msg .m_slotname , name );
1543
1544
msg .clearall = false;
1544
1545
}
1545
1546
else
@@ -1812,25 +1813,22 @@ pgstat_report_tempfile(size_t filesize)
1812
1813
* ----------
1813
1814
*/
1814
1815
void
1815
- pgstat_report_replslot (const char * slotname , PgStat_Counter spilltxns ,
1816
- PgStat_Counter spillcount , PgStat_Counter spillbytes ,
1817
- PgStat_Counter streamtxns , PgStat_Counter streamcount ,
1818
- PgStat_Counter streambytes )
1816
+ pgstat_report_replslot (const PgStat_ReplSlotStats * repSlotStat )
1819
1817
{
1820
1818
PgStat_MsgReplSlot msg ;
1821
1819
1822
1820
/*
1823
1821
* Prepare and send the message
1824
1822
*/
1825
1823
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_REPLSLOT );
1826
- strlcpy ( msg .m_slotname , slotname , NAMEDATALEN );
1824
+ namestrcpy ( & msg .m_slotname , NameStr ( repSlotStat -> slotname ) );
1827
1825
msg .m_drop = false;
1828
- msg .m_spill_txns = spilltxns ;
1829
- msg .m_spill_count = spillcount ;
1830
- msg .m_spill_bytes = spillbytes ;
1831
- msg .m_stream_txns = streamtxns ;
1832
- msg .m_stream_count = streamcount ;
1833
- msg .m_stream_bytes = streambytes ;
1826
+ msg .m_spill_txns = repSlotStat -> spill_txns ;
1827
+ msg .m_spill_count = repSlotStat -> spill_count ;
1828
+ msg .m_spill_bytes = repSlotStat -> spill_bytes ;
1829
+ msg .m_stream_txns = repSlotStat -> stream_txns ;
1830
+ msg .m_stream_count = repSlotStat -> stream_count ;
1831
+ msg .m_stream_bytes = repSlotStat -> stream_bytes ;
1834
1832
pgstat_send (& msg , sizeof (PgStat_MsgReplSlot ));
1835
1833
}
1836
1834
@@ -1846,7 +1844,7 @@ pgstat_report_replslot_drop(const char *slotname)
1846
1844
PgStat_MsgReplSlot msg ;
1847
1845
1848
1846
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_REPLSLOT );
1849
- strlcpy ( msg .m_slotname , slotname , NAMEDATALEN );
1847
+ namestrcpy ( & msg .m_slotname , slotname );
1850
1848
msg .m_drop = true;
1851
1849
pgstat_send (& msg , sizeof (PgStat_MsgReplSlot ));
1852
1850
}
@@ -5202,7 +5200,7 @@ pgstat_recv_resetreplslotcounter(PgStat_MsgResetreplslotcounter *msg,
5202
5200
else
5203
5201
{
5204
5202
/* Get the index of replication slot statistics to reset */
5205
- idx = pgstat_replslot_index (msg -> m_slotname , false);
5203
+ idx = pgstat_replslot_index (NameStr ( msg -> m_slotname ) , false);
5206
5204
5207
5205
/*
5208
5206
* Nothing to do if the given slot entry is not found. This could
@@ -5538,7 +5536,7 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len)
5538
5536
* Get the index of replication slot statistics. On dropping, we don't
5539
5537
* create the new statistics.
5540
5538
*/
5541
- idx = pgstat_replslot_index (msg -> m_slotname , !msg -> m_drop );
5539
+ idx = pgstat_replslot_index (NameStr ( msg -> m_slotname ) , !msg -> m_drop );
5542
5540
5543
5541
/*
5544
5542
* The slot entry is not found or there is no space to accommodate the new
@@ -5763,7 +5761,7 @@ pgstat_replslot_index(const char *name, bool create_it)
5763
5761
Assert (nReplSlotStats <= max_replication_slots );
5764
5762
for (i = 0 ; i < nReplSlotStats ; i ++ )
5765
5763
{
5766
- if (strcmp ( replSlotStats [i ].slotname , name ) == 0 )
5764
+ if (namestrcmp ( & replSlotStats [i ].slotname , name ) == 0 )
5767
5765
return i ; /* found */
5768
5766
}
5769
5767
@@ -5776,7 +5774,7 @@ pgstat_replslot_index(const char *name, bool create_it)
5776
5774
5777
5775
/* Register new slot */
5778
5776
memset (& replSlotStats [nReplSlotStats ], 0 , sizeof (PgStat_ReplSlotStats ));
5779
- strlcpy ( replSlotStats [nReplSlotStats ].slotname , name , NAMEDATALEN );
5777
+ namestrcpy ( & replSlotStats [nReplSlotStats ].slotname , name );
5780
5778
5781
5779
return nReplSlotStats ++ ;
5782
5780
}
0 commit comments