From d0818e1fbef75e7a3e2f6887e022959904dae6a2 Mon Sep 17 00:00:00 2001 From: krisdiano Date: Thu, 10 Aug 2023 09:51:22 +0800 Subject: [PATCH] fix get server major version --- pglogrepl.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/pglogrepl.go b/pglogrepl.go index 0e94efa..be3c9af 100644 --- a/pglogrepl.go +++ b/pglogrepl.go @@ -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 } @@ -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