File tree 5 files changed +32
-3
lines changed
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:
1434
1434
</varlistentry>
1435
1435
1436
1436
<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</> }
1438
1438
<indexterm><primary>CREATE_REPLICATION_SLOT</primary></indexterm>
1439
1439
</term>
1440
1440
<listitem>
@@ -1463,6 +1463,17 @@ The commands accepted in walsender mode are:
1463
1463
</para>
1464
1464
</listitem>
1465
1465
</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>
1466
1477
</variablelist>
1467
1478
</listitem>
1468
1479
</varlistentry>
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ Node *replication_parse_result;
76
76
%token K_PHYSICAL
77
77
%token K_LOGICAL
78
78
%token K_SLOT
79
+ %token K_RESERVE_WAL
79
80
80
81
%type <node> command
81
82
%type <node> base_backup start_replication start_logical_replication
@@ -88,6 +89,7 @@ Node *replication_parse_result;
88
89
%type <defelt> plugin_opt_elem
89
90
%type <node> plugin_opt_arg
90
91
%type <str> opt_slot
92
+ %type <boolval> opt_reserve_wal
91
93
92
94
%%
93
95
@@ -181,13 +183,14 @@ base_backup_opt:
181
183
;
182
184
183
185
create_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
186
188
{
187
189
CreateReplicationSlotCmd *cmd;
188
190
cmd = makeNode(CreateReplicationSlotCmd);
189
191
cmd->kind = REPLICATION_KIND_PHYSICAL;
190
192
cmd->slotname = $2 ;
193
+ cmd->reserve_wal = $4 ;
191
194
$$ = (Node *) cmd;
192
195
}
193
196
/* CREATE_REPLICATION_SLOT slot LOGICAL plugin */
@@ -268,6 +271,11 @@ opt_physical:
268
271
| /* EMPTY */
269
272
;
270
273
274
+ opt_reserve_wal :
275
+ K_RESERVE_WAL { $$ = true ; }
276
+ | /* EMPTY */ { $$ = false ; }
277
+ ;
278
+
271
279
opt_slot :
272
280
K_SLOT IDENT
273
281
{ $$ = $2 ; }
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ CREATE_REPLICATION_SLOT { return K_CREATE_REPLICATION_SLOT; }
95
95
DROP_REPLICATION_SLOT { return K_DROP_REPLICATION_SLOT; }
96
96
TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
97
97
PHYSICAL { return K_PHYSICAL; }
98
+ RESERVE_WAL { return K_RESERVE_WAL; }
98
99
LOGICAL { return K_LOGICAL; }
99
100
SLOT { return K_SLOT; }
100
101
Original file line number Diff line number Diff line change @@ -826,6 +826,14 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
826
826
827
827
ReplicationSlotPersist ();
828
828
}
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
+ }
829
837
830
838
slot_name = NameStr (MyReplicationSlot -> data .name );
831
839
snprintf (xpos , sizeof (xpos ), "%X/%X" ,
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ typedef struct CreateReplicationSlotCmd
55
55
char * slotname ;
56
56
ReplicationKind kind ;
57
57
char * plugin ;
58
+ bool reserve_wal ;
58
59
} CreateReplicationSlotCmd ;
59
60
60
61
You can’t perform that action at this time.
0 commit comments