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(iotdb): omit tree database from session handshake

t8y2847afca6fefe
diff --git a/agents/drivers/iotdb/driver.go b/agents/drivers/iotdb/driver.go
index 504ab0e54f..a72f12004d 100644
--- a/agents/drivers/iotdb/driver.go
+++ b/agents/drivers/iotdb/driver.go
@@ -215,10 +215,9 @@ func parseConnectionConfig(params connectParams) (connectionConfig, error) {
func newSessionClient(config connectionConfig) (*sessionClient, error) {
var session client.Session
var err error
- database := config.Database
- if config.Dialect == client.TableSqlDialect {
- database = ""
- }
+ // DBX applies a table database with USE after switching dialects. Do not
+ // include a tree database in openSession: IoTDB 2.x rejects it there, while
+ // DBX still retains it for metadata and path qualification.
if len(config.NodeURLs) > 1 {
session, err = client.NewClusterSession(&client.ClusterConfig{
NodeUrls: config.NodeURLs,
@@ -227,7 +226,6 @@ func newSessionClient(config connectionConfig) (*sessionClient, error) {
FetchSize: config.FetchSize,
TimeZone: config.TimeZone,
ConnectRetryMax: config.ConnectRetryMax,
- Database: database,
TLSConfig: config.TLSConfig,
})
if err == nil {
@@ -242,7 +240,6 @@ func newSessionClient(config connectionConfig) (*sessionClient, error) {
FetchSize: config.FetchSize,
TimeZone: config.TimeZone,
ConnectRetryMax: config.ConnectRetryMax,
- Database: database,
TLSConfig: config.TLSConfig,
})
err = session.Open(config.EnableCompression, config.ConnectTimeoutMS)
diff --git a/agents/drivers/iotdb/integration_test.go b/agents/drivers/iotdb/integration_test.go
index 8e92b12059..392df5ffc5 100644
--- a/agents/drivers/iotdb/integration_test.go
+++ b/agents/drivers/iotdb/integration_test.go
@@ -87,6 +87,30 @@ func TestLiveIoTDBAgentTreeAndTable(t *testing.T) {
}
}
+func TestLiveIoTDBAgentTreeDatabaseConnection(t *testing.T) {
+ if os.Getenv("DBX_IOTDB_LIVE") != "1" {
+ t.Skip("set DBX_IOTDB_LIVE=1 to run against a real IoTDB server")
+ }
+ database := "root.dbx_go_connection_" + strconv.Itoa(os.Getpid())
+ bootstrap := liveIoTDBServer(t, connectParams{})
+ defer bootstrap.disconnect()
+ mustExecuteNonQuery(t, bootstrap, "CREATE DATABASE "+database, "")
+ defer func() { _ = bootstrap.executeNonQuery("DELETE DATABASE "+database, "", 0) }()
+
+ scoped := liveIoTDBServer(t, connectParams{Database: database})
+ defer scoped.disconnect()
+ if err := scoped.validateConnection(); err != nil {
+ t.Fatal(err)
+ }
+ tables, err := scoped.listTables(database, metadataListConstraints{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if tables == nil {
+ t.Fatal("expected an initialized tree table list")
+ }
+}
+
func TestLiveIoTDBAgentProcessMultiSessionAndCancellation(t *testing.T) {
if os.Getenv("DBX_IOTDB_LIVE") != "1" {
t.Skip("set DBX_IOTDB_LIVE=1 to run against a real IoTDB server")