Skip to content

Commit

Permalink
fix udt fields network representation
Browse files Browse the repository at this point in the history
  • Loading branch information
sijms committed Sep 11, 2024
1 parent 22d3600 commit 83dff98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
7 changes: 2 additions & 5 deletions v2/network/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1876,8 +1876,8 @@ func (session *Session) GetFixedClr() ([]byte, error) {
}
var size int
switch nb {
case 0:
size = 0
case 0, 0xFD, 0xFF:
return nil, nil
case 0xFE:
size, err = session.GetInt(4, false, true)
if err != nil {
Expand All @@ -1886,9 +1886,6 @@ func (session *Session) GetFixedClr() ([]byte, error) {
default:
size = int(nb)
}
if size == 0 {
return nil, nil
}
return session.GetBytes(size)
}
func (session *Session) WriteFixedClr(buffer *bytes.Buffer, data []byte) {
Expand Down
15 changes: 8 additions & 7 deletions v2/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,14 @@ func (par *ParameterInfo) decodePrimValue(conn *Connection, temporaryLobs *[][]b
return nil
}
if udt { /*special extraction of udt fields*/
switch par.DataType {
case NCHAR, CHAR, LONG, LongVarChar:
par.BValue, err = session.GetFixedClr()
default:
par.BValue, err = session.GetClr()
}
//switch par.DataType {
//case NCHAR, CHAR, LONG, LongVarChar:
// par.BValue, err = session.GetFixedClr()
// //par.BValue, err = session.GetClr()
//default:
// par.BValue, err = session.GetClr()
//}
par.BValue, err = session.GetFixedClr()
} else {
par.BValue, err = session.GetClr()
}
Expand Down Expand Up @@ -649,7 +651,6 @@ func (par *ParameterInfo) decodePrimValue(conn *Connection, temporaryLobs *[][]b
locator, err = session.GetClr()
} else {
locator = par.BValue

}
if err != nil {
return err
Expand Down
7 changes: 4 additions & 3 deletions v2/parameter_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,11 @@ func (par *ParameterInfo) encodePrimValue(conn *Connection) error {
} else {
objectBuffer.Write(attrib.BValue)
}
case NCHAR, CHAR, LONG, LongVarChar:
session.WriteFixedClr(&objectBuffer, attrib.BValue)
//case NCHAR, CHAR, LONG, LongVarChar:
// session.WriteFixedClr(&objectBuffer, attrib.BValue)
default:
session.WriteClr(&objectBuffer, attrib.BValue)
session.WriteFixedClr(&objectBuffer, attrib.BValue)
//session.WriteClr(&objectBuffer, attrib.BValue)
}
}
if par.parent == nil {
Expand Down

0 comments on commit 83dff98

Please sign in to comment.