#include "storage/pg_shmem.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
+#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
if (SlotIsPhysical(slot))
return;
- strlcpy(msg.m_slotname, name, NAMEDATALEN);
+ namestrcpy(&msg.m_slotname, name);
msg.clearall = false;
}
else
* ----------
*/
void
-pgstat_report_replslot(const char *slotname, PgStat_Counter spilltxns,
- PgStat_Counter spillcount, PgStat_Counter spillbytes,
- PgStat_Counter streamtxns, PgStat_Counter streamcount,
- PgStat_Counter streambytes)
+pgstat_report_replslot(const PgStat_ReplSlotStats *repSlotStat)
{
PgStat_MsgReplSlot msg;
* Prepare and send the message
*/
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_REPLSLOT);
- strlcpy(msg.m_slotname, slotname, NAMEDATALEN);
+ namestrcpy(&msg.m_slotname, NameStr(repSlotStat->slotname));
msg.m_drop = false;
- msg.m_spill_txns = spilltxns;
- msg.m_spill_count = spillcount;
- msg.m_spill_bytes = spillbytes;
- msg.m_stream_txns = streamtxns;
- msg.m_stream_count = streamcount;
- msg.m_stream_bytes = streambytes;
+ msg.m_spill_txns = repSlotStat->spill_txns;
+ msg.m_spill_count = repSlotStat->spill_count;
+ msg.m_spill_bytes = repSlotStat->spill_bytes;
+ msg.m_stream_txns = repSlotStat->stream_txns;
+ msg.m_stream_count = repSlotStat->stream_count;
+ msg.m_stream_bytes = repSlotStat->stream_bytes;
pgstat_send(&msg, sizeof(PgStat_MsgReplSlot));
}
PgStat_MsgReplSlot msg;
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_REPLSLOT);
- strlcpy(msg.m_slotname, slotname, NAMEDATALEN);
+ namestrcpy(&msg.m_slotname, slotname);
msg.m_drop = true;
pgstat_send(&msg, sizeof(PgStat_MsgReplSlot));
}
else
{
/* Get the index of replication slot statistics to reset */
- idx = pgstat_replslot_index(msg->m_slotname, false);
+ idx = pgstat_replslot_index(NameStr(msg->m_slotname), false);
/*
* Nothing to do if the given slot entry is not found. This could
* Get the index of replication slot statistics. On dropping, we don't
* create the new statistics.
*/
- idx = pgstat_replslot_index(msg->m_slotname, !msg->m_drop);
+ idx = pgstat_replslot_index(NameStr(msg->m_slotname), !msg->m_drop);
/*
* The slot entry is not found or there is no space to accommodate the new
Assert(nReplSlotStats <= max_replication_slots);
for (i = 0; i < nReplSlotStats; i++)
{
- if (strcmp(replSlotStats[i].slotname, name) == 0)
+ if (namestrcmp(&replSlotStats[i].slotname, name) == 0)
return i; /* found */
}
/* Register new slot */
memset(&replSlotStats[nReplSlotStats], 0, sizeof(PgStat_ReplSlotStats));
- strlcpy(replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
+ namestrcpy(&replSlotStats[nReplSlotStats].slotname, name);
return nReplSlotStats++;
}
UpdateDecodingStats(LogicalDecodingContext *ctx)
{
ReorderBuffer *rb = ctx->reorder;
+ PgStat_ReplSlotStats repSlotStat;
/*
* Nothing to do if we haven't spilled or streamed anything since the last
(long long) rb->streamCount,
(long long) rb->streamBytes);
- pgstat_report_replslot(NameStr(ctx->slot->data.name),
- rb->spillTxns, rb->spillCount, rb->spillBytes,
- rb->streamTxns, rb->streamCount, rb->streamBytes);
+ namestrcpy(&repSlotStat.slotname, NameStr(ctx->slot->data.name));
+ repSlotStat.spill_txns = rb->spillTxns;
+ repSlotStat.spill_count = rb->spillCount;
+ repSlotStat.spill_bytes = rb->spillBytes;
+ repSlotStat.stream_txns = rb->streamTxns;
+ repSlotStat.stream_count = rb->streamCount;
+ repSlotStat.stream_bytes = rb->streamBytes;
+
+ pgstat_report_replslot(&repSlotStat);
rb->spillTxns = 0;
rb->spillCount = 0;
rb->spillBytes = 0;
typedef struct PgStat_MsgResetreplslotcounter
{
PgStat_MsgHdr m_hdr;
- char m_slotname[NAMEDATALEN];
+ NameData m_slotname;
bool clearall;
} PgStat_MsgResetreplslotcounter;
typedef struct PgStat_MsgReplSlot
{
PgStat_MsgHdr m_hdr;
- char m_slotname[NAMEDATALEN];
+ NameData m_slotname;
bool m_drop;
PgStat_Counter m_spill_txns;
PgStat_Counter m_spill_count;
*/
typedef struct PgStat_ReplSlotStats
{
- char slotname[NAMEDATALEN];
+ NameData slotname;
PgStat_Counter spill_txns;
PgStat_Counter spill_count;
PgStat_Counter spill_bytes;
extern void pgstat_report_deadlock(void);
extern void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount);
extern void pgstat_report_checksum_failure(void);
-extern void pgstat_report_replslot(const char *slotname, PgStat_Counter spilltxns,
- PgStat_Counter spillcount, PgStat_Counter spillbytes,
- PgStat_Counter streamtxns, PgStat_Counter streamcount,
- PgStat_Counter streambytes);
+extern void pgstat_report_replslot(const PgStat_ReplSlotStats *repSlotStat);
extern void pgstat_report_replslot_drop(const char *slotname);
extern void pgstat_initialize(void);