getVersion gets the version.
(ctx context.Context)
| 157 | |
| 158 | // getVersion gets the version. |
| 159 | func (d *Driver) getVersion(ctx context.Context) (string, error) { |
| 160 | query := "SELECT VERSION()" |
| 161 | var version string |
| 162 | if err := d.db.QueryRowContext(ctx, query).Scan(&version); err != nil { |
| 163 | if err == sql.ErrNoRows { |
| 164 | return "", common.FormatDBErrorEmptyRowWithQuery(query) |
| 165 | } |
| 166 | return "", util.FormatErrorWithQuery(err, query) |
| 167 | } |
| 168 | |
| 169 | return parseVersion(version) |
| 170 | } |
| 171 | |
| 172 | func parseVersion(version string) (string, error) { |
| 173 | // Examples: 8.0.11-TiDB-v8.5.0, 8.0.11-TiDB-v7.5.2-serverless. |
no test coverage detected