-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Remove PrepareStatementStateMachine #391
Remove PrepareStatementStateMachine #391
Conversation
Preparing a statement is a substep of running an extended query. For this reason we should reuse the ExtendedQueryStateMachine as much as we can. This patch removes the `PrepareStatementStateMachine` and uses the `ExtendedQueryStateMachine`. As a result of this we can simplify our code in lots of other places.
7e4baca
to
5ae831d
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
==========================================
- Coverage 46.02% 44.47% -1.55%
==========================================
Files 110 109 -1
Lines 8833 8724 -109
==========================================
- Hits 4065 3880 -185
- Misses 4768 4844 +76
|
@@ -4,7 +4,7 @@ struct ExtendedQueryStateMachine { | |||
|
|||
private enum State { | |||
case initialized(ExtendedQueryContext) | |||
case parseDescribeBindExecuteSyncSent(ExtendedQueryContext) | |||
case messagesSent(ExtendedQueryContext) |
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.
Is the name messageSent
intentionally generic? When I read it my first reaction was "What message? Do we have different kind of messages flying around?"
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.
yes. it depends on what the internal QueryContext says.
If we run an unnamed query, we sent parse, describe, bind, execute & sync
.
If we prepare a statement, we sent parse, describe & sync
.
If we execute a statement, we sent bind, execute & sync
.
enum RowSource { | ||
case stream(PSQLRowsDataSource) | ||
enum Source { | ||
case stream([RowDescription.Column], PSQLRowsDataSource) |
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.
What's the difference between RowDescription
and [RowDescription.Column]
?
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.
RowDescription
is a wrapper around [RowDescription.Column]
. A bit stupid. This makes sense if you look at how the PostgresBackendMessage
s are structured.
bufferState = .streaming(buffer: .init(), dataSource: dataSource) | ||
case .noRows(.success(let commandTag)): | ||
self.rowDescription = [] |
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.
In other parts of the codebase (e.g. in PrepareStatementStateMachine
) we allowed row description to be nil
. Is there any semantic difference between a RowDescription?
with a nil
value and an empty [RowDescription.Column]
?
Preparing a statement is a substep of running an extended query. For this reason we should reuse the ExtendedQueryStateMachine as much as we can. This patch removes the
PrepareStatementStateMachine
and uses theExtendedQueryStateMachine
. As a result of this we can simplify our code in lots of other places.