Changed CreateReplicationSlot to return the consistent_point and snapshot_name.
This commit is contained in:
+8
-2
@@ -435,8 +435,14 @@ func (rc *ReplicationConn) StartReplication(slotName string, startLsn uint64, ti
|
||||
}
|
||||
|
||||
// Create the replication slot, using the given name and output plugin.
|
||||
func (rc *ReplicationConn) CreateReplicationSlot(slotName, outputPlugin string) (err error) {
|
||||
_, err = rc.c.Exec(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s", slotName, outputPlugin))
|
||||
func (rc *ReplicationConn) CreateReplicationSlot(slotName, outputPlugin string) (consistentPoint string, snapshotName string, err error) {
|
||||
var dummy string
|
||||
var rows *Rows
|
||||
rows, err = rc.sendReplicationModeQuery(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s", slotName, outputPlugin))
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rows.Scan(&dummy, &consistentPoint, &snapshotName, &dummy)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ func TestSimpleReplicationConnection(t *testing.T) {
|
||||
replicationConn := mustReplicationConnect(t, *replicationConnConfig)
|
||||
defer closeReplicationConn(t, replicationConn)
|
||||
|
||||
err = replicationConn.CreateReplicationSlot("pgx_test", "test_decoding")
|
||||
_, _, err = replicationConn.CreateReplicationSlot("pgx_test", "test_decoding")
|
||||
if err != nil {
|
||||
t.Fatalf("replication slot create failed: %v", err)
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func TestReplicationConn_DropReplicationSlot(t *testing.T) {
|
||||
replicationConn := mustReplicationConnect(t, *replicationConnConfig)
|
||||
defer closeReplicationConn(t, replicationConn)
|
||||
|
||||
err := replicationConn.CreateReplicationSlot("pgx_slot_test", "test_decoding")
|
||||
_, _, err := replicationConn.CreateReplicationSlot("pgx_slot_test", "test_decoding")
|
||||
if err != nil {
|
||||
t.Logf("replication slot create failed: %v", err)
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func TestReplicationConn_DropReplicationSlot(t *testing.T) {
|
||||
}
|
||||
|
||||
// We re-create to ensure the drop worked.
|
||||
err = replicationConn.CreateReplicationSlot("pgx_slot_test", "test_decoding")
|
||||
_, _, err = replicationConn.CreateReplicationSlot("pgx_slot_test", "test_decoding")
|
||||
if err != nil {
|
||||
t.Logf("replication slot create failed: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user