-
Notifications
You must be signed in to change notification settings - Fork 103
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(c/driver/postgresql): Support queries that bind parameters and return a result #2065
Merged
paleolimbot
merged 25 commits into
apache:main
from
paleolimbot:c-driver-postgresql-bind-stream-read
Aug 14, 2024
Merged
feat(c/driver/postgresql): Support queries that bind parameters and return a result #2065
paleolimbot
merged 25 commits into
apache:main
from
paleolimbot:c-driver-postgresql-bind-stream-read
Aug 14, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130e81d
to
0937125
Compare
lidavidm
approved these changes
Aug 14, 2024
c/driver/postgresql/result_reader.cc
Outdated
Comment on lines
250
to
251
// For the case where we don't need a result, we either need to exhaust the bind | ||
// stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we either need to exhaust the bind stream, or ...?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows statements with a bind stream to return a result. This is not trivial because it requires concatenating results from multiple rows in a bind stream into one output stream. The existing bind stream had been wired up to pull and loop in one big function, but we need something with that knows which array/row it's on and can "bind and execute" the next one. I think I did this successfully without modifying the existing binding behaviour (which could maybe use the copy writer at some point in the future for better type support).
The behaviour of the "result reader" now incorporates the bind stream:
out
array stream, it will exhaust the bind stream before returning. This mirrors what currently happens and I think is more of what a user would expect; however, it does mean that a user would have to remember to fully consume the output array stream to ensure that the full bind stream was exhausted (if they specified an output stream in the first place).GetNext()
of the result, we check for an existingPGresult
to convert, and try to regenerate it if it's absent (== already been converted to an array and returned) using a new value from the bind stream. When pulling from the bind stream we pull everything we can until we get something with at least one row.Much existing behaviour (update, create table, insert, delete) flows through the first bullet, and I believe this has some more correct behaviour for the case where an insert or update or delete updates a number of rows that isn't one and/or there is more than one value in the bind stream.
Created on 2024-08-13 with reprex v2.0.2
Closes #2024.