repl_show_cmd_with_docs.patch
application/octet-stream
Filename: repl_show_cmd_with_docs.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/protocol.sgml | 22 | 0 |
| src/backend/replication/repl_gram.y | 15 | 1 |
| src/backend/replication/repl_scanner.l | 1 | 0 |
| src/backend/replication/walsender.c | 44 | 0 |
| src/include/nodes/nodes.h | 1 | 0 |
| src/include/nodes/replnodes.h | 10 | 0 |
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 9ba147c..111f3b8 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1392,6 +1392,28 @@ The commands accepted in walsender mode are:
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>SHOW</literal> <replaceable class="parameter">name</replaceable>
+ <indexterm><primary>SHOW</primary></indexterm>
+ </term>
+ <listitem>
+ <para>
+ Requests the server to send the current setting of a run-time parameter. If the passed argument is a valid configuration name, server will return its value. This is similar to the SQL command <xref linkend="sql-show">.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</></term>
+ <listitem>
+ <para>
+ The name of a run-time parameter. Available parameters are documented
+ in <xref linkend="runtime-config">.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><literal>TIMELINE_HISTORY</literal> <replaceable class="parameter">tli</replaceable>
diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y
index d962c76..2348195 100644
--- a/src/backend/replication/repl_gram.y
+++ b/src/backend/replication/repl_gram.y
@@ -61,6 +61,7 @@ Node *replication_parse_result;
/* Keyword tokens. */
%token K_BASE_BACKUP
%token K_IDENTIFY_SYSTEM
+%token K_SHOW
%token K_START_REPLICATION
%token K_CREATE_REPLICATION_SLOT
%token K_DROP_REPLICATION_SLOT
@@ -82,7 +83,7 @@ Node *replication_parse_result;
%type <node> command
%type <node> base_backup start_replication start_logical_replication
create_replication_slot drop_replication_slot identify_system
- timeline_history
+ timeline_history show
%type <list> base_backup_opt_list
%type <defelt> base_backup_opt
%type <uintval> opt_timeline
@@ -112,6 +113,7 @@ command:
| create_replication_slot
| drop_replication_slot
| timeline_history
+ | show
;
/*
@@ -125,6 +127,18 @@ identify_system:
;
/*
+ * SHOW setting
+ */
+show:
+ K_SHOW IDENT
+ {
+ ShowCmd *cmd = makeNode(ShowCmd);
+ cmd->arg = $2;
+ $$ = (Node *) cmd;
+ }
+ ;
+
+/*
* BASE_BACKUP [LABEL '<label>'] [PROGRESS] [FAST] [WAL] [NOWAIT]
* [MAX_RATE %d] [TABLESPACE_MAP]
*/
diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l
index a3b5f92..37f8579 100644
--- a/src/backend/replication/repl_scanner.l
+++ b/src/backend/replication/repl_scanner.l
@@ -83,6 +83,7 @@ identifier {ident_start}{ident_cont}*
BASE_BACKUP { return K_BASE_BACKUP; }
FAST { return K_FAST; }
IDENTIFY_SYSTEM { return K_IDENTIFY_SYSTEM; }
+SHOW { return K_SHOW; }
LABEL { return K_LABEL; }
NOWAIT { return K_NOWAIT; }
PROGRESS { return K_PROGRESS; }
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index f3082c3..1d60d68 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -294,6 +294,46 @@ WalSndShutdown(void)
}
/*
+ * Handle SHOW command
+ */
+static void
+GetConfig(ShowCmd *cmd)
+{
+ StringInfoData buf;
+ const char *varname;
+ char *value;
+ Size len;
+
+ /* Get the value and canonical spelling of arg */
+ value = GetConfigOptionByName(cmd->arg, &varname, false);
+
+ /* Send a RowDescription message */
+ pq_beginmessage(&buf, 'T');
+ pq_sendint(&buf, 1, 2); /* 1 field */
+
+ /* first field */
+ pq_sendstring(&buf, varname); /* col name */
+ pq_sendint(&buf, 0, 4); /* table oid */
+ pq_sendint(&buf, 0, 2); /* attnum */
+ pq_sendint(&buf, TEXTOID, 4); /* type oid */
+ pq_sendint(&buf, -1, 2); /* typlen */
+ pq_sendint(&buf, 0, 4); /* typmod */
+ pq_sendint(&buf, 0, 2); /* format code */
+ pq_endmessage(&buf);
+
+ /* Send a DataRow message */
+ pq_beginmessage(&buf, 'D');
+ pq_sendint(&buf, 1, 2); /* # of columns */
+
+ /* column 1: Wal segment size */
+ len = strlen(value);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, value, len);
+
+ pq_endmessage(&buf);
+}
+
+/*
* Handle the IDENTIFY_SYSTEM command.
*/
static void
@@ -1338,6 +1378,10 @@ exec_replication_command(const char *cmd_string)
IdentifySystem();
break;
+ case T_ShowCmd:
+ GetConfig((ShowCmd *) cmd_node);
+ break;
+
case T_BaseBackupCmd:
SendBaseBackup((BaseBackupCmd *) cmd_node);
break;
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index a1bb0ac..9709cff 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -464,6 +464,7 @@ typedef enum NodeTag
* TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
*/
T_IdentifySystemCmd,
+ T_ShowCmd,
T_BaseBackupCmd,
T_CreateReplicationSlotCmd,
T_DropReplicationSlotCmd,
diff --git a/src/include/nodes/replnodes.h b/src/include/nodes/replnodes.h
index f27354f..0e5646a 100644
--- a/src/include/nodes/replnodes.h
+++ b/src/include/nodes/replnodes.h
@@ -33,6 +33,16 @@ typedef struct IdentifySystemCmd
NodeTag type;
} IdentifySystemCmd;
+/* ---------------------------
+ * SHOW command
+ * ---------------------------
+ */
+typedef struct ShowCmd
+{
+ NodeTag type;
+ char *arg;
+} ShowCmd;
+
/* ----------------------
* BASE_BACKUP command