Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: remove dead code (#12399)

h3n4l32016f94f7e4
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index d3b312711f..bb5ee02084 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -451,10 +451,8 @@ func DoExport(ctx context.Context, storeInstance *store.Store, dbFactory *dbfact
}
queryContext := &db.QueryContext{
- ReadOnly: true,
- CurrentDatabase: database.DatabaseName,
- SensitiveSchemaInfo: nil,
- EnableSensitive: licenseService.IsFeatureEnabledForInstance(api.FeatureSensitiveData, instance) == nil,
+ ReadOnly: true,
+ CurrentDatabase: database.DatabaseName,
}
if request.Limit != 0 {
queryContext.Limit = int(request.Limit)
@@ -796,12 +794,10 @@ func (s *SQLService) doQuery(ctx context.Context, request *v1pb.QueryRequest, in
start := time.Now().UnixNano()
results, err := driver.QueryConn(ctx, conn, request.Statement, &db.QueryContext{
- Limit: int(request.Limit),
- Explain: request.Explain,
- ReadOnly: true,
- CurrentDatabase: database.DatabaseName,
- SensitiveSchemaInfo: nil,
- EnableSensitive: s.licenseService.IsFeatureEnabledForInstance(api.FeatureSensitiveData, instance) == nil,
+ Limit: int(request.Limit),
+ Explain: request.Explain,
+ ReadOnly: true,
+ CurrentDatabase: database.DatabaseName,
})
select {
case <-ctx.Done():
diff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.go
index a04896c5a2..659906e08a 100644
--- a/backend/legacyapi/plan.go
+++ b/backend/legacyapi/plan.go
@@ -124,8 +124,6 @@ const (
FeatureEncryptedSecrets FeatureType = "bb.feature.encrypted-secrets"
// FeatureDatabaseGrouping allows user to create database/schema groups.
FeatureDatabaseGrouping FeatureType = "bb.feature.database-grouping"
- // FeatureSchemaTemplate allows user to create and use the schema template.
- FeatureSchemaTemplate FeatureType = "bb.feature.schema-template"
// Database management.
@@ -230,8 +228,6 @@ func (e FeatureType) Name() string {
return "Encrypted secrets"
case FeatureDatabaseGrouping:
return "Database grouping"
- case FeatureSchemaTemplate:
- return "Schema template"
// Database management
case FeatureReadReplicaConnection:
return "Read replica connection"
@@ -312,7 +308,6 @@ var FeatureMatrix = map[FeatureType][3]bool{
FeatureTaskScheduleTime: {false, true, true},
FeatureEncryptedSecrets: {false, true, true},
FeatureDatabaseGrouping: {false, false, true},
- FeatureSchemaTemplate: {false, false, true},
// Database management
FeatureReadReplicaConnection: {false, false, true},
FeatureInstanceSSHConnection: {false, false, true},
diff --git a/backend/plugin/advisor/db/db.go b/backend/plugin/advisor/db/db.go
deleted file mode 100644
index d0f57ab889..0000000000
--- a/backend/plugin/advisor/db/db.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Package db provides the database utility for SQL advisor.
-package db
-
-// Type is the type of a database.
-// nolint
-type Type string
-
-// TODO(d): use a centric database type.
-const (
- // MySQL is the database type for MYSQL.
- MySQL Type = "MYSQL"
- // Postgres is the database type for POSTGRES.
- Postgres Type = "POSTGRES"
- // TiDB is the database type for TiDB.
- TiDB Type = "TIDB"
- // MariaDB is the database type for MariaDB.
- MariaDB Type = "MARIADB"
- // Oracle is the database type for Oracle.
- Oracle Type = "ORACLE"
- // OceanBase is the database type for OceanBase.
- OceanBase Type = "OCEANBASE"
- // Snowflake is the database type for Snowflake.
- Snowflake Type = "SNOWFLAKE"
- // MSSQL is the database type for SQL Server.
- MSSQL Type = "MSSQL"
- // DM is the database type for DM.
- DM Type = "DM"
-)
diff --git a/backend/plugin/db/dm/dm.go b/backend/plugin/db/dm/dm.go
index 87768f0917..6d678249d4 100644
--- a/backend/plugin/db/dm/dm.go
+++ b/backend/plugin/db/dm/dm.go
@@ -232,20 +232,6 @@ func (*Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, singleSQL bas
statement = getDMStatementWithResultLimit(statement, queryContext.Limit)
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("DM schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != database.Name {
- return nil, errors.Errorf("DM schema info should have the same database name and schema name, but got %s and %s", database.Name, database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, storepb.Engine_DM, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index 4d5304043d..c15db19418 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -13,7 +13,6 @@ import (
"github.com/pkg/errors"
"github.com/bytebase/bytebase/backend/common/log"
- "github.com/bytebase/bytebase/backend/plugin/parser/base"
"github.com/bytebase/bytebase/backend/store/model"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
@@ -233,12 +232,9 @@ type ConnectionContext struct {
// QueryContext is the context to query.
type QueryContext struct {
// Limit is the maximum row count returned. No limit enforced if limit <= 0
- Limit int
- Explain bool
- ReadOnly bool
- SensitiveSchemaInfo *base.SensitiveSchemaInfo
- // EnableSensitive will set to be true if the database instance has license.
- EnableSensitive bool
+ Limit int
+ Explain bool
+ ReadOnly bool
// CurrentDatabase is for MySQL
CurrentDatabase string
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index 1f59462b89..ffb0bc864f 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -514,20 +514,6 @@ func (d *Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, singleSQL b
}
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("MySQL schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != "" {
- return nil, errors.Errorf("MySQL schema info should have empty schema name, but got %s", database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, d.dbType, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/db/obo/obo.go b/backend/plugin/db/obo/obo.go
index ed18c5a5ee..ba103e2bce 100644
--- a/backend/plugin/db/obo/obo.go
+++ b/backend/plugin/db/obo/obo.go
@@ -221,20 +221,6 @@ func (*Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, singleSQL bas
statement = fmt.Sprintf("SELECT * FROM (%s) WHERE ROWNUM <= %d", statement, queryContext.Limit)
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("Oracle schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != database.Name {
- return nil, errors.Errorf("Oracle schema info should have the same database name and schema name, but got %s and %s", database.Name, database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, storepb.Engine_OCEANBASE_ORACLE, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.go
index bb6444c220..5a836c7907 100644
--- a/backend/plugin/db/oracle/oracle.go
+++ b/backend/plugin/db/oracle/oracle.go
@@ -279,20 +279,6 @@ func (driver *Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, single
statement = stmt
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("Oracle schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != database.Name {
- return nil, errors.Errorf("Oracle schema info should have the same database name and schema name, but got %s and %s", database.Name, database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, storepb.Engine_ORACLE, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/db/starrocks/starrocks.go b/backend/plugin/db/starrocks/starrocks.go
index c2e17d8139..0a09119a0f 100644
--- a/backend/plugin/db/starrocks/starrocks.go
+++ b/backend/plugin/db/starrocks/starrocks.go
@@ -280,20 +280,6 @@ func (driver *Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, single
}
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("MySQL schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != "" {
- return nil, errors.Errorf("MySQL schema info should have empty schema name, but got %s", database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, driver.dbType, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/db/tidb/tidb.go b/backend/plugin/db/tidb/tidb.go
index 8481d1ee30..c9636f6790 100644
--- a/backend/plugin/db/tidb/tidb.go
+++ b/backend/plugin/db/tidb/tidb.go
@@ -388,20 +388,6 @@ func (driver *Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, single
}
}
- if queryContext != nil && queryContext.SensitiveSchemaInfo != nil {
- for _, database := range queryContext.SensitiveSchemaInfo.DatabaseList {
- if len(database.SchemaList) == 0 {
- continue
- }
- if len(database.SchemaList) > 1 {
- return nil, errors.Errorf("MySQL schema info should only have one schema per database, but got %d, %v", len(database.SchemaList), database.SchemaList)
- }
- if database.SchemaList[0].Name != "" {
- return nil, errors.Errorf("MySQL schema info should have empty schema name, but got %s", database.SchemaList[0].Name)
- }
- }
- }
-
startTime := time.Now()
result, err := util.Query(ctx, driver.dbType, conn, statement, queryContext)
if err != nil {
diff --git a/backend/plugin/parser/base/interface.go b/backend/plugin/parser/base/interface.go
index 5edffee873..ccaa67e217 100644
--- a/backend/plugin/parser/base/interface.go
+++ b/backend/plugin/parser/base/interface.go
@@ -26,7 +26,6 @@ var (
)
type ValidateSQLForEditorFunc func(string) (bool, error)
-type GetMaskedFieldsFunc func(string, string, *SensitiveSchemaInfo) ([]SensitiveField, error)
type ExtractChangedResourcesFunc func(string, string, any) ([]SchemaResource, error)
type ExtractResourceListFunc func(string, string, string) ([]SchemaResource, error)
type SplitMultiSQLFunc func(string) ([]SingleSQL, error)
diff --git a/backend/plugin/parser/base/masking.go b/backend/plugin/parser/base/masking.go
index d3da3bdf49..2139d44158 100644
--- a/backend/plugin/parser/base/masking.go
+++ b/backend/plugin/parser/base/masking.go
@@ -4,14 +4,6 @@ import (
"github.com/bytebase/bytebase/backend/component/masker"
)
-// SensitiveSchemaInfo is the schema info using to extract sensitive fields.
-type SensitiveSchemaInfo struct {
- // IgnoreCaseSensitive is the flag to ignore case sensitive.
- // IMPORTANT: This flag is ONLY for database names, table names and view names in MySQL-like database.
- IgnoreCaseSensitive bool
- DatabaseList []DatabaseSchema
-}
-
// DatabaseSchema is the database schema using to extract sensitive fields.
type DatabaseSchema struct {
Name string