apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
XLogRecPtr lsn)
{
- StringInfoData s2;
int nchanges;
char path[MAXPGPATH];
char *buffer = NULL;
CurrentResourceOwner = oldowner;
buffer = palloc(BLCKSZ);
- initStringInfo(&s2);
MemoryContextSwitchTo(oldcxt);
nchanges = 0;
while (true)
{
+ StringInfoData s2;
size_t nbytes;
int len;
BufFileTell(stream_fd, &fileno, &offset);
- /* copy the buffer to the stringinfo and call apply_dispatch */
- resetStringInfo(&s2);
- appendBinaryStringInfo(&s2, buffer, len);
+ /* init a stringinfo using the buffer and call apply_dispatch */
+ initReadOnlyStringInfo(&s2, buffer, len);
/* Ensure we are reading the data into our memory context. */
oldcxt = MemoryContextSwitchTo(ApplyMessageContext);
static TimestampTz wakeup[NUM_WALRCV_WAKEUPS];
static StringInfoData reply_message;
-static StringInfoData incoming_message;
/* Prototypes for private functions */
static void WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last);
/* Initialize LogstreamResult and buffers for processing messages */
LogstreamResult.Write = LogstreamResult.Flush = GetXLogReplayRecPtr(NULL);
initStringInfo(&reply_message);
- initStringInfo(&incoming_message);
/* Initialize nap wakeup times. */
now = GetCurrentTimestamp();
TimestampTz sendTime;
bool replyRequested;
- resetStringInfo(&incoming_message);
-
switch (type)
{
case 'w': /* WAL records */
{
- /* copy message to StringInfo */
+ StringInfoData incoming_message;
+
hdrlen = sizeof(int64) + sizeof(int64) + sizeof(int64);
if (len < hdrlen)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg_internal("invalid WAL message received from primary")));
- appendBinaryStringInfo(&incoming_message, buf, hdrlen);
+
+ /* initialize a StringInfo with the given buffer */
+ initReadOnlyStringInfo(&incoming_message, buf, hdrlen);
/* read the fields */
dataStart = pq_getmsgint64(&incoming_message);
}
case 'k': /* Keepalive */
{
- /* copy message to StringInfo */
+ StringInfoData incoming_message;
+
hdrlen = sizeof(int64) + sizeof(int64) + sizeof(char);
if (len != hdrlen)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg_internal("invalid keepalive message received from primary")));
- appendBinaryStringInfo(&incoming_message, buf, hdrlen);
+
+ /* initialize a StringInfo with the given buffer */
+ initReadOnlyStringInfo(&incoming_message, buf, hdrlen);
/* read the fields */
walEnd = pq_getmsgint64(&incoming_message);