getPgVersionAndRedshiftVersion parses the output from Redshift's `SELECT version()` to get the PostgreSQL version and the Redshift version.
(version string)
| 692 | |
| 693 | // getPgVersionAndRedshiftVersion parses the output from Redshift's `SELECT version()` to get the PostgreSQL version and the Redshift version. |
| 694 | func 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>". |
| 719 | func buildRedshiftVersionString(redshiftVersion, postgresVersion string) string { |