}
else
{
- pq_sendint(&buf, strlen(ti->oid), 4); /* length */
- pq_sendbytes(&buf, ti->oid, strlen(ti->oid));
- pq_sendint(&buf, strlen(ti->path), 4); /* length */
- pq_sendbytes(&buf, ti->path, strlen(ti->path));
+ Size len;
+
+ len = strlen(ti->oid);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, ti->oid, len);
+
+ len = strlen(ti->path);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, ti->path, len);
}
if (ti->size >= 0)
send_int8_string(&buf, ti->size / 1024);
{
StringInfoData buf;
char str[MAXFNAMELEN];
+ Size len;
pq_beginmessage(&buf, 'T'); /* RowDescription */
pq_sendint(&buf, 2, 2); /* 2 fields */
pq_sendint(&buf, 0, 2); /* attnum */
/*
- * int8 may seem like a surprising data type for this, but in thory int4
+ * int8 may seem like a surprising data type for this, but in theory int4
* would not be wide enough for this, as TimeLineID is unsigned.
*/
pq_sendint(&buf, INT8OID, 4); /* type oid */
pq_beginmessage(&buf, 'D');
pq_sendint(&buf, 2, 2); /* number of columns */
- snprintf(str, sizeof(str), "%X/%X", (uint32) (ptr >> 32), (uint32) ptr);
- pq_sendint(&buf, strlen(str), 4); /* length */
- pq_sendbytes(&buf, str, strlen(str));
+ len = snprintf(str, sizeof(str),
+ "%X/%X", (uint32) (ptr >> 32), (uint32) ptr);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, str, len);
+
+ len = snprintf(str, sizeof(str), "%u", tli);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, str, len);
- snprintf(str, sizeof(str), "%u", tli);
- pq_sendint(&buf, strlen(str), 4); /* length */
- pq_sendbytes(&buf, str, strlen(str));
pq_endmessage(&buf);
/* Send a CommandComplete message */
char xpos[MAXFNAMELEN];
XLogRecPtr logptr;
char *dbname = NULL;
+ Size len;
/*
* Reply with a result set with one row, four columns. First col is system
/* Send a DataRow message */
pq_beginmessage(&buf, 'D');
pq_sendint(&buf, 4, 2); /* # of columns */
- pq_sendint(&buf, strlen(sysid), 4); /* col1 len */
- pq_sendbytes(&buf, (char *) &sysid, strlen(sysid));
- pq_sendint(&buf, strlen(tli), 4); /* col2 len */
- pq_sendbytes(&buf, (char *) tli, strlen(tli));
- pq_sendint(&buf, strlen(xpos), 4); /* col3 len */
- pq_sendbytes(&buf, (char *) xpos, strlen(xpos));
- /* send NULL if not connected to a database */
+
+ /* column 1: system identifier */
+ len = strlen(sysid);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) &sysid, len);
+
+ /* column 2: timeline */
+ len = strlen(tli);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) tli, len);
+
+ /* column 3: xlog position */
+ len = strlen(xpos);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) xpos, len);
+
+ /* column 4: database name, or NULL if none */
if (dbname)
{
- pq_sendint(&buf, strlen(dbname), 4); /* col4 len */
- pq_sendbytes(&buf, (char *) dbname, strlen(dbname));
+ len = strlen(dbname);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) dbname, len);
}
else
{
- pq_sendint(&buf, -1, 4); /* col4 len, NULL */
+ pq_sendint(&buf, -1, 4);
}
pq_endmessage(&buf);
int fd;
off_t histfilelen;
off_t bytesleft;
+ Size len;
/*
* Reply with a result set with one row, and two columns. The first col is
/* Send a DataRow message */
pq_beginmessage(&buf, 'D');
pq_sendint(&buf, 2, 2); /* # of columns */
- pq_sendint(&buf, strlen(histfname), 4); /* col1 len */
- pq_sendbytes(&buf, histfname, strlen(histfname));
+ len = strlen(histfname);
+ pq_sendint(&buf, len, 4); /* col1 len */
+ pq_sendbytes(&buf, histfname, len);
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0666);
if (fd < 0)
{
char tli_str[11];
char startpos_str[8 + 1 + 8 + 1];
+ Size len;
snprintf(tli_str, sizeof(tli_str), "%u", sendTimeLineNextTLI);
snprintf(startpos_str, sizeof(startpos_str), "%X/%X",
pq_beginmessage(&buf, 'D');
pq_sendint(&buf, 2, 2); /* number of columns */
- pq_sendint(&buf, strlen(tli_str), 4); /* length */
- pq_sendbytes(&buf, tli_str, strlen(tli_str));
+ len = strlen(tli_str);
+ pq_sendint(&buf, len, 4); /* length */
+ pq_sendbytes(&buf, tli_str, len);
- pq_sendint(&buf, strlen(startpos_str), 4); /* length */
- pq_sendbytes(&buf, startpos_str, strlen(startpos_str));
+ len = strlen(startpos_str);
+ pq_sendint(&buf, len, 4); /* length */
+ pq_sendbytes(&buf, startpos_str, len);
pq_endmessage(&buf);
}
static void
CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
{
- const char *slot_name;
const char *snapshot_name = NULL;
char xpos[MAXFNAMELEN];
StringInfoData buf;
+ Size len;
Assert(!MyReplicationSlot);
initStringInfo(&output_message);
- slot_name = NameStr(MyReplicationSlot->data.name);
-
if (cmd->kind == REPLICATION_KIND_LOGICAL)
{
LogicalDecodingContext *ctx;
- ctx = CreateInitDecodingContext(
- cmd->plugin, NIL,
+ ctx = CreateInitDecodingContext(cmd->plugin, NIL,
logical_read_xlog_page,
WalSndPrepareWrite, WalSndWriteData);
ReplicationSlotSave();
}
- slot_name = NameStr(MyReplicationSlot->data.name);
snprintf(xpos, sizeof(xpos), "%X/%X",
(uint32) (MyReplicationSlot->data.confirmed_flush >> 32),
(uint32) MyReplicationSlot->data.confirmed_flush);
pq_sendint(&buf, 4, 2); /* # of columns */
/* slot_name */
- pq_sendint(&buf, strlen(slot_name), 4); /* col1 len */
- pq_sendbytes(&buf, slot_name, strlen(slot_name));
+ len = strlen(NameStr(MyReplicationSlot->data.name));
+ pq_sendint(&buf, len, 4); /* col1 len */
+ pq_sendbytes(&buf, NameStr(MyReplicationSlot->data.name), len);
/* consistent wal location */
- pq_sendint(&buf, strlen(xpos), 4); /* col2 len */
- pq_sendbytes(&buf, xpos, strlen(xpos));
+ len = strlen(xpos);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, xpos, len);
- /* snapshot name */
+ /* snapshot name, or NULL if none */
if (snapshot_name != NULL)
{
- pq_sendint(&buf, strlen(snapshot_name), 4); /* col3 len */
- pq_sendbytes(&buf, snapshot_name, strlen(snapshot_name));
+ len = strlen(snapshot_name);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, snapshot_name, len);
}
else
- pq_sendint(&buf, -1, 4); /* col3 len, NULL */
+ pq_sendint(&buf, -1, 4);
- /* plugin */
+ /* plugin, or NULL if none */
if (cmd->plugin != NULL)
{
- pq_sendint(&buf, strlen(cmd->plugin), 4); /* col4 len */
- pq_sendbytes(&buf, cmd->plugin, strlen(cmd->plugin));
+ len = strlen(cmd->plugin);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, cmd->plugin, len);
}
else
- pq_sendint(&buf, -1, 4); /* col4 len, NULL */
+ pq_sendint(&buf, -1, 4);
pq_endmessage(&buf);