On Wed, 2020-12-02 at 15:16 -0500, Bruce Momjian wrote:
> Yes, we could, but I thought the format code was not something we set
> at
> this level. Looking at byteasend() it is true it just sends the
> bytes.
It can be set along with the type. Attached an example.
Andres objected (in a separate conversation) to forcing a binary-format
value on a client that didn't ask for one. He suggested that we mandate
that the data is ASCII-only (for both filename and content), closing
the gap Michael raised[1]; and then just declare all values to be text
format.
I am fine with either approach; but in any case, I don't see the point
in sending an incorrect RowDescription.
Regards,
Jeff Davis
[1] https://postgr.es/m/[email protected]
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 4899bacda7b..f383223f462 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1778,7 +1778,7 @@ The commands accepted in replication mode are:
<variablelist>
<varlistentry>
<term>
- <literal>systemid</literal> (<type>text</type>)
+ <literal>systemid</literal> (<type>text</type>, text format)
</term>
<listitem>
<para>
@@ -1791,7 +1791,7 @@ The commands accepted in replication mode are:
<varlistentry>
<term>
- <literal>timeline</literal> (<type>int4</type>)
+ <literal>timeline</literal> (<type>int4</type>, text format)
</term>
<listitem>
<para>
@@ -1803,7 +1803,7 @@ The commands accepted in replication mode are:
<varlistentry>
<term>
- <literal>xlogpos</literal> (<type>text</type>)
+ <literal>xlogpos</literal> (<type>text</type>, text format)
</term>
<listitem>
<para>
@@ -1815,7 +1815,7 @@ The commands accepted in replication mode are:
<varlistentry>
<term>
- <literal>dbname</literal> (<type>text</type>)
+ <literal>dbname</literal> (<type>text</type>, text format)
</term>
<listitem>
<para>
@@ -1861,27 +1861,26 @@ The commands accepted in replication mode are:
<para>
Requests the server to send over the timeline history file for timeline
<replaceable class="parameter">tli</replaceable>. Server replies with a
- result set of a single row, containing two fields. While the fields
- are labeled as <type>text</type>, they effectively return raw bytes,
- with no encoding conversion:
+ result set of a single row, containing two fields:
</para>
<para>
<variablelist>
<varlistentry>
<term>
- <literal>filename</literal> (<type>text</type>)
+ <literal>filename</literal> (<type>bytea</type>, binary format)
</term>
<listitem>
<para>
File name of the timeline history file, e.g., <filename>00000002.history</filename>.
+ No encoding conversion is performed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
- <literal>content</literal> (<type>text</type>)
+ <literal>content</literal> (<type>bytea</type>, binary format)
</term>
<listitem>
<para>
@@ -1975,7 +1974,7 @@ The commands accepted in replication mode are:
<variablelist>
<varlistentry>
- <term><literal>slot_name</literal> (<type>text</type>)</term>
+ <term><literal>slot_name</literal> (<type>text</type>, text format)</term>
<listitem>
<para>
The name of the newly-created replication slot.
@@ -1984,7 +1983,7 @@ The commands accepted in replication mode are:
</varlistentry>
<varlistentry>
- <term><literal>consistent_point</literal> (<type>text</type>)</term>
+ <term><literal>consistent_point</literal> (<type>text</type>, text format)</term>
<listitem>
<para>
The WAL location at which the slot became consistent. This is the
@@ -1995,7 +1994,7 @@ The commands accepted in replication mode are:
</varlistentry>
<varlistentry>
- <term><literal>snapshot_name</literal> (<type>text</type>)</term>
+ <term><literal>snapshot_name</literal> (<type>text</type>, text format)</term>
<listitem>
<para>
The identifier of the snapshot exported by the command. The
@@ -2007,7 +2006,7 @@ The commands accepted in replication mode are:
</varlistentry>
<varlistentry>
- <term><literal>output_plugin</literal> (<type>text</type>)</term>
+ <term><literal>output_plugin</literal> (<type>text</type>, text format)</term>
<listitem>
<para>
The name of the output plugin used by the newly-created replication
@@ -2636,7 +2635,7 @@ The commands accepted in replication mode are:
The fields in this row are:
<variablelist>
<varlistentry>
- <term><literal>spcoid</literal> (<type>oid</type>)</term>
+ <term><literal>spcoid</literal> (<type>oid</type>, text format)</term>
<listitem>
<para>
The OID of the tablespace, or null if it's the base
@@ -2645,7 +2644,7 @@ The commands accepted in replication mode are:
</listitem>
</varlistentry>
<varlistentry>
- <term><literal>spclocation</literal> (<type>text</type>)</term>
+ <term><literal>spclocation</literal> (<type>text</type>, text format)</term>
<listitem>
<para>
The full path of the tablespace directory, or null
@@ -2654,7 +2653,7 @@ The commands accepted in replication mode are:
</listitem>
</varlistentry>
<varlistentry>
- <term><literal>size</literal> (<type>int8</type>)</term>
+ <term><literal>size</literal> (<type>int8</type>, text format)</term>
<listitem>
<para>
The approximate size of the tablespace, in kilobytes (1024 bytes),
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2eb19ad2936..089b3692dec 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -487,19 +487,19 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
pq_sendstring(&buf, "filename"); /* col name */
pq_sendint32(&buf, 0); /* table oid */
pq_sendint16(&buf, 0); /* attnum */
- pq_sendint32(&buf, TEXTOID); /* type oid */
+ pq_sendint32(&buf, BYTEAOID); /* type oid */
pq_sendint16(&buf, -1); /* typlen */
pq_sendint32(&buf, 0); /* typmod */
- pq_sendint16(&buf, 0); /* format code */
+ pq_sendint16(&buf, 1); /* format code */
/* second field */
pq_sendstring(&buf, "content"); /* col name */
pq_sendint32(&buf, 0); /* table oid */
pq_sendint16(&buf, 0); /* attnum */
- pq_sendint32(&buf, TEXTOID); /* type oid */
+ pq_sendint32(&buf, BYTEAOID); /* type oid */
pq_sendint16(&buf, -1); /* typlen */
pq_sendint32(&buf, 0); /* typmod */
- pq_sendint16(&buf, 0); /* format code */
+ pq_sendint16(&buf, 1); /* format code */
pq_endmessage(&buf);
/* Send a DataRow message */