Corrections to replication slots code and documentation.
authorRobert Haas
Mon, 3 Mar 2014 12:16:54 +0000 (07:16 -0500)
committerRobert Haas
Mon, 3 Mar 2014 12:16:54 +0000 (07:16 -0500)
Andres Freund, per a report from Vik Faering

doc/src/sgml/func.sgml
doc/src/sgml/high-availability.sgml
src/backend/replication/slotfuncs.c
src/include/catalog/pg_proc.h

index ff503281140b87669d959fa4eddd40920b5fbe86..d344b3a894a7e72cd94ebf3b5cd8b6b51685ff8f 100644 (file)
@@ -16317,10 +16317,10 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
         
          pg_create_physical_replication_slot
         
-        pg_create_physical_replication_slot(slotname textplugin text)
+        pg_create_physical_replication_slot(slotname name)
        
        
-        (slotname textxlog_position pg_lsn)
+        (slotname namexlog_position pg_lsn)
        
        
         Creates a new physical replication slot named
@@ -16335,10 +16335,10 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
         
          pg_drop_replication_slot
         
-        pg_drop_replication_slot(slotname text)
+        pg_drop_replication_slot(slotname name)
        
        
-        (slotname text)
+        void
        
        
         Drops the physical or logical replication slot
index da174558d45de8eb5555e307bbc5de502f69ff8e..ecb51c4b1a224a141bec49f045e7e0bded11f204 100644 (file)
@@ -935,7 +935,7 @@ postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
 postgres=# SELECT * FROM pg_replication_slots;
   slot_name  | slot_type | datoid | database | active | xmin | restart_lsn
 -------------+-----------+--------+----------+--------+------+-------------
- node_a_slot | physical  |      0 |          | f      |      |
+ node_a_slot | physical  |        |          | f      |      |
 (1 row)
 
      To configure the standby to use this slot, primary_slotname
index 761c0f536fbacc55e4d73e81285e4b2460b22163..5acd2bae19c28881b0b5bd5478eee0de5305e18c 100644 (file)
@@ -56,7 +56,7 @@ pg_create_physical_replication_slot(PG_FUNCTION_ARGS)
    /* acquire replication slot, this will check for conflicting names*/
    ReplicationSlotCreate(NameStr(*name), false);
 
-   values[0] = CStringGetTextDatum(NameStr(MyReplicationSlot->data.name));
+   values[0] = NameGetDatum(&MyReplicationSlot->data.name);
 
    nulls[0] = false;
    nulls[1] = true;
@@ -141,7 +141,8 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
        XLogRecPtr  restart_lsn;
        bool        active;
        Oid         database;
-       const char *slot_name;
+       NameData    slot_name;
+
        int         i;
 
        SpinLockAcquire(&slot->mutex);
@@ -155,7 +156,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
            xmin = slot->data.xmin;
            database = slot->data.database;
            restart_lsn = slot->data.restart_lsn;
-           slot_name = pstrdup(NameStr(slot->data.name));
+           namecpy(&slot_name, &slot->data.name);
 
            active = slot->active;
        }
@@ -164,12 +165,15 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
        memset(nulls, 0, sizeof(nulls));
 
        i = 0;
-       values[i++] = CStringGetTextDatum(slot_name);
+       values[i++] = NameGetDatum(&slot_name);
        if (database == InvalidOid)
            values[i++] = CStringGetTextDatum("physical");
        else
            values[i++] = CStringGetTextDatum("logical");
-       values[i++] = database;
+       if (database == InvalidOid)
+           nulls[i++] = true;
+       else
+           values[i++] = database;
        values[i++] = BoolGetDatum(active);
        if (xmin != InvalidTransactionId)
            values[i++] = TransactionIdGetDatum(xmin);
index e33670ce8e0aae41220bd152a6c96ae76b37a7b8..7a11721ba444467ee8f623efd04d4fab53bd678b 100644 (file)
@@ -4800,11 +4800,11 @@ DATA(insert OID = 3473 (  spg_range_quad_leaf_consistent    PGNSP PGUID 12 1 0 0 0
 DESCR("SP-GiST support for quad tree over range");
 
 /* replication slots */
-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_ ));
+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_ ));
 DESCR("create a physical replication slot");
 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_ ));
 DESCR("drop a replication slot");
-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_ ));
+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_ ));
 DESCR("information about replication slots currently in use");
 
 /* event triggers */