Support streaming COPY FROM STDIN and COPY TO STDOUT - #1696
Open
doxlik wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@vietj @tsegismont hi. Please have a look once you have time. |
Expose the PostgreSQL COPY subprotocol on PgConnection as raw byte streams, so bulk data transfers no longer have to be materialized in memory. copyOut(String) executes a COPY ... TO STDOUT statement and returns a PgCopyOut, a ReadStream of Buffer whose completion() carries the row count reported by the server. Each CopyData message is emitted as one buffer by default; PgCopyOutOptions.setAggregationThreshold(int) coalesces small messages when throughput matters more than message boundaries. copyIn(String) executes a COPY ... FROM STDIN statement and returns a PgCopyIn, a WriteStream of Buffer honouring writeQueueFull() and drainHandler(). Small writes are batched up to PgCopyInOptions chunkSize, and abort(String) sends CopyFail so the server rolls the copy back. The outcome of a COPY is always the one PostgreSQL reports, never synthesised by the client: completion() resolves at ReadyForQuery, which is also what leaves the connection usable for the next statement. Signed-off-by: doxlik <doxlikx@gmail.com>
This file contains hidden or 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
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.
Expose the PostgreSQL COPY subprotocol on PgConnection as raw byte streams, so bulk data transfers no longer have to be materialized in memory.
copyOut(String) executes a COPY ... TO STDOUT statement and returns a PgCopyOut, a ReadStream of Buffer whose completion() carries the row count reported by the server. Each CopyData message is emitted as one buffer by default; PgCopyOutOptions.setAggregationThreshold(int) coalesces small messages when throughput matters more than message boundaries.
copyIn(String) executes a COPY ... FROM STDIN statement and returns a PgCopyIn, a WriteStream of Buffer honouring writeQueueFull() and drainHandler(). Small writes are batched up to PgCopyInOptions chunkSize, and abort(String) sends CopyFail so the server rolls the copy back.
The outcome of a COPY is always the one PostgreSQL reports, never synthesised by the client: completion() resolves at ReadyForQuery, which is also what leaves the connection usable for the next statement.
Resolves #153