From af01afca001022722c6239be8b076c202422627a Mon Sep 17 00:00:00 2001 From: Kris Wehner Date: Mon, 9 Jan 2017 14:19:08 -0800 Subject: [PATCH] Add the drop replication slot functionality --- replication.go | 2 +- replication_test.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/replication.go b/replication.go index f73b8528..6d78a7a1 100644 --- a/replication.go +++ b/replication.go @@ -362,7 +362,7 @@ func (rc *ReplicationConn) CreateReplicationSlot(slotName, outputPlugin string) } // Drop the replication slot for the given name -func (rc *ReplicationConn) DropReplicationSlot(slotName, outputPlugin string) (err error) { +func (rc *ReplicationConn) DropReplicationSlot(slotName string) (err error) { _, err = rc.c.Exec(fmt.Sprintf("DROP_REPLICATION_SLOT %s", slotName)) return } diff --git a/replication_test.go b/replication_test.go index 20572edd..42d133c4 100644 --- a/replication_test.go +++ b/replication_test.go @@ -173,6 +173,10 @@ func TestSimpleReplicationConnection(t *testing.T) { t.Errorf("Unexpected write position %d", status.WalWritePosition) } + err = replicationConn.DropReplicationSlot("pgx_test") + if err != nil { + t.Fatalf("Failed to drop replication slot %v", err) + } err = replicationConn.Close() if err != nil { t.Fatalf("Replication connection close failed: %v", err) @@ -183,10 +187,4 @@ func TestSimpleReplicationConnection(t *testing.T) { if integerRestartLsn != maxWal { t.Fatalf("Wal offset update failed, expected %s found %s", pgx.FormatLSN(maxWal), restartLsn) } - - _, err = conn.Exec("select pg_drop_replication_slot($1)", "pgx_test") - if err != nil { - t.Fatalf("Failed to drop replication slot: %v", err) - } - }