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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(postgres): resolve empty-schema metadata under gaussdb a mode
Xsyl.way652c72b9e2fd
diff --git a/crates/dbx-driver-postgres/src/postgres.rs b/crates/dbx-driver-postgres/src/postgres.rsindex 92006f8dce..79bbb81c35 100644--- a/crates/dbx-driver-postgres/src/postgres.rs+++ b/crates/dbx-driver-postgres/src/postgres.rs@@ -8104,7 +8104,7 @@ const POSTGRES_COLUMNS_SQL: &str = "SELECT a.attname AS column_name, \LEFT JOIN pg_sequence pseq ON pseq.seqrelid = dep.objid \LEFT JOIN information_schema.columns c \ON c.table_schema = relation_namespace.nspname AND c.table_name = relation_class.relname AND c.column_name = a.attname \- WHERE a.attrelid = (CASE WHEN $1 = '' THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \+ WHERE a.attrelid = (CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \AND a.attnum > 0 AND NOT a.attisdropped \ORDER BY a.attnum";@@ -8162,7 +8162,7 @@ const POSTGRES_COLUMNS_COMPAT_SQL: &str = "SELECT a.attname AS column_name, \) AND serial_seq.relkind = 'S' \LEFT JOIN information_schema.columns c \ON c.table_schema = relation_namespace.nspname AND c.table_name = relation_class.relname AND c.column_name = a.attname \- WHERE a.attrelid = (CASE WHEN $1 = '' THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \+ WHERE a.attrelid = (CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \AND a.attnum > 0 AND NOT a.attisdropped \ORDER BY a.attnum";@@ -8190,7 +8190,8 @@ const POSTGRES_COLUMNS_INFORMATION_SCHEMA_SQL: &str = "SELECT c.column_name, \CAST(c.character_maximum_length AS int) AS character_maximum_length, \NULL::text AS enum_values \FROM information_schema.columns c \- WHERE c.table_schema = $1 AND c.table_name = $2 \+ WHERE c.table_schema = (CASE WHEN coalesce(length($1), 0) = 0 THEN current_schema() ELSE $1 END) \+ AND c.table_name = $2 \ORDER BY c.ordinal_position";fn parse_enum_values_from_row(row: &impl ValueRow, index: usize) -> Option<Vec<String>> {@@ -9664,7 +9665,7 @@ const POSTGRES_INDEXES_SQL: &str = "SELECT i.relname AS index_name, \LEFT JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = k.attnum AND k.attnum > 0 \LEFT JOIN pg_opclass oc ON oc.oid = k.class_oid \LEFT JOIN pg_namespace opcns ON opcns.oid = oc.opcnamespace \- WHERE t.oid = (CASE WHEN $1 = '' THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \+ WHERE t.oid = (CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \GROUP BY i.relname, i.oid, ix.indisunique, ix.indisvalid, ix.indisprimary, ix.indpred, ix.indrelid, am.amname, ix.indnkeyatts, ix.indkey \ORDER BY i.relname";@@ -9716,7 +9717,7 @@ const POSTGRES_INDEXES_COMPAT_SQL: &str = "SELECT i.relname AS index_name, \JOIN pg_class i ON i.oid = ix.indexrelid \JOIN pg_namespace n ON n.oid = t.relnamespace \JOIN pg_am am ON am.oid = i.relam \- WHERE t.oid = (CASE WHEN $1 = '' THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \+ WHERE t.oid = (CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2) ELSE quote_ident($1) || '.' || quote_ident($2) END)::regclass \ORDER BY i.relname";const POSTGRES_OWNERS_SQL: &str =@@ -14329,13 +14330,21 @@ mod tests {#[test]fn postgres_single_relation_metadata_can_resolve_through_search_path() {+ // GaussDB A mode folds `''` to NULL, so `$1 = ''` is never true there and the+ // unqualified branch was skipped (issue #12198). `coalesce(length($1), 0) = 0`+ // matches both NULL and the empty string on every PostgreSQL-compatible kernel.for sql in [POSTGRES_COLUMNS_SQL, POSTGRES_COLUMNS_COMPAT_SQL] {- assert!(sql.contains("CASE WHEN $1 = '' THEN quote_ident($2)"));+ assert!(sql.contains("CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2)"), "{sql}");assert!(sql.contains("c.table_schema = relation_namespace.nspname"));}for sql in [POSTGRES_INDEXES_SQL, POSTGRES_INDEXES_COMPAT_SQL] {- assert!(sql.contains("t.oid = (CASE WHEN $1 = '' THEN quote_ident($2)"));+ assert!(sql.contains("t.oid = (CASE WHEN coalesce(length($1), 0) = 0 THEN quote_ident($2)"), "{sql}");}+ assert!(+ POSTGRES_COLUMNS_INFORMATION_SCHEMA_SQL+ .contains("CASE WHEN coalesce(length($1), 0) = 0 THEN current_schema() ELSE $1 END"),+ "{POSTGRES_COLUMNS_INFORMATION_SCHEMA_SQL}"+ );}#[test]