Skip to content

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

chore: hello1 (#16940)

Danny Xu5252f44f033f
diff --git a/action/command/azure_devops.go b/action/command/azure_devops.go
index e8c7b7c4ba..8973b32cef 100644
--- a/action/command/azure_devops.go
+++ b/action/command/azure_devops.go
@@ -33,6 +33,8 @@ func loggingReleaseChecks(resp *v1pb.CheckReleaseResponse) error {
hasWarning = true
case v1pb.Advice_ERROR:
hasError = true
+ default:
+ // Handle other advice statuses (SUCCESS, UNSPECIFIED) - no action needed
}
position := fmt.Sprintf("line %d", common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine())))
diff --git a/action/command/check.go b/action/command/check.go
index c9a1b333bd..c482dded0d 100644
--- a/action/command/check.go
+++ b/action/command/check.go
@@ -86,6 +86,8 @@ func runCheck(w *world.World) func(*cobra.Command, []string) error {
if err := createBitbucketReport(checkReleaseResponse); err != nil {
return err
}
+ default:
+ // Unknown platform, no specific output handling
}
// Evaluate check results and return errors based on CheckRelease flag
@@ -101,6 +103,8 @@ func runCheck(w *world.World) func(*cobra.Command, []string) error {
errorCount++
case v1pb.Advice_WARNING:
warningCount++
+ default:
+ // Other advice statuses don't affect counts
}
}
}
diff --git a/action/command/file.go b/action/command/file.go
index 966a68f647..bf7120cceb 100644
--- a/action/command/file.go
+++ b/action/command/file.go
@@ -23,12 +23,15 @@ func getReleaseFiles(w *world.World, pattern string) ([]*v1pb.Release_File, erro
return nil, err
}
base := filepath.Base(m)
- t := v1pb.Release_File_DDL
+ var t v1pb.Release_File_ChangeType
switch {
case strings.HasSuffix(base, "dml"):
t = v1pb.Release_File_DML
case strings.HasSuffix(base, "ghost"):
t = v1pb.Release_File_DDL_GHOST
+ default:
+ // Default to DDL for files without recognized suffixes
+ t = v1pb.Release_File_DDL
}
version := extractVersion(base)
diff --git a/action/command/rollout.go b/action/command/rollout.go
index f7dc17aae8..1d0af81a40 100644
--- a/action/command/rollout.go
+++ b/action/command/rollout.go
@@ -161,8 +161,12 @@ func runAndWaitForPlanChecks(ctx context.Context, w *world.World, client *Client
errorCount++
case v1pb.PlanCheckRun_Result_WARNING:
warningCount++
+ default:
+ // Other result statuses don't affect counts
}
}
+ default:
+ // Other run statuses don't affect counts
}
}
if failedCount > 0 {
@@ -384,6 +388,9 @@ func waitForRollout(ctx context.Context, w *world.World, client *Client, pending
done = false
case v1pb.Task_DONE:
case v1pb.Task_SKIPPED:
+ default:
+ // Treat unknown task status as not done to be safe
+ done = false
}
}
if foundFailed {
diff --git a/action/common/common.go b/action/common/common.go
index 4f923ac37a..44b9355a9b 100644
--- a/action/common/common.go
+++ b/action/common/common.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
func ConvertLineToActionLine(line int) int {
diff --git a/action/github/github.go b/action/github/github.go
index e5aaa0c3fc..24afe01660 100644
--- a/action/github/github.go
+++ b/action/github/github.go
@@ -110,6 +110,8 @@ func buildCommentMessage(resp *v1pb.CheckReleaseResponse) string {
errorCount++
case v1pb.Advice_STATUS_UNSPECIFIED, v1pb.Advice_SUCCESS:
// No action needed
+ default:
+ // Ignore unknown advice statuses
}
}
}
@@ -146,6 +148,8 @@ func buildCommentMessage(resp *v1pb.CheckReleaseResponse) string {
errorCount++
case v1pb.Advice_STATUS_UNSPECIFIED, v1pb.Advice_SUCCESS:
// No action needed
+ default:
+ // Ignore unknown advice statuses
}
}
counts := []string{}
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index edd62f3d28..0ad6c7a203 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -387,6 +387,8 @@ func getAuthContext(fullMethod string) (*common.AuthContext, error) {
authMethod = common.AuthMethodIAM
case v1pb.AuthMethod_CUSTOM:
authMethod = common.AuthMethodCustom
+ default:
+ return nil, errs.Errorf("unknown auth method %v for full method name %q", am, fullMethod)
}
auditAny := proto.GetExtension(md, v1pb.E_Audit)
audit, ok := auditAny.(bool)
diff --git a/backend/common/const.go b/backend/common/const.go
index 87c10e200c..c44ce5616a 100644
--- a/backend/common/const.go
+++ b/backend/common/const.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
const (
diff --git a/backend/common/db_schema.go b/backend/common/db_schema.go
index 21a581e3cf..79d657da2a 100644
--- a/backend/common/db_schema.go
+++ b/backend/common/db_schema.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
import (
diff --git a/backend/common/error.go b/backend/common/error.go
index 391f196b9f..716fa0cff4 100644
--- a/backend/common/error.go
+++ b/backend/common/error.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
import (
diff --git a/backend/common/position_test.go b/backend/common/position_test.go
index 9d6021cf95..9264f92fd1 100644
--- a/backend/common/position_test.go
+++ b/backend/common/position_test.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
import (
diff --git a/backend/common/retry.go b/backend/common/retry.go
index 93cc6a6b67..e474dccc5e 100644
--- a/backend/common/retry.go
+++ b/backend/common/retry.go
@@ -1,3 +1,4 @@
+//nolint:revive
package common
import (
diff --git a/backend/common/util.go b/backend/common/util.go
index 846fc7459d..cf0fd5b91e 100644
--- a/backend/common/util.go
+++ b/backend/common/util.go
@@ -221,6 +221,8 @@ func IsNil(val any) bool {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer,
reflect.UnsafePointer, reflect.Interface, reflect.Slice:
return v.IsNil()
+ default:
+ // Other types cannot be nil
}
return false
diff --git a/backend/common/util_test.go b/backend/common/util_test.go
index 93291c5487..007f89a5ae 100644
--- a/backend/common/util_test.go
+++ b/backend/common/util_test.go
@@ -218,7 +218,7 @@ func TestNormalizeExternalURL(t *testing.T) {
}
} else {
if tt.wantErr {
- t.Errorf("expect error")
+ t.Error("expect error")
} else if tt.want != g {
t.Errorf("expect %s, got %s", tt.want, g)
}
diff --git a/backend/component/masker/masker.go b/backend/component/masker/masker.go
index faea8e1798..84e343ab9d 100644
--- a/backend/component/masker/masker.go
+++ b/backend/component/masker/masker.go
@@ -745,6 +745,9 @@ func (m *InnerOuterMasker) Mask(data *MaskData) *v1pb.RowValue {
maskedData = m.maskInner([]rune(unmaskedData))
case InnerOuterMaskerTypeOuter:
maskedData = m.maskOuter([]rune(unmaskedData))
+ default:
+ // For undefined or unknown masker types, return the original data unmasked
+ maskedData = unmaskedData
}
return &v1pb.RowValue{
diff --git a/backend/component/secret/secret.go b/backend/component/secret/secret.go
index 0f6aec9f1b..0d30ed9291 100644
--- a/backend/component/secret/secret.go
+++ b/backend/component/secret/secret.go
@@ -27,6 +27,8 @@ func ReplaceExternalSecret(ctx context.Context, secret string, externalSecret *s
return getSecretFromVault(ctx, externalSecret)
case storepb.DataSourceExternalSecret_GCP_SECRET_MANAGER:
return getSecretFromGCP(ctx, externalSecret)
+ default:
+ return "", errors.Errorf("unsupported secret type: %v", externalSecret.SecretType)
}
}
diff --git a/backend/component/secret/vault.go b/backend/component/secret/vault.go
index 48a2bdac6d..6ee624f162 100644
--- a/backend/component/secret/vault.go
+++ b/backend/component/secret/vault.go
@@ -36,6 +36,8 @@ func getVaultClient(ctx context.Context, externalSecret *storepb.DataSourceExter
appRoleSecret.FromString = role.SecretId
case storepb.DataSourceExternalSecret_AppRoleAuthOption_ENVIRONMENT:
appRoleSecret.FromEnv = role.SecretId
+ default:
+ return nil, errors.Errorf("unsupported app role auth type: %v", role.Type)
}
opts := []approle.LoginOption{}
@@ -58,6 +60,8 @@ func getVaultClient(ctx context.Context, externalSecret *storepb.DataSourceExter
return nil, errors.Wrapf(err, "failed to login with approle: %v", err.Error())
}
token = resp.Auth.ClientToken
+ default:
+ return nil, errors.Errorf("unsupported auth type: %v", externalSecret.AuthType)
}
client.SetToken(token)
diff --git a/backend/component/sheet/sheet.go b/backend/component/sheet/sheet.go
index 17b2febbea..2024b9fbbc 100644
--- a/backend/component/sheet/sheet.go
+++ b/backend/component/sheet/sheet.go
@@ -239,6 +239,8 @@ func syntaxCheck(dbType storepb.Engine, statement string) (any, []*storepb.Advic
return partiqlSyntaxCheck(statement)
case storepb.Engine_COCKROACHDB:
return cockroachdbSyntaxCheck(statement)
+ default:
+ // Return default advice for unsupported database types
}
return nil, []*storepb.Advice{
{
diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.go
index 009f3dfe44..d1a62c7857 100644
--- a/backend/component/webhook/manager.go
+++ b/backend/component/webhook/manager.go
@@ -102,6 +102,9 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
case "CANCELED":
title = "Issue canceled"
titleZh = "工单取消"
+ default:
+ title = "Issue status changed"
+ titleZh = "工单状态变更"
}
case common.EventTypeIssueCommentCreate:
@@ -188,6 +191,8 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
usersGetters = append(usersGetters, getUsersFromIssueLastApprover(m.store, e.Issue.Approval))
case "roles/CREATOR":
usersGetters = append(usersGetters, getUsersFromUsers(e.Issue.Creator))
+ default:
+ // Skip unknown issue roles
}
}
}
@@ -260,6 +265,9 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
mentions = append(mentions, phone)
}
}
+ default:
+ // Unsupported event type
+ return nil, errors.Errorf("unsupported activity type %q for generating webhook context", e.Type)
}
var mentionEndUsers []*store.UserMessage
diff --git a/backend/enterprise/plugin/aws/aws.go b/backend/enterprise/plugin/aws/aws.go
index 726161a584..d5a7ebb959 100644
--- a/backend/enterprise/plugin/aws/aws.go
+++ b/backend/enterprise/plugin/aws/aws.go
@@ -106,6 +106,8 @@ func (p *Provider) LoadSubscription(ctx context.Context) *v1pb.Subscription {
subscription.Instances = subscription.ActiveInstances
case "seat":
subscription.Seats = int32(aws.ToInt64(entitlement.MaxCount))
+ default:
+ // Ignore unknown entitlement names
}
}
diff --git a/backend/plugin/advisor/catalog/state.go b/backend/plugin/advisor/catalog/state.go
index e2a3c52b24..59830933ac 100644
--- a/backend/plugin/advisor/catalog/state.go
+++ b/backend/plugin/advisor/catalog/state.go
@@ -96,6 +96,8 @@ func newTableState(t *storepb.TableMetadata, context *FinderContext) *TableState
switch context.EngineType {
case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE:
columnName = strings.ToLower(columnName)
+ default:
+ // For other engine types, keep the original column name without normalization
}
table.columnSet[columnName] = newColumnState(column, i+1)
}
@@ -105,6 +107,8 @@ func newTableState(t *storepb.TableMetadata, context *FinderContext) *TableState
switch context.EngineType {
case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE:
indexName = strings.ToLower(indexName)
+ default:
+ // For other engine types, keep the original index name without normalization
}
table.indexSet[indexName] = newIndexState(index)
}
@@ -210,6 +214,8 @@ func (d *DatabaseState) FindIndex(find *IndexFind) (string, *IndexState) {
switch d.dbType {
case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE:
find.IndexName = strings.ToLower(find.IndexName)
+ default:
+ // For other engine types, keep the original index name without normalization
}
// There are two cases to find a index:
// 1. find an index in specific table. e.g. MySQL and TiDB.
@@ -313,6 +319,8 @@ func (d *DatabaseState) FindColumn(find *ColumnFind) *ColumnState {
switch d.dbType {
case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE:
find.ColumnName = strings.ToLower(find.ColumnName)
+ default:
+ // For other engine types, keep the original column name without normalization
}
schema, exists := d.schemaSet[find.SchemaName]
if !exists {
@@ -537,6 +545,8 @@ func (col *ColumnState) HasDefault() bool {
switch strings.ToLower(col.Type()) {
case "serial", "smallserial", "bigserial":
return true
+ default:
+ // For other column types, check if defaultValue is not nil
}
return col.defaultValue != nil
}
diff --git a/backend/plugin/advisor/catalog/walk_through_for_mysql.go b/backend/plugin/advisor/catalog/walk_through_for_mysql.go
index 57a6373078..c5a3ad1e28 100644
--- a/backend/plugin/advisor/catalog/walk_through_for_mysql.go
+++ b/backend/plugin/advisor/catalog/walk_through_for_mysql.go
@@ -170,6 +170,8 @@ func (l *mysqlListener) EnterCreateTable(ctx *mysql.CreateTableContext) {
l.err = err
return
}
+ default:
+ // Ignore other table element types
}
}
}
@@ -297,6 +299,8 @@ func (l *mysqlListener) EnterAlterTable(ctx *mysql.AlterTableContext) {
l.err = err
return
}
+ default:
+ // Ignore other ADD variations
}
// drop column or key.
case item.DROP_SYMBOL() != nil && item.ALTER_SYMBOL() == nil:
@@ -324,6 +328,8 @@ func (l *mysqlListener) EnterAlterTable(ctx *mysql.AlterTableContext) {
l.err = err
return
}
+ default:
+ // Ignore other DROP variations
}
// modify column.
case item.MODIFY_SYMBOL() != nil && item.ColumnInternalRef() != nil:
@@ -381,6 +387,8 @@ func (l *mysqlListener) EnterAlterTable(ctx *mysql.AlterTableContext) {
l.err = err
return
}
+ default:
+ // Ignore other alter table actions
}
}
}
diff --git a/backend/plugin/advisor/catalog/walk_through_for_pg.go b/backend/plugin/advisor/catalog/walk_through_for_pg.go
index e4395287d0..a9c5b53445 100644
--- a/backend/plugin/advisor/catalog/walk_through_for_pg.go
+++ b/backend/plugin/advisor/catalog/walk_through_for_pg.go
@@ -710,6 +710,8 @@ func (s *SchemaState) pgCreateTableConstraint(t *TableState, constraint *ast.Con
// We do not deal with EXCLUSION constraint.
case ast.ConstraintTypeForeign:
// We do not deal with FOREIGN constraint.
+ default:
+ // For any other constraint types, skip processing
}
return nil
}
diff --git a/backend/plugin/advisor/generator/main.go b/backend/plugin/advisor/generator/main.go
index ad0fdd36c5..0c57d4dc7c 100644
--- a/backend/plugin/advisor/generator/main.go
+++ b/backend/plugin/advisor/generator/main.go
@@ -72,6 +72,8 @@ var (
case lowerMSSQL:
advisorComment = strings.Join(wordList[i+1:], " ")
engineType = lowerMSSQL
+ default:
+ // Continue to next word
}
if advisorComment != "" {
break
@@ -89,6 +91,8 @@ var (
switch token {
case lowerMySQL, lowerPostgreSQL, lowerOracle, lowerSnowflake, lowerMSSQL:
needed = true
+ default:
+ // Not a database engine type
}
}
break
diff --git a/backend/plugin/advisor/mssql/rule_builtin_prior_backup_check.go b/backend/plugin/advisor/mssql/rule_builtin_prior_backup_check.go
index ce6cb16ec1..a5fc7712a7 100644
--- a/backend/plugin/advisor/mssql/rule_builtin_prior_backup_check.go
+++ b/backend/plugin/advisor/mssql/rule_builtin_prior_backup_check.go
@@ -152,6 +152,8 @@ func (r *StatementDisallowMixDMLRule) OnEnter(ctx antlr.ParserRuleContext, nodeT
r.enterUpdateStatement(ctx.(*parser.Update_statementContext))
case NodeTypeDeleteStatement:
r.enterDeleteStatement(ctx.(*parser.Delete_statementContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mssql/rule_column_require.go b/backend/plugin/advisor/mssql/rule_column_require.go
index 51daa6c517..755d89c5b2 100644
--- a/backend/plugin/advisor/mssql/rule_column_require.go
+++ b/backend/plugin/advisor/mssql/rule_column_require.go
@@ -100,6 +100,8 @@ func (r *ColumnRequireRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string
r.enterColumnDefinition(ctx.(*parser.Column_definitionContext))
case NodeTypeAlterTable:
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mssql/rule_migration_compatibility.go b/backend/plugin/advisor/mssql/rule_migration_compatibility.go
index e009e7ebd5..6037b57e9b 100644
--- a/backend/plugin/advisor/mssql/rule_migration_compatibility.go
+++ b/backend/plugin/advisor/mssql/rule_migration_compatibility.go
@@ -102,6 +102,8 @@ func (r *MigrationCompatibilityRule) OnEnter(ctx antlr.ParserRuleContext, nodeTy
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
case "Execute_body":
r.enterExecuteBody(ctx.(*parser.Execute_bodyContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mssql/rule_statement_disallow_cross_db_queries.go b/backend/plugin/advisor/mssql/rule_statement_disallow_cross_db_queries.go
index 2f24630874..eb2d3c8a0f 100644
--- a/backend/plugin/advisor/mssql/rule_statement_disallow_cross_db_queries.go
+++ b/backend/plugin/advisor/mssql/rule_statement_disallow_cross_db_queries.go
@@ -72,6 +72,8 @@ func (r *DisallowCrossDBQueriesRule) OnEnter(ctx antlr.ParserRuleContext, nodeTy
r.enterTableSourceItem(ctx.(*parser.Table_source_itemContext))
case "Use_statement":
r.enterUseStatement(ctx.(*parser.Use_statementContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mssql/rule_table_require_pk.go b/backend/plugin/advisor/mssql/rule_table_require_pk.go
index 2a9f8e67f8..e64bc6ce72 100644
--- a/backend/plugin/advisor/mssql/rule_table_require_pk.go
+++ b/backend/plugin/advisor/mssql/rule_table_require_pk.go
@@ -95,6 +95,8 @@ func (r *TableRequirePkRule) OnEnter(ctx antlr.ParserRuleContext, nodeType strin
r.enterColumnDefTableConstraints(ctx.(*parser.Column_def_table_constraintsContext))
case NodeTypeAlterTable:
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_column_auto_increment_must_integer.go b/backend/plugin/advisor/mysql/rule_column_auto_increment_must_integer.go
index 2ee9ae1184..6d4875a5dd 100644
--- a/backend/plugin/advisor/mysql/rule_column_auto_increment_must_integer.go
+++ b/backend/plugin/advisor/mysql/rule_column_auto_increment_must_integer.go
@@ -83,6 +83,8 @@ func (r *ColumnAutoIncrementMustIntegerRule) OnEnter(ctx antlr.ParserRuleContext
r.checkCreateTable(ctx.(*mysql.CreateTableContext))
case NodeTypeAlterTable:
r.checkAlterTable(ctx.(*mysql.AlterTableContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -145,6 +147,8 @@ func (r *ColumnAutoIncrementMustIntegerRule) checkAlterTable(ctx *mysql.AlterTab
_, _, columnName := mysqlparser.NormalizeMySQLColumnName(tableElement.ColumnDefinition().ColumnName())
r.checkFieldDefinition(tableName, columnName, tableElement.ColumnDefinition().FieldDefinition())
}
+ default:
+ // Ignore other ADD column syntax variations
}
// change column.
case item.CHANGE_SYMBOL() != nil && item.ColumnInternalRef() != nil && item.Identifier() != nil && item.FieldDefinition() != nil:
@@ -160,6 +164,8 @@ func (r *ColumnAutoIncrementMustIntegerRule) checkAlterTable(ctx *mysql.AlterTab
}
columnName = mysqlparser.NormalizeMySQLColumnInternalRef(item.ColumnInternalRef())
r.checkFieldDefinition(tableName, columnName, item.FieldDefinition())
+ default:
+ // Ignore other alter table actions
}
}
}
diff --git a/backend/plugin/advisor/mysql/rule_index_type_allow_list.go b/backend/plugin/advisor/mysql/rule_index_type_allow_list.go
index a31ba9c13d..2bc8c26773 100644
--- a/backend/plugin/advisor/mysql/rule_index_type_allow_list.go
+++ b/backend/plugin/advisor/mysql/rule_index_type_allow_list.go
@@ -89,6 +89,8 @@ func (r *IndexTypeAllowListRule) OnEnter(ctx antlr.ParserRuleContext, nodeType s
r.checkAlterTable(ctx.(*mysql.AlterTableContext))
case NodeTypeCreateIndex:
r.checkCreateIndex(ctx.(*mysql.CreateIndexContext))
+ default:
+ // No action required for other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_statement_maximum_join_table_count.go b/backend/plugin/advisor/mysql/rule_statement_maximum_join_table_count.go
index e1694da1dd..6bce398018 100644
--- a/backend/plugin/advisor/mysql/rule_statement_maximum_join_table_count.go
+++ b/backend/plugin/advisor/mysql/rule_statement_maximum_join_table_count.go
@@ -90,6 +90,8 @@ func (r *StatementMaximumJoinTableCountRule) OnEnter(ctx antlr.ParserRuleContext
r.text = queryCtx.GetParser().GetTokenStream().GetTextFromRuleContext(queryCtx)
case NodeTypeJoinedTable:
r.checkJoinedTable(ctx.(*mysql.JoinedTableContext))
+ default:
+ // No action required for other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go b/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go
index 4e1b7dae00..8177357972 100644
--- a/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go
+++ b/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go
@@ -85,6 +85,8 @@ func (r *TableDisallowTriggerRule) OnEnter(ctx antlr.ParserRuleContext, nodeType
r.text = queryCtx.GetParser().GetTokenStream().GetTextFromRuleContext(queryCtx)
case NodeTypeCreateTrigger:
r.checkCreateTrigger(ctx.(*mysql.CreateTriggerContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_table_no_fk.go b/backend/plugin/advisor/mysql/rule_table_no_fk.go
index 7ca4813889..24fb1267a1 100644
--- a/backend/plugin/advisor/mysql/rule_table_no_fk.go
+++ b/backend/plugin/advisor/mysql/rule_table_no_fk.go
@@ -83,6 +83,8 @@ func (r *TableNoFKRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string) er
r.checkCreateTable(ctx.(*mysql.CreateTableContext))
case NodeTypeAlterTable:
r.checkAlterTable(ctx.(*mysql.AlterTableContext))
+ default:
+ // No action required for other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_table_text_fields_total_length.go b/backend/plugin/advisor/mysql/rule_table_text_fields_total_length.go
index b054c61ffb..b0f2cea176 100644
--- a/backend/plugin/advisor/mysql/rule_table_text_fields_total_length.go
+++ b/backend/plugin/advisor/mysql/rule_table_text_fields_total_length.go
@@ -91,6 +91,8 @@ func (r *TableTextFieldsTotalLengthRule) OnEnter(ctx antlr.ParserRuleContext, no
r.checkCreateTable(ctx.(*mysql.CreateTableContext))
case NodeTypeAlterTable:
r.checkAlterTable(ctx.(*mysql.AlterTableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/mysql/rule_view_disallow_create.go b/backend/plugin/advisor/mysql/rule_view_disallow_create.go
index 3f2453068a..67183bb7df 100644
--- a/backend/plugin/advisor/mysql/rule_view_disallow_create.go
+++ b/backend/plugin/advisor/mysql/rule_view_disallow_create.go
@@ -84,6 +84,8 @@ func (r *ViewDisallowCreateRule) OnEnter(ctx antlr.ParserRuleContext, nodeType s
}
case NodeTypeCreateView:
r.checkCreateView(ctx.(*mysql.CreateViewContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
index 4042a666f5..c4e464ccf3 100644
--- a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
+++ b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
@@ -123,6 +123,8 @@ func (checker *disallowOfflineDdlChecker) EnterAlterTable(ctx *mysql.AlterTableC
if item.TableConstraintDef().PRIMARY_SYMBOL() != nil && item.TableConstraintDef().KEY_SYMBOL() != nil {
checker.advice(ctx, "Adding primary keys")
}
+ default:
+ // Skip other ADD operations
}
// modify column
case item.MODIFY_SYMBOL() != nil && item.ColumnInternalRef() != nil && item.FieldDefinition() != nil:
@@ -148,10 +150,14 @@ func (checker *disallowOfflineDdlChecker) EnterAlterTable(ctx *mysql.AlterTableC
// drop primary key
case item.PRIMARY_SYMBOL() != nil && item.KEY_SYMBOL() != nil:
checker.advice(ctx, "Dropping primary keys")
+ default:
+ // Skip other DROP operations
}
// change charset or collate
case item.Charset() != nil || item.Collate() != nil:
checker.advice(ctx, "Changing charset or collate")
+ default:
+ // Skip other ALTER TABLE operations
}
}
}
@@ -184,6 +190,8 @@ func (checker *disallowOfflineDdlChecker) EnterAlterPartition(ctx *mysql.AlterPa
checker.advice(ctx, "Dropping partitions")
case ctx.TRUNCATE_SYMBOL() != nil:
checker.advice(ctx, "Truncating partitions")
+ default:
+ // Skip other partition operations
}
}
diff --git a/backend/plugin/advisor/oracle/rule_column_no_null.go b/backend/plugin/advisor/oracle/rule_column_no_null.go
index b136a8593e..da399defed 100644
--- a/backend/plugin/advisor/oracle/rule_column_no_null.go
+++ b/backend/plugin/advisor/oracle/rule_column_no_null.go
@@ -90,6 +90,8 @@ func (r *ColumnNoNullRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string)
r.handleAlterTable(ctx.(*parser.Alter_tableContext))
case "Modify_col_properties":
r.handleModifyColProperties(ctx.(*parser.Modify_col_propertiesContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -103,6 +105,8 @@ func (r *ColumnNoNullRule) OnExit(_ antlr.ParserRuleContext, nodeType string) er
r.columnID = ""
case "Alter_table":
r.tableName = ""
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/oracle/rule_column_require.go b/backend/plugin/advisor/oracle/rule_column_require.go
index 22e7b5c3ef..88b4be5f40 100644
--- a/backend/plugin/advisor/oracle/rule_column_require.go
+++ b/backend/plugin/advisor/oracle/rule_column_require.go
@@ -96,6 +96,8 @@ func (r *ColumnRequireRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string
r.handleDropColumnClause(ctx.(*parser.Drop_column_clauseContext))
case "Rename_column_clause":
r.handleRenameColumnClause(ctx.(*parser.Rename_column_clauseContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -107,6 +109,8 @@ func (r *ColumnRequireRule) OnExit(ctx antlr.ParserRuleContext, nodeType string)
r.handleCreateTableExit(ctx.(*parser.Create_tableContext))
case "Alter_table":
r.handleAlterTableExit(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/oracle/rule_column_require_default.go b/backend/plugin/advisor/oracle/rule_column_require_default.go
index a15863b961..57b84348dd 100644
--- a/backend/plugin/advisor/oracle/rule_column_require_default.go
+++ b/backend/plugin/advisor/oracle/rule_column_require_default.go
@@ -83,6 +83,8 @@ func (r *ColumnRequireDefaultRule) OnEnter(ctx antlr.ParserRuleContext, nodeType
r.handleAlterTable(ctx.(*parser.Alter_tableContext))
case "Modify_col_properties":
r.handleModifyColProperties(ctx.(*parser.Modify_col_propertiesContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -94,6 +96,8 @@ func (r *ColumnRequireDefaultRule) OnExit(_ antlr.ParserRuleContext, nodeType st
r.tableName = ""
case "Alter_table":
r.tableName = ""
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go b/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go
index 3afed64b6e..6b74eae1a6 100644
--- a/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go
+++ b/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go
@@ -83,6 +83,8 @@ func (r *ColumnTypeDisallowListRule) OnEnter(ctx antlr.ParserRuleContext, nodeTy
r.handleColumnDefinition(ctx.(*parser.Column_definitionContext))
case "Modify_col_properties":
r.handleModifyColProperties(ctx.(*parser.Modify_col_propertiesContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go b/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go
index f41ad7913e..94acc00eb4 100644
--- a/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go
+++ b/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go
@@ -74,6 +74,8 @@ func (r *WhereRequireForUpdateDeleteRule) OnEnter(ctx antlr.ParserRuleContext, n
r.handleUpdateStatement(ctx.(*parser.Update_statementContext))
case "Delete_statement":
r.handleDeleteStatement(ctx.(*parser.Delete_statementContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
index e84a494edf..b08cdbb27d 100644
--- a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
+++ b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
@@ -81,6 +81,8 @@ func (checker *indexNoDuplicateColumnChecker) Visit(node ast.Node) ast.Visitor {
line: checker.line,
})
}
+ default:
+ // Other constraint types are not checked for duplicate columns
}
}
case *ast.CreateIndexStmt:
@@ -112,6 +114,8 @@ func (checker *indexNoDuplicateColumnChecker) Visit(node ast.Node) ast.Visitor {
line: checker.line,
})
}
+ default:
+ // Other constraint types are not checked for duplicate columns
}
default:
continue
diff --git a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go b/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
index aa82026252..291b42666c 100644
--- a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
+++ b/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
@@ -159,12 +159,17 @@ func createIndex(in ast.Node) bool {
switch constraint.Type {
case ast.ConstraintTypePrimary, ast.ConstraintTypeUnique:
return true
+ default:
+ // Other constraint types don't count as indexes
}
}
case *ast.ConstraintDef:
switch node.Type {
case ast.ConstraintTypePrimary, ast.ConstraintTypeUnique:
return true
+ default:
+ // Other constraint types don't count as indexes
+ return false
}
}
return false
diff --git a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
index 8194d80ec6..ca64e20181 100644
--- a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
+++ b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
@@ -199,6 +199,8 @@ func (checker *namingPKConventionChecker) getPrimaryKeyMetadata(schemaName strin
metaData: metaData,
}
}
+ default:
+ // Not a primary key constraint, return nil
}
return nil
}
diff --git a/backend/plugin/advisor/snowflake/rule_column_require.go b/backend/plugin/advisor/snowflake/rule_column_require.go
index e51e7b2a91..8af754a4dc 100644
--- a/backend/plugin/advisor/snowflake/rule_column_require.go
+++ b/backend/plugin/advisor/snowflake/rule_column_require.go
@@ -98,6 +98,8 @@ func (r *ColumnRequireRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
case NodeTypeTableColumnAction:
r.enterTableColumnAction(ctx.(*parser.Table_column_actionContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -109,6 +111,8 @@ func (r *ColumnRequireRule) OnExit(ctx antlr.ParserRuleContext, nodeType string)
r.exitCreateTable(ctx.(*parser.Create_tableContext))
case NodeTypeAlterTable:
r.exitAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go b/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go
index 5edda8ac1b..13bcfd3f9a 100644
--- a/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go
+++ b/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go
@@ -80,6 +80,8 @@ func (r *NamingIdentifierNoKeywordRule) OnEnter(ctx antlr.ParserRuleContext, nod
r.enterColumnDeclItemList(ctx.(*parser.Column_decl_item_listContext))
case NodeTypeAlterTable:
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
@@ -89,6 +91,8 @@ func (r *NamingIdentifierNoKeywordRule) OnExit(_ antlr.ParserRuleContext, nodeTy
switch nodeType {
case NodeTypeCreateTable, "Create_table_as_select":
r.currentOriginalTableName = ""
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/snowflake/rule_naming_table.go b/backend/plugin/advisor/snowflake/rule_naming_table.go
index 090b05a619..7f2cf80805 100644
--- a/backend/plugin/advisor/snowflake/rule_naming_table.go
+++ b/backend/plugin/advisor/snowflake/rule_naming_table.go
@@ -84,6 +84,8 @@ func (r *NamingTableRule) OnEnter(ctx antlr.ParserRuleContext, nodeType string)
r.enterCreateTable(ctx.(*parser.Create_tableContext))
case NodeTypeAlterTable:
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/snowflake/rule_naming_table_no_keyword.go b/backend/plugin/advisor/snowflake/rule_naming_table_no_keyword.go
index f716c8315a..95bf62d538 100644
--- a/backend/plugin/advisor/snowflake/rule_naming_table_no_keyword.go
+++ b/backend/plugin/advisor/snowflake/rule_naming_table_no_keyword.go
@@ -73,6 +73,8 @@ func (r *NamingTableNoKeywordRule) OnEnter(ctx antlr.ParserRuleContext, nodeType
r.enterCreateTable(ctx.(*parser.Create_tableContext))
case NodeTypeAlterTable:
r.enterAlterTable(ctx.(*parser.Alter_tableContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go b/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go
index 584f9e9482..4b7a72ad09 100644
--- a/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go
+++ b/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go
@@ -72,6 +72,8 @@ func (r *WhereRequireForUpdateDeleteRule) OnEnter(ctx antlr.ParserRuleContext, n
r.enterUpdateStatement(ctx.(*parser.Update_statementContext))
case NodeTypeDeleteStatement:
r.enterDeleteStatement(ctx.(*parser.Delete_statementContext))
+ default:
+ // Ignore other node types
}
return nil
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go
index 4609e9b2ec..5c3f2b1a6e 100644
--- a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go
+++ b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go
@@ -103,6 +103,8 @@ func (checker *columnAutoIncrementMustIntegerChecker) Enter(in ast.Node) (ast.No
line: node.OriginTextPosition(),
})
}
+ default:
+ // Ignore other alter table specs
}
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
index f77d39a19b..8291abc6a6 100644
--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
@@ -74,6 +74,8 @@ func (checker *columnDisallowChangingTypeChecker) Enter(in ast.Node) (ast.Node,
changeType = checker.changeColumnType(node.Table.Name.O, spec.OldColumnName.Name.O, spec.NewColumns[0].Tp.String())
case ast.AlterTableModifyColumn:
changeType = checker.changeColumnType(node.Table.Name.O, spec.NewColumns[0].Name.Name.O, spec.NewColumns[0].Tp.String())
+ default:
+ // Skip other alter table specification types
}
if changeType {
break
diff --git a/backend/plugin/advisor/tidb/advisor_column_no_null.go b/backend/plugin/advisor/tidb/advisor_column_no_null.go
index e9d8827926..f78a1c80ea 100644
--- a/backend/plugin/advisor/tidb/advisor_column_no_null.go
+++ b/backend/plugin/advisor/tidb/advisor_column_no_null.go
@@ -151,6 +151,8 @@ func (checker *columnNoNullChecker) Enter(in ast.Node) (ast.Node, bool) {
if _, exists := checker.columnSet[col.name()]; !exists {
checker.columnSet[col.name()] = col
}
+ default:
+ // Skip other alter table specification types
}
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go b/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go
index f4667a7425..384e799b07 100644
--- a/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go
+++ b/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go
@@ -110,6 +110,8 @@ func (checker *columnSetDefaultForNotNullChecker) Enter(in ast.Node) (ast.Node,
line: node.OriginTextPosition(),
})
}
+ default:
+ // Skip other alter table specification types
}
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
index c13fbb6f30..01fd76c5d3 100644
--- a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
+++ b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
@@ -88,6 +88,8 @@ func (checker *indexNoDuplicateColumnChecker) Enter(in ast.Node) (ast.Node, bool
line: constraint.OriginTextPosition(),
})
}
+ default:
+ // Ignore other constraint types
}
}
case *ast.CreateIndexStmt:
diff --git a/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go
index d897aad96b..255724e888 100644
--- a/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go
+++ b/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go
@@ -111,6 +111,8 @@ func (v *indexPrimaryKeyTypeAllowlistChecker) Enter(in ast.Node) (ast.Node, bool
}
pds := v.changeColumn(tableName, oldColumnName, node.OriginTextPosition(), newColumnDef)
pkDataList = append(pkDataList, pds...)
+ default:
+ // Ignore other alter table specs
}
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_column.go b/backend/plugin/advisor/tidb/advisor_naming_column.go
index 0616f32a9c..9716174e15 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_column.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_column.go
@@ -46,7 +46,6 @@ func (*NamingColumnConventionAdvisor) Check(_ context.Context, checkCtx advisor.
title: string(checkCtx.Rule.Type),
format: format,
maxLength: maxLength,
- tables: make(tableState),
}
for _, stmtNode := range root {
@@ -62,7 +61,6 @@ type namingColumnConventionChecker struct {
title string
format *regexp.Regexp
maxLength int
- tables tableState
}
// Enter implements the ast.Visitor interface.
@@ -108,6 +106,8 @@ func (v *namingColumnConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
name: spec.NewColumns[0].Name.Name.O,
line: in.OriginTextPosition(),
})
+ default:
+ // Skip other alter table specification types
}
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go b/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
index 5f5e6f906f..bf07af0378 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
@@ -192,6 +192,8 @@ func (checker *namingIndexConventionChecker) getMetaDataList(in ast.Node) []*ind
line: in.OriginTextPosition(),
})
}
+ default:
+ // Skip other alter table specification types
}
}
case *ast.CreateIndexStmt:
diff --git a/backend/plugin/advisor/tidb/advisor_table_require_pk.go b/backend/plugin/advisor/tidb/advisor_table_require_pk.go
index fcd08d9a8e..8e0ac77afe 100644
--- a/backend/plugin/advisor/tidb/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/tidb/advisor_table_require_pk.go
@@ -119,6 +119,8 @@ func (v *tableRequirePKChecker) Enter(in ast.Node) (ast.Node, bool) {
if v.dropColumn(tableName, spec.OldColumnName.Name.String()) {
v.line[tableName] = node.OriginTextPosition()
}
+ default:
+ // Skip other alter table specification types
}
}
}
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index 2a5e6cb9ec..452adeae45 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -275,6 +275,8 @@ func convertValue(v bigquery.Value, fieldType bigquery.FieldType) *v1pb.RowValue
case bigquery.IntervalFieldType:
case bigquery.JSONFieldType:
case bigquery.RangeFieldType:
+ default:
+ // Unknown field type, will fall back to string representation
}
// Fall back to string representation.
diff --git a/backend/plugin/db/cassandra/sync.go b/backend/plugin/db/cassandra/sync.go
index b915d67a93..6574deb937 100644
--- a/backend/plugin/db/cassandra/sync.go
+++ b/backend/plugin/db/cassandra/sync.go
@@ -217,6 +217,8 @@ func getPKExpressions(pks []primaryKey) []string {
partition = append(partition, k.name)
case "clustering":
clustering = append(clustering, k.name)
+ default:
+ // Ignore other key types
}
}
@@ -247,6 +249,8 @@ func getPKDefinition(pks []primaryKey) string {
partition = append(partition, k.name)
case "clustering":
clustering = append(clustering, k.name)
+ default:
+ // Ignore other key types
}
}
if len(partition) == 1 {
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index bb90c5abb2..b32702fd35 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -99,8 +99,9 @@ func (t MigrationType) GetVersionTypeSuffix() string {
return "sdl"
case Baseline:
return "baseline"
+ default:
+ return ""
}
- return ""
}
func (t MigrationType) NeedDump() bool {
diff --git a/backend/plugin/db/dynamodb/sync.go b/backend/plugin/db/dynamodb/sync.go
index 1409478a66..526b9f6b3b 100644
--- a/backend/plugin/db/dynamodb/sync.go
+++ b/backend/plugin/db/dynamodb/sync.go
@@ -95,6 +95,8 @@ func (d *Driver) syncTable(ctx context.Context, tableName string) (*storepb.Tabl
hashKeyAttributes = append(hashKeyAttributes, *keySchema.AttributeName)
case types.KeyTypeRange:
rangeKeyAttributes = append(rangeKeyAttributes, *keySchema.AttributeName)
+ default:
+ // Unknown key type, ignore
}
}
tableMetadata.Indexes = append(tableMetadata.Indexes, &storepb.IndexMetadata{
diff --git a/backend/plugin/db/elasticsearch/sync.go b/backend/plugin/db/elasticsearch/sync.go
index 407e4e608e..4b8a1f8775 100644
--- a/backend/plugin/db/elasticsearch/sync.go
+++ b/backend/plugin/db/elasticsearch/sync.go
@@ -159,6 +159,8 @@ func unitConversion(sizeWithUnit string) (int64, error) {
size *= 1024 * 1024
case "gb":
size *= 1024 * 1024 * 1024
+ default:
+ // For "b" (bytes) or any other unit, keep the size as-is
}
return int64(size), nil
diff --git a/backend/plugin/db/hive/sync.go b/backend/plugin/db/hive/sync.go
index ae98a46d8b..78756fa353 100644
--- a/backend/plugin/db/hive/sync.go
+++ b/backend/plugin/db/hive/sync.go
@@ -272,6 +272,8 @@ func (d *Driver) getTableInfo(ctx context.Context, tableName string, databaseNam
section = storageSection
case strings.HasPrefix(colName, "# View Information"):
section = viewSection
+ default:
+ // No action needed for other cases
}
switch section {
case columnSection:
@@ -303,6 +305,8 @@ func (d *Driver) getTableInfo(ctx context.Context, tableName string, databaseNam
tableInfo.totalSize = n
case trimField(dataType) == "comment":
tableInfo.comment = trimField(comment)
+ default:
+ // No action needed for other table info fields
}
case viewSection:
switch {
@@ -310,7 +314,11 @@ func (d *Driver) getTableInfo(ctx context.Context, tableName string, databaseNam
tableInfo.viewDef = trimField(dataType)
case strings.HasPrefix(colName, "Original Query:"):
tableInfo.viewDef = trimField(dataType)
+ default:
+ // No action needed for other view fields
}
+ default:
+ // No action needed for other sections
}
}
diff --git a/backend/plugin/db/mssql/query.go b/backend/plugin/db/mssql/query.go
index 382977f62e..709d7d15ab 100644
--- a/backend/plugin/db/mssql/query.go
+++ b/backend/plugin/db/mssql/query.go
@@ -58,8 +58,10 @@ func makeValueByTypeName(typeName string, _ *sql.ColumnType) any {
return new([]byte)
case "SQL_VARIANT":
return new([]byte)
+ default:
+ // For unknown types, default to sql.NullString which can handle most values
+ return new(sql.NullString)
}
- return new(sql.NullString)
}
func convertValue(typeName string, columnType *sql.ColumnType, value any) *v1pb.RowValue {
diff --git a/backend/plugin/db/mssql/stmt_type.go b/backend/plugin/db/mssql/stmt_type.go
index 292b8ea483..5a602e09a1 100644
--- a/backend/plugin/db/mssql/stmt_type.go
+++ b/backend/plugin/db/mssql/stmt_type.go
@@ -46,6 +46,9 @@ func (l *stmtTypeListener) EnterBatch_without_go(ctx *rawparser.Batch_without_go
l.stmtType = stmtTypeUnknown
case ctx.Execute_body_batch() != nil:
l.err = errors.Errorf("unsupported execute func proc")
+ default:
+ // For any other unhandled cases, set the statement type to unknown
+ l.stmtType = stmtTypeUnknown
}
}
@@ -70,6 +73,8 @@ func getStmtTypeFromSQLClauses(ctx rawparser.ISql_clausesContext) (stmtType, err
return stmtTypeUnknown, nil
case ctx.Backup_statement() != nil:
return stmtTypeUnknown, nil
+ default:
+ // For any unhandled SQL clause types, return unknown
+ return stmtTypeUnknown, nil
}
- return stmtTypeUnknown, nil
}
diff --git a/backend/plugin/db/mssql/sync.go b/backend/plugin/db/mssql/sync.go
index 7e9c745cbb..0f166b13e6 100644
--- a/backend/plugin/db/mssql/sync.go
+++ b/backend/plugin/db/mssql/sync.go
@@ -496,7 +496,7 @@ func getColumnType(definition, typeName sql.NullString, isComputed, isPersisted
return "", err
}
if isPersisted.Valid && isPersisted.Bool {
- if _, err := fmt.Fprintf(&buf, " PERSISTED"); err != nil {
+ if _, err := fmt.Fprint(&buf, " PERSISTED"); err != nil {
return "", err
}
}
@@ -537,7 +537,7 @@ func getColumnType(definition, typeName sql.NullString, isComputed, isPersisted
case "char", "nchar", "varchar", "nvarchar", "binary", "varbinary":
if maxLength.Valid {
if maxLength.Int64 == -1 {
- if _, err := fmt.Fprintf(&buf, "(max)"); err != nil {
+ if _, err := fmt.Fprint(&buf, "(max)"); err != nil {
return "", err
}
} else {
@@ -552,6 +552,9 @@ func getColumnType(definition, typeName sql.NullString, isComputed, isPersisted
}
}
}
+ default:
+ // For other types, no additional formatting is needed
+ // The type name has already been written to the buffer
}
return buf.String(), nil
}
diff --git a/backend/plugin/db/mssql/sync_spatial_testcontainer_test.go b/backend/plugin/db/mssql/sync_spatial_testcontainer_test.go
index c2a253a5f6..4a2e0c3ec0 100644
--- a/backend/plugin/db/mssql/sync_spatial_testcontainer_test.go
+++ b/backend/plugin/db/mssql/sync_spatial_testcontainer_test.go
@@ -231,7 +231,7 @@ GO
require.Equal(t, "MEDIUM", gridMap[3], "Level 3 should be MEDIUM")
require.Equal(t, "LOW", gridMap[4], "Level 4 should be LOW")
} else {
- t.Errorf("Expected spatial index idx_location_point not found")
+ t.Error("Expected spatial index idx_location_point not found")
}
if idx, exists := spatialIndexes["idx_boundary_polygon"]; exists {
@@ -252,7 +252,7 @@ GO
require.Equal(t, "HIGH", gridMap[3], "Level 3 should be HIGH")
require.Equal(t, "MEDIUM", gridMap[4], "Level 4 should be MEDIUM")
} else {
- t.Errorf("Expected spatial index idx_boundary_polygon not found")
+ t.Error("Expected spatial index idx_boundary_polygon not found")
}
if idx, exists := spatialIndexes["idx_area_shape"]; exists {
@@ -273,7 +273,7 @@ GO
require.Equal(t, "MEDIUM", gridMap[3], "Level 3 should be MEDIUM")
require.Equal(t, "LOW", gridMap[4], "Level 4 should be LOW")
} else {
- t.Errorf("Expected spatial index idx_area_shape not found")
+ t.Error("Expected spatial index idx_area_shape not found")
}
// Verify that we have at least the expected number of spatial indexes
@@ -558,7 +558,7 @@ GO
require.Equal(t, "LOW", gridMap[3], "Level 3 should be LOW")
require.Equal(t, "LOW", gridMap[4], "Level 4 should be LOW")
} else {
- t.Errorf("Expected spatial index idx_location_geom not found")
+ t.Error("Expected spatial index idx_location_geom not found")
}
if idx, exists := spatialIndexes["idx_boundary_geom"]; exists {
@@ -586,7 +586,7 @@ GO
require.Equal(t, "MEDIUM", gridMap[3], "Level 3 should be MEDIUM")
require.Equal(t, "LOW", gridMap[4], "Level 4 should be LOW")
} else {
- t.Errorf("Expected spatial index idx_boundary_geom not found")
+ t.Error("Expected spatial index idx_boundary_geom not found")
}
require.GreaterOrEqual(t, len(spatialIndexes), 2, "Should have at least 2 GEOMETRY spatial indexes")
diff --git a/backend/plugin/db/mysql/query.go b/backend/plugin/db/mysql/query.go
index 414d59c349..6538fc854b 100644
--- a/backend/plugin/db/mysql/query.go
+++ b/backend/plugin/db/mysql/query.go
@@ -167,6 +167,8 @@ func (r *mysqlRewriter) EnterQueryExpression(ctx *mysql.QueryExpressionContext)
r.rewriter.InsertAfterDefault(ctx.QueryExpressionBody().GetStop().GetTokenIndex(), fmt.Sprintf(" LIMIT %d", r.limitCount))
case ctx.QueryExpressionParens() != nil:
r.rewriter.InsertAfterDefault(ctx.QueryExpressionParens().GetStop().GetTokenIndex(), fmt.Sprintf(" LIMIT %d", r.limitCount))
+ default:
+ // No action needed for other query expression types
}
}
}
diff --git a/backend/plugin/db/mysql/sync.go b/backend/plugin/db/mysql/sync.go
index 68d7fb9dc8..7472078bad 100644
--- a/backend/plugin/db/mysql/sync.go
+++ b/backend/plugin/db/mysql/sync.go
@@ -591,6 +591,8 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad
if view, ok := viewMap[key]; ok {
schemaMetadata.Views = append(schemaMetadata.Views, view)
}
+ default:
+ // Unknown table type, skip
}
}
if err := tableRows.Err(); err != nil {
diff --git a/backend/plugin/db/obo/dump.go b/backend/plugin/db/obo/dump.go
index 5b601f1202..ea1385843c 100644
--- a/backend/plugin/db/obo/dump.go
+++ b/backend/plugin/db/obo/dump.go
@@ -59,6 +59,8 @@ func assembleTableStatement(tableMap map[string]*tableSchema, out io.Writer) err
case !table.meta.TableName.Valid,
!table.meta.Owner.Valid:
continue
+ default:
+ // Table has valid name and owner, include it in the list
}
tableList = append(tableList, table)
}
@@ -263,6 +265,8 @@ func (t *tableSchema) assembleStorage(out io.Writer) error {
if _, err := fmt.Fprintf(out, "\n BUFFER_POOL %s", t.meta.BufferPool.String); err != nil {
return err
}
+ default:
+ // No valid storage parameters found, this shouldn't happen as we check for them before calling this switch
}
if _, err := out.Write([]byte("\n)")); err != nil {
@@ -306,6 +310,11 @@ func (t *tableSchema) assembleCompression(out io.Writer) error {
if _, err := out.Write([]byte("\nCOLUMN STORE COMPRESS FOR ARCHIVE HIGH")); err != nil {
return err
}
+ default:
+ // Unknown compression format, use default COMPRESS
+ if _, err := out.Write([]byte("\nCOMPRESS")); err != nil {
+ return err
+ }
}
}
return nil
@@ -478,6 +487,8 @@ func (f *fieldMeta) assembleType(out io.Writer) error {
if _, err := fmt.Fprintf(out, "(%d,%d)", f.DataPrecision.Int64, f.DataScale.Int64); err != nil {
return err
}
+ default:
+ // Unexpected precision/scale combination, do nothing
}
case "FLOAT":
switch {
@@ -487,7 +498,11 @@ func (f *fieldMeta) assembleType(out io.Writer) error {
if _, err := fmt.Fprintf(out, "(%d)", f.DataPrecision.Int64); err != nil {
return err
}
+ default:
+ // Unexpected precision value, do nothing
}
+ default:
+ // Data type doesn't require length or precision specification
}
return nil
}
@@ -735,6 +750,8 @@ func assembleIndexStatement(index *mergedIndexMeta, out io.Writer) error {
if _, err := out.Write([]byte(` BITMAP`)); err != nil {
return err
}
+ default:
+ // Other index types don't need special keywords
}
if index.Uniqueness.String == "UNIQUE" {
@@ -1023,7 +1040,14 @@ func (i *mergedIndexMeta) assembleStorage(out io.Writer) error {
if _, err := out.Write([]byte("\n FLASH_CACHE NONE")); err != nil {
return err
}
+ default:
+ // Unknown FlashCache value, use default
+ if _, err := out.Write([]byte("\n FLASH_CACHE DEFAULT")); err != nil {
+ return err
+ }
}
+ default:
+ // No valid storage parameters found, this shouldn't happen as we check for them before calling this switch
}
if _, err := out.Write([]byte("\n)")); err != nil {
diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.go
index 4aae52537f..f1269a45e6 100644
--- a/backend/plugin/db/oracle/oracle.go
+++ b/backend/plugin/db/oracle/oracle.go
@@ -397,6 +397,8 @@ func skipAddLimit(stmt string) (bool, error) {
return false, nil
case len(selectStatement.AllFetch_clause()) != 0:
return false, nil
+ default:
+ // No additional clauses
}
selectOnly := selectStatement.Select_only_statement()
@@ -440,6 +442,8 @@ func skipAddLimit(stmt string) (bool, error) {
queryBlock.Order_by_clause() != nil,
queryBlock.Fetch_clause() != nil:
return false, nil
+ default:
+ // Query block has no special clauses
}
from := queryBlock.From_clause()
diff --git a/backend/plugin/db/oracle/sync.go b/backend/plugin/db/oracle/sync.go
index 734eed41c4..bf7925576c 100644
--- a/backend/plugin/db/oracle/sync.go
+++ b/backend/plugin/db/oracle/sync.go
@@ -558,6 +558,8 @@ func getTypeString(dataType string, dataLength, dataPrecision, dataScale sql.Nul
return fmt.Sprintf("%s(%d)", dataType, dataPrecision.Int64)
case dataPrecision.Valid && dataPrecision.Int64 > 0 && dataScale.Valid && dataScale.Int64 > 0:
return fmt.Sprintf("%s(%d,%d)", dataType, dataPrecision.Int64, dataScale.Int64)
+ default:
+ // do nothing
}
case "FLOAT":
switch {
@@ -565,7 +567,11 @@ func getTypeString(dataType string, dataLength, dataPrecision, dataScale sql.Nul
// do nothing
case dataPrecision.Valid && dataPrecision.Int64 > 0:
return fmt.Sprintf("%s(%d)", dataType, dataPrecision.Int64)
+ default:
+ // do nothing
}
+ default:
+ // return dataType as-is for unhandled types
}
return dataType
}
@@ -737,6 +743,8 @@ func getConstraints(txn *sql.Tx, schemaName string) (
}
foreignKeyMap[key] = append(foreignKeyMap[key], foreignKey)
}
+ default:
+ // Ignore other constraint types
}
}
if err := constraintRows.Err(); err != nil {
diff --git a/backend/plugin/db/redshift/sync.go b/backend/plugin/db/redshift/sync.go
index b059da95d5..755e01be34 100644
--- a/backend/plugin/db/redshift/sync.go
+++ b/backend/plugin/db/redshift/sync.go
@@ -392,6 +392,8 @@ func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, er
// https://www.postgresql.org/docs/current/infoschema-columns.html.
column.Type = fmt.Sprintf("%s(%s)", column.Type, characterMaxLength.String)
}
+ default:
+ // No special handling needed for other types
}
column.Collation = collation.String
column.Comment = comment.String
@@ -686,6 +688,8 @@ func getPgVersionAndRedshiftVersion(version string) (string, string, error) {
pgVersion = matches[i]
case "redshiftVersion":
redshiftVersion = matches[i]
+ default:
+ // Ignore other named groups
}
}
}
diff --git a/backend/plugin/db/risingwave/sync.go b/backend/plugin/db/risingwave/sync.go
index 26568b236d..852ceaa84e 100644
--- a/backend/plugin/db/risingwave/sync.go
+++ b/backend/plugin/db/risingwave/sync.go
@@ -230,6 +230,8 @@ func getTableColumns(txn *sql.Tx) (map[db.TableKey][]*storepb.ColumnMetadata, er
column.Type = fmt.Sprintf("%s.%s", udtSchema.String, udtName.String)
case "ARRAY":
column.Type = udtName.String
+ default:
+ // Keep the original type for other cases
}
column.Collation = collation.String
column.Comment = ""
diff --git a/backend/plugin/db/snowflake/sync.go b/backend/plugin/db/snowflake/sync.go
index 21d2e8a052..fba94183ce 100644
--- a/backend/plugin/db/snowflake/sync.go
+++ b/backend/plugin/db/snowflake/sync.go
@@ -179,6 +179,8 @@ func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[stri
staleIndex = i
case "mode":
modeIndex = i
+ default:
+ // Ignore other columns
}
}
@@ -216,6 +218,8 @@ func (d *Driver) getStreamSchema(ctx context.Context, database string) (map[stri
storePbMode = storepb.StreamMetadata_MODE_APPEND_ONLY
case "INSERT_ONLY":
storePbMode = storepb.StreamMetadata_MODE_INSERT_ONLY
+ default:
+ // Keep as MODE_UNSPECIFIED for unknown modes
}
streamMetadata := &storepb.StreamMetadata{
Name: streamName,
@@ -314,6 +318,8 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[string
stateIndex = i
case "condition":
nullConditionIndex = i
+ default:
+ // Ignore other columns
}
}
for streamMetaRows.Next() {
@@ -346,6 +352,8 @@ func (d *Driver) getTaskSchema(ctx context.Context, database string) (map[string
storePbState = storepb.TaskMetadata_STATE_STARTED
case "suspended":
storePbState = storepb.TaskMetadata_STATE_SUSPENDED
+ default:
+ // Keep as STATE_UNSPECIFIED for unknown states
}
var schedule, condition, warehouse string
if nullSchedule.Valid {
diff --git a/backend/plugin/db/starrocks/query.go b/backend/plugin/db/starrocks/query.go
index e4614a512b..9846314949 100644
--- a/backend/plugin/db/starrocks/query.go
+++ b/backend/plugin/db/starrocks/query.go
@@ -168,6 +168,8 @@ func (r *mysqlRewriter) EnterQueryExpression(ctx *mysql.QueryExpressionContext)
r.rewriter.InsertAfterDefault(ctx.QueryExpressionBody().GetStop().GetTokenIndex(), fmt.Sprintf(" LIMIT %d", r.limitCount))
case ctx.QueryExpressionParens() != nil:
r.rewriter.InsertAfterDefault(ctx.QueryExpressionParens().GetStop().GetTokenIndex(), fmt.Sprintf(" LIMIT %d", r.limitCount))
+ default:
+ // No query expression body or parens found, skip adding LIMIT
}
}
}
diff --git a/backend/plugin/db/starrocks/sync.go b/backend/plugin/db/starrocks/sync.go
index 17aef8bf69..2400e081cc 100644
--- a/backend/plugin/db/starrocks/sync.go
+++ b/backend/plugin/db/starrocks/sync.go
@@ -292,6 +292,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad
view.Comment = comment
schemaMetadata.Views = append(schemaMetadata.Views, view)
}
+ default:
+ // Skip unknown table types (e.g., SYSTEM VIEW, TEMPORARY, etc.)
+ slog.Debug("skipping unknown table type", slog.String("tableName", tableName), slog.String("tableType", tableType))
}
}
if err := tableRows.Err(); err != nil {
diff --git a/backend/plugin/db/tidb/sync.go b/backend/plugin/db/tidb/sync.go
index 1f8c12ec95..bcd81d94a8 100644
--- a/backend/plugin/db/tidb/sync.go
+++ b/backend/plugin/db/tidb/sync.go
@@ -435,6 +435,9 @@ func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetad
if view, ok := viewMap[key]; ok {
schemaMetadata.Views = append(schemaMetadata.Views, view)
}
+ default:
+ // Skip unknown table types (e.g., SEQUENCE, SYSTEM VERSIONED)
+ slog.Debug("skipping unknown table type", slog.String("tableType", tableType), slog.String("tableName", tableName))
}
}
if err := tableRows.Err(); err != nil {
diff --git a/backend/plugin/db/util/ssl.go b/backend/plugin/db/util/ssl.go
index 1773dbf3bb..d1d76cb4de 100644
--- a/backend/plugin/db/util/ssl.go
+++ b/backend/plugin/db/util/ssl.go
@@ -1,3 +1,4 @@
+//nolint:revive
package util
import (
diff --git a/backend/plugin/db/util/statement_parser.go b/backend/plugin/db/util/statement_parser.go
index 3d1c7bb7d1..e26e571d93 100644
--- a/backend/plugin/db/util/statement_parser.go
+++ b/backend/plugin/db/util/statement_parser.go
@@ -1,3 +1,4 @@
+//nolint:revive
package util
import (
diff --git a/backend/plugin/db/util/statement_parser_test.go b/backend/plugin/db/util/statement_parser_test.go
index 2b9c40a7e2..5e21b94b9b 100644
--- a/backend/plugin/db/util/statement_parser_test.go
+++ b/backend/plugin/db/util/statement_parser_test.go
@@ -1,3 +1,4 @@
+//nolint:revive
package util
import (
diff --git a/backend/plugin/idp/ldap/ldap_test.go b/backend/plugin/idp/ldap/ldap_test.go
index 0d7bfa2c4d..3105f35906 100644
--- a/backend/plugin/idp/ldap/ldap_test.go
+++ b/backend/plugin/idp/ldap/ldap_test.go
@@ -3,7 +3,6 @@ package ldap
import (
"crypto/tls"
"flag"
- "os"
"testing"
"time"
@@ -20,7 +19,7 @@ func TestMain(m *testing.M) {
if !testing.Verbose() {
ldapserver.Logger = ldapserver.DiscardingLogger
}
- os.Exit(m.Run())
+ m.Run()
}
func TestNewIdentityProvider(t *testing.T) {
diff --git a/backend/plugin/parser/base/c3.go b/backend/plugin/parser/base/c3.go
index f2ba35a34b..765083b59f 100644
--- a/backend/plugin/parser/base/c3.go
+++ b/backend/plugin/parser/base/c3.go
@@ -508,6 +508,8 @@ func (c *CodeCompletionCore) fetchEndStatus(startState antlr.ATNState, tokenInde
case antlr.ATNStateRuleStop:
result[currentEntry.TokenIndex] = true
continue
+ default:
+ // Other state types don't require special handling
}
for _, t := range currentEntry.State.GetTransitions() {
@@ -538,6 +540,8 @@ func (c *CodeCompletionCore) fetchEndStatus(startState antlr.ATNState, tokenInde
if c.lastShadowQueryRuleContext != nil {
c.lastShadowQueryRuleContext.CTEList = append(c.lastShadowQueryRuleContext.CTEList, c.tokens[currentEntry.TokenIndex].StartPosition)
}
+ default:
+ // Other rule indices don't require special handling
}
case *antlr.PredicateTransition:
if checkPredicate(c.parser, transition) {
diff --git a/backend/plugin/parser/base/interface.go b/backend/plugin/parser/base/interface.go
index 7bb9d8ed6a..a8c438b770 100644
--- a/backend/plugin/parser/base/interface.go
+++ b/backend/plugin/parser/base/interface.go
@@ -306,6 +306,8 @@ func TSQLRecognizeExplainType(spans []*QuerySpan, stmt []string) {
on = true
case "off":
on = false
+ default:
+ // Unknown status, keep default value
}
}
}
diff --git a/backend/plugin/parser/bigquery/query_span_extractor.go b/backend/plugin/parser/bigquery/query_span_extractor.go
index f6e8373bc9..af6262e776 100644
--- a/backend/plugin/parser/bigquery/query_span_extractor.go
+++ b/backend/plugin/parser/bigquery/query_span_extractor.go
@@ -371,6 +371,8 @@ func (q *querySpanExtractor) extractTableSourceFromSelect(selectCtx parser.ISele
Name: aliasName,
SourceColumns: sourceColumnSet,
})
+ default:
+ // Skip unrecognized select list item types
}
}
return &base.PseudoTable{
@@ -909,6 +911,10 @@ func joinTable(anchor base.TableSource, tp joinType, usingColumns []string, tabl
}
resultField = append(resultField, rFields...)
+ default:
+ // For unhandled join types, combine all fields from both sources
+ resultField = append(resultField, anchor.GetQuerySpanResult()...)
+ resultField = append(resultField, tableSource.GetQuerySpanResult()...)
}
return &base.PseudoTable{
Name: "",
@@ -929,9 +935,9 @@ func getJoinTypeFromJoinType(joinType parser.IJoin_typeContext) joinType {
return leftOuterJoin
case joinType.RIGHT_SYMBOL() != nil:
return rightOuterJoin
+ default:
+ return crossJoin
}
-
- return crossJoin
}
func getJoinTypeFromJoinItem(joinItem parser.IJoin_itemContext) joinType {
diff --git a/backend/plugin/parser/cosmosdb/query_span.go b/backend/plugin/parser/cosmosdb/query_span.go
index 6aa381f46c..5bbbcc5bd0 100644
--- a/backend/plugin/parser/cosmosdb/query_span.go
+++ b/backend/plugin/parser/cosmosdb/query_span.go
@@ -168,11 +168,15 @@ func extractPathFromScalarExpression(ctx parser.IScalar_expressionContext, origi
// Rebuild the ast because of the different level of array index and array name.
last := path[len(path)-1]
path[len(path)-1] = base.NewArraySelector(last.GetIdentifier(), index)
+ default:
+ // Unsupported bracket expression type
}
return path
case ctx.Unary_operator() != nil:
return extractPathFromScalarExpression(ctx.Scalar_expression(), originalContainerName, fromAlias)
+ default:
+ // Unsupported scalar expression type
}
return nil
diff --git a/backend/plugin/parser/cosmosdb/query_span_predicate.go b/backend/plugin/parser/cosmosdb/query_span_predicate.go
index ee474d1fd0..8f148eadd5 100644
--- a/backend/plugin/parser/cosmosdb/query_span_predicate.go
+++ b/backend/plugin/parser/cosmosdb/query_span_predicate.go
@@ -120,6 +120,8 @@ func extractPredicateFieldsFromScalarExpressionInWhere(ctx parser.IScalar_expres
// Rebuild the ast because of the different level of array index and array name.
last := paths[i][len(paths[i])-1]
paths[i][len(paths[i])-1] = base.NewArraySelector(last.GetIdentifier(), index)
+ default:
+ // Do nothing for other cases
}
}
return paths
@@ -152,9 +154,14 @@ func extractPredicateFieldsFromScalarExpressionInWhere(ctx parser.IScalar_expres
paths = append(paths, path...)
}
return paths
+ default:
+ // Other scalar function expression types
+ return nil
}
case ctx.LR_BRACKET_SYMBOL() != nil:
return extractPredicateFieldsFromScalarExpressionInWhere(ctx.Scalar_expression_in_where(0), originalContainerName, fromAlias)
+ default:
+ // Return nil for unhandled cases
}
return nil
diff --git a/backend/plugin/parser/doris/query_span_extractor.go b/backend/plugin/parser/doris/query_span_extractor.go
index b7ab46c72c..1ee7069ad1 100644
--- a/backend/plugin/parser/doris/query_span_extractor.go
+++ b/backend/plugin/parser/doris/query_span_extractor.go
@@ -104,6 +104,8 @@ func (l *accessTableListener) EnterTableAtom(ctx *parser.TableAtomContext) {
Database: list[0],
Table: list[1],
}] = true
+ default:
+ // Ignore qualified names with more than 2 parts
}
}
diff --git a/backend/plugin/parser/elasticsearch/parser.go b/backend/plugin/parser/elasticsearch/parser.go
index 9a508e8cc6..c0dc02f324 100644
--- a/backend/plugin/parser/elasticsearch/parser.go
+++ b/backend/plugin/parser/elasticsearch/parser.go
@@ -366,6 +366,8 @@ func splitDataIntoJSONObjects(s string) []string {
depth++
case '}':
depth--
+ default:
+ // Other characters don't affect depth
}
if depth == 0 {
@@ -722,6 +724,7 @@ func (p *parser) word() (any, error) {
if err := p.next('e'); err != nil {
return nil, err
}
+ return true, nil
case 'f':
if err := p.next('f'); err != nil {
return nil, err
@@ -753,8 +756,9 @@ func (p *parser) word() (any, error) {
return nil, err
}
return nil, nil
+ default:
+ return nil, errors.Errorf("unexpected '%c'", p.ch)
}
- return nil, errors.Errorf("unexpected '%c'", p.ch)
}
func (p *parser) number() (float64, error) {
diff --git a/backend/plugin/parser/mysql/query_span_extractor.go b/backend/plugin/parser/mysql/query_span_extractor.go
index f4150cd344..afdac075cd 100644
--- a/backend/plugin/parser/mysql/query_span_extractor.go
+++ b/backend/plugin/parser/mysql/query_span_extractor.go
@@ -156,9 +156,9 @@ func (q *querySpanExtractor) extractSelectStatement(ctx parser.ISelectStatementC
return q.extractQueryExpressionParens(ctx.QueryExpressionParens())
case ctx.SelectStatementWithInto() != nil:
return nil, errors.New("meet unsupported select statement with into")
+ default:
+ return nil, errors.New("unexpected select statement")
}
-
- panic("unreachable")
}
func (q *querySpanExtractor) extractQueryExpression(ctx parser.IQueryExpressionContext) (*base.PseudoTable, error) {
diff --git a/backend/plugin/parser/mysql/query_type.go b/backend/plugin/parser/mysql/query_type.go
index 2084a29a01..b47cd64a8d 100644
--- a/backend/plugin/parser/mysql/query_type.go
+++ b/backend/plugin/parser/mysql/query_type.go
@@ -67,6 +67,9 @@ func (l *queryTypeListener) EnterSimpleStatement(ctx *mysql.SimpleStatementConte
l.result = base.Explain
}
}
+ default:
+ // For any other statement type, default to Select
+ l.result = base.Select
}
}
diff --git a/backend/plugin/parser/mysql/split.go b/backend/plugin/parser/mysql/split.go
index 77bac8a8fe..257a78ad79 100644
--- a/backend/plugin/parser/mysql/split.go
+++ b/backend/plugin/parser/mysql/split.go
@@ -367,6 +367,8 @@ func splitMySQLStatement(stream *antlr.CommonTokenStream, statement string) ([]b
}
case parser.MySQLParserSEMICOLON_SYMBOL:
semicolonStack = append(semicolonStack, i)
+ default:
+ // Do nothing for other token types
}
}
diff --git a/backend/plugin/parser/mysql/statement_type_check.go b/backend/plugin/parser/mysql/statement_type_check.go
index a85cfe3d14..d1cdaf5ef5 100644
--- a/backend/plugin/parser/mysql/statement_type_check.go
+++ b/backend/plugin/parser/mysql/statement_type_check.go
@@ -365,6 +365,8 @@ func (checker *SDLTypeChecker) EnterAlterTable(ctx *mysql.AlterTableContext) {
},
},
})
+ default:
+ // Other drop types are not tracked
}
default:
}
diff --git a/backend/plugin/parser/partiql/completion.go b/backend/plugin/parser/partiql/completion.go
index abf469a936..1a34a718e8 100644
--- a/backend/plugin/parser/partiql/completion.go
+++ b/backend/plugin/parser/partiql/completion.go
@@ -387,6 +387,8 @@ func (c *Completer) collectLeadingTableReferences(caretIndex int) {
}
case partiqlparser.PartiQLLexerFROM:
found = true
+ default:
+ // Continue scanning for FROM clause
}
}
if !found {
@@ -424,6 +426,8 @@ func (c *Completer) collectRemainingTableReferences() {
if level == 0 {
found = true
}
+ default:
+ // Continue scanning
}
}
diff --git a/backend/plugin/parser/pg/completion.go b/backend/plugin/parser/pg/completion.go
index e473689327..cd23f812a7 100644
--- a/backend/plugin/parser/pg/completion.go
+++ b/backend/plugin/parser/pg/completion.go
@@ -659,6 +659,8 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]
columnEntries.insertColumns(c, schemas, tables)
}
}
+ default:
+ // No specific completion for this rule
}
}
diff --git a/backend/plugin/parser/pg/differ.go b/backend/plugin/parser/pg/differ.go
index cb181e34a7..e8472eb91f 100644
--- a/backend/plugin/parser/pg/differ.go
+++ b/backend/plugin/parser/pg/differ.go
@@ -1901,13 +1901,13 @@ func printDropMaterializedView(buf io.Writer, viewName *ast.TableDef) error {
return nil
}
- if _, err := fmt.Fprintf(buf, "DROP MATERIALIZED VIEW "); err != nil {
+ if _, err := fmt.Fprint(buf, "DROP MATERIALIZED VIEW "); err != nil {
return err
}
if _, err := fmt.Fprintf(buf, `"%s"."%s"`, viewName.Schema, viewName.Name); err != nil {
return err
}
- if _, err := fmt.Fprintf(buf, ";\n\n"); err != nil {
+ if _, err := fmt.Fprint(buf, ";\n\n"); err != nil {
return err
}
return nil
@@ -1917,13 +1917,13 @@ func printDropView(buf io.Writer, viewName *ast.TableDef) error {
if viewName == nil {
return nil
}
- if _, err := fmt.Fprintf(buf, "DROP VIEW "); err != nil {
+ if _, err := fmt.Fprint(buf, "DROP VIEW "); err != nil {
return err
}
if _, err := fmt.Fprintf(buf, `"%s"."%s"`, viewName.Schema, viewName.Name); err != nil {
return err
}
- if _, err := fmt.Fprintf(buf, ";\n\n"); err != nil {
+ if _, err := fmt.Fprint(buf, ";\n\n"); err != nil {
return err
}
return nil
@@ -1939,7 +1939,7 @@ func printDropFunction(buf io.Writer, function *ast.FunctionDef) error {
}
func printDropTable(buf io.Writer, table *ast.TableDef) error {
- if _, err := fmt.Fprintf(buf, "DROP TABLE "); err != nil {
+ if _, err := fmt.Fprint(buf, "DROP TABLE "); err != nil {
return err
}
@@ -1947,7 +1947,7 @@ func printDropTable(buf io.Writer, table *ast.TableDef) error {
return err
}
- _, err := fmt.Fprintf(buf, ";\n\n")
+ _, err := fmt.Fprint(buf, ";\n\n")
return err
}
diff --git a/backend/plugin/parser/pg/pg.go b/backend/plugin/parser/pg/pg.go
index 9388b60df3..5c02610cd2 100644
--- a/backend/plugin/parser/pg/pg.go
+++ b/backend/plugin/parser/pg/pg.go
@@ -209,9 +209,9 @@ func normalizePostgreSQLAnyIdentifier(ctx parser.IAny_identifierContext) string
return NormalizePostgreSQLColid(ctx.Colid())
case ctx.Plsql_unreserved_keyword() != nil:
return strings.ToLower(ctx.Plsql_unreserved_keyword().GetText())
+ default:
+ return ""
}
-
- return ""
}
func normalizePostgreSQLIdentifier(ctx parser.IIdentifierContext) string {
diff --git a/backend/plugin/parser/pg/query_span_extractor.go b/backend/plugin/parser/pg/query_span_extractor.go
index 11c31a6d48..0cd9ca6ffd 100644
--- a/backend/plugin/parser/pg/query_span_extractor.go
+++ b/backend/plugin/parser/pg/query_span_extractor.go
@@ -462,6 +462,8 @@ func (q *querySpanExtractor) extractTableSourceFromSystemFunction(node *pgquery.
Type: "function",
Name: funcName,
}
+ default:
+ // For unknown functions, continue with the generic handling below
}
if node.RangeFunction.Alias == nil {
@@ -731,8 +733,9 @@ func (q *querySpanExtractor) getColumnsForFunction(name, definition string) ([]b
return q.extractTableSourceFromSQLFunction(createFunc, name, asBody)
case languageTypePLPGSQL:
return q.extractTableSourceFromPLPGSQLFunction(createFunc, name, definition)
+ default:
+ return nil, errors.Errorf("unsupported language type: %d", language)
}
- return nil, errors.Errorf("unsupported language type: %d", language)
}
func (q *querySpanExtractor) extractTableSourceFromPLPGSQLFunction(createFunc *pgquery.Node_CreateFunctionStmt, name, definition string) ([]base.QuerySpanResult, error) {
@@ -745,6 +748,8 @@ func (q *querySpanExtractor) extractTableSourceFromPLPGSQLFunction(createFunc *p
switch funcPara.Mode {
case pgquery.FunctionParameterMode_FUNC_PARAM_OUT, pgquery.FunctionParameterMode_FUNC_PARAM_TABLE:
columnNames = append(columnNames, funcPara.Name)
+ default:
+ // IN, INOUT, VARIADIC parameters are not included in the column names
}
}
@@ -958,6 +963,9 @@ func extractSQL(data any) string {
return extractSQL(data["query"])
case data["PLpgSQL_expr"] != nil:
return extractSQL(data["PLpgSQL_expr"])
+ default:
+ // No SQL found in this map
+ return ""
}
}
return ""
@@ -985,6 +993,8 @@ func (q *querySpanExtractor) extractTableSourceFromSQLFunction(createFunc *pgque
switch funcPara.Mode {
case pgquery.FunctionParameterMode_FUNC_PARAM_OUT, pgquery.FunctionParameterMode_FUNC_PARAM_TABLE:
columnNames = append(columnNames, funcPara.Name)
+ default:
+ // IN, INOUT, VARIADIC parameters are not included in the column names
}
}
if len(columnNames) != len(span.Results) {
diff --git a/backend/plugin/parser/pg/restore.go b/backend/plugin/parser/pg/restore.go
index 5591b787e3..ccec7f30d8 100644
--- a/backend/plugin/parser/pg/restore.go
+++ b/backend/plugin/parser/pg/restore.go
@@ -186,7 +186,7 @@ func (g *generator) EnterUpdatestmt(ctx *parser.UpdatestmtContext) {
}
for i, field := range l.result {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ", "); err != nil {
+ if _, err := fmt.Fprint(&buf, ", "); err != nil {
g.err = errors.Wrapf(err, "failed to generate update statement")
return
}
@@ -197,7 +197,7 @@ func (g *generator) EnterUpdatestmt(ctx *parser.UpdatestmtContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, `;`); err != nil {
+ if _, err := fmt.Fprint(&buf, `;`); err != nil {
g.err = errors.Wrapf(err, "failed to generate update statement")
return
}
diff --git a/backend/plugin/parser/plsql/differ.go b/backend/plugin/parser/plsql/differ.go
index 9b33d62ca9..eb4743326a 100644
--- a/backend/plugin/parser/plsql/differ.go
+++ b/backend/plugin/parser/plsql/differ.go
@@ -298,6 +298,8 @@ func (diff *diffNode) getConstraintID(ctx plsql.IRelational_propertyContext) str
}
_, constraintName := NormalizeConstraintName(constraint.Constraint_name())
return strings.TrimSpace(constraintName)
+ default:
+ return ""
}
} else if ctx.Out_of_line_constraint() != nil || ctx.Out_of_line_ref_constraint() != nil {
return strings.TrimSpace(EraseString(EraseContext{
@@ -349,6 +351,8 @@ func (diff *diffNode) diffConstraint(oldTable, newTable *tableInfo) error {
dropConstraints = append(dropConstraints, id)
}
delete(oldConstraintMap, id)
+ default:
+ // Ignore other relational properties
}
}
for _, item := range oldConstraintMap {
diff --git a/backend/plugin/parser/plsql/replace.go b/backend/plugin/parser/plsql/replace.go
index 5c75cf6767..2868334b27 100644
--- a/backend/plugin/parser/plsql/replace.go
+++ b/backend/plugin/parser/plsql/replace.go
@@ -141,6 +141,8 @@ func getNormalizeIndexName(ctx *parser.Create_indexContext) string {
slog.Debug("Failed to write byte", log.BBError(err))
return ""
}
+ default:
+ // No table/cluster name to add
}
if err := buf.WriteByte('_'); err != nil {
slog.Debug("Failed to write byte", log.BBError(err))
@@ -187,6 +189,12 @@ func getNormalizeIndexName(ctx *parser.Create_indexContext) string {
slog.Debug("Failed to write byte", log.BBError(err))
return ""
}
+ default:
+ // No index type specified
+ if err := buf.WriteByte('0'); err != nil {
+ slog.Debug("Failed to write byte", log.BBError(err))
+ return ""
+ }
}
// USABLE or UNUSABLE
diff --git a/backend/plugin/parser/plsql/restore.go b/backend/plugin/parser/plsql/restore.go
index fb46c179f8..6d510f51a0 100644
--- a/backend/plugin/parser/plsql/restore.go
+++ b/backend/plugin/parser/plsql/restore.go
@@ -187,7 +187,7 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
}
for i, column := range uk {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, " AND"); err != nil {
+ if _, err := fmt.Fprint(&buf, " AND"); err != nil {
g.err = err
return
}
@@ -197,13 +197,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, ")\nWHEN MATCHED THEN\n UPDATE SET"); err != nil {
+ if _, err := fmt.Fprint(&buf, ")\nWHEN MATCHED THEN\n UPDATE SET"); err != nil {
g.err = err
return
}
for i, field := range l.result {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ","); err != nil {
+ if _, err := fmt.Fprint(&buf, ","); err != nil {
g.err = err
return
}
@@ -214,13 +214,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, "\nWHEN NOT MATCHED THEN\n INSERT ("); err != nil {
+ if _, err := fmt.Fprint(&buf, "\nWHEN NOT MATCHED THEN\n INSERT ("); err != nil {
g.err = err
return
}
for i, column := range g.table.GetColumns() {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ", "); err != nil {
+ if _, err := fmt.Fprint(&buf, ", "); err != nil {
g.err = err
return
}
@@ -230,13 +230,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, ") VALUES ("); err != nil {
+ if _, err := fmt.Fprint(&buf, ") VALUES ("); err != nil {
g.err = err
return
}
for i, column := range g.table.GetColumns() {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ", "); err != nil {
+ if _, err := fmt.Fprint(&buf, ", "); err != nil {
g.err = err
return
}
@@ -246,7 +246,7 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, ");"); err != nil {
+ if _, err := fmt.Fprint(&buf, ");"); err != nil {
g.err = err
return
}
diff --git a/backend/plugin/parser/plsql/split.go b/backend/plugin/parser/plsql/split.go
index 9b787e2a6e..0f1ab7af22 100644
--- a/backend/plugin/parser/plsql/split.go
+++ b/backend/plugin/parser/plsql/split.go
@@ -158,6 +158,7 @@ func needSemicolon(stmt parser.IUnit_statementContext) bool {
stmt.Create_package_body() != nil,
stmt.Create_trigger() != nil:
return true
+ default:
+ return false
}
- return false
}
diff --git a/backend/plugin/parser/plsql/strings_test.go b/backend/plugin/parser/plsql/strings_test.go
index 413c3825d5..45ba6839ed 100644
--- a/backend/plugin/parser/plsql/strings_test.go
+++ b/backend/plugin/parser/plsql/strings_test.go
@@ -99,6 +99,8 @@ func convertActionsForTest(actions []testAction) []base.StringsManipulatorAction
result = append(result, NewDropIndexAction(schemaName, action.Arguments[0], action.Arguments[1]))
case "modifyIndex":
result = append(result, NewModifyIndexAction(schemaName, action.Arguments[0], action.Arguments[1], action.Arguments[2]))
+ default:
+ // Unknown action type, skip
}
}
diff --git a/backend/plugin/parser/spanner/query_span_extractor.go b/backend/plugin/parser/spanner/query_span_extractor.go
index 88f531751b..da4c96d3f4 100644
--- a/backend/plugin/parser/spanner/query_span_extractor.go
+++ b/backend/plugin/parser/spanner/query_span_extractor.go
@@ -371,6 +371,8 @@ func (q *querySpanExtractor) extractTableSourceFromSelect(selectCtx parser.ISele
Name: aliasName,
SourceColumns: sourceColumnSet,
})
+ default:
+ // Ignore other select list item types
}
}
return &base.PseudoTable{
@@ -908,6 +910,8 @@ func joinTable(anchor base.TableSource, tp joinType, usingColumns []string, tabl
}
resultField = append(resultField, rFields...)
+ default:
+ // No special handling for other join types
}
return &base.PseudoTable{
Name: "",
@@ -928,9 +932,9 @@ func getJoinTypeFromJoinType(joinType parser.IJoin_typeContext) joinType {
return leftOuterJoin
case joinType.RIGHT_SYMBOL() != nil:
return rightOuterJoin
+ default:
+ return innerJoin
}
-
- return crossJoin
}
func getJoinTypeFromJoinItem(joinItem parser.IJoin_itemContext) joinType {
diff --git a/backend/plugin/parser/sql/ast/float.go b/backend/plugin/parser/sql/ast/float.go
index c4292f1e59..47f50070b6 100644
--- a/backend/plugin/parser/sql/ast/float.go
+++ b/backend/plugin/parser/sql/ast/float.go
@@ -18,6 +18,7 @@ func (f *Float) EquivalentType(tp string) bool {
return tp == "float4" || tp == "real"
case 8:
return tp == "float" || tp == "float8" || tp == "double precision"
+ default:
+ return false
}
- return false
}
diff --git a/backend/plugin/parser/sql/ast/integer.go b/backend/plugin/parser/sql/ast/integer.go
index 8ee2d6a85b..19f268afc6 100644
--- a/backend/plugin/parser/sql/ast/integer.go
+++ b/backend/plugin/parser/sql/ast/integer.go
@@ -20,6 +20,7 @@ func (i *Integer) EquivalentType(tp string) bool {
return tp == "int" || tp == "int4" || tp == "integer"
case 8:
return tp == "bigint" || tp == "int8"
+ default:
+ return false
}
- return false
}
diff --git a/backend/plugin/parser/sql/ast/serial.go b/backend/plugin/parser/sql/ast/serial.go
index 0a6d9733d2..8b6b49c8c2 100644
--- a/backend/plugin/parser/sql/ast/serial.go
+++ b/backend/plugin/parser/sql/ast/serial.go
@@ -20,6 +20,7 @@ func (s *Serial) EquivalentType(tp string) bool {
return tp == "serial" || tp == "serial4"
case 8:
return tp == "bigserial" || tp == "serial8"
+ default:
+ return false
}
- return false
}
diff --git a/backend/plugin/parser/sql/engine/pg/convert.go b/backend/plugin/parser/sql/engine/pg/convert.go
index 8481e9b07f..5774ae3fa8 100644
--- a/backend/plugin/parser/sql/engine/pg/convert.go
+++ b/backend/plugin/parser/sql/engine/pg/convert.go
@@ -168,6 +168,8 @@ func convert(node *pgquery.Node, statement base.SingleSQL) (res ast.Node, err er
}
}
alterTable.AlterItemList = append(alterTable.AlterItemList, attachPartition)
+ default:
+ // Ignore unsupported alter table commands
}
}
}
@@ -237,6 +239,8 @@ func convert(node *pgquery.Node, statement base.SingleSQL) (res ast.Node, err er
Schema: in.RenameStmt.Subname,
NewName: in.RenameStmt.Newname,
}, nil
+ default:
+ return nil, NewConvertErrorf("unsupported rename type %v", in.RenameStmt.RenameType)
}
case *pgquery.Node_IndexStmt:
indexDef := &ast.IndexDef{
@@ -468,6 +472,8 @@ func convert(node *pgquery.Node, statement base.SingleSQL) (res ast.Node, err er
}
return dropTypeStmt, nil
+ default:
+ return nil, NewConvertErrorf("unsupported drop type %v", in.DropStmt.RemoveType)
}
case *pgquery.Node_DropdbStmt:
return &ast.DropDatabaseStmt{
diff --git a/backend/plugin/parser/sql/engine/pg/deparse.go b/backend/plugin/parser/sql/engine/pg/deparse.go
index 4c77fe881a..b41173152e 100644
--- a/backend/plugin/parser/sql/engine/pg/deparse.go
+++ b/backend/plugin/parser/sql/engine/pg/deparse.go
@@ -321,6 +321,8 @@ func deparseIndexMethod(method ast.IndexMethodType, buf *strings.Builder) (err e
_, err = buf.WriteString("brin")
case ast.IndexMethodTypeIvfflat:
_, err = buf.WriteString("ivfflat")
+ default:
+ return errors.Errorf("unsupported index method type: %v", method)
}
return err
}
@@ -345,6 +347,8 @@ func deparseIndexKey(context DeparseContext, in *ast.IndexKeyDef, buf *strings.B
if err := buf.WriteByte(')'); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported index key type: %v", in.Type)
}
if in.SortOrder == ast.SortOrderTypeDescending {
@@ -362,6 +366,8 @@ func deparseIndexKey(context DeparseContext, in *ast.IndexKeyDef, buf *strings.B
if _, err := buf.WriteString(" NULLS LAST"); err != nil {
return err
}
+ default:
+ // No explicit null ordering specified
}
return nil
@@ -707,6 +713,8 @@ func deparseConstraintDef(_ DeparseContext, in *ast.ConstraintDef, buf *strings.
if err := deparseReferentialAction(DeparseContext{}, "ON UPDATE", in.Foreign.OnUpdate, buf); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported constraint type: %v", in.Type)
}
return nil
}
@@ -742,6 +750,8 @@ func deparseReferentialAction(_ DeparseContext, prefix string, in *ast.Referenti
if _, err := buf.WriteString("SET DEFAULT"); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported referential action type: %v", in.Type)
}
return nil
}
@@ -758,6 +768,8 @@ func deparseForeignMatchType(_ DeparseContext, in ast.ForeignMatchType, buf *str
if _, err := buf.WriteString(" MATCH PARTIAL"); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported foreign match type: %v", in)
}
return nil
}
@@ -955,6 +967,8 @@ func deparsePartitionDef(_ DeparseContext, in *ast.PartitionDef, buf *strings.Bu
strategy = "RANGE"
case pgquery.PartitionStrategy_PARTITION_STRATEGY_HASH:
strategy = "HASH"
+ default:
+ return errors.Errorf("unsupported partition strategy: %v", in.Strategy)
}
if _, err := buf.WriteString(strategy); err != nil {
return err
@@ -983,6 +997,8 @@ func deparsePartitionDef(_ DeparseContext, in *ast.PartitionDef, buf *strings.Bu
if _, err := buf.WriteString(")"); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported partition key type: %v", key.Type)
}
}
if _, err := buf.WriteString(")"); err != nil {
@@ -1502,6 +1518,8 @@ func deparseAddEnumValue(_ DeparseContext, in *ast.AddEnumLabelStmt, buf *string
if _, err := buf.WriteString(" AFTER "); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported position type: %v", in.Position)
}
return writeSurrounding(buf, in.NeighborLabel, "'")
}
@@ -1821,6 +1839,8 @@ func deparseRoleSpec(_ DeparseContext, in *ast.RoleSpec, buf *strings.Builder) e
if _, err := buf.WriteString("SESSION_USER"); err != nil {
return err
}
+ default:
+ return errors.Errorf("unsupported role spec type: %v", in.Type)
}
}
return nil
diff --git a/backend/plugin/parser/sql/transform/mysql/transform.go b/backend/plugin/parser/sql/transform/mysql/transform.go
index f2d37e5fca..a2dc5e11f7 100644
--- a/backend/plugin/parser/sql/transform/mysql/transform.go
+++ b/backend/plugin/parser/sql/transform/mysql/transform.go
@@ -346,6 +346,8 @@ func removeRedundantTableOption(table *ast.CreateTableStmt, standard *ast.Create
if collation == nil {
continue
}
+ default:
+ // Keep other table options as-is
}
newOptionList = append(newOptionList, option)
}
@@ -361,6 +363,8 @@ func extractEngineCharsetAndCollation(table *ast.CreateTableStmt) (engine, chars
charset = option
case ast.TableOptionCollate:
collation = option
+ default:
+ // Ignore other table options
}
}
return engine, charset, collation
@@ -432,6 +436,8 @@ func (*SchemaTransformer) Check(schema string) (int, error) {
return int(stmt.End.GetLine()), errors.Errorf("The column-level check constraint is invalid SDL format. Please use table-level check constraints, such as \"CREATE TABLE t(id INT, CONSTRAINT ck_t CHECK (id > 0));\"")
case ast.ColumnOptionReference:
return int(stmt.End.GetLine()), errors.Errorf("The column-level foreign key constraint is invalid SDL format. Please use table-level foreign key constraints, such as \"CREATE TABLE t(id INT, CONSTRAINT fk_t_id FOREIGN KEY (id) REFERENCES t1(c1));\"")
+ default:
+ // Ignore other column options
}
}
}
diff --git a/backend/plugin/parser/tidb/differ.go b/backend/plugin/parser/tidb/differ.go
index 4f99aad6a5..996a4310fa 100644
--- a/backend/plugin/parser/tidb/differ.go
+++ b/backend/plugin/parser/tidb/differ.go
@@ -316,6 +316,9 @@ func (diff *diffNode) diffConstraint(oldTable, newTable *tableInfo) {
},
},
})
+ default:
+ // Skip other constraint types (e.g., key, index, unique)
+ // These are handled separately by diffIndex
}
}
@@ -352,6 +355,8 @@ func (diff *diffNode) diffConstraint(oldTable, newTable *tableInfo) {
},
},
})
+ default:
+ // Skip other constraint types
}
}
}
@@ -938,6 +943,8 @@ func getID(node ast.Node) string {
return in.Table.Name.String()
case ast.AlterTableDropCheck:
return fmt.Sprintf("%s.%s", in.Table.Name.String(), spec.Constraint.Name)
+ default:
+ return in.Table.Name.String()
}
}
case *ast.CreateIndexStmt:
@@ -1578,6 +1585,8 @@ func normalizeColumnOptions(options []*ast.ColumnOption) (*ast.ColumnOption, []*
if option.Expr.GetType().GetType() == mysql.TypeNull {
continue
}
+ default:
+ // Include all other column options
}
retOptions = append(retOptions, option)
}
@@ -1872,6 +1881,8 @@ func diffTableOptions(tableName *ast.TableName, o, n []*ast.TableOption) *ast.Al
// we skip drop them.
case ast.TableOptionEngine, ast.TableOptionCharset, ast.TableOptionCollate:
continue
+ default:
+ // Drop other table options
}
// We should drop the table option if it doesn't exist in the new table options.
if astOption := dropTableOption(oldOption); astOption != nil {
@@ -2031,6 +2042,8 @@ func dropTableOption(option *ast.TableOption) *ast.TableOption {
// TODO(zp): handle the table space
case ast.TableOptionUnion:
// TODO(zp): handle the union
+ default:
+ // Return nil for unhandled table options
}
return nil
}
@@ -2118,8 +2131,10 @@ func isTableOptionValEqual(o, n *ast.TableOption) bool {
}
}
return true
+ default:
+ // For unknown option types, consider them equal
+ return true
}
- return true
}
// isViewEqual checks whether two views with same name are equal.
diff --git a/backend/plugin/parser/tidb/split.go b/backend/plugin/parser/tidb/split.go
index d59db9a1fb..8581c1b383 100644
--- a/backend/plugin/parser/tidb/split.go
+++ b/backend/plugin/parser/tidb/split.go
@@ -302,6 +302,8 @@ func splitTiDBStatement(stream *antlr.CommonTokenStream, statement string) ([]ba
}
case parser.MySQLParserSEMICOLON_SYMBOL:
semicolonStack = append(semicolonStack, i)
+ default:
+ // Continue processing other token types
}
}
diff --git a/backend/plugin/parser/tidb/tidb.go b/backend/plugin/parser/tidb/tidb.go
index a07abba3d8..d596ef53b8 100644
--- a/backend/plugin/parser/tidb/tidb.go
+++ b/backend/plugin/parser/tidb/tidb.go
@@ -303,8 +303,9 @@ func TypeString(tp byte) string {
return "binary"
case mysql.TypeGeometry:
return "geometry"
+ default:
+ return "unknown"
}
- return "unknown"
}
func tidbAddSemicolonIfNeeded(sql string) string {
diff --git a/backend/plugin/parser/tokenizer/tokenizer.go b/backend/plugin/parser/tokenizer/tokenizer.go
index 6491a2c06f..8d4ce3e98c 100644
--- a/backend/plugin/parser/tokenizer/tokenizer.go
+++ b/backend/plugin/parser/tokenizer/tokenizer.go
@@ -196,8 +196,10 @@ func matchMySQLTableConstraint(text string, cons *tidbast.Constraint) bool {
notForeign := !strings.Contains(text, "foreign key")
isIndex := strings.Contains(text, "index") || strings.Contains(text, "key")
return notUnique && notPrimary && notForeign && isIndex
+ default:
+ // Unknown constraint type
+ return false
}
- return false
}
// SetLineForPGCreateTableStmt sets the line for columns and table constraints in CREATE TABLE statements.
@@ -357,8 +359,10 @@ func matchTableConstraint(text string, cons *ast.ConstraintDef) bool {
return strings.Contains(text, "primary key")
case ast.ConstraintTypeForeign:
return strings.Contains(text, "foreign key")
+ default:
+ // Unknown constraint type
+ return false
}
- return false
}
// SplitTiDBMultiSQL splits the statement to a string slice.
@@ -792,6 +796,8 @@ func (t *Tokenizer) scanComment() error {
t.skip(1)
t.skipToNewLine()
return nil
+ default:
+ // Not a comment
}
return errors.Errorf("no comment found")
}
diff --git a/backend/plugin/parser/trino/completion.go b/backend/plugin/parser/trino/completion.go
index 583588c929..c03cac0881 100644
--- a/backend/plugin/parser/trino/completion.go
+++ b/backend/plugin/parser/trino/completion.go
@@ -840,6 +840,8 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) []b
}
}
}
+ default:
+ // Ignore other rule candidates
}
}
@@ -1104,6 +1106,9 @@ func deriveObjectRefContextsFromCandidates(candidates []string, includeColumn bo
if includeColumn {
results = append(results, refCtx.clone().setCatalog(candidates[0]).setSchema(candidates[1]).setObject(candidates[2]).setColumn(candidates[3]))
}
+ default:
+ // For cases with more than 4 identifiers, ignore them
+ return []*objectRefContext{refCtx.clone()}
}
// If no results were generated, return the default empty context
@@ -1214,6 +1219,8 @@ func (c *Completer) collectLeadingTableReferences(caretIndex int) {
}
case trinoparser.TrinoParserFROM_:
found = true
+ default:
+ // Continue scanning for other tokens
}
}
if !found {
@@ -1251,6 +1258,8 @@ func (c *Completer) collectRemainingTableReferences() {
if level == 0 {
found = true
}
+ default:
+ // Continue scanning for other tokens
}
}
@@ -1532,6 +1541,8 @@ func (c *Completer) fetchSelectItemAliases(ruleStack []*base.RuleContext) []stri
case trinoparser.TrinoParserRULE_groupBy, trinoparser.TrinoParserRULE_sortItem, trinoparser.TrinoParserRULE_booleanExpression:
// These represent ORDER BY, GROUP BY, and HAVING contexts
canUseAliases = true
+ default:
+ // Continue iterating through other rule types
}
}
diff --git a/backend/plugin/parser/trino/parser_test.go b/backend/plugin/parser/trino/parser_test.go
index f58160a4f6..16255f5105 100644
--- a/backend/plugin/parser/trino/parser_test.go
+++ b/backend/plugin/parser/trino/parser_test.go
@@ -2,7 +2,6 @@ package trino
import (
"context"
- "os"
"testing"
"github.com/stretchr/testify/assert"
@@ -197,6 +196,5 @@ func TestGetQuerySpan(t *testing.T) {
func TestMain(m *testing.M) {
// Run the tests and print results to stdout
- code := m.Run()
- os.Exit(code)
+ m.Run()
}
diff --git a/backend/plugin/parser/trino/query_span_feature_test.go b/backend/plugin/parser/trino/query_span_feature_test.go
index 64ad0c4c74..6782fffacf 100644
--- a/backend/plugin/parser/trino/query_span_feature_test.go
+++ b/backend/plugin/parser/trino/query_span_feature_test.go
@@ -60,6 +60,8 @@ func TestPredicateExtraction(t *testing.T) {
foundIDCol = true
case "name":
foundNameCol = true
+ default:
+ // Other columns that we don't track in this test
}
}
diff --git a/backend/plugin/parser/tsql/batch/batch.go b/backend/plugin/parser/tsql/batch/batch.go
index 5328ac888e..5927b538ec 100644
--- a/backend/plugin/parser/tsql/batch/batch.go
+++ b/backend/plugin/parser/tsql/batch/batch.go
@@ -216,6 +216,8 @@ parse:
b.raw = append(b.raw[:i], b.raw[cend:]...)
break parse
}
+ default:
+ // Continue processing normal characters
}
}
@@ -278,6 +280,8 @@ func (*Batcher) readString(r []rune, i, end int, quote rune) (int, bool) {
quote == '"' && c == '"',
quote == '[' && c == ']':
return i, true
+ default:
+ // Continue scanning for string terminator
}
prev = c
}
diff --git a/backend/plugin/parser/tsql/differ.go b/backend/plugin/parser/tsql/differ.go
index 5088143c82..75dfeb667c 100644
--- a/backend/plugin/parser/tsql/differ.go
+++ b/backend/plugin/parser/tsql/differ.go
@@ -391,7 +391,7 @@ func (d *diffNode) appendAddConstraint(schemaName, tableName string, addConstrai
}
for i, addConstraint := range addConstraints {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ","); err != nil {
+ if _, err := fmt.Fprint(&buf, ","); err != nil {
return err
}
}
@@ -484,7 +484,7 @@ func (d *diffNode) appendAddColumn(schemaName, tableName string, addColumns []ts
}
for i, addColumn := range addColumns {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ","); err != nil {
+ if _, err := fmt.Fprint(&buf, ","); err != nil {
return err
}
}
diff --git a/backend/plugin/parser/tsql/query_type.go b/backend/plugin/parser/tsql/query_type.go
index f2052be9be..6f96701257 100644
--- a/backend/plugin/parser/tsql/query_type.go
+++ b/backend/plugin/parser/tsql/query_type.go
@@ -41,9 +41,9 @@ func (l *queryTypeListener) getQueryTypeForBatchWithoutGo(batch parser.IBatch_wi
return l.getQueryTypeForBatchLevelStatement(batch.Batch_level_statement())
case batch.Execute_body_batch() != nil:
return l.getQueryTypeForExecuteBodyBatch(batch.Execute_body_batch())
+ default:
+ return base.QueryTypeUnknown, nil
}
-
- return base.QueryTypeUnknown, nil
}
func (l *queryTypeListener) getQueryTypeForSQLClause(clause parser.ISql_clausesContext) (base.QueryType, error) {
@@ -67,8 +67,9 @@ func (l *queryTypeListener) getQueryTypeForSQLClause(clause parser.ISql_clausesC
return base.QueryTypeUnknown, nil
case clause.Cfl_statement() != nil, clause.Dbcc_clause() != nil, clause.Backup_statement() != nil:
return base.QueryTypeUnknown, nil
+ default:
+ return base.QueryTypeUnknown, nil
}
- return base.QueryTypeUnknown, nil
}
func (*queryTypeListener) getQueryTypeForBatchLevelStatement(parser.IBatch_level_statementContext) (base.QueryType, error) {
diff --git a/backend/plugin/parser/tsql/restore.go b/backend/plugin/parser/tsql/restore.go
index 767942ca7b..0eb1ddd270 100644
--- a/backend/plugin/parser/tsql/restore.go
+++ b/backend/plugin/parser/tsql/restore.go
@@ -185,7 +185,7 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
}
for i, column := range uk {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, " AND"); err != nil {
+ if _, err := fmt.Fprint(&buf, " AND"); err != nil {
g.err = err
return
}
@@ -195,13 +195,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, "\nWHEN MATCHED THEN\n UPDATE SET"); err != nil {
+ if _, err := fmt.Fprint(&buf, "\nWHEN MATCHED THEN\n UPDATE SET"); err != nil {
g.err = err
return
}
for i, field := range l.result {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ","); err != nil {
+ if _, err := fmt.Fprint(&buf, ","); err != nil {
g.err = err
return
}
@@ -211,13 +211,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, "\nWHEN NOT MATCHED THEN\n INSERT ("); err != nil {
+ if _, err := fmt.Fprint(&buf, "\nWHEN NOT MATCHED THEN\n INSERT ("); err != nil {
g.err = err
return
}
for i, column := range g.table.GetColumns() {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ", "); err != nil {
+ if _, err := fmt.Fprint(&buf, ", "); err != nil {
g.err = err
return
}
@@ -227,13 +227,13 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, ") VALUES ("); err != nil {
+ if _, err := fmt.Fprint(&buf, ") VALUES ("); err != nil {
g.err = err
return
}
for i, column := range g.table.GetColumns() {
if i > 0 {
- if _, err := fmt.Fprintf(&buf, ", "); err != nil {
+ if _, err := fmt.Fprint(&buf, ", "); err != nil {
g.err = err
return
}
@@ -243,7 +243,7 @@ func (g *generator) EnterUpdate_statement(ctx *parser.Update_statementContext) {
return
}
}
- if _, err := fmt.Fprintf(&buf, ");"); err != nil {
+ if _, err := fmt.Fprint(&buf, ");"); err != nil {
g.err = err
return
}
diff --git a/backend/plugin/parser/tsql/split.go b/backend/plugin/parser/tsql/split.go
index e1879812d5..f68cb210dd 100644
--- a/backend/plugin/parser/tsql/split.go
+++ b/backend/plugin/parser/tsql/split.go
@@ -236,6 +236,8 @@ func splitBatchWithoutGo(b parser.IBatch_without_goContext, tokens []antlr.Token
})
start = pos + 1
}
+ default:
+ // No statements found in this batch
}
return result, start
}
diff --git a/backend/plugin/schema/clickhouse/state.go b/backend/plugin/schema/clickhouse/state.go
index 4e3ed9bf96..c80bbb55ff 100644
--- a/backend/plugin/schema/clickhouse/state.go
+++ b/backend/plugin/schema/clickhouse/state.go
@@ -83,7 +83,7 @@ func (t *tableState) toString(buf *strings.Builder) error {
})
for i, column := range columns {
if i > 0 {
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
}
diff --git a/backend/plugin/schema/mssql/generate_migration.go b/backend/plugin/schema/mssql/generate_migration.go
index a06e0744a7..c4101a691b 100644
--- a/backend/plugin/schema/mssql/generate_migration.go
+++ b/backend/plugin/schema/mssql/generate_migration.go
@@ -79,6 +79,8 @@ func generateMigration(diff *schema.MetadataDiff) (string, error) {
_, _ = buf.WriteString(fk.Name)
_, _ = buf.WriteString("];\n")
}
+ default:
+ // Ignore other actions for this phase
}
}
@@ -456,6 +458,8 @@ func generateMigration(diff *schema.MetadataDiff) (string, error) {
_, _ = buf.WriteString(";")
}
_, _ = buf.WriteString("\nGO\n")
+ default:
+ // Ignore other actions
}
}
@@ -531,6 +535,8 @@ func generateCreateTable(schemaName, tableName string, table *storepb.TableMetad
_, _ = buf.WriteString(" CLUSTERED")
case "NONCLUSTERED":
_, _ = buf.WriteString(" NONCLUSTERED")
+ default:
+ // Default to "" if not specified
}
_, _ = buf.WriteString(" (")
for j, expr := range idx.Expressions {
diff --git a/backend/plugin/schema/mssql/get_database_definition.go b/backend/plugin/schema/mssql/get_database_definition.go
index b8cd770f12..2b247e1eb9 100644
--- a/backend/plugin/schema/mssql/get_database_definition.go
+++ b/backend/plugin/schema/mssql/get_database_definition.go
@@ -337,7 +337,7 @@ func writeTable(out *strings.Builder, schemaName string, table *storepb.TableMet
_, _ = out.WriteString(",\n")
writeCheck(out, check)
}
- _, _ = fmt.Fprintf(out, "\n);\n\n")
+ _, _ = fmt.Fprint(out, "\n);\n\n")
for _, index := range table.Indexes {
if index.IsConstraint {
diff --git a/backend/plugin/schema/mssql/get_database_metadata_testcontainer_test.go b/backend/plugin/schema/mssql/get_database_metadata_testcontainer_test.go
index 73252d84e2..968863e0c0 100644
--- a/backend/plugin/schema/mssql/get_database_metadata_testcontainer_test.go
+++ b/backend/plugin/schema/mssql/get_database_metadata_testcontainer_test.go
@@ -179,7 +179,7 @@ GO
require.Equal(t, "GEOMETRY", idx.SpatialConfig.Dimensional.DataType)
require.Equal(t, int32(2), idx.SpatialConfig.Dimensional.Dimensions)
} else {
- t.Errorf("idx_location_point not found")
+ t.Error("idx_location_point not found")
}
// Validate idx_boundary_polygon
@@ -205,7 +205,7 @@ GO
require.Equal(t, "HIGH", gridMap[3])
require.Equal(t, "HIGH", gridMap[4])
} else {
- t.Errorf("idx_boundary_polygon not found")
+ t.Error("idx_boundary_polygon not found")
}
// Validate idx_geo_location
@@ -238,7 +238,7 @@ GO
require.Equal(t, "GEOGRAPHY", idx.SpatialConfig.Dimensional.DataType)
require.Equal(t, int32(2), idx.SpatialConfig.Dimensional.Dimensions)
} else {
- t.Errorf("idx_geo_location not found")
+ t.Error("idx_geo_location not found")
}
// Validate idx_route_line
@@ -257,7 +257,7 @@ GO
require.Equal(t, "HIGH", gridMap[3])
require.Equal(t, "HIGH", gridMap[4])
} else {
- t.Errorf("idx_route_line not found")
+ t.Error("idx_route_line not found")
}
},
},
@@ -365,7 +365,7 @@ GO
require.Equal(t, "LOW", level.Density)
}
} else {
- t.Errorf("idx_min_geom not found")
+ t.Error("idx_min_geom not found")
}
// Validate maximum GEOMETRY index
@@ -390,7 +390,7 @@ GO
require.True(t, idx.SpatialConfig.Storage.AllowRowLocks)
require.True(t, idx.SpatialConfig.Storage.AllowPageLocks)
} else {
- t.Errorf("idx_max_geom not found")
+ t.Error("idx_max_geom not found")
}
// Validate minimal GEOGRAPHY index
@@ -404,7 +404,7 @@ GO
require.Equal(t, "LOW", level.Density)
}
} else {
- t.Errorf("idx_min_geog not found")
+ t.Error("idx_min_geog not found")
}
// Validate maximum GEOGRAPHY index
@@ -419,7 +419,7 @@ GO
require.Equal(t, int32(50), idx.SpatialConfig.Storage.Fillfactor)
} else {
- t.Errorf("idx_max_geog not found")
+ t.Error("idx_max_geog not found")
}
},
},
diff --git a/backend/plugin/schema/mysql/generate_migration.go b/backend/plugin/schema/mysql/generate_migration.go
index dd57b293c0..cb34c0cc01 100644
--- a/backend/plugin/schema/mysql/generate_migration.go
+++ b/backend/plugin/schema/mysql/generate_migration.go
@@ -319,6 +319,8 @@ func createObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) error
if err := writeCreateOrReplaceView(buf, viewDiff.ViewName, viewDiff.NewView); err != nil {
return err
}
+ default:
+ // No action needed for other diff actions
}
}
@@ -570,6 +572,9 @@ func writeCreateTableWithoutForeignKeys(buf *strings.Builder, tableName string,
_, _ = buf.WriteString("STORED")
case storepb.GenerationMetadata_TYPE_VIRTUAL:
_, _ = buf.WriteString("VIRTUAL")
+ default:
+ // Default to VIRTUAL for unknown types
+ _, _ = buf.WriteString("VIRTUAL")
}
}
@@ -707,6 +712,9 @@ func writeAddColumn(buf *strings.Builder, table string, column *storepb.ColumnMe
_, _ = buf.WriteString("STORED")
case storepb.GenerationMetadata_TYPE_VIRTUAL:
_, _ = buf.WriteString("VIRTUAL")
+ default:
+ // Default to VIRTUAL for unknown types
+ _, _ = buf.WriteString("VIRTUAL")
}
}
@@ -768,6 +776,9 @@ func writeModifyColumn(buf *strings.Builder, table string, column *storepb.Colum
_, _ = buf.WriteString("STORED")
case storepb.GenerationMetadata_TYPE_VIRTUAL:
_, _ = buf.WriteString("VIRTUAL")
+ default:
+ // Default to VIRTUAL for unknown types
+ _, _ = buf.WriteString("VIRTUAL")
}
}
diff --git a/backend/plugin/schema/mysql/get_database_definition.go b/backend/plugin/schema/mysql/get_database_definition.go
index fc5d579473..4ee37e69a1 100644
--- a/backend/plugin/schema/mysql/get_database_definition.go
+++ b/backend/plugin/schema/mysql/get_database_definition.go
@@ -542,7 +542,7 @@ func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {
for i, column := range table.Columns {
if i != 0 {
- if _, err := fmt.Fprintf(out, ",\n"); err != nil {
+ if _, err := fmt.Fprint(out, ",\n"); err != nil {
return err
}
}
@@ -675,7 +675,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if len(partitions[0].Subpartitions) > 0 {
- if _, err := fmt.Fprintf(buf, "\nSUBPARTITION BY "); err != nil {
+ if _, err := fmt.Fprint(buf, "\nSUBPARTITION BY "); err != nil {
return err
}
switch partitions[0].Subpartitions[0].Type {
@@ -716,7 +716,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if useDefault == 0 {
- if _, err := fmt.Fprintf(buf, "\n("); err != nil {
+ if _, err := fmt.Fprint(buf, "\n("); err != nil {
return err
}
preposition, err := getPrepositionByType(partitions[0].Type)
@@ -725,7 +725,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
for i, partition := range partitions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
}
@@ -745,7 +745,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if subUseDefault == 0 && len(partition.Subpartitions) > 0 {
- if _, err := fmt.Fprintf(buf, "\n ("); err != nil {
+ if _, err := fmt.Fprint(buf, "\n ("); err != nil {
return err
}
for j, subPartition := range partition.Subpartitions {
@@ -756,11 +756,11 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
return err
}
if j == len(partition.Subpartitions)-1 {
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
} else {
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
}
@@ -772,14 +772,14 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if i == len(partitions)-1 {
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
}
}
}
- if _, err := fmt.Fprintf(buf, " */"); err != nil {
+ if _, err := fmt.Fprint(buf, " */"); err != nil {
return err
}
@@ -862,7 +862,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
for i, column := range fk.Columns {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -877,7 +877,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
for i, column := range fk.ReferencedColumns {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -886,7 +886,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
@@ -910,20 +910,20 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
return nil
}
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
if index.Unique {
- if _, err := fmt.Fprintf(buf, "UNIQUE "); err != nil {
+ if _, err := fmt.Fprint(buf, "UNIQUE "); err != nil {
return err
}
} else if strings.EqualFold(index.Type, mysqlIndexFullText) {
- if _, err := fmt.Fprintf(buf, "FULLTEXT "); err != nil {
+ if _, err := fmt.Fprint(buf, "FULLTEXT "); err != nil {
return err
}
} else if strings.EqualFold(index.Type, mysqlIndexSpatial) {
- if _, err := fmt.Fprintf(buf, "SPATIAL "); err != nil {
+ if _, err := fmt.Fprint(buf, "SPATIAL "); err != nil {
return err
}
}
@@ -934,7 +934,7 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
for i, expr := range index.Expressions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -951,7 +951,7 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
@@ -999,12 +999,12 @@ func printIndexKeyPart(buf *strings.Builder, expr string, length int64, descendi
func printPrimaryKeyClause(buf *strings.Builder, indexes []*storepb.IndexMetadata) error {
for _, index := range indexes {
if index.Primary {
- if _, err := fmt.Fprintf(buf, ",\n PRIMARY KEY ("); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n PRIMARY KEY ("); err != nil {
return err
}
for i, column := range index.Expressions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -1020,7 +1020,7 @@ func printPrimaryKeyClause(buf *strings.Builder, indexes []*storepb.IndexMetadat
return err
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
return nil
@@ -1057,18 +1057,20 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tab
}
switch column.Generation.Type {
case storepb.GenerationMetadata_TYPE_STORED:
- if _, err := fmt.Fprintf(buf, "STORED"); err != nil {
+ if _, err := fmt.Fprint(buf, "STORED"); err != nil {
return err
}
case storepb.GenerationMetadata_TYPE_VIRTUAL:
- if _, err := fmt.Fprintf(buf, "VIRTUAL"); err != nil {
+ if _, err := fmt.Fprint(buf, "VIRTUAL"); err != nil {
return err
}
+ default:
+ // Unknown generation type
}
}
if !column.Nullable {
- if _, err := fmt.Fprintf(buf, " NOT NULL"); err != nil {
+ if _, err := fmt.Fprint(buf, " NOT NULL"); err != nil {
return err
}
}
@@ -1113,7 +1115,7 @@ func printDefaultClause(buf *strings.Builder, column *storepb.ColumnMetadata) er
if column.Generation != nil && column.Generation.Expression != "" {
return nil
}
- if _, err := fmt.Fprintf(buf, " DEFAULT NULL"); err != nil {
+ if _, err := fmt.Fprint(buf, " DEFAULT NULL"); err != nil {
return err
}
return nil
diff --git a/backend/plugin/schema/mysql/get_database_metadata.go b/backend/plugin/schema/mysql/get_database_metadata.go
index a925f8acdd..cb928d99ee 100644
--- a/backend/plugin/schema/mysql/get_database_metadata.go
+++ b/backend/plugin/schema/mysql/get_database_metadata.go
@@ -1078,6 +1078,8 @@ func normalizeDefaultValue(defaultValue string) string {
return "1"
case "false":
return "0"
+ default:
+ // Return as-is for non-boolean values
}
return defaultValue
diff --git a/backend/plugin/schema/pg/generate_migration.go b/backend/plugin/schema/pg/generate_migration.go
index aa2dfb266c..d72bd02e95 100644
--- a/backend/plugin/schema/pg/generate_migration.go
+++ b/backend/plugin/schema/pg/generate_migration.go
@@ -1275,6 +1275,8 @@ func writeFunctionDiff(out *strings.Builder, funcDiff *schema.FunctionDiff) erro
_, _ = out.WriteString(";")
}
_, _ = out.WriteString("\n\n")
+ default:
+ // Ignore other actions
}
return nil
}
diff --git a/backend/plugin/schema/pg/get_database_metadata.go b/backend/plugin/schema/pg/get_database_metadata.go
index ce6cdb4893..521f0b21e5 100644
--- a/backend/plugin/schema/pg/get_database_metadata.go
+++ b/backend/plugin/schema/pg/get_database_metadata.go
@@ -429,6 +429,8 @@ func normalizePostgreSQLType(typeName string) string {
return "timestamp with time zone"
case "timetz":
return "time with time zone"
+ default:
+ // Return type as-is for unrecognized types
}
// Handle specific length specifications for character types
@@ -649,6 +651,8 @@ func (e *metadataExtractor) extractColumnConstraint(ctx parser.IColconstraintele
// Create identity sequence for this column
e.createIdentitySequence(table, column, schemaName)
+ default:
+ // Ignore other column constraints
}
}
diff --git a/backend/plugin/schema/tidb/generate_migration.go b/backend/plugin/schema/tidb/generate_migration.go
index d73b702801..7c1d775c6e 100644
--- a/backend/plugin/schema/tidb/generate_migration.go
+++ b/backend/plugin/schema/tidb/generate_migration.go
@@ -215,6 +215,8 @@ func createObjectsInOrder(diff *schema.MetadataDiff, buf *strings.Builder) error
if err := writeCreateOrReplaceView(buf, viewDiff.ViewName, viewDiff.NewView); err != nil {
return err
}
+ default:
+ // Ignore other view actions
}
}
@@ -601,6 +603,8 @@ func writePartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
_, _ = fmt.Fprintf(buf, "HASH (%s)", partitions[0].Expression)
case storepb.TablePartitionMetadata_KEY:
_, _ = fmt.Fprintf(buf, "KEY (%s)", partitions[0].Expression)
+ default:
+ // Unsupported partition type
}
// Add partitions count if specified
@@ -624,6 +628,8 @@ func writePartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
case storepb.TablePartitionMetadata_LIST, storepb.TablePartitionMetadata_LIST_COLUMNS:
_, _ = fmt.Fprintf(buf, " VALUES IN (%s)", partition.Value)
+ default:
+ // No VALUES clause for other partition types like HASH/KEY
}
}
}
@@ -1073,6 +1079,8 @@ func writeSequenceDiff(buf *strings.Builder, seqDiff *schema.SequenceDiff) error
return writeCreateSequence(buf, seqDiff.NewSequence)
case schema.MetadataDiffActionAlter:
return writeAlterSequence(buf, seqDiff.SequenceName, seqDiff.NewSequence)
+ default:
+ // Ignore other sequence actions
}
return nil
}
diff --git a/backend/plugin/schema/tidb/get_database_definition.go b/backend/plugin/schema/tidb/get_database_definition.go
index c07275d805..ed6bbf3619 100644
--- a/backend/plugin/schema/tidb/get_database_definition.go
+++ b/backend/plugin/schema/tidb/get_database_definition.go
@@ -607,7 +607,7 @@ func writeTable(out *strings.Builder, table *storepb.TableMetadata) error {
for i, column := range table.Columns {
if i != 0 {
- if _, err := fmt.Fprintf(out, ",\n"); err != nil {
+ if _, err := fmt.Fprint(out, ",\n"); err != nil {
return err
}
}
@@ -746,7 +746,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if len(partitions[0].Subpartitions) > 0 {
- if _, err := fmt.Fprintf(buf, "\nSUBPARTITION BY "); err != nil {
+ if _, err := fmt.Fprint(buf, "\nSUBPARTITION BY "); err != nil {
return err
}
switch partitions[0].Subpartitions[0].Type {
@@ -787,7 +787,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if useDefault == 0 {
- if _, err := fmt.Fprintf(buf, "\n("); err != nil {
+ if _, err := fmt.Fprint(buf, "\n("); err != nil {
return err
}
preposition, err := getPrepositionByType(partitions[0].Type)
@@ -796,7 +796,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
for i, partition := range partitions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
}
@@ -816,7 +816,7 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if subUseDefault == 0 && len(partition.Subpartitions) > 0 {
- if _, err := fmt.Fprintf(buf, "\n ("); err != nil {
+ if _, err := fmt.Fprint(buf, "\n ("); err != nil {
return err
}
for j, subPartition := range partition.Subpartitions {
@@ -827,11 +827,11 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
return err
}
if j == len(partition.Subpartitions)-1 {
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
} else {
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
}
@@ -843,14 +843,14 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
}
if i == len(partitions)-1 {
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
}
}
}
- if _, err := fmt.Fprintf(buf, " */"); err != nil {
+ if _, err := fmt.Fprint(buf, " */"); err != nil {
return err
}
@@ -933,7 +933,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
for i, column := range fk.Columns {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -948,7 +948,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
for i, column := range fk.ReferencedColumns {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -957,7 +957,7 @@ func printForeignKeyClause(buf *strings.Builder, fk *storepb.ForeignKeyMetadata)
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
@@ -981,20 +981,20 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
return nil
}
- if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n "); err != nil {
return err
}
if index.Unique {
- if _, err := fmt.Fprintf(buf, "UNIQUE "); err != nil {
+ if _, err := fmt.Fprint(buf, "UNIQUE "); err != nil {
return err
}
} else if strings.EqualFold(index.Type, mysqlIndexFullText) {
- if _, err := fmt.Fprintf(buf, "FULLTEXT "); err != nil {
+ if _, err := fmt.Fprint(buf, "FULLTEXT "); err != nil {
return err
}
} else if strings.EqualFold(index.Type, mysqlIndexSpatial) {
- if _, err := fmt.Fprintf(buf, "SPATIAL "); err != nil {
+ if _, err := fmt.Fprint(buf, "SPATIAL "); err != nil {
return err
}
}
@@ -1005,7 +1005,7 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
for i, expr := range index.Expressions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -1022,7 +1022,7 @@ func printIndexClause(buf *strings.Builder, index *storepb.IndexMetadata) error
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
@@ -1070,12 +1070,12 @@ func printIndexKeyPart(buf *strings.Builder, expr string, length int64, descendi
func printPrimaryKeyClause(buf *strings.Builder, table *storepb.TableMetadata) error {
for _, index := range table.GetIndexes() {
if index.Primary {
- if _, err := fmt.Fprintf(buf, ",\n PRIMARY KEY ("); err != nil {
+ if _, err := fmt.Fprint(buf, ",\n PRIMARY KEY ("); err != nil {
return err
}
for i, column := range index.Expressions {
if i != 0 {
- if _, err := fmt.Fprintf(buf, ", "); err != nil {
+ if _, err := fmt.Fprint(buf, ", "); err != nil {
return err
}
}
@@ -1091,7 +1091,7 @@ func printPrimaryKeyClause(buf *strings.Builder, table *storepb.TableMetadata) e
return err
}
}
- if _, err := fmt.Fprintf(buf, ")"); err != nil {
+ if _, err := fmt.Fprint(buf, ")"); err != nil {
return err
}
if _, err := fmt.Fprintf(buf, " /*T![clustered_index] %s */", table.PrimaryKeyType); err != nil {
@@ -1135,18 +1135,20 @@ func printColumnClause(buf *strings.Builder, column *storepb.ColumnMetadata, tab
}
switch column.Generation.Type {
case storepb.GenerationMetadata_TYPE_STORED:
- if _, err := fmt.Fprintf(buf, "STORED"); err != nil {
+ if _, err := fmt.Fprint(buf, "STORED"); err != nil {
return err
}
case storepb.GenerationMetadata_TYPE_VIRTUAL:
- if _, err := fmt.Fprintf(buf, "VIRTUAL"); err != nil {
+ if _, err := fmt.Fprint(buf, "VIRTUAL"); err != nil {
return err
}
+ default:
+ // No special handling for other generation types
}
}
if !column.Nullable {
- if _, err := fmt.Fprintf(buf, " NOT NULL"); err != nil {
+ if _, err := fmt.Fprint(buf, " NOT NULL"); err != nil {
return err
}
}
@@ -1195,7 +1197,7 @@ func printDefaultClause(buf *strings.Builder, column *storepb.ColumnMetadata) er
if column.Generation != nil && column.Generation.Expression != "" {
return nil
}
- if _, err := fmt.Fprintf(buf, " DEFAULT NULL"); err != nil {
+ if _, err := fmt.Fprint(buf, " DEFAULT NULL"); err != nil {
return err
}
return nil
diff --git a/backend/plugin/schema/tidb/get_database_metadata.go b/backend/plugin/schema/tidb/get_database_metadata.go
index aefcbd3449..4ac5103946 100644
--- a/backend/plugin/schema/tidb/get_database_metadata.go
+++ b/backend/plugin/schema/tidb/get_database_metadata.go
@@ -150,6 +150,8 @@ func (m *metadataExtractor) processCreateDatabase(stmt *ast.CreateDatabaseStmt)
m.result.CharacterSet = option.Value
case ast.DatabaseOptionCollate:
m.result.Collation = option.Value
+ default:
+ // Ignore other database options
}
}
@@ -213,6 +215,8 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) error
case ast.ColumnOptionUniqKey:
// Handle unique constraint at column level
// We'll handle creating unique indexes after processing all columns
+ default:
+ // Ignore other column options
}
}
@@ -288,6 +292,8 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) error
case ast.ConstraintCheck:
// Handle check constraints
m.processCheckConstraint(constraint, table)
+ default:
+ // Ignore other constraint types
}
}
@@ -313,6 +319,8 @@ func (m *metadataExtractor) processCreateTable(stmt *ast.CreateTableStmt) error
case ast.TableOptionRowFormat:
// Handle row format (DYNAMIC, COMPACT, etc.)
// Store in comment for now as TableMetadata doesn't have RowFormat field
+ default:
+ // Ignore other table options
}
}
@@ -470,6 +478,8 @@ func (*metadataExtractor) getColumnType(tp *types.FieldType) string {
case mysql.TypeYear:
// YEAR(4) - MySQL/TiDB YEAR type
return fmt.Sprintf("%s(%d)", baseType, tp.GetFlen())
+ default:
+ // Return baseType for other types that don't need length specification
}
}
@@ -699,6 +709,8 @@ func (*metadataExtractor) processColumnLevelConstraints(stmt *ast.CreateTableStm
columnName: columnName,
indexName: columnName, // Use column name as index name for single-column unique
})
+ default:
+ // Ignore other column options
}
}
}
diff --git a/backend/plugin/webhook/discord.go b/backend/plugin/webhook/discord.go
index 536f7123b8..04da9424a5 100644
--- a/backend/plugin/webhook/discord.go
+++ b/backend/plugin/webhook/discord.go
@@ -67,6 +67,9 @@ func (*DiscordReceiver) Post(context Context) error {
status = ":warning: "
case WebhookError:
status = ":exclamation: "
+ default:
+ // No status icon for other levels
+ status = ""
}
embedList = append(embedList, DiscordWebhookEmbed{
Title: fmt.Sprintf("%s%s", status, context.Title),
diff --git a/backend/plugin/webhook/slack/slack.go b/backend/plugin/webhook/slack/slack.go
index db8418554c..d534a6fb3b 100644
--- a/backend/plugin/webhook/slack/slack.go
+++ b/backend/plugin/webhook/slack/slack.go
@@ -68,6 +68,8 @@ func GetBlocks(context webhook.Context) []Block {
status = ":warning: "
case webhook.WebhookError:
status = ":exclamation: "
+ default:
+ status = ""
}
blockList = append(blockList, Block{
Type: "section",
diff --git a/backend/plugin/webhook/wecom/wecom.go b/backend/plugin/webhook/wecom/wecom.go
index 949601134b..7e2256c724 100644
--- a/backend/plugin/webhook/wecom/wecom.go
+++ b/backend/plugin/webhook/wecom/wecom.go
@@ -59,6 +59,9 @@ func getMessageCard(context webhook.Context) *WebhookMarkdown {
status = "<font color=\"yellow\">Warn</font> "
case webhook.WebhookError:
status = "<font color=\"red\">Error</font> "
+ default:
+ // For any other level (including WebhookInfo), use no special formatting
+ status = ""
}
content := fmt.Sprintf("# %s%s\n\n%s\n[View in Bytebase](%s)", status, context.Title, strings.Join(metaStrList, "\n"), context.Link)
if context.Description != "" {
diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.go
index 58ed838568..751a02401e 100644
--- a/backend/runner/schemasync/syncer.go
+++ b/backend/runner/schemasync/syncer.go
@@ -628,6 +628,10 @@ func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.In
return false
}
return backupDB != nil
+ default:
+ // Unsupported database engine for backup
+ slog.Debug("Unsupported database engine for backup", "engine", instance.Metadata.GetEngine())
+ return false
}
return false
}
diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.go
index 3c935f43ed..246e829835 100644
--- a/backend/runner/taskrun/data_update_executor.go
+++ b/backend/runner/taskrun/data_update_executor.go
@@ -279,6 +279,8 @@ func (exec *DataUpdateExecutor) backupData(
if _, err := driver.Execute(driverCtx, fmt.Sprintf(`COMMENT ON TABLE "%s"."%s" IS '%s, source table (%s, %s)'`, backupDatabaseName, statement.TargetTableName, bbSource, database.DatabaseName, statement.SourceTableName), db.ExecuteOptions{}); err != nil {
return nil, errors.Wrap(err, "failed to set table comment")
}
+ default:
+ // No action needed for other database engines
}
item := &storepb.PriorBackupDetail_Item{
@@ -401,6 +403,8 @@ func getPrependStatements(engine storepb.Engine, statement string) (string, erro
switch n.Name {
case "role", "search_path":
return n.Text(), nil
+ default:
+ // Ignore other variable names
}
}
}
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 60955a3631..65f91d86a4 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -307,6 +307,8 @@ func doMigrationWithFunc(
default:
// do nothing
}
+ default:
+ // No task run log needed for other task types
}
}
@@ -584,6 +586,8 @@ func convertTaskType(t storepb.Task_Type) storepb.ChangelogPayload_Type {
case storepb.Task_DATABASE_CREATE:
case storepb.Task_DATABASE_EXPORT:
+ default:
+ // Return unspecified for other task types
}
return storepb.ChangelogPayload_TYPE_UNSPECIFIED
}
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index c17f32df02..6f7ab2580e 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -704,6 +704,15 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRun
s.createActivityForTaskRunStatusUpdate(ctx, task, storepb.TaskRun_DONE, "")
s.stateCfg.TaskSkippedOrDoneChan <- task.ID
return
+ default:
+ // This case should not happen in normal flow, but adding for completeness
+ slog.Error("Unexpected task execution state",
+ slog.Int("id", task.ID),
+ slog.String("type", string(task.Type)),
+ slog.Bool("done", done),
+ slog.Bool("has_error", err != nil),
+ )
+ return
}
}
diff --git a/backend/store/changelog.go b/backend/store/changelog.go
index cdb76d725d..e1dc0e9e6c 100644
--- a/backend/store/changelog.go
+++ b/backend/store/changelog.go
@@ -523,6 +523,8 @@ func (r *expressionRewriter) rewriteExpression(expr *exprpb.Expr) error {
schema.tables[args[2]] = &resourceTable{
name: args[2],
}
+ default:
+ // Ignore other function calls
}
default:
return errors.Errorf("invalid expression: %v", expr)
diff --git a/backend/store/idp.go b/backend/store/idp.go
index 90686761ff..ffcb58c2a8 100644
--- a/backend/store/idp.go
+++ b/backend/store/idp.go
@@ -330,6 +330,9 @@ func convertIdentityProviderConfigString(identityProviderType storepb.IdentityPr
identityProviderConfig.Config = &storepb.IdentityProviderConfig_LdapConfig{
LdapConfig: &formattedConfig,
}
+ default:
+ // Return nil for unknown identity provider types
+ return nil
}
return identityProviderConfig
}
diff --git a/backend/tests/main_test.go b/backend/tests/main_test.go
index 907ec012e3..048480a133 100644
--- a/backend/tests/main_test.go
+++ b/backend/tests/main_test.go
@@ -2,8 +2,6 @@ package tests
import (
"context"
- "log"
- "os"
"testing"
)
@@ -11,10 +9,12 @@ func TestMain(m *testing.M) {
ctx := context.Background()
code, err := startMain(ctx, m)
if err != nil {
- log.Fatal(err)
+ panic(err)
}
- os.Exit(code)
+ if code != 0 {
+ panic("tests failed")
+ }
}
func startMain(ctx context.Context, m *testing.M) (int, error) {
diff --git a/backend/tests/transaction_mode_test.go b/backend/tests/transaction_mode_test.go
index 487a46beac..54c4226baa 100644
--- a/backend/tests/transaction_mode_test.go
+++ b/backend/tests/transaction_mode_test.go
@@ -239,6 +239,8 @@ func getDriver(ctx context.Context, engine storepb.Engine, container *testcontai
case storepb.Engine_MSSQL:
config.DataSource.Username = "sa"
config.Password = "Test123!"
+ default:
+ // Use default config for other engines
}
driver, err := db.Open(ctx, engine, config)
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index a205c624ae..57f25c0152 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -1,4 +1,6 @@
// Package utils is a utility library for server.
+//
+//nolint:revive
package utils
import (
diff --git a/backend/utils/utils_test.go b/backend/utils/utils_test.go
index 131f5d237f..8f7b3d8b2e 100644
--- a/backend/utils/utils_test.go
+++ b/backend/utils/utils_test.go
@@ -1,3 +1,4 @@
+//nolint:revive
package utils
import (