Skip to content

Commit ec41758

Browse files
authored
fix: correct lifetime for do query (#260)
* fix: correct lifetime for do query * fix: duckdb example * fix: integration test server and sqlite
1 parent 034c62d commit ec41758

11 files changed

Lines changed: 20 additions & 56 deletions

File tree

examples/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl SimpleQueryHandler for DummyProcessor {
2424
async fn do_query<'a, C>(
2525
&self,
2626
_client: &mut C,
27-
_query: &'a str,
27+
_query: &str,
2828
) -> PgWireResult<Vec<Response<'a>>>
2929
where
3030
C: ClientInfo + Unpin + Send + Sync,

examples/copy.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ impl NoopStartupHandler for DummyProcessor {}
2323

2424
#[async_trait]
2525
impl SimpleQueryHandler for DummyProcessor {
26-
async fn do_query<'a, C>(
27-
&self,
28-
client: &mut C,
29-
query: &'a str,
30-
) -> PgWireResult<Vec<Response<'a>>>
26+
async fn do_query<'a, C>(&self, client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
3127
where
3228
C: ClientInfo + Sink<PgWireBackendMessage> + Unpin + Send + Sync,
3329
C::Error: Debug,

examples/duckdb.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ impl AuthSource for DummyAuthSource {
4545

4646
#[async_trait]
4747
impl SimpleQueryHandler for DuckDBBackend {
48-
async fn do_query<'a, C>(
49-
&self,
50-
_client: &mut C,
51-
query: &'a str,
52-
) -> PgWireResult<Vec<Response<'a>>>
48+
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
5349
where
5450
C: ClientInfo + Unpin + Send + Sync,
5551
{
@@ -247,7 +243,7 @@ impl ExtendedQueryHandler for DuckDBBackend {
247243
async fn do_query<'a, C>(
248244
&self,
249245
_client: &mut C,
250-
portal: &'a Portal<Self::Statement>,
246+
portal: &Portal<Self::Statement>,
251247
_max_rows: usize,
252248
) -> PgWireResult<Response<'a>>
253249
where

examples/gluesql.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ impl NoopStartupHandler for GluesqlProcessor {}
2121

2222
#[async_trait]
2323
impl SimpleQueryHandler for GluesqlProcessor {
24-
async fn do_query<'a, C>(
25-
&self,
26-
_client: &mut C,
27-
query: &'a str,
28-
) -> PgWireResult<Vec<Response<'a>>>
24+
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
2925
where
3026
C: ClientInfo + Unpin + Send + Sync,
3127
{

examples/scram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl SimpleQueryHandler for DummyProcessor {
2727
async fn do_query<'a, C>(
2828
&self,
2929
_client: &mut C,
30-
_query: &'a str,
30+
_query: &str,
3131
) -> PgWireResult<Vec<Response<'a>>>
3232
where
3333
C: ClientInfo + Unpin + Send + Sync,

examples/secure_server.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ impl NoopStartupHandler for DummyProcessor {}
2424

2525
#[async_trait]
2626
impl SimpleQueryHandler for DummyProcessor {
27-
async fn do_query<'a, C>(
28-
&self,
29-
_client: &mut C,
30-
query: &'a str,
31-
) -> PgWireResult<Vec<Response<'a>>>
27+
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
3228
where
3329
C: ClientInfo + Unpin + Send + Sync,
3430
{

examples/server.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ impl NoopStartupHandler for DummyProcessor {
4141

4242
#[async_trait]
4343
impl SimpleQueryHandler for DummyProcessor {
44-
async fn do_query<'a, C>(
45-
&self,
46-
client: &mut C,
47-
query: &'a str,
48-
) -> PgWireResult<Vec<Response<'a>>>
44+
async fn do_query<'a, C>(&self, client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
4945
where
5046
C: ClientInfo + Sink<PgWireBackendMessage> + Unpin + Send + Sync,
5147
C::Error: Debug,

examples/sqlite.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ impl AuthSource for DummyAuthSource {
4747

4848
#[async_trait]
4949
impl SimpleQueryHandler for SqliteBackend {
50-
async fn do_query<'a, C>(
51-
&self,
52-
_client: &mut C,
53-
query: &'a str,
54-
) -> PgWireResult<Vec<Response<'a>>>
50+
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
5551
where
5652
C: ClientInfo + Unpin + Send + Sync,
5753
{
@@ -205,7 +201,7 @@ impl ExtendedQueryHandler for SqliteBackend {
205201
async fn do_query<'a, C>(
206202
&self,
207203
_client: &mut C,
208-
portal: &'a Portal<Self::Statement>,
204+
portal: &Portal<Self::Statement>,
209205
_max_rows: usize,
210206
) -> PgWireResult<Response<'a>>
211207
where

examples/transaction.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ impl NoopStartupHandler for DummyProcessor {
4747

4848
#[async_trait]
4949
impl SimpleQueryHandler for DummyProcessor {
50-
async fn do_query<'a, C>(
51-
&self,
52-
_client: &mut C,
53-
query: &'a str,
54-
) -> PgWireResult<Vec<Response<'a>>>
50+
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
5551
where
5652
C: ClientInfo + Sink<PgWireBackendMessage> + Unpin + Send + Sync,
5753
C::Error: Debug,

src/api/query.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ pub trait SimpleQueryHandler: Send + Sync {
121121
}
122122

123123
/// Provide your query implementation using the incoming query string.
124-
async fn do_query<'a, 'b: 'a, C>(
125-
&'b self,
126-
client: &mut C,
127-
query: &'a str,
128-
) -> PgWireResult<Vec<Response<'a>>>
124+
async fn do_query<'a, C>(&self, client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
129125
where
130126
C: ClientInfo + ClientPortalStore + Sink<PgWireBackendMessage> + Unpin + Send + Sync,
131127
C::Error: Debug,
@@ -388,10 +384,10 @@ pub trait ExtendedQueryHandler: Send + Sync {
388384
/// - `client`: Information of the client sending the query
389385
/// - `portal`: Statement and parameters for the query
390386
/// - `max_rows`: Max requested rows of the query
391-
async fn do_query<'a, 'b: 'a, C>(
392-
&'b self,
387+
async fn do_query<'a, C>(
388+
&self,
393389
client: &mut C,
394-
portal: &'a Portal<Self::Statement>,
390+
portal: &Portal<Self::Statement>,
395391
max_rows: usize,
396392
) -> PgWireResult<Response<'a>>
397393
where
@@ -522,10 +518,10 @@ impl ExtendedQueryHandler for PlaceholderExtendedQueryHandler {
522518
unimplemented!("Extended Query is not implemented on this server.")
523519
}
524520

525-
async fn do_query<'a, 'b: 'a, C>(
526-
&'b self,
521+
async fn do_query<'a, C>(
522+
&self,
527523
_client: &mut C,
528-
_portal: &'a Portal<Self::Statement>,
524+
_portal: &Portal<Self::Statement>,
529525
_max_rows: usize,
530526
) -> PgWireResult<Response<'a>>
531527
where

0 commit comments

Comments
 (0)