feat(multi-query): 适配 MariaDB/SQLServer/DiROS 多结果集并增加回退提示

- MariaDB: DSN 添加 multiStatements=true,实现 QueryMulti/QueryMultiContext
- SQL Server: 实现 QueryMulti/QueryMultiContext(go-mssqldb 原生支持批处理)
- DiROS: DSN 添加 multiStatements=true(继承 MySQLDB 的方法)
- Sphinx: 自动继承 MySQLDB 多结果集支持,无需额外改动
- 不支持原生多语句的数据源执行多条 SQL 时,前端展示 info 提示
- refs #235
This commit is contained in:
杨国锋
2026-03-17 22:53:24 +08:00
parent e6b822c967
commit 6ee0fea110
5 changed files with 60 additions and 3 deletions

View File

@@ -128,6 +128,30 @@ func (s *SqlServerDB) Ping() error {
return s.conn.PingContext(ctx)
}
func (s *SqlServerDB) QueryMulti(query string) ([]connection.ResultSetData, error) {
if s.conn == nil {
return nil, fmt.Errorf("连接未打开")
}
rows, err := s.conn.Query(query)
if err != nil {
return nil, err
}
defer rows.Close()
return scanMultiRows(rows)
}
func (s *SqlServerDB) QueryMultiContext(ctx context.Context, query string) ([]connection.ResultSetData, error) {
if s.conn == nil {
return nil, fmt.Errorf("连接未打开")
}
rows, err := s.conn.QueryContext(ctx, query)
if err != nil {
return nil, err
}
defer rows.Close()
return scanMultiRows(rows)
}
func (s *SqlServerDB) QueryContext(ctx context.Context, query string) ([]map[string]interface{}, []string, error) {
if s.conn == nil {
return nil, nil, fmt.Errorf("连接未打开")