6464#include "storage/pg_shmem.h"
6565#include "storage/proc.h"
6666#include "storage/procsignal.h"
67+ #include "utils/builtins.h"
6768#include "utils/guc.h"
6869#include "utils/memutils.h"
6970#include "utils/ps_status.h"
@@ -1539,7 +1540,7 @@ pgstat_reset_replslot_counter(const char *name)
15391540 if (SlotIsPhysical (slot ))
15401541 return ;
15411542
1542- strlcpy ( msg .m_slotname , name , NAMEDATALEN );
1543+ namestrcpy ( & msg .m_slotname , name );
15431544 msg .clearall = false;
15441545 }
15451546 else
@@ -1812,25 +1813,22 @@ pgstat_report_tempfile(size_t filesize)
18121813 * ----------
18131814 */
18141815void
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 )
18191817{
18201818 PgStat_MsgReplSlot msg ;
18211819
18221820 /*
18231821 * Prepare and send the message
18241822 */
18251823 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_REPLSLOT );
1826- strlcpy ( msg .m_slotname , slotname , NAMEDATALEN );
1824+ namestrcpy ( & msg .m_slotname , NameStr ( repSlotStat -> slotname ) );
18271825 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 ;
18341832 pgstat_send (& msg , sizeof (PgStat_MsgReplSlot ));
18351833}
18361834
@@ -1846,7 +1844,7 @@ pgstat_report_replslot_drop(const char *slotname)
18461844 PgStat_MsgReplSlot msg ;
18471845
18481846 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_REPLSLOT );
1849- strlcpy ( msg .m_slotname , slotname , NAMEDATALEN );
1847+ namestrcpy ( & msg .m_slotname , slotname );
18501848 msg .m_drop = true;
18511849 pgstat_send (& msg , sizeof (PgStat_MsgReplSlot ));
18521850}
@@ -5202,7 +5200,7 @@ pgstat_recv_resetreplslotcounter(PgStat_MsgResetreplslotcounter *msg,
52025200 else
52035201 {
52045202 /* 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);
52065204
52075205 /*
52085206 * 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)
55385536 * Get the index of replication slot statistics. On dropping, we don't
55395537 * create the new statistics.
55405538 */
5541- idx = pgstat_replslot_index (msg -> m_slotname , !msg -> m_drop );
5539+ idx = pgstat_replslot_index (NameStr ( msg -> m_slotname ) , !msg -> m_drop );
55425540
55435541 /*
55445542 * 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)
57635761 Assert (nReplSlotStats <= max_replication_slots );
57645762 for (i = 0 ; i < nReplSlotStats ; i ++ )
57655763 {
5766- if (strcmp ( replSlotStats [i ].slotname , name ) == 0 )
5764+ if (namestrcmp ( & replSlotStats [i ].slotname , name ) == 0 )
57675765 return i ; /* found */
57685766 }
57695767
@@ -5776,7 +5774,7 @@ pgstat_replslot_index(const char *name, bool create_it)
57765774
57775775 /* Register new slot */
57785776 memset (& replSlotStats [nReplSlotStats ], 0 , sizeof (PgStat_ReplSlotStats ));
5779- strlcpy ( replSlotStats [nReplSlotStats ].slotname , name , NAMEDATALEN );
5777+ namestrcpy ( & replSlotStats [nReplSlotStats ].slotname , name );
57805778
57815779 return nReplSlotStats ++ ;
57825780}
0 commit comments