Skip to content

Commit 15b6046

Browse files
driver/pgsql: optimize regex for version matching (#3583)
1 parent 1455440 commit 15b6046

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

contrib/drivers/pgsql/pgsql_tables.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ WHERE
3232
ORDER BY
3333
c.relname
3434
`
35+
36+
versionRegex = regexp.MustCompile(`PostgreSQL (\d+\.\d+)`)
3537
)
3638

3739
func init() {
@@ -90,7 +92,7 @@ func (d *Driver) version(ctx context.Context, link gdb.Link) string {
9092
}
9193
if len(result) > 0 {
9294
if v, ok := result[0]["version"]; ok {
93-
matches := regexp.MustCompile(`PostgreSQL (\d+\.\d+)`).FindStringSubmatch(v.String())
95+
matches := versionRegex.FindStringSubmatch(v.String())
9496
if len(matches) >= 2 {
9597
return matches[1]
9698
}

0 commit comments

Comments
 (0)