MCPcopy Index your code
hub / github.com/bytebase/bytebase / getPgVersionAndRedshiftVersion

Function getPgVersionAndRedshiftVersion

backend/plugin/db/redshift/sync.go:694–716  ·  view source on GitHub ↗

getPgVersionAndRedshiftVersion parses the output from Redshift's `SELECT version()` to get the PostgreSQL version and the Redshift version.

(version string)

Source from the content-addressed store, hash-verified

692
693// getPgVersionAndRedshiftVersion parses the output from Redshift's `SELECT version()` to get the PostgreSQL version and the Redshift version.
694func getPgVersionAndRedshiftVersion(version string) (string, string, error) {
695 matches := parseVersionRegex.FindStringSubmatch(version)
696 if len(matches) == 0 {
697 return "", "", errors.Errorf("unable to parse version string: %s", version)
698 }
699
700 pgVersion := ""
701 redshiftVersion := ""
702 for i, name := range parseVersionRegex.SubexpNames() {
703 if i != 0 && name != "" {
704 switch name {
705 case "pgVersion":
706 pgVersion = matches[i]
707 case "redshiftVersion":
708 redshiftVersion = matches[i]
709 default:
710 // Ignore other named groups
711 }
712 }
713 }
714
715 return pgVersion, redshiftVersion, nil
716}
717
718// buildRedshiftVersionString builds the Redshift version string, format is "Redshift <redshiftVersion> based on PostgreSQL <postgresVersion>".
719func buildRedshiftVersionString(redshiftVersion, postgresVersion string) string {

Callers 2

getVersionMethod · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 1