forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 68
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
adds pre tds 7.1 compatibility #83
Open
eshaker
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
eshaker:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ type xmlInfo struct { | |
XmlSchemaCollection string | ||
} | ||
|
||
func readTypeInfo(r *tdsBuffer) (res typeInfo) { | ||
func readTypeInfo(sess *tdsSession, r *tdsBuffer) (res typeInfo) { | ||
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. I'm not sure about the code-style. I did not want to copy the whole readTypeInfo func for v7.1 compatibility as the version-info is needed in readVarLen |
||
res.TypeId = r.byte() | ||
switch res.TypeId { | ||
case typeNull, typeInt1, typeBit, typeInt2, typeInt4, typeDateTim4, | ||
|
@@ -140,7 +140,7 @@ func readTypeInfo(r *tdsBuffer) (res typeInfo) { | |
res.Reader = readFixedType | ||
res.Buffer = make([]byte, res.Size) | ||
default: // all others are VARLENTYPE | ||
readVarLen(&res, r) | ||
readVarLen(sess, &res, r) | ||
} | ||
return | ||
} | ||
|
@@ -719,7 +719,7 @@ func writePLPType(w io.Writer, ti typeInfo, buf []byte) (err error) { | |
} | ||
} | ||
|
||
func readVarLen(ti *typeInfo, r *tdsBuffer) { | ||
func readVarLen(sess *tdsSession, ti *typeInfo, r *tdsBuffer) { | ||
switch ti.TypeId { | ||
case typeDateN: | ||
ti.Size = 3 | ||
|
@@ -798,17 +798,25 @@ func readVarLen(ti *typeInfo, r *tdsBuffer) { | |
switch ti.TypeId { | ||
case typeText, typeNText: | ||
ti.Collation = readCollation(r) | ||
// ignore tablenames | ||
numparts := int(r.byte()) | ||
for i := 0; i < numparts; i++ { | ||
// only present in TDS > 7.2 | ||
if sess.loginAck.TDSVersion >= verTDS72 { | ||
// ignore tablenames | ||
numparts := int(r.byte()) | ||
for i := 0; i < numparts; i++ { | ||
r.UsVarChar() | ||
} | ||
} else { | ||
r.UsVarChar() | ||
} | ||
ti.Reader = readLongLenType | ||
case typeImage: | ||
// ignore tablenames | ||
numparts := int(r.byte()) | ||
for i := 0; i < numparts; i++ { | ||
r.UsVarChar() | ||
// only present in TDS >= 7.2 | ||
if sess.loginAck.TDSVersion >= verTDS72 { | ||
// ignore tablenames | ||
numparts := int(r.byte()) | ||
for i := 0; i < numparts; i++ { | ||
r.UsVarChar() | ||
} | ||
} | ||
ti.Reader = readLongLenType | ||
case typeVariant: | ||
|
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.
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.
does this check need to be protected by the TDS version check too?
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 per https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/60f56408-0188-4cd5-8b90-25c6f2423868 there seems to be no constraint on the TDS-Version.
As I understand the documentation, the parameter is used for the client to communicate its thread-id for debugging-purposes. If sent by the server, it should be empty in any case.