Skip to content
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

Add support for COPY IN protocol #72

Merged
merged 16 commits into from
Nov 11, 2024
Merged

Conversation

flimzy
Copy link
Contributor

@flimzy flimzy commented Aug 9, 2024

This PR is still a bit rough. It does not have tests for corner cases (most important: when client sends CopyFail), and I'm not entirely sure that the structure is as simple as it can be.

But I'd love to get some feedback on the approach.

Two main API changes:

  1. CopyIn added to the DataWriter type.
  2. The Execute method in the PortalCache interface needs an additional argument. I've implemented this in a backward-compatible way, though.

Still to do:

  • Clean up commit history
  • What error code should the server return when the client sends a CopyFail?
  • Test for CopyFail from client
  • Test for Text format
  • Test for mixed column formats
  • Should we provide any parsing of the copy stream? IMO, probably not by default (I don't need to parse it for my own needs), but maybe as helper utilities, in future PRs, if needed by someone?

Note that this does not implement CopyOutResponse or CopyBothResponse. I don't (yet) need either of these. But with the groundwork in this PR, they should both be easier to accomplish if/when needed.

Copy link
Owner

@jeroenrinzema jeroenrinzema left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Left a few comments. Would like to explore if we could expose the copy implementation as a io interface.

writer.go Outdated Show resolved Hide resolved
writer.go Outdated Show resolved Hide resolved
command.go Outdated Show resolved Hide resolved
command.go Outdated Show resolved Hide resolved
@flimzy flimzy force-pushed the copyIn branch 3 times, most recently from 0af1145 to 3325a8a Compare August 12, 2024 13:26
@jeroenrinzema
Copy link
Owner

Much thanks @flimzy! I have implemented the last changes as discussed in the comments. This PR is ready to be merged!

@jeroenrinzema jeroenrinzema merged commit ebab8df into jeroenrinzema:main Nov 11, 2024
2 checks passed
@flimzy
Copy link
Contributor Author

flimzy commented Nov 12, 2024

Thank you, @jeroenrinzema , for picking up the ball where I dropped it. And thanks for the great package!

@flimzy flimzy deleted the copyIn branch November 12, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants