-
Notifications
You must be signed in to change notification settings - Fork 39
feat: allow explicit use of Simple Query Protocol (v3) #118
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
Conversation
Codecov ReportAll modified lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #118 +/- ##
==========================================
+ Coverage 86.56% 87.26% +0.70%
==========================================
Files 29 29
Lines 2493 2498 +5
==========================================
+ Hits 2158 2180 +22
+ Misses 335 318 -17
☔ View full report in Codecov by Sentry. |
/// | ||
/// When [useSimpleQueryProtocol] is set to true, the implementation will use | ||
/// the Simple Query Protocol. Please note, a query with [parameters] cannot | ||
/// be used with this protocol. | ||
Future<PgResult> execute( | ||
Object /* String | PgSql */ query, { | ||
Object? /* List<Object?|PgTypedParameter> | Map<String, Object?|PgTypedParameter> */ | ||
parameters, | ||
bool ignoreRows = false, |
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.
Since we'll receive the rows anyway and just chose to ignore them, perhaps the ignoreRows
parameter doesn't make much sense anymore when we have a useSimpleQueryProtocol
parameter as well.
So maybe the ignoreRows
parameter should just be removed in favor of useSimpleQueryProtocol
?
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.
I wasn't sure what is the use of ignoreRows
so I left it as is.. I will take a closer look later today and update the PR accordingly.
I will also expand on the docs for useSimpleQueryProtocol
and mention some of its use cases.
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.
If possible, I would like to keep ignoreRows
, because if the caller needs only a non-error execution, we can spare a bit of processing. I don't mind having useSimpleQueryProtocol
but only if that's the only way to do it (see my main comment about having it at connection level or with a callback).
I have no idea about this, but can a connection switch between replication mode and normal mode? If it can't, it would seem to be better to make it a connection-level attribute to always use the simple query protocol. And even if it can, I would assume that it is something that can be turned on, and from that onward, every query must be sent like that. Having to use an explicit wdyt? |
No, a connection must be established as either one since it's defined in the StartUpMessage. But within a session, either Query protocol can be used. Definitely, the default one should be as it is which is the Extended Query Protocol. I am not sure about the other cases where the Simple Query Protocol is preferable or a must over the Extended one, but it is obviously an execution option.
I agree with you having done the mistake few times already but, in my case, the server returns a clear error message (e.g. Another option is to have a dedicated method (e.g. Please let me know what do you prefer. I am fine with any option as long as it's available.
About |
I just looked at pgx implementation for reference, and they do have two options available for users to set the Query protocol:
... as explained in their docs:
If that's a preferable approach, we can create an enum e.g. |
Maybe the name can be as short as |
2c87252
to
d4489a8
Compare
@osaxma: I think this is close - only a single test started to fail. Could you please check it? |
e82d7e0
to
703c909
Compare
@isoos there were some merge conflicts and my branch wasn't up to date. I am not sure why when you merged with master, the conflicts didn't show up.
I think it's a good idea to have an umbrella issue mentioning all these stuff that we would like to cleanup later so we don't forget. |
The Simple Query Protocol is the only protocol that can be used when the connection is in Replication Mode in order to query system information such as
IDENTIFY_SYSTEM;
query.Currently, the only way to use the Simple Protocol is to set
ignoreRows
totrue
but this will return no result and there's no way around it.While taking @simolus3 comment from PR #102 into consideration, I added an option to explicit use the Simple Query Protocol. In addition, it is used when there are no parameters and
ignoreRows
is set to true.