Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(hive): use legacy-compatible session protocol

t8y25f8cc0b08b97
diff --git a/agents/drivers/hive-go/MIGRATION_PARITY.md b/agents/drivers/hive-go/MIGRATION_PARITY.md
index fcd8cdd22f..64ed9c60f6 100644
--- a/agents/drivers/hive-go/MIGRATION_PARITY.md
+++ b/agents/drivers/hive-go/MIGRATION_PARITY.md
@@ -1,6 +1,6 @@
# Hive JDBC to Go migration parity
-Status date: 2026-08-11.
+Status date: 2026-08-12.
The migration is not complete until a capability is implemented, covered by
automated tests, validated against a real compatible server, and included in
@@ -14,8 +14,10 @@ production parity.
JDBC profiles. The Go migration must not infer Hive 2 support from Hive 3/4.
- DBX protocol baseline: the Go Agent implements the same stdin/stdout JSON-RPC
methods used by the Java Agent.
-- HS2 client protocol: Go requests `HIVE_CLI_SERVICE_PROTOCOL_V10`; Hive 3.1.3
- and Hive 4.2.0 accepted it in live validation.
+- HS2 client protocol: Go requests `HIVE_CLI_SERVICE_PROTOCOL_V6`, matching the
+ upstream GoHive compatibility baseline. Hive 3.1.3 and Hive 4.2.0 accepted
+ the newer V10 request in earlier live validation, but older Hive-compatible
+ servers can reject that unknown enum value during `OpenSession` decoding.
- The current completion pass validates the Go Agent only. JDBC is retained as
a historical behavior reference, not as a candidate in the secure discovery
or Kerberos validation path.
diff --git a/agents/go-common/gohive/driver_test.go b/agents/go-common/gohive/driver_test.go
index 6b43efd2de..bf95ebf8a3 100644
--- a/agents/go-common/gohive/driver_test.go
+++ b/agents/go-common/gohive/driver_test.go
@@ -51,3 +51,22 @@ func TestCursorAffectedRowsNormalizesMissingAndNegativeValues(t *testing.T) {
}
}
}
+
+func TestOpenSessionRequestUsesLegacyCompatibleProtocol(t *testing.T) {
+ configuration := &connectConfiguration{
+ Username: "admin",
+ Password: "secret",
+ HiveConfiguration: map[string]string{"use:database": "default"},
+ }
+ request := newOpenSessionRequest(configuration)
+
+ if request.ClientProtocol != hiveserver.TProtocolVersion_HIVE_CLI_SERVICE_PROTOCOL_V6 {
+ t.Fatalf("unexpected HiveServer2 client protocol: %s", request.ClientProtocol)
+ }
+ if request.GetUsername() != configuration.Username || request.GetPassword() != configuration.Password {
+ t.Fatalf("unexpected OpenSession credentials: %#v", request)
+ }
+ if request.Configuration["use:database"] != "default" {
+ t.Fatalf("unexpected OpenSession configuration: %#v", request.Configuration)
+ }
+}
diff --git a/agents/go-common/gohive/hive.go b/agents/go-common/gohive/hive.go
index 76e9ca5bc7..2d4d909ae5 100644
--- a/agents/go-common/gohive/hive.go
+++ b/agents/go-common/gohive/hive.go
@@ -615,11 +615,7 @@ func innerConnect(ctx context.Context, host string, port int, auth string,
protocolFactory := thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{MaxMessageSize: configuration.MaxMessageSize})
client := hiveserver.NewTCLIServiceClientFactory(transport, protocolFactory)
- openSession := hiveserver.NewTOpenSessionReq()
- openSession.ClientProtocol = hiveserver.TProtocolVersion_HIVE_CLI_SERVICE_PROTOCOL_V10
- openSession.Configuration = configuration.HiveConfiguration
- openSession.Username = &configuration.Username
- openSession.Password = &configuration.Password
+ openSession := newOpenSessionRequest(configuration)
// Context is ignored
response, err := client.OpenSession(ctx, openSession)
if auth == "BROWSER" && browserClient != nil && err != nil && browserClient.HasRedirect() {
@@ -673,6 +669,15 @@ func innerConnect(ctx context.Context, host string, port int, auth string,
return conn, nil
}
+func newOpenSessionRequest(configuration *connectConfiguration) *hiveserver.TOpenSessionReq {
+ request := hiveserver.NewTOpenSessionReq()
+ request.ClientProtocol = hiveserver.TProtocolVersion_HIVE_CLI_SERVICE_PROTOCOL_V6
+ request.Configuration = configuration.HiveConfiguration
+ request.Username = &configuration.Username
+ request.Password = &configuration.Password
+ return request
+}
+
type cookieDedupTransport struct {
http.RoundTripper
}