-
Notifications
You must be signed in to change notification settings - Fork 293
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
Merge common code bases for TdsParserStateObject.cs (4) #2254
Changes from 6 commits
40d1351
cae8c3f
fde2178
53e4333
9076c6a
cedc2b5
40a355c
2a9558d
6a8f0d9
e22c4e9
4a9ba4e
a9b5585
e6cb4ab
0f14302
e695cc7
7ca012a
832e378
240e242
619bb4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,34 +106,6 @@ internal uint Status | |
} | ||
} | ||
|
||
private partial struct NullBitmap | ||
{ | ||
internal bool TryInitialize(TdsParserStateObject stateObj, int columnsCount) | ||
{ | ||
_columnsCount = columnsCount; | ||
// 1-8 columns need 1 byte | ||
// 9-16: 2 bytes, and so on | ||
int bitmapArrayLength = (columnsCount + 7) / 8; | ||
|
||
// allow reuse of previously allocated bitmap | ||
if (_nullBitmap == null || _nullBitmap.Length != bitmapArrayLength) | ||
{ | ||
_nullBitmap = new byte[bitmapArrayLength]; | ||
} | ||
|
||
// read the null bitmap compression information from TDS | ||
if (!stateObj.TryReadByteArray(_nullBitmap, _nullBitmap.Length)) | ||
{ | ||
return false; | ||
} | ||
|
||
SqlClientEventSource.Log.TryAdvancedTraceEvent("TdsParserStateObject.NullBitmap.Initialize | INFO | ADV | State Object Id {0}, NBCROW bitmap received, column count = {1}", stateObj.ObjectID, columnsCount); | ||
SqlClientEventSource.Log.TryAdvancedTraceBinEvent("TdsParserStateObject.NullBitmap.Initialize | INFO | ADV | State Object Id {0}, NBCROW bitmap data. Null Bitmap {1}, Null bitmap length: {2}", stateObj.ObjectID, _nullBitmap, (ushort)_nullBitmap.Length); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
///////////////////// | ||
// General methods // | ||
///////////////////// | ||
|
@@ -372,38 +344,6 @@ internal void StartSession(int objectID) | |
_allowObjectID = objectID; | ||
} | ||
|
||
///////////////////////////////////////// | ||
// Value Skip Logic // | ||
///////////////////////////////////////// | ||
|
||
|
||
// Reads bytes from the buffer but doesn't return them, in effect simply deleting them. | ||
// Does not handle plp fields, need to use SkipPlpBytesValue for those. | ||
// Does not handle null values or NBC bitmask, ensure the value is not null before calling this method | ||
internal bool TrySkipLongBytes(long num) | ||
{ | ||
Debug.Assert(_syncOverAsync || !_asyncReadWithoutSnapshot, "This method is not safe to call when doing sync over async"); | ||
|
||
while (num > 0) | ||
{ | ||
int cbSkip = (int)Math.Min(int.MaxValue, num); | ||
if (!TryReadByteArray(Span<byte>.Empty, cbSkip)) | ||
{ | ||
return false; | ||
} | ||
num -= cbSkip; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
// Reads bytes from the buffer but doesn't return them, in effect simply deleting them. | ||
internal bool TrySkipBytes(int num) | ||
{ | ||
Debug.Assert(_syncOverAsync || !_asyncReadWithoutSnapshot, "This method is not safe to call when doing sync over async"); | ||
return TryReadByteArray(Span<byte>.Empty, num); | ||
} | ||
|
||
///////////////////////////////////////// | ||
// Network/Packet Reading & Processing // | ||
///////////////////////////////////////// | ||
|
@@ -916,7 +856,6 @@ internal bool IsConnectionAlive(bool throwOnException) | |
else | ||
{ | ||
uint error; | ||
IntPtr readPacket = IntPtr.Zero; | ||
|
||
RuntimeHelpers.PrepareConstrainedRegions(); | ||
try | ||
|
@@ -947,12 +886,6 @@ internal bool IsConnectionAlive(bool throwOnException) | |
} | ||
finally | ||
{ | ||
if (readPacket != IntPtr.Zero) | ||
{ | ||
// Be sure to release packet, otherwise it will be leaked by native. | ||
SNINativeMethodWrapper.SNIPacketRelease(readPacket); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this code is unreachable, the enclosing try/finally serves no purpose other than whatever RuntimeHelpers.PrepareConstrainedRegions does. I have preserved the try/finally (by adding it in .net core) but I suspect it can be removed, because according to the documentation (emphasis mine):
If I understand correctly, RuntimeHelpers.PrepareConstrainedRegions only affects catch/finally and has no effect if they are empty. |
||
} | ||
|
||
} | ||
} | ||
} | ||
|
@@ -1837,7 +1770,7 @@ private Task SNIWritePacket(SNIHandle handle, SNIPacket packet, out uint sniErro | |
return task; | ||
} | ||
|
||
#pragma warning restore 420 | ||
#pragma warning restore 420 | ||
|
||
// Sends an attention signal - executing thread will consume attn. | ||
internal void SendAttention(bool mustTakeWriteLock = false, bool asyncClose = false) | ||
|
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.
I like the way you addressed the code differences. 👏🏼