-
Notifications
You must be signed in to change notification settings - Fork 192
Clean up and simplify Begin/EndInsert #448
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
theory
left a comment
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.
Nice cleanup, especially the elimination of ReceivePreparePackets, thank you! I've confirmed this commit works with the FDW.
|
|
||
| // Send empty block as marker of end of data. | ||
| SendData(Block()); | ||
| inserting = 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.
I had it here because I got an error from the bits waiting for a result when I had it where you've now moved it.
clickhouse/client.cpp
Outdated
| Block Client::Impl::BeginInsert(Query query) { | ||
| if (inserting) { | ||
| if (inserting_) { | ||
| throw ProtocolError("cannot execute query while inserting"); |
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.
Do you want to change this one to ValidationError(), too?
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.
Oops, my bad, yeah, meant to that too!
clickhouse/client.cpp
Outdated
| // Wait for a data packet and return | ||
| uint64_t server_packet = 0; | ||
| while (ReceivePacket(&server_packet)) { | ||
| if (server_packet == ServerCodes::Data) { | ||
| return block; | ||
| } |
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.
So much nicer to remove the duplication, thank you!
- Renamed `InsertData` to `SendInsertBlock`, to prevent it from appearing first when searching for `Insert...` - Removed `EndInsert` with a block. Instead, users should now use `SendInsertBlock` followed by `EndInsert`. - Removed `ReceivePreparePackets` and replaced it with a call to `ReceivePacket`, similar to what is done in `Insert`. - Renamed `inserting` to `inserting_` to follow the member variable naming convention.
9ba3679 to
605a6ba
Compare
Move the `BeginInsert` body to match the order of the class declaration, placing it between `Insert` and `SendInsertData`.
InsertDatatoSendInsertBlock, to prevent it from appearing first when searching forInsert...EndInsertwith a block. Instead, users should now useSendInsertBlockfollowed byEndInsert.ReceivePreparePacketsand replaced it with a call toReceivePacket, similar to what is done inInsert.insertingtoinserting_to follow the member variable naming convention.ProtocolErrorwithValidationErrorfor the situation when calling other operations is not allowed betweenBeginInsertandEndInsertBeginInsertbody to match the order of the class declaration, placing it betweenInsertandSendInsertData.