Skip to content

Commit

Permalink
Fix: fix pglogrepl.SendStandbyCopyDone
Browse files Browse the repository at this point in the history
Change the return value '*CopyDoneResult' to struct to avoid NPE when receive a DataRow message.
  • Loading branch information
zzzzwc committed Aug 3, 2023
1 parent 38e8a4e commit 864b4b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pglogrepl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <steve@blighty.com>
conn.Frontend().Send(&pgproto3.CopyDone{})
Expand Down
2 changes: 1 addition & 1 deletion pglogrepl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 864b4b5

Please sign in to comment.