Add BCP bulk copy and streamed result set support for TDS 5.0#239
Open
Jakeharlan73 wants to merge 1 commit intoDataAction:masterfrom
Open
Add BCP bulk copy and streamed result set support for TDS 5.0#239Jakeharlan73 wants to merge 1 commit intoDataAction:masterfrom
Jakeharlan73 wants to merge 1 commit intoDataAction:masterfrom
Conversation
Implements bulk copy operations using the native TDS 5.0 BCP wire protocol, enabling high-performance data loading (BCP IN) and extraction (BCP OUT) for SAP ASE databases. Public API follows the SqlBulkCopy pattern: - AseBulkCopy.WriteToServer() for bulk insert from IDataReader/DataTable - AseBulkCopy.ReadFromServer() for bulk extraction to DataTable - Column mapping, batching, and row notification support Protocol details: - Native BCP row format (no TDS_ROW token prefix) - APL and DOL (datarows-locked) offset table formats - REQ_BCP capability negotiation - Supports all fixed and variable-length TDS data types (TEXT/IMAGE/UNITEXT deferred) Verified: 508-row round-trip (BCP OUT -> BCP IN) with full data integrity. All 1389 existing unit tests pass with no regressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
SqlBulkCopyAPI pattern for familiarityCommandBehavior.SequentialAccessis requested, token processing runs on a background thread so theAseDataReaderis returned as soon as the first result set arrives — enabling streaming consumption of large or multi-result-set queriesBCP Details
Public API:
AseBulkCopy.WriteToServer()— bulk insert fromIDataReaderorDataTableAseBulkCopy.ReadFromServer()— bulk extraction toDataTableProtocol:
TDS_ROWtoken prefix)REQ_BCPcapability negotiationTEXT/IMAGE/UNITEXTdeferred)Streamed Result Sets
Small change to
InternalConnection.ExecuteReaderTaskRunnable— whenSequentialAccessis set,InternalExecuteQueryAsyncruns viaTask.Run()so the existingStreamingDataReaderTokenHandlercan resolve theTaskCompletionSource<DbDataReader>after the first result set while the background thread continues receiving remaining data.Test Plan
AseBulkCopyColumnMappingTests,BcpRowFormatterTests,BcpValueWriterTests)