Skip to content

Commit

Permalink
fix get server major version
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdiano authored and jackc committed Aug 10, 2023
1 parent 163df88 commit d0818e1
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions pglogrepl.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func FinishBaseBackup(ctx context.Context, conn *pgconn.PgConn) (result BaseBack
}

// Base_Backup done, server send a command complete response from pg13
vmaj, err := getMajorVersion(conn)
vmaj, err := serverMajorVersion(conn)
if err != nil {
return
}
Expand Down Expand Up @@ -604,24 +604,6 @@ func FinishBaseBackup(ctx context.Context, conn *pgconn.PgConn) (result BaseBack
return
}

func getMajorVersion(conn *pgconn.PgConn) (int, error) {
sversion := conn.ParameterStatus("server_version")
if len(sversion) == 0 {
return 0, fmt.Errorf("no server_version")
}
var vmaj, vmin, vrev int
cnt, err := fmt.Sscanf(sversion, "%d.%d.%d", &vmaj, &vmin, &vrev)
if err != nil {
return 0, err
}
switch cnt {
case 1, 2, 3:
return vmaj, nil
default:
}
return 0, fmt.Errorf("unknown server version")
}

type PrimaryKeepaliveMessage struct {
ServerWALEnd LSN
ServerTime time.Time
Expand Down

0 comments on commit d0818e1

Please sign in to comment.