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

Fix for Clobs/NClobs not persisting after RS/Connection closes #682

Merged
merged 29 commits into from
May 3, 2018

Conversation

rene-ye
Copy link
Member

@rene-ye rene-ye commented Apr 20, 2018

The ASCII stream functionality did not work, removed for now. Added streaming functionality to character streams. Junit tests for streams to come at a later date.

rene-ye and others added 23 commits February 2, 2018 15:46
To help debug an irreproducable/random mismatch error if it occurs in the future.
…#666)

* Dont throw exception for colmetadata token

* Adding a comment

* Update comment

* Adding a warning message

* remove ignoreLengthPrefixedToken
* Added more information to error messages

To help debug an irreproducable/random mismatch error if it occurs in the future.

* Revert "Added information to error message"

This reverts commit 25301e6.

* Fix for microsoft#659

Added error handling logic for special cases.

* Read message length

Read the message length instead of reading until terminating character

* Unsigned byte update

Message length is an unsigned byte, converting before using.

* Removed clunky hex conversions

convert the byte straight to an int and use existing constants instead of making new ones

* Narrowed trigger conditions

fixed an issue where column names who had the hex token 'AA' would cause an error to be thrown.

* Spacing fixes

* Added test case

* spacing adjustment

* Edited test drop procedures

Changed IF EXISTS DROP commands to be compatible with sql server 2008

* github spacing misalignment fixes

* Changed test condition

now only runs on compatible database or higher

* Removed error check

Removed a previous implementation in favor of one that changes the TDS parser

* tdsreader change

* removing test for now

* enabled tests

* github spacing fix

* removed array import

* removed "arrays" instead of "array"

* spacing changes
Implement a more generic and compatible test in the future
Used in removed test
@codecov-io
Copy link

codecov-io commented Apr 20, 2018

Codecov Report

Merging #682 into dev will decrease coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #682      +/-   ##
============================================
- Coverage     48.17%   48.15%   -0.02%     
- Complexity     2585     2587       +2     
============================================
  Files           113      114       +1     
  Lines         26572    26577       +5     
  Branches       4450     4452       +2     
============================================
- Hits          12801    12799       -2     
- Misses        11634    11639       +5     
- Partials       2137     2139       +2
Flag Coverage Δ Complexity Δ
#JDBC42 48.08% <66.66%> (+0.1%) 2583 <8> (+8) ⬆️
#JDBC43 47.93% <66.66%> (-0.09%) 2578 <8> (+1)
Impacted Files Coverage Δ Complexity Δ
...va/com/microsoft/sqlserver/jdbc/SQLServerBlob.java 34.19% <0%> (ø) 18 <1> (ø) ⬇️
...ava/com/microsoft/sqlserver/jdbc/SQLServerLob.java 100% <100%> (ø) 1 <1> (?)
...va/com/microsoft/sqlserver/jdbc/SQLServerClob.java 30% <62.5%> (+1.73%) 4 <0> (ø) ⬇️
...m/microsoft/sqlserver/jdbc/SQLServerResultSet.java 33.53% <73.33%> (+0.38%) 248 <6> (+3) ⬆️
...a/com/microsoft/sqlserver/jdbc/PLPInputStream.java 53.01% <0%> (-2.41%) 29% <0%> (-2%)
...n/java/com/microsoft/sqlserver/jdbc/Parameter.java 61.71% <0%> (-1.05%) 63% <0%> (ø)
...c/main/java/com/microsoft/sqlserver/jdbc/Util.java 60.91% <0%> (-0.66%) 88% <0%> (-1%)
...in/java/com/microsoft/sqlserver/jdbc/IOBuffer.java 55.23% <0%> (-0.27%) 0% <0%> (ø)
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 50.44% <0%> (-0.25%) 157% <0%> (ø)
...om/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java 52.42% <0%> (-0.2%) 238% <0%> (-1%)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f752e4...d327db2. Read the comment docs.

getterStream = new BufferedReader(new InputStreamReader(inputStream, UTF_16LE));
}
else {
getStringFromStream();
Copy link
Member

Choose a reason for hiding this comment

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

Calling getStringFromStream() here is not required. Lets remove it from here.

@@ -312,10 +306,23 @@ public String getSubString(long pos,
public long length() throws SQLException {
checkClosed();

if (value == null && activeStreams.get(0) instanceof PLPInputStream) {
return (long)((PLPInputStream)activeStreams.get(0)).payloadLength/2;
}
getStringFromStream();
Copy link
Member

Choose a reason for hiding this comment

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

If value is NULL, code doesn't reach here, and if it is NOT NULL, calling getStringFromStream() is not needed.

@@ -243,7 +243,7 @@ public long length() throws SQLException {
* Function for the result set to maintain blobs it has created
* @throws SQLException
*/
void fillByteArray() throws SQLException {
void fillFromStream() throws SQLException {
Copy link
Member

Choose a reason for hiding this comment

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

Let's make fillFromStream() part of Interface that can be implemented by SQLServerBlob, SQLServerClob and SQLServerNClob classes and can be declared type for activeLOB in ResultSet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added an abstract base class for blob/clob/nclob. Includes an abstract function fillFromStream which the child classes inherit and override.

rene-ye and others added 2 commits May 1, 2018 10:01
Created an abstract class with a shared method between Blobs/Clobs/NClobs. More functionality can be moved to this class, but the functions will have their visibility increased to package level.
@peterbae peterbae self-requested a review May 1, 2018 21:20
try {
((SQLServerBlob)activeBlob).fillByteArray();
((SQLServerBlob)activeLOB).fillFromStream();
Copy link
Contributor

Choose a reason for hiding this comment

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

About the errors, we should throw an appropriate error message instead of logging it, from our resources file

@rene-ye rene-ye merged commit b60068c into microsoft:dev May 3, 2018
MSSQL JDBC automation moved this from Under Peer Review to Closed/Merged PRs May 3, 2018
@rene-ye rene-ye deleted the issue673 branch May 3, 2018 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed/Merged PRs
Development

Successfully merging this pull request may close these issues.

None yet

5 participants