File tree Expand file tree Collapse file tree 5 files changed +32
-3
lines changed Expand file tree Collapse file tree 5 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -1434,7 +1434,7 @@ The commands accepted in walsender mode are:
14341434 </varlistentry>
14351435
14361436 <varlistentry>
1437- <term>CREATE_REPLICATION_SLOT <replaceable class="parameter">slot_name</> { <literal>PHYSICAL</> | <literal>LOGICAL</> <replaceable class="parameter">output_plugin</> }
1437+ <term>CREATE_REPLICATION_SLOT <replaceable class="parameter">slot_name</> { <literal>PHYSICAL</> [ RESERVE_WAL ] | <literal>LOGICAL</> <replaceable class="parameter">output_plugin</> }
14381438 <indexterm><primary>CREATE_REPLICATION_SLOT</primary></indexterm>
14391439 </term>
14401440 <listitem>
@@ -1463,6 +1463,17 @@ The commands accepted in walsender mode are:
14631463 </para>
14641464 </listitem>
14651465 </varlistentry>
1466+
1467+ <varlistentry>
1468+ <term><literal>RESERVE_WAL</></term>
1469+ <listitem>
1470+ <para>
1471+ Specify that this physical replication reserves <acronym>WAL</>
1472+ immediately; otherwise <acronym>WAL</> is only reserved upon
1473+ connection from a streaming replication client.
1474+ </para>
1475+ </listitem>
1476+ </varlistentry>
14661477 </variablelist>
14671478 </listitem>
14681479 </varlistentry>
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ Node *replication_parse_result;
7676%token K_PHYSICAL
7777%token K_LOGICAL
7878%token K_SLOT
79+ %token K_RESERVE_WAL
7980
8081%type <node> command
8182%type <node> base_backup start_replication start_logical_replication
@@ -88,6 +89,7 @@ Node *replication_parse_result;
8889%type <defelt> plugin_opt_elem
8990%type <node> plugin_opt_arg
9091%type <str> opt_slot
92+ %type <boolval> opt_reserve_wal
9193
9294%%
9395
@@ -181,13 +183,14 @@ base_backup_opt:
181183 ;
182184
183185create_replication_slot :
184- /* CREATE_REPLICATION_SLOT slot PHYSICAL */
185- K_CREATE_REPLICATION_SLOT IDENT K_PHYSICAL
186+ /* CREATE_REPLICATION_SLOT slot PHYSICAL RESERVE_WAL */
187+ K_CREATE_REPLICATION_SLOT IDENT K_PHYSICAL opt_reserve_wal
186188 {
187189 CreateReplicationSlotCmd *cmd;
188190 cmd = makeNode(CreateReplicationSlotCmd);
189191 cmd->kind = REPLICATION_KIND_PHYSICAL;
190192 cmd->slotname = $2 ;
193+ cmd->reserve_wal = $4 ;
191194 $$ = (Node *) cmd;
192195 }
193196 /* CREATE_REPLICATION_SLOT slot LOGICAL plugin */
@@ -268,6 +271,11 @@ opt_physical:
268271 | /* EMPTY */
269272 ;
270273
274+ opt_reserve_wal :
275+ K_RESERVE_WAL { $$ = true ; }
276+ | /* EMPTY */ { $$ = false ; }
277+ ;
278+
271279opt_slot :
272280 K_SLOT IDENT
273281 { $$ = $2 ; }
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ CREATE_REPLICATION_SLOT { return K_CREATE_REPLICATION_SLOT; }
9595DROP_REPLICATION_SLOT { return K_DROP_REPLICATION_SLOT; }
9696TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
9797PHYSICAL { return K_PHYSICAL; }
98+ RESERVE_WAL { return K_RESERVE_WAL; }
9899LOGICAL { return K_LOGICAL; }
99100SLOT { return K_SLOT; }
100101
Original file line number Diff line number Diff line change @@ -826,6 +826,14 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
826826
827827 ReplicationSlotPersist ();
828828 }
829+ else if (cmd -> kind == REPLICATION_KIND_PHYSICAL && cmd -> reserve_wal )
830+ {
831+ ReplicationSlotReserveWal ();
832+
833+ /* Write this slot to disk */
834+ ReplicationSlotMarkDirty ();
835+ ReplicationSlotSave ();
836+ }
829837
830838 slot_name = NameStr (MyReplicationSlot -> data .name );
831839 snprintf (xpos , sizeof (xpos ), "%X/%X" ,
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ typedef struct CreateReplicationSlotCmd
5555 char * slotname ;
5656 ReplicationKind kind ;
5757 char * plugin ;
58+ bool reserve_wal ;
5859} CreateReplicationSlotCmd ;
5960
6061
You can’t perform that action at this time.
0 commit comments