Skip to content

Commit

Permalink
Skip vitess generated tables in Discover output
Browse files Browse the repository at this point in the history
  • Loading branch information
Phani Raj committed Jan 24, 2024
1 parent 54a459f commit 92f3278
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/internal/planetscale_edge_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"github.com/pkg/errors"
"regexp"
"strings"
"time"
)
Expand Down Expand Up @@ -109,6 +110,12 @@ func (p planetScaleEdgeMySQLAccess) PingContext(ctx context.Context, psc PlanetS
return p.db.PingContext(ctx)
}

const (
gCTableNameExpression string = `^_vt_(HOLD|PURGE|EVAC|DROP)_([0-f]{32})_([0-9]{14})$`
)

var gcTableNameRegexp = regexp.MustCompile(gCTableNameExpression)

func (p planetScaleEdgeMySQLAccess) GetTableNames(ctx context.Context, psc PlanetScaleSource) ([]string, error) {
var tables []string

Expand All @@ -123,7 +130,10 @@ func (p planetScaleEdgeMySQLAccess) GetTableNames(ctx context.Context, psc Plane
return tables, errors.Wrap(err, "unable to get table names")
}

tables = append(tables, name)
// skip any that are Vitess's GC tables.
if !gcTableNameRegexp.MatchString(name) {
tables = append(tables, name)
}
}

if err := tableNamesQR.Err(); err != nil {
Expand Down

0 comments on commit 92f3278

Please sign in to comment.