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(impala): keep long-running queries active

zipg3b75c8861dc1
diff --git a/agents/go-common/gohive/hive.go b/agents/go-common/gohive/hive.go
index e769092f77..52f0170bfd 100644
--- a/agents/go-common/gohive/hive.go
+++ b/agents/go-common/gohive/hive.go
@@ -1490,10 +1490,15 @@ func (c *cursor) pollUntilData(ctx context.Context, n int) (err error) {
}
c.response = responseFetch
- if !success(safeStatus(responseFetch.GetStatus())) {
- rowsAvailable <- hiveStatusError("fetching results", responseFetch.GetStatus())
+ resultsReady, statusErr := fetchResultsReady(responseFetch.GetStatus())
+ if statusErr != nil {
+ rowsAvailable <- statusErr
return
}
+ if !resultsReady {
+ time.Sleep(time.Duration(c.conn.configuration.PollIntervalInMillis) * time.Millisecond)
+ continue
+ }
err = c.parseResults(responseFetch)
if err != nil {
rowsAvailable <- err
@@ -1643,6 +1648,18 @@ func hiveStatusError(action string, status *hiveserver.TStatus) error {
}
}
+func fetchResultsReady(status *hiveserver.TStatus) (bool, error) {
+ status = safeStatus(status)
+ switch status.GetStatusCode() {
+ case hiveserver.TStatusCode_SUCCESS_STATUS, hiveserver.TStatusCode_SUCCESS_WITH_INFO_STATUS:
+ return true, nil
+ case hiveserver.TStatusCode_STILL_EXECUTING_STATUS:
+ return false, nil
+ default:
+ return false, hiveStatusError("fetching results", status)
+ }
+}
+
func hiveStatusDiagnostic(status *hiveserver.TStatus) string {
messages := make([]string, 0, len(status.GetInfoMessages())+1)
if message := strings.TrimSpace(status.GetErrorMessage()); message != "" {
diff --git a/agents/go-common/gohive/hive_status_error_test.go b/agents/go-common/gohive/hive_status_error_test.go
index 049aca8bfc..d27d371f9e 100644
--- a/agents/go-common/gohive/hive_status_error_test.go
+++ b/agents/go-common/gohive/hive_status_error_test.go
@@ -41,3 +41,28 @@ func TestHiveStatusErrorPreservesUsefulServerDiagnostics(t *testing.T) {
t.Fatalf("unexpected Hive error payload: %#v", err)
}
}
+
+func TestFetchResultsReadyPollsWhileOperationIsStillExecuting(t *testing.T) {
+ ready, err := fetchResultsReady(&hiveserver.TStatus{
+ StatusCode: hiveserver.TStatusCode_STILL_EXECUTING_STATUS,
+ })
+ if err != nil || ready {
+ t.Fatalf("still-executing fetch must be retried: ready=%v err=%v", ready, err)
+ }
+}
+
+func TestFetchResultsReadyAcceptsSuccessAndRejectsErrors(t *testing.T) {
+ ready, err := fetchResultsReady(&hiveserver.TStatus{
+ StatusCode: hiveserver.TStatusCode_SUCCESS_WITH_INFO_STATUS,
+ })
+ if err != nil || !ready {
+ t.Fatalf("successful fetch was rejected: ready=%v err=%v", ready, err)
+ }
+
+ ready, err = fetchResultsReady(&hiveserver.TStatus{
+ StatusCode: hiveserver.TStatusCode_ERROR_STATUS,
+ })
+ if err == nil || ready || !strings.Contains(err.Error(), "ERROR_STATUS") {
+ t.Fatalf("failed fetch did not preserve the server status: ready=%v err=%v", ready, err)
+ }
+}