mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-17 09:12:53 +00:00
works now, few fixes
This commit is contained in:
Generated
+20
-13
@@ -297,7 +297,7 @@ dependencies = [
|
||||
"http",
|
||||
"http-body",
|
||||
"lazy_static",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project-lite",
|
||||
"tracing",
|
||||
]
|
||||
@@ -401,7 +401,7 @@ dependencies = [
|
||||
"hex",
|
||||
"http",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"regex",
|
||||
"ring",
|
||||
"time",
|
||||
@@ -522,7 +522,7 @@ dependencies = [
|
||||
"http-body",
|
||||
"hyper",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"tokio",
|
||||
@@ -544,7 +544,7 @@ dependencies = [
|
||||
"http-body",
|
||||
"hyper",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"tracing",
|
||||
@@ -684,7 +684,7 @@ dependencies = [
|
||||
"matchit",
|
||||
"memchr",
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
@@ -1580,7 +1580,7 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2584,7 +2584,7 @@ dependencies = [
|
||||
"futures-util",
|
||||
"once_cell",
|
||||
"opentelemetry_api",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
@@ -2749,6 +2749,12 @@ dependencies = [
|
||||
"base64 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.2.0"
|
||||
@@ -3112,6 +3118,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"opentelemetry",
|
||||
"parking_lot",
|
||||
"percent-encoding 1.0.1",
|
||||
"pin-project-lite",
|
||||
"postgres_backend",
|
||||
"pq_proto",
|
||||
@@ -3316,7 +3323,7 @@ dependencies = [
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project-lite",
|
||||
"rustls 0.20.8",
|
||||
"rustls-pemfile",
|
||||
@@ -3389,7 +3396,7 @@ dependencies = [
|
||||
"http",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"regex",
|
||||
]
|
||||
|
||||
@@ -4332,7 +4339,7 @@ dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"phf",
|
||||
"pin-project-lite",
|
||||
"postgres-protocol",
|
||||
@@ -4480,7 +4487,7 @@ dependencies = [
|
||||
"http-body",
|
||||
"hyper",
|
||||
"hyper-timeout",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project",
|
||||
"prost",
|
||||
"prost-derive",
|
||||
@@ -4512,7 +4519,7 @@ dependencies = [
|
||||
"http-body",
|
||||
"hyper",
|
||||
"hyper-timeout",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"pin-project",
|
||||
"prost",
|
||||
"rustls-native-certs",
|
||||
@@ -4822,7 +4829,7 @@ checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
"percent-encoding 2.2.0",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ uuid = { version = "1.2", features = ["v4", "serde"] }
|
||||
walkdir = "2.3.2"
|
||||
webpki-roots = "0.23"
|
||||
x509-parser = "0.15"
|
||||
percent-encoding = "1.0"
|
||||
|
||||
## TODO replace this with tracing
|
||||
env_logger = "0.10"
|
||||
|
||||
@@ -65,6 +65,7 @@ x509-parser.workspace = true
|
||||
|
||||
workspace_hack.workspace = true
|
||||
tokio-util.workspace = true
|
||||
percent-encoding.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
rcgen.workspace = true
|
||||
|
||||
+27
-11
@@ -31,6 +31,7 @@ use tokio_util::sync::CancellationToken;
|
||||
use tracing::{error, info, info_span, warn, Instrument};
|
||||
use url::form_urlencoded;
|
||||
use utils::http::{error::ApiError, json::json_response};
|
||||
use percent_encoding::percent_decode;
|
||||
|
||||
// TODO: use `std::sync::Exclusive` once it's stabilized.
|
||||
// Tracking issue: https://github.com/rust-lang/rust/issues/98407.
|
||||
@@ -232,7 +233,11 @@ async fn handle_sql(
|
||||
.map(|s| s.to_string())
|
||||
.ok_or(anyhow::anyhow!("missing host header"))?;
|
||||
|
||||
let params = StartupMessageParams::new([]);
|
||||
let params = StartupMessageParams::new([
|
||||
("user", username.as_str()),
|
||||
("database", dbname.as_str()),
|
||||
("application_name", "proxy_http_sql"),
|
||||
]);
|
||||
let tls = config.tls_config.as_ref();
|
||||
let common_names = tls.and_then(|tls| tls.common_names.clone());
|
||||
let creds = config
|
||||
@@ -256,15 +261,19 @@ async fn handle_sql(
|
||||
}
|
||||
};
|
||||
|
||||
let conn_string = &format!(
|
||||
"host={} port={} user={} password={} dbname={}",
|
||||
host,
|
||||
conf.get_ports().first().expect("no port"),
|
||||
username,
|
||||
password,
|
||||
dbname
|
||||
);
|
||||
|
||||
info!("!!!! connecting to: {}", conn_string);
|
||||
|
||||
let (client, connection) = tokio_postgres::connect(
|
||||
&format!(
|
||||
"host={} port={} user={} password={} dbname={}",
|
||||
host,
|
||||
conf.get_ports().first().expect("no port"),
|
||||
username,
|
||||
password,
|
||||
dbname
|
||||
),
|
||||
conn_string,
|
||||
tokio_postgres::NoTls,
|
||||
)
|
||||
.await?;
|
||||
@@ -275,14 +284,21 @@ async fn handle_sql(
|
||||
}
|
||||
});
|
||||
|
||||
let sql = percent_decode(sql.as_bytes()).decode_utf8()?.to_string();
|
||||
info!("!!!! query: '{}'", sql);
|
||||
|
||||
let rows: Result<Vec<serde_json::Value>, anyhow::Error> = client
|
||||
.query(sql, &[])
|
||||
.query(&sql, &[])
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(postgres_row_to_json_value)
|
||||
.collect();
|
||||
|
||||
Ok(serde_json::to_string(&rows?)?)
|
||||
let rows = rows?;
|
||||
|
||||
info!("!!!! n_rows: {}", rows.len());
|
||||
|
||||
Ok(serde_json::to_string(&rows)?)
|
||||
}
|
||||
|
||||
pub async fn task_main(
|
||||
|
||||
Reference in New Issue
Block a user