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(postgres): 修复 GaussDB Schema 浏览对象报错 (#2186)

weihand3272b4750a2
diff --git a/crates/dbx-core/src/db/postgres.rs b/crates/dbx-core/src/db/postgres.rs
index 696a6fa861..e965470c60 100644
--- a/crates/dbx-core/src/db/postgres.rs
+++ b/crates/dbx-core/src/db/postgres.rs
@@ -1652,17 +1652,30 @@ async fn postgres_proc_has_prokind(client: &deadpool_postgres::Client) -> Result
Ok(row.get(0))
}
+async fn list_objects_rows(
+ client: &deadpool_postgres::Client,
+ schema: &str,
+ include_timestamps: bool,
+ has_proc_prokind: bool,
+) -> Result<Vec<Row>, String> {
+ let sql = list_objects_sql(include_timestamps, has_proc_prokind);
+ let stmt = client.prepare_cached(&sql).await.map_err(|e| e.to_string())?;
+ client.query(&stmt, &[&schema]).await.map_err(|e| e.to_string())
+}
+
pub async fn list_objects(pool: &Pool, schema: &str) -> Result<Vec<ObjectInfo>, String> {
let client = checkout_postgres_client(pool, None, super::connection_timeout()).await?;
let has_proc_prokind = postgres_proc_has_prokind(&client).await?;
- let sql = list_objects_sql(true, has_proc_prokind);
- let stmt = client.prepare_cached(&sql).await.map_err(|e| e.to_string())?;
- let rows = match client.query(&stmt, &[&schema]).await {
+ let rows = match list_objects_rows(&client, schema, true, has_proc_prokind).await {
Ok(rows) => rows,
- Err(_) => {
- let fallback_sql = list_objects_sql(false, has_proc_prokind);
- let stmt = client.prepare_cached(&fallback_sql).await.map_err(|e| e.to_string())?;
- client.query(&stmt, &[&schema]).await.map_err(|e| e.to_string())?
+ Err(primary_error) => {
+ log::debug!("[postgres][list_objects:timestamp-fallback] primary_error={}", primary_error);
+ match list_objects_rows(&client, schema, false, has_proc_prokind).await {
+ Ok(rows) => rows,
+ Err(fallback_error) => {
+ return Err(format!("{primary_error}; timestamp fallback failed: {fallback_error}"));
+ }
+ }
}
};