From 01475c9e75ce2143cc791d7525e3cbd92b1d8d19 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Fri, 6 Dec 2024 12:19:40 +0000 Subject: [PATCH] fix accidental recursion --- libs/proxy/tokio-postgres2/src/client.rs | 19 +------------------ .../tokio-postgres2/src/generic_client.rs | 13 ++++++------- libs/proxy/tokio-postgres2/src/transaction.rs | 15 --------------- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/libs/proxy/tokio-postgres2/src/client.rs b/libs/proxy/tokio-postgres2/src/client.rs index fc1852ab19..ed5c8c5c96 100644 --- a/libs/proxy/tokio-postgres2/src/client.rs +++ b/libs/proxy/tokio-postgres2/src/client.rs @@ -4,12 +4,10 @@ use crate::config::Host; use crate::config::SslMode; use crate::connection::{Request, RequestMessages}; -use crate::query::RowStream; - use crate::types::{Oid, Type}; use crate::{ - query, simple_query, CancelToken, Error, ReadyForQueryStatus, Statement, Transaction, + simple_query, CancelToken, Error, ReadyForQueryStatus, Statement, Transaction, TransactionBuilder, }; use bytes::BytesMut; @@ -182,21 +180,6 @@ impl Client { self.process_id } - /// Pass text directly to the Postgres backend to allow it to sort out typing itself and - /// to save a roundtrip - pub async fn query_raw_txt( - &mut self, - statement: &str, - params: I, - ) -> Result - where - S: AsRef, - I: IntoIterator>, - I::IntoIter: ExactSizeIterator, - { - query::query_txt(&mut self.inner, statement, params).await - } - /// Executes a sequence of SQL statements using the simple query protocol. /// /// Statements should be separated by semicolons. If an error occurs, execution of the sequence will stop at that diff --git a/libs/proxy/tokio-postgres2/src/generic_client.rs b/libs/proxy/tokio-postgres2/src/generic_client.rs index 1a5bf04be5..186cdaa190 100644 --- a/libs/proxy/tokio-postgres2/src/generic_client.rs +++ b/libs/proxy/tokio-postgres2/src/generic_client.rs @@ -1,4 +1,4 @@ -use crate::query::RowStream; +use crate::query::{self, RowStream}; use crate::types::Type; use crate::{Client, Error, Transaction}; use async_trait::async_trait; @@ -13,8 +13,7 @@ mod private { /// This trait is "sealed", and cannot be implemented outside of this crate. #[async_trait] pub trait GenericClient: private::Sealed { - /// Like `Client::query_raw_txt`. - async fn query_raw_txt(&self, statement: &str, params: I) -> Result + async fn query_raw_txt(&mut self, statement: &str, params: I) -> Result where S: AsRef + Sync + Send, I: IntoIterator> + Sync + Send, @@ -28,13 +27,13 @@ impl private::Sealed for Client {} #[async_trait] impl GenericClient for Client { - async fn query_raw_txt(&self, statement: &str, params: I) -> Result + async fn query_raw_txt(&mut self, statement: &str, params: I) -> Result where S: AsRef + Sync + Send, I: IntoIterator> + Sync + Send, I::IntoIter: ExactSizeIterator + Sync + Send, { - self.query_raw_txt(statement, params).await + query::query_txt(&mut self.inner, statement, params).await } /// Query for type information @@ -48,13 +47,13 @@ impl private::Sealed for Transaction<'_> {} #[async_trait] #[allow(clippy::needless_lifetimes)] impl GenericClient for Transaction<'_> { - async fn query_raw_txt(&self, statement: &str, params: I) -> Result + async fn query_raw_txt(&mut self, statement: &str, params: I) -> Result where S: AsRef + Sync + Send, I: IntoIterator> + Sync + Send, I::IntoIter: ExactSizeIterator + Sync + Send, { - self.query_raw_txt(statement, params).await + query::query_txt(&mut self.client().inner, statement, params).await } /// Query for type information diff --git a/libs/proxy/tokio-postgres2/src/transaction.rs b/libs/proxy/tokio-postgres2/src/transaction.rs index ed2087c993..9c39cf5ed7 100644 --- a/libs/proxy/tokio-postgres2/src/transaction.rs +++ b/libs/proxy/tokio-postgres2/src/transaction.rs @@ -1,6 +1,5 @@ use crate::codec::FrontendMessage; use crate::connection::RequestMessages; -use crate::query::RowStream; use crate::{CancelToken, Client, Error, ReadyForQueryStatus}; use postgres_protocol2::message::frontend; @@ -52,20 +51,6 @@ impl<'a> Transaction<'a> { self.client.batch_execute("ROLLBACK").await } - /// Like `Client::query_raw_txt`. - pub async fn query_raw_txt( - &mut self, - statement: &str, - params: I, - ) -> Result - where - S: AsRef, - I: IntoIterator>, - I::IntoIter: ExactSizeIterator, - { - self.client.query_raw_txt(statement, params).await - } - /// Like `Client::cancel_token`. pub fn cancel_token(&self) -> CancelToken { self.client.cancel_token()