fix(windows): restore Windows 7 startup compatibility

This commit is contained in:
zipg authored and GitHub committed 2026-08-05 00:07:41 +08:00
1 parent 4aa36cb893
commit e82c1aedf0
81 files changed
+17157 -66

No files matched your search

+21 -3
View File
@@ -1441,11 +1441,27 @@ async fn stream_query_rows_text_on_client(
}
pub async fn connect(url: &str, fallback_timeout: Duration) -> Result<Pool, String> {
let timezone = iana_time_zone::get_timezone().unwrap_or_else(|_| "UTC".to_string());
connect_with_local_timezone(url, fallback_timeout, &timezone).await
#[cfg(all(windows, target_vendor = "win7"))]
{
connect_with_optional_local_timezone(url, fallback_timeout, None).await
}
#[cfg(not(all(windows, target_vendor = "win7")))]
{
let timezone = iana_time_zone::get_timezone().unwrap_or_else(|_| "UTC".to_string());
connect_with_local_timezone(url, fallback_timeout, &timezone).await
}
}
async fn connect_with_local_timezone(url: &str, fallback_timeout: Duration, timezone: &str) -> Result<Pool, String> {
connect_with_optional_local_timezone(url, fallback_timeout, Some(timezone)).await
}
async fn connect_with_optional_local_timezone(
url: &str,
fallback_timeout: Duration,
timezone: Option<&str>,
) -> Result<Pool, String> {
let url_with_keepalive = inject_postgres_keepalive_params(url);
let postgres_url = postgres_connection_url(&url_with_keepalive)?;
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
@@ -1488,7 +1504,9 @@ async fn connect_with_local_timezone(url: &str, fallback_timeout: Duration, time
let client =
pool.get().await.map_err(|e| format!("PostgreSQL connection failed: {}", pg_pool_error_to_string(e)))?;
if !pg_url_has_timezone_setting(url) {
set_automatic_postgres_timezone(&client, timezone).await?;
if let Some(timezone) = timezone {
set_automatic_postgres_timezone(&client, timezone).await?;
}
}
Ok(pool)