Skip to content

Commit 07580d5

Browse files
committed
WIP fix(postgres): use non-prepared statements for metadata queries
1 parent b6cb1e3 commit 07580d5

3 files changed

Lines changed: 426 additions & 94 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-postgres/src/connection/executor.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{pin::pin, sync::Arc};
2323
async fn prepare(
2424
conn: &mut PgConnection,
2525
sql: &str,
26-
parameters: &[PgTypeInfo],
26+
arg_types: &[PgTypeInfo],
2727
metadata: Option<Arc<PgStatementMetadata>>,
2828
persistent: bool,
2929
fetch_column_origin: bool,
@@ -39,12 +39,7 @@ async fn prepare(
3939
// build a list of type OIDs to send to the database in the PARSE command
4040
// we have not yet started the query sequence, so we are *safe* to cleanly make
4141
// additional queries here to get any missing OIDs
42-
43-
let mut param_types = Vec::with_capacity(parameters.len());
44-
45-
for ty in parameters {
46-
param_types.push(conn.resolve_type_id(&ty.0).await?);
47-
}
42+
let param_types = conn.argument_types_to_oids(arg_types).await?;
4843

4944
// flush and wait until we are re-ready
5045
conn.wait_until_ready().await?;
@@ -292,8 +287,7 @@ impl PgConnection {
292287
PgValueFormat::Binary
293288
} else {
294289
// Query will trigger a ReadyForQuery
295-
self.inner.stream.write_msg(Query(sql))?;
296-
self.inner.pending_ready_for_query_count += 1;
290+
self.queue_simple_query(sql)?;
297291

298292
// metadata starts out as "nothing"
299293
metadata = Arc::new(PgStatementMetadata::default());

0 commit comments

Comments
 (0)