Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Work with pools that don't support prepared statements#1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sfackler merged 6 commits intorust-postgres:masterfromexograph:exograph
Jul 13, 2024

Conversation

ramnivas
Copy link
Contributor

Introduce a newquery_with_param_types method that allows to specify Postgres type parameters. This obviated the need to use prepared statements just to obtain parameter types for a query. It then combines parse, bind, and execute in a single packet.

Related:#1017,#1067

jwilm and nicolasvan reacted with heart emoji
Introduce a new `query_with_param_types` method that allows to specify Postgres type parameters. This obviated the need to use prepared statementsjust to obtain parameter types for a query. It then combines parse, bind, and execute in a single packet.Related:rust-postgres#1017,rust-postgres#1067
) ->implExactSizeIterator<Item =(&'adynToSql,Type)> +'a{
s.iter()
.map(|(param, param_type)|(*paramas_, param_type.clone()))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There's no need to factor this into a separate function here since it's only being called one place.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed. Earlier thought was to allow access to the rawRowStream.

})
}

enumQueryProcessingState{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It feels like this is a lot of boilerplate over a fewmatch responses.next().await? { ... } in a sequence.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed.

@sfackler
Copy link
Collaborator

Thinking about it, it seems like we could make query_typed do this when invoked with a non-prepared statement instead of adding a new method.

@ramnivas
Copy link
ContributorAuthor

Thinking about it, it seems like we could make query_typed do this when invoked with a non-prepared statement instead of adding a new method.

Did you meanprepare_typed (there is noquery_typed). One nice thing about the newquery_with_param_types is that it takes param values and param types through tuples, so the client cannot specify fewer (or more) types than parameter length.

@sfackler
Copy link
Collaborator

Did you meanprepare_typed (there is noquery_typed).

Ah yeah my idea didn't really make much sense :D

ramnivas reacted with laugh emoji

@sfackler
Copy link
Collaborator

Let's rename the method toquery_typed, which aligns withprepare_typed and is a bit shorter.

@ramnivas
Copy link
ContributorAuthor

Let's rename the method toquery_typed, which aligns withprepare_typed and is a bit shorter.

Done!

@sfackler
Copy link
Collaborator

LGTM but there's one small clippy error to fix.

@ramnivas
Copy link
ContributorAuthor

LGTM but there's one small clippy error to fix.

Fixed.

@sfacklersfackler merged commit257bcfd intorust-postgres:masterJul 13, 2024
@sfackler
Copy link
Collaborator

Thanks!

@ramnivas
Copy link
ContributorAuthor

Thanks!

Thank you!

ramnivas added a commit to exograph/exograph that referenced this pull requestSep 18, 2024
Withrust-postgres/rust-postgres#1165 merged and a new release with that change available in 0.7.12, we no longer need to use our fork.Compared torust-postgres/rust-postgres#1147, there was a name change for `query_typed`, so this commit takes care of that.
thibmeu pushed a commit to cloudflare/plexi that referenced this pull requestJan 21, 2025
Currently, each query requires three RTTs to the DB. By switching to typed queries, wecan do the parse, bind and execute all in a single RTT.Queries which use `SqlNamespaceStatus` were not ported due to me not being able to figureout which type they have. It's a user-generated type, and I'm not sure there's a matchingtype in `postgres-types::Type`. In any case, this just means we eat the extra RTTs whencreating or updating namespaces. This feels fine to me, since at least the hot path isable to be typed.Related tokio-postgres PR:rust-postgres/rust-postgres#1147
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sfacklersfacklersfackler left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ramnivas@sfackler

[8]ページ先頭

©2009-2025 Movatter.jp