@@ -90,17 +90,17 @@ func NewColumn(h api.SQLHSTMT, idx int) (Column, error) {
90
90
var v api.SQLGUID
91
91
return NewBindableColumn (b , api .SQL_C_GUID , int (unsafe .Sizeof (v ))), nil
92
92
case api .SQL_CHAR , api .SQL_VARCHAR :
93
- return NewVariableWidthColumn (b , api .SQL_C_CHAR , size ), nil
93
+ return NewVariableWidthColumn (b , api .SQL_C_CHAR , size )
94
94
case api .SQL_WCHAR , api .SQL_WVARCHAR :
95
- return NewVariableWidthColumn (b , api .SQL_C_WCHAR , size ), nil
95
+ return NewVariableWidthColumn (b , api .SQL_C_WCHAR , size )
96
96
case api .SQL_BINARY , api .SQL_VARBINARY :
97
- return NewVariableWidthColumn (b , api .SQL_C_BINARY , size ), nil
97
+ return NewVariableWidthColumn (b , api .SQL_C_BINARY , size )
98
98
case api .SQL_LONGVARCHAR :
99
- return NewVariableWidthColumn (b , api .SQL_C_CHAR , 0 ), nil
99
+ return NewVariableWidthColumn (b , api .SQL_C_CHAR , 0 )
100
100
case api .SQL_WLONGVARCHAR , api .SQL_SS_XML :
101
- return NewVariableWidthColumn (b , api .SQL_C_WCHAR , 0 ), nil
101
+ return NewVariableWidthColumn (b , api .SQL_C_WCHAR , 0 )
102
102
case api .SQL_LONGVARBINARY :
103
- return NewVariableWidthColumn (b , api .SQL_C_BINARY , 0 ), nil
103
+ return NewVariableWidthColumn (b , api .SQL_C_BINARY , 0 )
104
104
default :
105
105
return nil , fmt .Errorf ("unsupported column type %d" , sqltype )
106
106
}
@@ -199,10 +199,10 @@ func NewBindableColumn(b *BaseColumn, ctype api.SQLSMALLINT, bufSize int) *Binda
199
199
return c
200
200
}
201
201
202
- func NewVariableWidthColumn (b * BaseColumn , ctype api.SQLSMALLINT , colWidth api.SQLULEN ) Column {
202
+ func NewVariableWidthColumn (b * BaseColumn , ctype api.SQLSMALLINT , colWidth api.SQLULEN ) ( Column , error ) {
203
203
if colWidth == 0 || colWidth > 1024 {
204
204
b .CType = ctype
205
- return & NonBindableColumn {b }
205
+ return & NonBindableColumn {b }, nil
206
206
}
207
207
l := int (colWidth )
208
208
switch ctype {
@@ -214,11 +214,11 @@ func NewVariableWidthColumn(b *BaseColumn, ctype api.SQLSMALLINT, colWidth api.S
214
214
case api .SQL_C_BINARY :
215
215
// nothing to do
216
216
default :
217
- panic ( fmt .Errorf ("do not know how wide column of ctype %d is" , ctype ) )
217
+ return nil , fmt .Errorf ("do not know how wide column of ctype %d is" , ctype )
218
218
}
219
219
c := NewBindableColumn (b , ctype , l )
220
220
c .IsVariableWidth = true
221
- return c
221
+ return c , nil
222
222
}
223
223
224
224
func (c * BindableColumn ) Bind (h api.SQLHSTMT , idx int ) (bool , error ) {
@@ -242,7 +242,7 @@ func (c *BindableColumn) Value(h api.SQLHSTMT, idx int) (driver.Value, error) {
242
242
return nil , nil
243
243
}
244
244
if ! c .IsVariableWidth && int (c .Len ) != c .Size {
245
- panic ( fmt .Errorf ("wrong column #%d length %d returned, %d expected" , idx , c .Len , c .Size ) )
245
+ return nil , fmt .Errorf ("wrong column #%d length %d returned, %d expected" , idx , c .Len , c .Size )
246
246
}
247
247
return c .BaseColumn .Value (c .Buffer [:c .Len ])
248
248
}
0 commit comments