fix(database): cast count(*)::int in get_db_status to match i32 field
count(*) returns bigint (int8) in PostgreSQL, but the result was read as i32 via conn_row.get(0). tokio-postgres's FromSql<i32> rejects an int8 column, so get_db_status panicked at runtime with 'error deserializing column 0' (HTTP 500). Cast count(*)::int to int4, matching the adjacent setting::int column and the total_connections/max_connections i32 struct fields. No other queries in the file are affected: reltuples is already ::bigint -> i64, size columns are native bigint -> i64, and system_status.rs reads its count(*) as i64 correctly.
This commit is contained in:
parent
ecf3c73715
commit
116286f80f
@ -89,10 +89,12 @@ pub async fn get_db_status() -> Result<DbStatus, ServerFnError> {
|
||||
.map_err(AppError::query)?
|
||||
.get(0);
|
||||
|
||||
// 当前库连接数 + 全局最大连接数
|
||||
// 当前库连接数 + 全局最大连接数。
|
||||
// count(*) 原生返回 bigint(int8),与下方 setting::int 一并显式转 int4,
|
||||
// 以匹配 total_connections/max_connections 的 i32 类型(否则 FromSql 反序列化失败)。
|
||||
let conn_row = client
|
||||
.query_one(
|
||||
"SELECT count(*), \
|
||||
"SELECT count(*)::int, \
|
||||
(SELECT setting::int FROM pg_settings WHERE name = 'max_connections') \
|
||||
FROM pg_stat_activity WHERE datname = current_database()",
|
||||
&[],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user