Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkaflik committed Apr 24, 2023
2 parents 82a0a56 + 2069a7c commit 1812cf4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions clickhouse_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func (std *stdDriver) PrepareContext(ctx context.Context, query string) (driver.
if err != nil {
if isConnBrokenError(err) {
std.debugf("PrepareContext got a fatal error, resetting connection: %v\n", err)
return nil, driver.ErrBadConn
}
std.debugf("PrepareContext error: %v\n", err)
return nil, err
Expand Down
5 changes: 1 addition & 4 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ func (h *httpConnect) readVersion(ctx context.Context) (proto.Version, error) {
for rows.Next() {
var v string
rows.Scan(&v)
version, err := proto.ParseVersion(v)
if err != nil {
return proto.Version{}, err
}
version := proto.ParseVersion(v)
return version, nil
}
return proto.Version{}, errors.New("unable to determine version")
Expand Down
13 changes: 7 additions & 6 deletions lib/proto/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,22 @@ type Version struct {
Patch uint64
}

func ParseVersion(v string) (ver Version, err error) {
func ParseVersion(v string) (ver Version) {
var err error
parts := strings.Split(v, ".")
if len(parts) < 3 {
return Version{}, fmt.Errorf("%s is not a valid version", v)
return ver
}
if ver.Major, err = strconv.ParseUint(parts[0], 10, 8); err != nil {
return Version{}, err
return ver
}
if ver.Minor, err = strconv.ParseUint(parts[1], 10, 8); err != nil {
return Version{}, err
return ver
}
if ver.Patch, err = strconv.ParseUint(parts[2], 10, 8); err != nil {
return Version{}, err
return ver
}
return ver, nil
return ver
}

func CheckMinVersion(constraint Version, version Version) bool {
Expand Down

0 comments on commit 1812cf4

Please sign in to comment.