Skip to content

Commit 72eff7f

Browse files
wttwjackc
authored andcommitted
Don't test NOVERIFY_CHECKSUMS on Postgresql 11.
Return formatted error for pgproto3.ErrorResponse in StartBaseBackup().
1 parent 40536e4 commit 72eff7f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pglogrepl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ func getBaseBackupInfo(ctx context.Context, conn *pgconn.PgConn) (start LSN, tim
444444
case *pgproto3.NoticeResponse:
445445
case *pgproto3.CommandComplete:
446446
return start, timelineID, nil
447+
case *pgproto3.ErrorResponse:
448+
return start, timelineID, errors.Errorf("error response sev=%q code=%q message=%q detail=%q position=%d", msg.Severity, msg.Code, msg.Message, msg.Detail, msg.Position)
447449
default:
448450
return start, timelineID, errors.Errorf("unexpected response: %t", msg)
449451
}

pglogrepl_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"strconv"
8+
"strings"
89
"testing"
910
"time"
1011

@@ -336,8 +337,10 @@ func TestBaseBackup(t *testing.T) {
336337
require.NoError(t, err)
337338
defer closeConn(t, conn)
338339

340+
// NOVERIFY_CHECKSUMS is only supported in PG11 and later
341+
noVerifyChecksums := !strings.HasPrefix(conn.ParameterStatus("server_version"), "10.")
339342
options := pglogrepl.BaseBackupOptions{
340-
NoVerifyChecksums: true,
343+
NoVerifyChecksums: noVerifyChecksums,
341344
Progress: true,
342345
Label: "pglogrepltest",
343346
Fast: true,
@@ -347,8 +350,8 @@ func TestBaseBackup(t *testing.T) {
347350
TablespaceMap: true,
348351
}
349352
startRes, err := pglogrepl.StartBaseBackup(context.Background(), conn, options)
350-
require.GreaterOrEqual(t, startRes.TimelineID, int32(1))
351353
require.NoError(t, err)
354+
require.GreaterOrEqual(t, startRes.TimelineID, int32(1))
352355

353356
//Write the tablespaces
354357
for i := 0; i < len(startRes.Tablespaces)+1; i++ {

0 commit comments

Comments
 (0)