Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d83ee62

Browse files
committed
Corrections to replication slots code and documentation.
Andres Freund, per a report from Vik Faering
1 parent 45ffeb7 commit d83ee62

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

doc/src/sgml/func.sgml

+4-4
Original file line numberDiff line numberDiff line change
@@ -16317,10 +16317,10 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1631716317
<indexterm>
1631816318
<primary>pg_create_physical_replication_slot</primary>
1631916319
</indexterm>
16320-
<literal><function>pg_create_physical_replication_slot(<parameter>slotname</parameter> <type>text</type>, <parameter>plugin</parameter> <type>text</type>)</function></literal>
16320+
<literal><function>pg_create_physical_replication_slot(<parameter>slotname</parameter> <type>name</type>)</function></literal>
1632116321
</entry>
1632216322
<entry>
16323-
(<parameter>slotname</parameter> <type>text</type>, <parameter>xlog_position</parameter> <type>pg_lsn</type>)
16323+
(<parameter>slotname</parameter> <type>name</type>, <parameter>xlog_position</parameter> <type>pg_lsn</type>)
1632416324
</entry>
1632516325
<entry>
1632616326
Creates a new physical replication slot named
@@ -16335,10 +16335,10 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1633516335
<indexterm>
1633616336
<primary>pg_drop_replication_slot</primary>
1633716337
</indexterm>
16338-
<literal><function>pg_drop_replication_slot(<parameter>slotname</parameter> <type>text</type>)</function></literal>
16338+
<literal><function>pg_drop_replication_slot(<parameter>slotname</parameter> <type>name</type>)</function></literal>
1633916339
</entry>
1634016340
<entry>
16341-
(<parameter>slotname</parameter> <type>text</type>)
16341+
<type>void</type>
1634216342
</entry>
1634316343
<entry>
1634416344
Drops the physical or logical replication slot

doc/src/sgml/high-availability.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
935935
postgres=# SELECT * FROM pg_replication_slots;
936936
slot_name | slot_type | datoid | database | active | xmin | restart_lsn
937937
-------------+-----------+--------+----------+--------+------+-------------
938-
node_a_slot | physical | 0 | | f | |
938+
node_a_slot | physical | | | f | |
939939
(1 row)
940940
</programlisting>
941941
To configure the standby to use this slot, <varname>primary_slotname</>

src/backend/replication/slotfuncs.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pg_create_physical_replication_slot(PG_FUNCTION_ARGS)
5656
/* acquire replication slot, this will check for conflicting names*/
5757
ReplicationSlotCreate(NameStr(*name), false);
5858

59-
values[0] = CStringGetTextDatum(NameStr(MyReplicationSlot->data.name));
59+
values[0] = NameGetDatum(&MyReplicationSlot->data.name);
6060

6161
nulls[0] = false;
6262
nulls[1] = true;
@@ -141,7 +141,8 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
141141
XLogRecPtr restart_lsn;
142142
bool active;
143143
Oid database;
144-
const char *slot_name;
144+
NameData slot_name;
145+
145146
int i;
146147

147148
SpinLockAcquire(&slot->mutex);
@@ -155,7 +156,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
155156
xmin = slot->data.xmin;
156157
database = slot->data.database;
157158
restart_lsn = slot->data.restart_lsn;
158-
slot_name = pstrdup(NameStr(slot->data.name));
159+
namecpy(&slot_name, &slot->data.name);
159160

160161
active = slot->active;
161162
}
@@ -164,12 +165,15 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
164165
memset(nulls, 0, sizeof(nulls));
165166

166167
i = 0;
167-
values[i++] = CStringGetTextDatum(slot_name);
168+
values[i++] = NameGetDatum(&slot_name);
168169
if (database == InvalidOid)
169170
values[i++] = CStringGetTextDatum("physical");
170171
else
171172
values[i++] = CStringGetTextDatum("logical");
172-
values[i++] = database;
173+
if (database == InvalidOid)
174+
nulls[i++] = true;
175+
else
176+
values[i++] = database;
173177
values[i++] = BoolGetDatum(active);
174178
if (xmin != InvalidTransactionId)
175179
values[i++] = TransactionIdGetDatum(xmin);

src/include/catalog/pg_proc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4800,11 +4800,11 @@ DATA(insert OID = 3473 ( spg_range_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0
48004800
DESCR("SP-GiST support for quad tree over range");
48014801

48024802
/* replication slots */
4803-
DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2249 "19" "{19,25,3220}" "{i,o,o}" "{slotname,slotname,xlog_position}" _null_ pg_create_physical_replication_slot _null_ _null_ _null_ ));
4803+
DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2249 "19" "{19,19,3220}" "{i,o,o}" "{slotname,slotname,xlog_position}" _null_ pg_create_physical_replication_slot _null_ _null_ _null_ ));
48044804
DESCR("create a physical replication slot");
48054805
DATA(insert OID = 3780 ( pg_drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2278 "19" _null_ _null_ _null_ _null_ pg_drop_replication_slot _null_ _null_ _null_ ));
48064806
DESCR("drop a replication slot");
4807-
DATA(insert OID = 3781 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{25,25,26,16,28,3220}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ ));
4807+
DATA(insert OID = 3781 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{19,25,26,16,28,3220}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ ));
48084808
DESCR("information about replication slots currently in use");
48094809

48104810
/* event triggers */

0 commit comments

Comments
 (0)