mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
driver/pgsql: optimize regex for version matching (#3583)
This commit is contained in:
@ -32,6 +32,8 @@ WHERE
|
||||
ORDER BY
|
||||
c.relname
|
||||
`
|
||||
|
||||
versionRegex = regexp.MustCompile(`PostgreSQL (\d+\.\d+)`)
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -90,7 +92,7 @@ func (d *Driver) version(ctx context.Context, link gdb.Link) string {
|
||||
}
|
||||
if len(result) > 0 {
|
||||
if v, ok := result[0]["version"]; ok {
|
||||
matches := regexp.MustCompile(`PostgreSQL (\d+\.\d+)`).FindStringSubmatch(v.String())
|
||||
matches := versionRegex.FindStringSubmatch(v.String())
|
||||
if len(matches) >= 2 {
|
||||
return matches[1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user