-
Notifications
You must be signed in to change notification settings - Fork 429
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
fix bulk copy cursor issue #270
fix bulk copy cursor issue #270
Conversation
…lkCopy_Cursor_Issue
Codecov Report
@@ Coverage Diff @@
## dev #270 +/- ##
============================================
+ Coverage 34.64% 37.12% +2.48%
- Complexity 1570 1648 +78
============================================
Files 102 102
Lines 23660 23694 +34
Branches 3873 3882 +9
============================================
+ Hits 8197 8797 +600
+ Misses 13847 13301 -546
+ Partials 1616 1596 -20
Continue to review full report at Codecov.
|
// Create and send the initial command for bulk copy ("INSERT BULK ..."). | ||
tdsWriter = command.startRequest(TDS.PKT_QUERY); | ||
String bulkCmd = createInsertBulkCommand(tdsWriter); | ||
tdsWriter.writeString(bulkCmd); |
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.
As the bulkCmd
is going to be same with and w/o cursors, let this be in SQLServerBulkCopy#doInsertBulk(as before) and not inside a while loop.
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.
With cursor, we need to send data row by row, so it has to be inside the while loop. Also, to bypass MARS, the sending must happen after the reading, which is goToNextRow()
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.
sending 'bulkCmd' in loop is fine, but driver will generate the same insert bulk .....
command again and again in line 3208.
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.
the thing is, we have to reset the tdsWriter
after goToNextRow()
, and createInsertBulkCommand
requires the new tdsWriter
, so, it has to be here, otherwise it fails when column is encrypted
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.
Got it! thanks for details Shwan!
Fixes #236