feat: upgrade pgwire to 0.19 (#3157)

* feat: upgrade pgwire to 0.19

* fix: update pgwire to 0.19.1
This commit is contained in:
Ning Sun
2024-01-15 17:14:08 +08:00
committed by GitHub
parent 6f07d69155
commit 1294d6f6e1
5 changed files with 14 additions and 18 deletions

5
Cargo.lock generated
View File

@@ -6112,9 +6112,9 @@ dependencies = [
[[package]]
name = "pgwire"
version = "0.18.0"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b277432819ee6b76bf56de5e91eae578d6b332bd6f05f963ee81fc788bc886f"
checksum = "17780c93587822c191c3f4d43fa5f6bc6df1e51b9f58a0be0cd1b7fd6e80d9e6"
dependencies = [
"async-trait",
"base64 0.21.5",
@@ -6122,7 +6122,6 @@ dependencies = [
"chrono",
"derive-new 0.6.0",
"futures",
"getset",
"hex",
"log",
"md5",

View File

@@ -58,7 +58,7 @@ openmetrics-parser = "0.4"
opensrv-mysql = { git = "https://github.com/MichaelScofield/opensrv.git", rev = "1676c1d" }
opentelemetry-proto.workspace = true
parking_lot = "0.12"
pgwire = "0.18"
pgwire = "0.19.1"
pin-project = "1.0"
postgres-types = { version = "0.2", features = ["with-chrono-0_4"] }
pprof = { version = "0.13", features = [

View File

@@ -184,7 +184,7 @@ impl StartupHandler for PostgresServerHandler {
let login_info = LoginInfo::from_client_info(client);
// do authenticate
let auth_result = self.login_verifier.auth(&login_info, pwd.password()).await;
let auth_result = self.login_verifier.auth(&login_info, &pwd.password).await;
if let Ok(Some(user_info)) = auth_result {
self.session.set_user_info(user_info);

View File

@@ -72,10 +72,7 @@ fn output_to_query_response<'a>(
field_format: &Format,
) -> PgWireResult<Response<'a>> {
match output {
Ok(Output::AffectedRows(rows)) => Ok(Response::Execution(Tag::new_for_execution(
"OK",
Some(rows),
))),
Ok(Output::AffectedRows(rows)) => Ok(Response::Execution(Tag::new("OK").with_rows(rows))),
Ok(Output::Stream(record_stream)) => {
let schema = record_stream.schema();
recordbatches_to_query_response(record_stream, schema, field_format)
@@ -212,7 +209,7 @@ impl ExtendedQueryHandler for PostgresServerHandler {
.with_label_values(&[crate::metrics::METRIC_POSTGRES_EXTENDED_QUERY, db.as_str()])
.start_timer();
let sql_plan = portal.statement().statement();
let sql_plan = &portal.statement.statement;
let output = if let Some(plan) = &sql_plan.plan {
let plan = plan
@@ -231,7 +228,7 @@ impl ExtendedQueryHandler for PostgresServerHandler {
self.query_handler.do_query(&sql, query_ctx).await.remove(0)
};
output_to_query_response(output, portal.result_column_format())
output_to_query_response(output, &portal.result_column_format)
}
async fn do_describe<C>(
@@ -244,7 +241,7 @@ impl ExtendedQueryHandler for PostgresServerHandler {
{
let (param_types, sql_plan, format) = match target {
StatementOrPortal::Statement(stmt) => {
let sql_plan = stmt.statement();
let sql_plan = &stmt.statement;
if let Some(plan) = &sql_plan.plan {
let param_types = plan
.get_param_types()
@@ -255,14 +252,14 @@ impl ExtendedQueryHandler for PostgresServerHandler {
(Some(types), sql_plan, &Format::UnifiedBinary)
} else {
let param_types = Some(stmt.parameter_types().clone());
let param_types = Some(stmt.parameter_types.clone());
(param_types, sql_plan, &Format::UnifiedBinary)
}
}
StatementOrPortal::Portal(portal) => (
None,
portal.statement().statement(),
portal.result_column_format(),
&portal.statement.statement,
&portal.result_column_format,
),
};

View File

@@ -168,7 +168,7 @@ pub(super) fn type_pg_to_gt(origin: &Type) -> Result<ConcreteDataType> {
pub(super) fn parameter_to_string(portal: &Portal<SqlPlan>, idx: usize) -> PgWireResult<String> {
// the index is managed from portal's parameters count so it's safe to
// unwrap here.
let param_type = portal.statement().parameter_types().get(idx).unwrap();
let param_type = portal.statement.parameter_types.get(idx).unwrap();
match param_type {
&Type::VARCHAR | &Type::TEXT => Ok(format!(
"'{}'",
@@ -218,7 +218,7 @@ pub(super) fn parameter_to_string(portal: &Portal<SqlPlan>, idx: usize) -> PgWir
pub(super) fn invalid_parameter_error(msg: &str, detail: Option<&str>) -> PgWireError {
let mut error_info = ErrorInfo::new("ERROR".to_owned(), "22023".to_owned(), msg.to_owned());
error_info.set_detail(detail.map(|s| s.to_owned()));
error_info.detail = detail.map(|s| s.to_owned());
PgWireError::UserError(Box::new(error_info))
}
@@ -246,7 +246,7 @@ pub(super) fn parameters_to_scalar_values(
let param_count = portal.parameter_len();
let mut results = Vec::with_capacity(param_count);
let client_param_types = portal.statement().parameter_types();
let client_param_types = &portal.statement.parameter_types;
let param_types = plan
.get_param_types()
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;