feat: update pgwire to 0.32 (#6674)

* feat: update pgwire api

* feat: update pgwire and override on_query/on_execute

* feat: update pgwire to 0.32

* chore: remove code example

Signed-off-by: Ning Sun <sunning@greptime.com>

---------

Signed-off-by: Ning Sun <sunning@greptime.com>
This commit is contained in:
Ning Sun
2025-08-07 14:17:52 +08:00
committed by GitHub
parent e2015ce1af
commit bbe48e9e8b
4 changed files with 22 additions and 27 deletions

View File

@@ -89,10 +89,7 @@ opensrv-mysql = { git = "https://github.com/datafuselabs/opensrv", rev = "a1fb4d
opentelemetry-proto.workspace = true
otel-arrow-rust.workspace = true
parking_lot.workspace = true
#pgwire = { version = "0.30", default-features = false, features = ["server-api-ring"] }
pgwire = { git = "https://github.com/sunng87/pgwire", rev = "127573d997228cfb70c7699881c568eae8131270", default-features = false, features = [
"server-api-ring",
] }
pgwire = { version = "0.32", default-features = false, features = ["server-api-ring"] }
pin-project = "1.0"
pipeline.workspace = true
postgres-types = { version = "0.2", features = ["with-chrono-0_4", "with-serde_json-1"] }

View File

@@ -32,9 +32,9 @@ use std::sync::Arc;
use ::auth::UserProviderRef;
use derive_builder::Builder;
use pgwire::api::auth::ServerParameterProvider;
use pgwire::api::copy::NoopCopyHandler;
use pgwire::api::{ClientInfo, PgWireServerHandlers};
use pgwire::api::auth::{ServerParameterProvider, StartupHandler};
use pgwire::api::query::{ExtendedQueryHandler, SimpleQueryHandler};
use pgwire::api::{ClientInfo, ErrorHandler, PgWireServerHandlers};
pub use server::PostgresServer;
use session::context::Channel;
use session::Session;
@@ -92,29 +92,19 @@ pub(crate) struct MakePostgresServerHandler {
pub(crate) struct PostgresServerHandler(Arc<PostgresServerHandlerInner>);
impl PgWireServerHandlers for PostgresServerHandler {
type StartupHandler = PostgresServerHandlerInner;
type SimpleQueryHandler = PostgresServerHandlerInner;
type ExtendedQueryHandler = PostgresServerHandlerInner;
type CopyHandler = NoopCopyHandler;
type ErrorHandler = PostgresServerHandlerInner;
fn simple_query_handler(&self) -> Arc<Self::SimpleQueryHandler> {
fn simple_query_handler(&self) -> Arc<impl SimpleQueryHandler> {
self.0.clone()
}
fn extended_query_handler(&self) -> Arc<Self::ExtendedQueryHandler> {
fn extended_query_handler(&self) -> Arc<impl ExtendedQueryHandler> {
self.0.clone()
}
fn startup_handler(&self) -> Arc<Self::StartupHandler> {
fn startup_handler(&self) -> Arc<impl StartupHandler> {
self.0.clone()
}
fn copy_handler(&self) -> Arc<Self::CopyHandler> {
Arc::new(NoopCopyHandler)
}
fn error_handler(&self) -> Arc<Self::ErrorHandler> {
fn error_handler(&self) -> Arc<impl ErrorHandler> {
self.0.clone()
}
}

View File

@@ -24,7 +24,7 @@ use pgwire::api::auth::StartupHandler;
use pgwire::api::{auth, ClientInfo, PgWireConnectionState};
use pgwire::error::{ErrorInfo, PgWireError, PgWireResult};
use pgwire::messages::response::ErrorResponse;
use pgwire::messages::startup::Authentication;
use pgwire::messages::startup::{Authentication, SecretKey};
use pgwire::messages::{PgWireBackendMessage, PgWireFrontendMessage};
use session::Session;
use snafu::IntoError;
@@ -127,7 +127,8 @@ where
// pass generated process id and secret key to client, this information will
// be sent to postgres client for query cancellation.
client.set_pid_and_secret_key(session.process_id() as i32, rand::random::<i32>());
// use all 0 before we actually supported query cancellation
client.set_pid_and_secret_key(0, SecretKey::I32(0));
// set userinfo outside
}