Skip to content

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

chore: golangci-lint version (#14751)

Danny Xu83371d78c600
diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml
index ef5bcff632..0546b94bac 100644
--- a/.github/workflows/backend-tests.yml
+++ b/.github/workflows/backend-tests.yml
@@ -39,7 +39,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
- version: v1.60.2
+ version: v1.62.2
args: --verbose --timeout 20m --max-same-issues=30 --allow-parallel-runners
- name: Run all tests
run: go test -p=8 -tags=mysql -v ./backend/... | tee test.log; exit ${PIPESTATUS[0]}
diff --git a/backend/api/v1/branch_service.go b/backend/api/v1/branch_service.go
index 5656d6d265..3110457018 100644
--- a/backend/api/v1/branch_service.go
+++ b/backend/api/v1/branch_service.go
@@ -1291,17 +1291,17 @@ func reconcileMySQLPartitionMetadata(partitions []*storepb.TablePartitionMetadat
// updateConfigBranchUpdateInfoForUpdate compare the proto of old and new metadata, and update the config branch update info.
// NOTE: this function would not delete the config of deleted objects, and it's safe because the next time adding the object
// back will trigger the update of the config branch update info.
-func updateConfigBranchUpdateInfoForUpdate(old *storepb.DatabaseSchemaMetadata, new *storepb.DatabaseSchemaMetadata, config *storepb.DatabaseConfig, formattedUserUID string, formattedBranchResourceID string) *storepb.DatabaseConfig {
+func updateConfigBranchUpdateInfoForUpdate(o *storepb.DatabaseSchemaMetadata, n *storepb.DatabaseSchemaMetadata, config *storepb.DatabaseConfig, formattedUserUID string, formattedBranchResourceID string) *storepb.DatabaseConfig {
time := timestamppb.Now()
- alignedConfig := alignDatabaseConfig(new, config)
- oldModel := model.NewDatabaseMetadata(old)
+ alignedConfig := alignDatabaseConfig(n, config)
+ oldModel := model.NewDatabaseMetadata(o)
newSchemaConfigMap := buildMap(alignedConfig.SchemaConfigs, func(s *storepb.SchemaConfig) string {
return s.Name
})
var newSchemaConfigs []*storepb.SchemaConfig
- for _, schema := range new.Schemas {
+ for _, schema := range n.Schemas {
newSchemaConfig, ok := newSchemaConfigMap[schema.Name]
if !ok {
newSchemaConfigs = append(newSchemaConfigs, initSchemaConfig(schema, formattedUserUID, formattedBranchResourceID, time))
diff --git a/backend/plugin/parser/mysql/differ.go b/backend/plugin/parser/mysql/differ.go
index 65953dc9ef..3d23c0317c 100644
--- a/backend/plugin/parser/mysql/differ.go
+++ b/backend/plugin/parser/mysql/differ.go
@@ -170,12 +170,12 @@ func (diff *diffNode) diffCheckConstraint(oldTable, newTable *tableDef) {
}
}
-func isCheckConstraintEqual(old, new *checkDef) bool {
- if !strings.EqualFold(old.name, new.name) {
+func isCheckConstraintEqual(o, n *checkDef) bool {
+ if !strings.EqualFold(o.name, n.name) {
return false
}
- if old.ctx.GetText() != new.ctx.GetText() {
+ if o.ctx.GetText() != n.ctx.GetText() {
return false
}
@@ -312,14 +312,14 @@ func (diff *diffNode) diffPrimaryKey(oldTable, newTable *tableDef) {
}
// isPrimaryKeyEqual returns true if definitions of two priamry indexes are the same.
-func isPrimaryKeyEqual(old, new *primaryKeyDef) bool {
- if old.tableName != new.tableName {
+func isPrimaryKeyEqual(o, n *primaryKeyDef) bool {
+ if o.tableName != n.tableName {
return false
}
- if !isKeyPartEqual(old.columns, new.columns) {
+ if !isKeyPartEqual(o.columns, n.columns) {
return false
}
- if old.ctx.GetText() != new.ctx.GetText() {
+ if o.ctx.GetText() != n.ctx.GetText() {
return false
}
return true
@@ -343,17 +343,17 @@ func (diff *diffNode) diffForeignKey(oldTable, newTable *tableDef) {
}
// isForeignKeyEqual returns true if two foreign keys are the same.
-func isForeignKeyEqual(old, new *foreignKeyDef) bool {
- if !strings.EqualFold(old.name, new.name) {
+func isForeignKeyEqual(o, n *foreignKeyDef) bool {
+ if !strings.EqualFold(o.name, n.name) {
return false
}
- if !isKeyPartEqual(old.columns, new.columns) {
+ if !isKeyPartEqual(o.columns, n.columns) {
return false
}
- if !isKeyPartEqual(old.referencedColumns, new.referencedColumns) {
+ if !isKeyPartEqual(o.referencedColumns, n.referencedColumns) {
return false
}
- if old.referencedTable != new.referencedTable {
+ if o.referencedTable != n.referencedTable {
return false
}
return true
@@ -477,8 +477,8 @@ func (diff *diffNode) diffFunction(oldDatabase, newDatabase *databaseDef) error
return nil
}
-func isFunctionEqual(old, new *functionDef) bool {
- return old.ctx.GetText() == new.ctx.GetText()
+func isFunctionEqual(o, n *functionDef) bool {
+ return o.ctx.GetText() == n.ctx.GetText()
}
func (diff *diffNode) diffProcedure(oldDatabase, newDatabase *databaseDef) error {
@@ -502,8 +502,8 @@ func (diff *diffNode) diffProcedure(oldDatabase, newDatabase *databaseDef) error
return nil
}
-func isProcedureEqual(old, new *procedureDef) bool {
- return old.ctx.GetText() == new.ctx.GetText()
+func isProcedureEqual(o, n *procedureDef) bool {
+ return o.ctx.GetText() == n.ctx.GetText()
}
func (diff *diffNode) diffEvent(oldSchema, newSchema *schemaDef) error {
@@ -525,8 +525,8 @@ func (diff *diffNode) diffEvent(oldSchema, newSchema *schemaDef) error {
return nil
}
-func isEventEqual(old, new *eventDef) bool {
- return old.ctx.GetText() == new.ctx.GetText()
+func isEventEqual(o, n *eventDef) bool {
+ return o.ctx.GetText() == n.ctx.GetText()
}
func (diff *diffNode) diffTrigger(oldSchema, newSchema *schemaDef) error {
@@ -548,8 +548,8 @@ func (diff *diffNode) diffTrigger(oldSchema, newSchema *schemaDef) error {
return nil
}
-func isTriggerEqual(old, new *triggerDef) bool {
- return old.ctx.GetText() == new.ctx.GetText()
+func isTriggerEqual(o, n *triggerDef) bool {
+ return o.ctx.GetText() == n.ctx.GetText()
}
func (diff *diffNode) diffColumn(oldTable, newTable *tableDef) {
@@ -643,12 +643,12 @@ func (diff *diffNode) diffIndexConstraint(oldTable, newTable *tableDef) {
}
}
-func isIndexConstraintEqual(new, old *indexConstraintDef) bool {
- if old.name != new.name {
+func isIndexConstraintEqual(n, o *indexConstraintDef) bool {
+ if o.name != n.name {
return false
}
- if old.ctx.GetText() != new.ctx.GetText() {
+ if o.ctx.GetText() != n.ctx.GetText() {
return false
}
return true
@@ -678,25 +678,25 @@ func (diff *diffNode) buildSchemaInfo(statement string) (*databaseDef, error) {
}
// isViewEqual checks whether two views with same name are equal.
-func (*diffNode) isViewEqual(old, new *viewDef) bool {
- if old.name != new.name {
+func (*diffNode) isViewEqual(o, n *viewDef) bool {
+ if o.name != n.name {
return false
}
- if old.ctx.GetText() != new.ctx.GetText() {
+ if o.ctx.GetText() != n.ctx.GetText() {
return false
}
return true
}
// isColumnEqual returns true if definitions of two columns with the same name are the same.
-func isColumnEqual(old, new *columnDef) bool {
+func isColumnEqual(o, n *columnDef) bool {
// column name
- return old.ctx.GetText() == new.ctx.GetText()
+ return o.ctx.GetText() == n.ctx.GetText()
}
// isIndexEqual returns true if definitions of two indexes are the same.
-func isIndexEqual(old, new *indexDef) bool {
+func isIndexEqual(o, n *indexDef) bool {
// CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
// [index_type]
// ON tbl_name (key_part,...)
@@ -704,23 +704,23 @@ func isIndexEqual(old, new *indexDef) bool {
// [algorithm_option | lock_option] ...
// MySQL index names are case insensitive.
- if !strings.EqualFold(old.name, new.name) {
+ if !strings.EqualFold(o.name, n.name) {
return false
}
- if old.ctx.GetText() != new.ctx.GetText() {
+ if o.ctx.GetText() != n.ctx.GetText() {
return false
}
return true
}
-func isKeyPartEqual(old, new []string) bool {
- if len(old) != len(new) {
+func isKeyPartEqual(o, n []string) bool {
+ if len(o) != len(n) {
return false
}
- for idx, oldKey := range old {
- if oldKey != new[idx] {
+ for idx, oldKey := range o {
+ if oldKey != n[idx] {
return false
}
}
diff --git a/backend/plugin/parser/tidb/differ.go b/backend/plugin/parser/tidb/differ.go
index 19949fc977..808cd0127d 100644
--- a/backend/plugin/parser/tidb/differ.go
+++ b/backend/plugin/parser/tidb/differ.go
@@ -1484,23 +1484,23 @@ func buildConstraintMap(stmt *ast.CreateTableStmt) (*ast.Constraint, constraintM
}
// isColumnEqual returns true if definitions of two columns with the same name are the same.
-func isColumnEqual(old, new *ast.ColumnDef) bool {
- if !isColumnTypesEqual(old, new) {
+func isColumnEqual(o, n *ast.ColumnDef) bool {
+ if !isColumnTypesEqual(o, n) {
return false
}
- if !isColumnOptionsEqual(old.Options, new.Options) {
+ if !isColumnOptionsEqual(o.Options, n.Options) {
return false
}
return true
}
-func isColumnTypesEqual(old, new *ast.ColumnDef) bool {
- return old.Tp.String() == new.Tp.String()
+func isColumnTypesEqual(o, n *ast.ColumnDef) bool {
+ return o.Tp.String() == n.Tp.String()
}
-func isColumnOptionsEqual(old, new []*ast.ColumnOption) bool {
- oldCollate, oldNormalizeOptions := normalizeColumnOptions(old)
- newCollate, newNormalizeOptions := normalizeColumnOptions(new)
+func isColumnOptionsEqual(o, n []*ast.ColumnOption) bool {
+ oldCollate, oldNormalizeOptions := normalizeColumnOptions(o)
+ newCollate, newNormalizeOptions := normalizeColumnOptions(n)
if len(oldNormalizeOptions) != len(newNormalizeOptions) {
return false
}
@@ -1559,7 +1559,7 @@ func normalizeColumnOptions(options []*ast.ColumnOption) (*ast.ColumnOption, []*
}
// isIndexEqual returns true if definitions of two indexes are the same.
-func isIndexEqual(old, new *ast.CreateIndexStmt) bool {
+func isIndexEqual(o, n *ast.CreateIndexStmt) bool {
// CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
// [index_type]
// ON tbl_name (key_part,...)
@@ -1567,59 +1567,59 @@ func isIndexEqual(old, new *ast.CreateIndexStmt) bool {
// [algorithm_option | lock_option] ...
// MySQL index names are case insensitive.
- if !strings.EqualFold(old.IndexName, new.IndexName) {
+ if !strings.EqualFold(o.IndexName, n.IndexName) {
return false
}
- if (old.IndexOption == nil) != (new.IndexOption == nil) {
+ if (o.IndexOption == nil) != (n.IndexOption == nil) {
return false
}
- if old.IndexOption != nil && new.IndexOption != nil {
- if old.IndexOption.Tp != new.IndexOption.Tp {
+ if o.IndexOption != nil && n.IndexOption != nil {
+ if o.IndexOption.Tp != n.IndexOption.Tp {
return false
}
}
- if !isKeyPartEqual(old.IndexPartSpecifications, new.IndexPartSpecifications) {
+ if !isKeyPartEqual(o.IndexPartSpecifications, n.IndexPartSpecifications) {
return false
}
- if !isIndexOptionEqual(old.IndexOption, new.IndexOption) {
+ if !isIndexOptionEqual(o.IndexOption, n.IndexOption) {
return false
}
return true
}
// isPrimaryKeyEqual returns true if definitions of two indexes are the same.
-func isPrimaryKeyEqual(old, new *ast.Constraint) bool {
+func isPrimaryKeyEqual(o, n *ast.Constraint) bool {
// {INDEX | KEY} [index_name] [index_type] (key_part,...) [index_option] ...
- if old.Name != new.Name {
+ if o.Name != n.Name {
return false
}
- if (old.Option == nil) != (new.Option == nil) {
+ if (o.Option == nil) != (n.Option == nil) {
return false
}
- if old.Option != nil && new.Option != nil {
- if old.Option.Tp != new.Option.Tp {
+ if o.Option != nil && n.Option != nil {
+ if o.Option.Tp != n.Option.Tp {
return false
}
}
- if !isKeyPartEqual(old.Keys, new.Keys) {
+ if !isKeyPartEqual(o.Keys, n.Keys) {
return false
}
- if !isIndexOptionEqual(old.Option, new.Option) {
+ if !isIndexOptionEqual(o.Option, n.Option) {
return false
}
return true
}
// isKeyPartEqual returns true if two key parts are the same.
-func isKeyPartEqual(old, new []*ast.IndexPartSpecification) bool {
- if len(old) != len(new) {
+func isKeyPartEqual(o, n []*ast.IndexPartSpecification) bool {
+ if len(o) != len(n) {
return false
}
// key_part: {col_name [(length)] | (expr)} [ASC | DESC]
- for idx, oldKeyPart := range old {
- newKeyPart := new[idx]
+ for idx, oldKeyPart := range o {
+ newKeyPart := n[idx]
if (oldKeyPart.Column == nil) != (newKeyPart.Column == nil) {
return false
}
@@ -1659,7 +1659,7 @@ func isKeyPartEqual(old, new []*ast.IndexPartSpecification) bool {
}
// isIndexOptionEqual returns true if two index options are the same.
-func isIndexOptionEqual(old, new *ast.IndexOption) bool {
+func isIndexOptionEqual(o, n *ast.IndexOption) bool {
// index_option: {
// KEY_BLOCK_SIZE [=] value
// | index_type
@@ -1669,25 +1669,25 @@ func isIndexOptionEqual(old, new *ast.IndexOption) bool {
// |ENGINE_ATTRIBUTE [=] 'string'
// |SECONDARY_ENGINE_ATTRIBUTE [=] 'string'
// }
- if (old == nil) != (new == nil) {
+ if (o == nil) != (n == nil) {
return false
}
- if old == nil && new == nil {
+ if o == nil && n == nil {
return true
}
- if old.KeyBlockSize != new.KeyBlockSize {
+ if o.KeyBlockSize != n.KeyBlockSize {
return false
}
- if old.Tp != new.Tp {
+ if o.Tp != n.Tp {
return false
}
- if old.ParserName.O != new.ParserName.O {
+ if o.ParserName.O != n.ParserName.O {
return false
}
- if old.Comment != new.Comment {
+ if o.Comment != n.Comment {
return false
}
- if old.Visibility != new.Visibility {
+ if o.Visibility != n.Visibility {
return false
}
// TODO(zp): support ENGINE_ATTRIBUTE and SECONDARY_ENGINE_ATTRIBUTE.
@@ -1695,56 +1695,56 @@ func isIndexOptionEqual(old, new *ast.IndexOption) bool {
}
// isForeignKeyEqual returns true if two foreign keys are the same.
-func isForeignKeyConstraintEqual(old, new *ast.Constraint) bool {
+func isForeignKeyConstraintEqual(o, n *ast.Constraint) bool {
// FOREIGN KEY [index_name] (index_col_name,...) reference_definition
- if !strings.EqualFold(old.Name, new.Name) {
+ if !strings.EqualFold(o.Name, n.Name) {
return false
}
- if !isKeyPartEqual(old.Keys, new.Keys) {
+ if !isKeyPartEqual(o.Keys, n.Keys) {
return false
}
- if !isReferenceDefinitionEqual(old.Refer, new.Refer) {
+ if !isReferenceDefinitionEqual(o.Refer, n.Refer) {
return false
}
return true
}
// isReferenceDefinitionEqual returns true if two reference definitions are the same.
-func isReferenceDefinitionEqual(old, new *ast.ReferenceDef) bool {
+func isReferenceDefinitionEqual(o, n *ast.ReferenceDef) bool {
// reference_definition:
// REFERENCES tbl_name (index_col_name,...)
// [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
// [ON DELETE reference_option]
// [ON UPDATE reference_option]
- if old.Table.Name.String() != new.Table.Name.String() {
+ if o.Table.Name.String() != n.Table.Name.String() {
return false
}
- if len(old.IndexPartSpecifications) != len(new.IndexPartSpecifications) {
+ if len(o.IndexPartSpecifications) != len(n.IndexPartSpecifications) {
return false
}
- for idx, oldIndexColName := range old.IndexPartSpecifications {
- newIndexColName := new.IndexPartSpecifications[idx]
+ for idx, oldIndexColName := range o.IndexPartSpecifications {
+ newIndexColName := n.IndexPartSpecifications[idx]
if oldIndexColName.Column.Name.String() != newIndexColName.Column.Name.String() {
return false
}
}
- if old.Match != new.Match {
+ if o.Match != n.Match {
return false
}
- if (old.OnDelete == nil) != (new.OnDelete == nil) {
+ if (o.OnDelete == nil) != (n.OnDelete == nil) {
return false
}
- if old.OnDelete != nil && new.OnDelete != nil && old.OnDelete.ReferOpt != new.OnDelete.ReferOpt {
+ if o.OnDelete != nil && n.OnDelete != nil && o.OnDelete.ReferOpt != n.OnDelete.ReferOpt {
return false
}
- if (old.OnUpdate == nil) != (new.OnUpdate == nil) {
+ if (o.OnUpdate == nil) != (n.OnUpdate == nil) {
return false
}
- if old.OnUpdate != nil && new.OnUpdate != nil && old.OnUpdate.ReferOpt != new.OnUpdate.ReferOpt {
+ if o.OnUpdate != nil && n.OnUpdate != nil && o.OnUpdate.ReferOpt != n.OnUpdate.ReferOpt {
return false
}
return true
@@ -1764,23 +1764,23 @@ func trimParentheses(expr ast.ExprNode) ast.ExprNode {
}
// isCheckConstraintEqual returns true if two check constraints are the same.
-func isCheckConstraintEqual(old, new *ast.Constraint) bool {
+func isCheckConstraintEqual(o, n *ast.Constraint) bool {
// check_constraint_definition:
// [CONSTRAINT [symbol]] CHECK (expr) [[NOT] ENFORCED]
- if !strings.EqualFold(old.Name, new.Name) {
+ if !strings.EqualFold(o.Name, n.Name) {
return false
}
- if old.Enforced != new.Enforced {
+ if o.Enforced != n.Enforced {
return false
}
- oldExpr, err := toString(trimParentheses(old.Expr))
+ oldExpr, err := toString(trimParentheses(o.Expr))
if err != nil {
slog.Error("failed to convert old check constraint expression to string", log.BBError(err))
return false
}
- newExpr, err := toString(trimParentheses(new.Expr))
+ newExpr, err := toString(trimParentheses(n.Expr))
if err != nil {
slog.Error("failed to convert new check constraint expression to string", log.BBError(err))
return false
@@ -1789,7 +1789,7 @@ func isCheckConstraintEqual(old, new *ast.Constraint) bool {
}
// diffTableOptions returns the diff of two table options, returns nil if they are the same.
-func diffTableOptions(tableName *ast.TableName, old, new []*ast.TableOption) *ast.AlterTableStmt {
+func diffTableOptions(tableName *ast.TableName, o, n []*ast.TableOption) *ast.AlterTableStmt {
// https://dev.mysql.com/doc/refman/8.0/en/create-table.html
// table_option: {
// AUTOEXTEND_SIZE [=] value
@@ -1825,8 +1825,8 @@ func diffTableOptions(tableName *ast.TableName, old, new []*ast.TableOption) *as
// }
// We use map to record the table options, so we can easily find the difference.
- oldOptionsMap := buildTableOptionMap(old)
- newOptionsMap := buildTableOptionMap(new)
+ oldOptionsMap := buildTableOptionMap(o)
+ newOptionsMap := buildTableOptionMap(n)
var options []*ast.TableOption
for oldTp, oldOption := range oldOptionsMap {
@@ -2002,77 +2002,77 @@ func dropTableOption(option *ast.TableOption) *ast.TableOption {
// isTableOptionValEqual compare the two table options value, if they are equal, returns true.
// Caller need to ensure the two table options are not nil and the type is the same.
-func isTableOptionValEqual(old, new *ast.TableOption) bool {
- switch old.Tp {
+func isTableOptionValEqual(o, n *ast.TableOption) bool {
+ switch o.Tp {
case ast.TableOptionAutoIncrement:
// You cannot reset the counter to a value less than or equal to the value that is currently in use.
// For both InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column,
// the value is reset to the current maximum AUTO_INCREMENT column value plus one.
// https://dev.mysql.com/doc/refman/8.0/en/alter-table.html
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionAvgRowLength:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionCharset:
- if old.Default != new.Default {
+ if o.Default != n.Default {
return false
}
- if old.Default && new.Default {
+ if o.Default && n.Default {
return true
}
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionCollate:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionCheckSum:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionComment:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionCompression:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionConnection:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionDataDirectory:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionIndexDirectory:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionDelayKeyWrite:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionEncryption:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionEngine:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionInsertMethod:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionKeyBlockSize:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionMaxRows:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionMinRows:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionPackKeys:
// TiDB doesn't support this, and the restore will always write "DEFAULT".
// The parser will ignore it. So we can only ignore it here.
// https://github.com/pingcap/tidb/blob/master/parser/parser.y#L11661
- return old.Default == new.Default
+ return o.Default == n.Default
case ast.TableOptionPassword:
// mysqldump will not dump the password, so we just return false here.
return false
case ast.TableOptionRowFormat:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionStatsAutoRecalc:
// TiDB parser will ignore the DEFAULT value. So we just can compare the UINT value here.
// https://github.com/pingcap/tidb/blob/master/parser/parser.y#L11599
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionStatsPersistent:
// TiDB parser doesn't support this, it only assign the type without any value.
// https://github.com/pingcap/tidb/blob/master/parser/parser.y#L11595
return true
case ast.TableOptionStatsSamplePages:
- return old.UintValue == new.UintValue
+ return o.UintValue == n.UintValue
case ast.TableOptionTablespace:
- return old.StrValue == new.StrValue
+ return o.StrValue == n.StrValue
case ast.TableOptionUnion:
- oldTableNames := old.TableNames
- newTableNames := new.TableNames
+ oldTableNames := o.TableNames
+ newTableNames := n.TableNames
if len(oldTableNames) != len(newTableNames) {
return false
}
@@ -2088,7 +2088,7 @@ func isTableOptionValEqual(old, new *ast.TableOption) bool {
}
// isViewEqual checks whether two views with same name are equal.
-func (diff *diffNode) isViewEqual(old, new *ast.CreateViewStmt) bool {
+func (diff *diffNode) isViewEqual(o, n *ast.CreateViewStmt) bool {
// CREATE
// [OR REPLACE]
// [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
@@ -2100,24 +2100,24 @@ func (diff *diffNode) isViewEqual(old, new *ast.CreateViewStmt) bool {
// We can easily replace view statement by using `CREATE OR REPLACE VIEW` statement to replace the old one.
// So we don't need to compare each part, just compare the restore string.
if diff.ignoreCaseSensitive {
- oldViewStr, err := toLowerNameString(old)
+ oldViewStr, err := toLowerNameString(o)
if err != nil {
slog.Error("fail to convert old view to string", log.BBError(err))
return false
}
- newViewStr, err := toLowerNameString(new)
+ newViewStr, err := toLowerNameString(n)
if err != nil {
slog.Error("fail to convert new view to string", log.BBError(err))
return false
}
return oldViewStr == newViewStr
}
- oldViewStr, err := toString(old)
+ oldViewStr, err := toString(o)
if err != nil {
slog.Error("fail to convert old view to string", log.BBError(err))
return false
}
- newViewStr, err := toString(new)
+ newViewStr, err := toString(n)
if err != nil {
slog.Error("fail to convert new view to string", log.BBError(err))
return false
diff --git a/backend/plugin/schema/clickhouse/state.go b/backend/plugin/schema/clickhouse/state.go
index 90c4fa0988..649368240c 100644
--- a/backend/plugin/schema/clickhouse/state.go
+++ b/backend/plugin/schema/clickhouse/state.go
@@ -149,28 +149,6 @@ func convertToTableState(id int, table *storepb.TableMetadata) *tableState {
return state
}
-type indexState struct {
- id int
- name string
- keys []string
- lengths []int64
- primary bool
- unique bool
- tp string
-}
-
-func convertToIndexState(id int, index *storepb.IndexMetadata) *indexState {
- return &indexState{
- id: id,
- name: index.Name,
- keys: index.Expressions,
- lengths: index.KeyLength,
- primary: index.Primary,
- unique: index.Unique,
- tp: index.Type,
- }
-}
-
type defaultValue interface {
toString() string
}