From 864b4b51cc8ddad00c78931da3c95ac889369eec Mon Sep 17 00:00:00 2001 From: zzzzwc Date: Thu, 3 Aug 2023 16:54:33 +0800 Subject: [PATCH] Fix: fix pglogrepl.SendStandbyCopyDone Change the return value '*CopyDoneResult' to struct to avoid NPE when receive a DataRow message. --- pglogrepl.go | 2 +- pglogrepl_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pglogrepl.go b/pglogrepl.go index ce6f6ec..78f8b72 100644 --- a/pglogrepl.go +++ b/pglogrepl.go @@ -671,7 +671,7 @@ type CopyDoneResult struct { // SendStandbyCopyDone sends a StandbyCopyDone to the PostgreSQL server // to confirm ending the copy-both mode. -func SendStandbyCopyDone(_ context.Context, conn *pgconn.PgConn) (cdr *CopyDoneResult, err error) { +func SendStandbyCopyDone(_ context.Context, conn *pgconn.PgConn) (cdr CopyDoneResult, err error) { // I am suspicious that this is wildly wrong, but I'm pretty sure the previous // code was wildly wrong too -- wttw conn.Frontend().Send(&pgproto3.CopyDone{}) diff --git a/pglogrepl_test.go b/pglogrepl_test.go index ee684b2..433393d 100644 --- a/pglogrepl_test.go +++ b/pglogrepl_test.go @@ -324,7 +324,7 @@ drop table mytable; copyDoneResult, err := pglogrepl.SendStandbyCopyDone(ctx, conn) require.NoError(t, err) - assert.Nil(t, copyDoneResult) + assert.Equal(t, copyDoneResult, pglogrepl.CopyDoneResult{}) } func TestBaseBackup(t *testing.T) {