Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove deadcode (#18540)
h3n4l841ab2cbac28
diff --git a/backend/api/lsp/handler.go b/backend/api/lsp/handler.goindex 248c4dedfe..59f8087050 100644--- a/backend/api/lsp/handler.go+++ b/backend/api/lsp/handler.go@@ -57,7 +57,6 @@ func NewHandlerWithAuth(s *store.Store, profile *config.Profile, iamManager *iamiamManager: iamManager,diagnosticsDebouncer: NewDiagnosticsDebouncer(500 * time.Millisecond), // 500ms debouncecontentCache: NewContentCache(100), // Cache up to 100 documents- perfMonitor: NewPerformanceMonitor(),}return lspHandler{Handler: jsonrpc2.HandlerWithError(handler.handle)}}@@ -94,7 +93,6 @@ type Handler struct {// Performance optimizationsdiagnosticsDebouncer *DiagnosticsDebouncercontentCache *ContentCache- perfMonitor *PerformanceMonitor}// ShutDown shuts down the handler.diff --git a/backend/api/lsp/performance_optimizer.go b/backend/api/lsp/performance_optimizer.goindex 722cf2335b..a3880cbafa 100644--- a/backend/api/lsp/performance_optimizer.go+++ b/backend/api/lsp/performance_optimizer.go@@ -223,20 +223,6 @@ func (c *ContentCache) Get(uri string) (*CachedContent, bool) {return content, exists}-// Invalidate removes a specific entry from cache-func (c *ContentCache) Invalidate(uri string) {- c.mu.Lock()- defer c.mu.Unlock()-- delete(c.cache, uri)- for i, u := range c.order {- if u == uri {- c.order = append(c.order[:i], c.order[i+1:]...)- break- }- }-}-// Set stores content in cache with LRU evictionfunc (c *ContentCache) Set(uri string, content *CachedContent) {c.mu.Lock()@@ -267,74 +253,3 @@ func (c *ContentCache) Set(uri string, content *CachedContent) {c.cache[uri] = content}--// PerformanceMonitor tracks LSP performance metrics-type PerformanceMonitor struct {- mu sync.RWMutex- requestCounts map[Method]int64- requestDurations map[Method]time.Duration- lastReset time.Time-}--// NewPerformanceMonitor creates a new performance monitor-func NewPerformanceMonitor() *PerformanceMonitor {- return &PerformanceMonitor{- requestCounts: make(map[Method]int64),- requestDurations: make(map[Method]time.Duration),- lastReset: time.Now(),- }-}--// RecordRequest records a request for performance monitoring-func (p *PerformanceMonitor) RecordRequest(method Method, duration time.Duration) {- p.mu.Lock()- defer p.mu.Unlock()-- p.requestCounts[method]++- p.requestDurations[method] += duration-}--// GetStats returns current performance statistics-func (p *PerformanceMonitor) GetStats() map[Method]struct {- Count int64- TotalTime time.Duration- AverageTime time.Duration-} {- p.mu.RLock()- defer p.mu.RUnlock()-- stats := make(map[Method]struct {- Count int64- TotalTime time.Duration- AverageTime time.Duration- })-- for method, count := range p.requestCounts {- totalTime := p.requestDurations[method]- avgTime := time.Duration(0)- if count > 0 {- avgTime = totalTime / time.Duration(count)- }- stats[method] = struct {- Count int64- TotalTime time.Duration- AverageTime time.Duration- }{- Count: count,- TotalTime: totalTime,- AverageTime: avgTime,- }- }-- return stats-}--// Reset clears all performance statistics-func (p *PerformanceMonitor) Reset() {- p.mu.Lock()- defer p.mu.Unlock()-- p.requestCounts = make(map[Method]int64)- p.requestDurations = make(map[Method]time.Duration)- p.lastReset = time.Now()-}diff --git a/backend/api/v1/common.go b/backend/api/v1/common.goindex 1d25c0329c..fa1ba53ee0 100644--- a/backend/api/v1/common.go+++ b/backend/api/v1/common.go@@ -8,7 +8,6 @@ import ("connectrpc.com/connect""github.com/pkg/errors"- "golang.org/x/exp/ebnf""google.golang.org/protobuf/proto""github.com/bytebase/bytebase/backend/common"@@ -73,47 +72,6 @@ func validateLabels(labels map[string]string) error {return nil}-// getEBNFTokens will parse the simple filter such as `project = "abc" | "def".` to {project: ["abc", "def"]} .-func getEBNFTokens(filter, filterKey string) ([]string, error) {- grammar, err := ebnf.Parse("", strings.NewReader(filter))- if err != nil {- return nil, errors.Wrapf(err, "invalid filter %q", filter)- }- productions, ok := grammar[filterKey]- if !ok {- return nil, nil- }- switch expr := productions.Expr.(type) {- case *ebnf.Token:- // filterKey = "abc".- return []string{expr.String}, nil- case ebnf.Alternative:- // filterKey = "abc" | "def".- var tokens []string- for _, expr := range expr {- token, ok := expr.(*ebnf.Token)- if !ok {- return nil, errors.Errorf("invalid filter %q", filter)- }- tokens = append(tokens, token.String)- }- return tokens, nil- case *ebnf.Alternative:- // filterKey = "abc" | "def".- var tokens []string- for _, expr := range *expr {- token, ok := expr.(*ebnf.Token)- if !ok {- return nil, errors.Errorf("invalid filter %q", filter)- }- tokens = append(tokens, token.String)- }- return tokens, nil- default:- return nil, errors.Errorf("invalid filter %q", filter)- }-}-type orderByKey struct {key stringisAscend booldiff --git a/backend/api/v1/common_test.go b/backend/api/v1/common_test.goindex 5d2f7bff79..4c0fa55ce8 100644--- a/backend/api/v1/common_test.go+++ b/backend/api/v1/common_test.go@@ -41,60 +41,6 @@ func TestIsValidResourceID(t *testing.T) {}}-func TestGetEBNFTokens(t *testing.T) {- testCases := []struct {- input string- key string- want []string- wantErr bool- }{- {- input: `resource="environments/e1/instances/i2".`,- key: "resource",- want: []string{- "environments/e1/instances/i2",- },- wantErr: false,- },- {- input: `resource="environments/e1/instances/i2/databases/db3".`,- key: "resource",- want: []string{- "environments/e1/instances/i2/databases/db3",- },- wantErr: false,- },- {- input: `type="DATABASE_BACKUP_MISSING" | "DATABASE_BACKUP_FAILED".`,- key: "type",- want: []string{- "DATABASE_BACKUP_MISSING",- "DATABASE_BACKUP_FAILED",- },- wantErr: false,- },- {- input: `a="1" | "2". b="3" | "4".`,- key: "b",- want: []string{- "3",- "4",- },- wantErr: false,- },- }-- for _, tc := range testCases {- got, err := getEBNFTokens(tc.input, tc.key)- if tc.wantErr {- require.Error(t, err)- } else {- require.NoError(t, err)- require.Equal(t, tc.want, got)- }- }-}-func TestParseFilter(t *testing.T) {testCases := []struct {input stringdiff --git a/backend/common/position.go b/backend/common/position.goindex 881e13d4fd..917dc7658d 100644--- a/backend/common/position.go+++ b/backend/common/position.go@@ -78,33 +78,3 @@ func ConvertTiDBParserErrorPositionToPosition(line, column int) *storepb.PositioColumn: int32(column),}}--func ConvertPGParserErrorCursorPosToPosition(cursorPos int, text string) *storepb.Position {- // PostgreSQL cursorPos is 1-based character (rune) position.- // Cursorpos points to the character WHERE the error is.- // We need to count characters BEFORE the error position.- if cursorPos >= 1 {- cursorPos--- }- line := 1 // Start at 1 for 1-based line numbering- column := 0- rText := []rune(text)- for i, r := range rText {- // Stop when we reach the error position- if i == cursorPos {- break- }- if r == '\n' {- line++- column = 0- continue- }- // Count characters (not bytes)- column++- }- // Convert from 0-based to 1-based column- return &storepb.Position{- Line: int32(line),- Column: int32(column + 1),- }-}diff --git a/backend/common/position_test.go b/backend/common/position_test.goindex a0d854e0bc..e6cb3d20da 100644--- a/backend/common/position_test.go+++ b/backend/common/position_test.go@@ -44,46 +44,6 @@ func TestConvertANTLRPositionToPosition(t *testing.T) {}}-func TestConvertPGParserErrorCursorPosToPosition(t *testing.T) {- testCases := []struct {- name string- cursorPos int- text string- expectedLine int32- expectedColumn int32- }{- {- name: "ASCII single line",- cursorPos: 8,- text: "SELECT * FROM t",- expectedLine: 1,- expectedColumn: 8,- },- {- name: "multi-byte characters",- cursorPos: 8,- text: "SELECT 你好 FROM t",- expectedLine: 1,- expectedColumn: 8, // Character-based (8th character is '你')- },- {- name: "multi-line",- cursorPos: 20,- text: "SELECT * FROM t\nWHERE x = 1",- expectedLine: 2,- expectedColumn: 4, // 4th character on line 2- },- }-- for _, tc := range testCases {- t.Run(tc.name, func(t *testing.T) {- pos := ConvertPGParserErrorCursorPosToPosition(tc.cursorPos, tc.text)- require.Equal(t, tc.expectedLine, pos.Line, "line mismatch")- require.Equal(t, tc.expectedColumn, pos.Column, "column mismatch")- })- }-}-func TestConvertTiDBParserErrorPositionToPosition(t *testing.T) {testCases := []struct {name stringdiff --git a/backend/common/resource_name.go b/backend/common/resource_name.goindex e34861846d..5b5003dcc7 100644--- a/backend/common/resource_name.go+++ b/backend/common/resource_name.go@@ -79,18 +79,6 @@ func GetProjectIDDatabaseGroupID(name string) (string, string, error) {return tokens[0], tokens[1], nil}-// GetSchemaTableName returns the schema and table names from a resource name.-func GetSchemaTableName(name string) (string, string, error) {- tokens, err := GetNameParentTokens(name, SchemaNamePrefix, TableNamePrefix)- if err != nil {- return "", "", err- }- if tokens[0] == "-" {- tokens[0] = ""- }- return tokens[0], tokens[1], nil-}-// GetProjectIDWebhookID returns the project ID and webhook ID from a resource name.func GetProjectIDWebhookID(name string) (string, string, error) {tokens, err := GetNameParentTokens(name, ProjectNamePrefix, WebhookIDPrefix)@@ -100,19 +88,6 @@ func GetProjectIDWebhookID(name string) (string, string, error) {return tokens[0], tokens[1], nil}-// GetUIDFromName returns the UID from a resource name.-func GetUIDFromName(name, prefix string) (int, error) {- tokens, err := GetNameParentTokens(name, prefix)- if err != nil {- return 0, err- }- uid, err := strconv.Atoi(tokens[0])- if err != nil {- return 0, errors.Errorf("invalid ID %q", tokens[0])- }- return uid, nil-}-// TrimSuffixAndGetInstanceDatabaseID trims the suffix from the name and returns the instance ID and database ID.func TrimSuffixAndGetInstanceDatabaseID(name string, suffix string) (string, string, error) {trimmed, err := TrimSuffix(name, suffix)@@ -178,11 +153,6 @@ func GetInstanceDatabaseChangelogUID(name string) (string, string, int64, error)return tokens[0], tokens[1], changelogUID, nil}-// GetUserID returns the user ID from a resource name.-func GetUserID(name string) (int, error) {- return GetUIDFromName(name, UserNamePrefix)-}-// GetUserEmail returns the user email from a resource name.func GetUserEmail(name string) (string, error) {tokens, err := GetNameParentTokens(name, UserNamePrefix)@@ -240,19 +210,6 @@ func GetProjectIDIssueUIDIssueCommentUID(name string) (string, int, int, error)return tokens[0], issueUID, issueCommentUID, nil}-// GetIssueID returns the issue ID from a resource name.-func GetIssueID(name string) (int, error) {- tokens, err := GetNameParentTokens(name, ProjectNamePrefix, IssueNamePrefix)- if err != nil {- return 0, err- }- issueID, err := strconv.Atoi(tokens[1])- if err != nil {- return 0, errors.Errorf("invalid issue ID %q", tokens[1])- }- return issueID, nil-}-// GetProjectIDPlanID returns the project ID and plan ID from a resource name.func GetProjectIDPlanID(name string) (string, int64, error) {tokens, err := GetNameParentTokens(name, ProjectNamePrefix, PlanPrefix)diff --git a/backend/common/resource_name_test.go b/backend/common/resource_name_test.goindex e9ddb6563f..845145ed40 100644--- a/backend/common/resource_name_test.go+++ b/backend/common/resource_name_test.go@@ -15,20 +15,3 @@ func TestGetInstanceDatabaseID(t *testing.T) {_, err = GetInstanceID("instances/i2/databases/d3")require.Error(t, err)}--func TestGetSchemaTableName(t *testing.T) {- schema, table, err := GetSchemaTableName("schemas/a/tables/b")- require.NoError(t, err)- require.Equal(t, "a", schema)- require.Equal(t, "b", table)-- schema, table, err = GetSchemaTableName("schemas//tables/b")- require.NoError(t, err)- require.Equal(t, "", schema)- require.Equal(t, "b", table)-- schema, table, err = GetSchemaTableName("schemas/-/tables/b")- require.NoError(t, err)- require.Equal(t, "", schema)- require.Equal(t, "b", table)-}diff --git a/go.mod b/go.modindex f055224525..cc283162f2 100644--- a/go.mod+++ b/go.mod@@ -96,7 +96,6 @@ require (go.mongodb.org/mongo-driver/v2 v2.4.0go.uber.org/multierr v1.11.0golang.org/x/crypto v0.45.0- golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39golang.org/x/oauth2 v0.33.0golang.org/x/text v0.31.0google.golang.org/api v0.257.0@@ -271,6 +270,7 @@ require (go.yaml.in/yaml/v2 v2.4.2 // indirectgo.yaml.in/yaml/v3 v3.0.4 // indirectgo.yaml.in/yaml/v4 v4.0.0-rc.2 // indirect+ golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirectgolang.org/x/mod v0.30.0 // indirectgolang.org/x/sys v0.38.0 // indirectgolang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54 // indirect