Closed GoogleCodeExporter closed 9 years ago
I didn't look at your problem properly, but it sounds like it works fine on
Windows. If that is true, you can achieve similar behaviour on Linux by
changing NewVariableWidthColumn function. Just go for NonBindableColumn not
only when colWidth is 0, but also when it is “very large”. Pick a number
for a “very large” - maybe 2MB or something - it is up to you.
I will think about this more, but I don’t see any better solution for it. If
it is not too much trouble, please provide small example program for me to try.
Thank you.
Alex
Original comment by alex.bra...@gmail.com
on 18 Oct 2014 at 12:13
I cannot reproduce your problem here. I made changes similar to yours:
diff -r 78314be168c8 column.go
--- a/column.go Tue Sep 02 11:28:47 2014 +1000
+++ b/column.go Mon Oct 20 12:43:03 2014 +1100
@@ -192,6 +192,7 @@
}
func NewVariableWidthColumn(b *BaseColumn, ctype api.SQLSMALLINT, colWidth api.SQLULEN) Column {
+ fmt.Printf("col: %+v type: %v width: %v\n", b, ctype, colWidth)
if colWidth == 0 {
b.CType = ctype
return &NonBindableColumn{b}
diff -r 78314be168c8 mssql_test.go
--- a/mssql_test.go Tue Sep 02 11:28:47 2014 +1000
+++ b/mssql_test.go Mon Oct 20 12:43:03 2014 +1100
@@ -1344,3 +1344,21 @@
exec(t, db, "drop table dbo.temp")
}
+
+func TestALEX(t *testing.T) {
+ db, sc, err := mssqlConnect()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer closeDB(t, db, sc, sc)
+
+ query := fmt.Sprintf("select cast('hello' as xml)")
+ var s string
+ err = db.QueryRow(query).Scan(&s)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if s != "hello" {
+ t.Errorf("expected \"hello\", but received %v", s)
+ }
+}
and new test prints this on both linux and windows:
# go test -mssrv=xxx -msdb=xxx -msuser=xxxx -mspass=xxx -v -run=ALEX
=== RUN TestALEX
col: &{name: CType:0} type: -8 width: 0
--- PASS: TestALEX (0.01s)
PASS
ok code.google.com/p/odbc 0.011s
I use freetds-0.91 and unixODBC-2.3.1 on linux.
Alex
Original comment by alex.bra...@gmail.com
on 20 Oct 2014 at 1:47
I copied your test into my clone and got this:
$ TDSVER=7.2 go test -run TestALEX -mssrv=xxx -msdb=xxx -msuser=xxx -mspass=xxx
col: &{name: CType:0} type: 1 width: 2147483647
PASS
ok code.google.com/p/odbc 0.009s
The client is running CentOS release 6.4 (Final) with FreeTDS 0.91 and
unixODBC-2.3.1 both installed from source. Note that I have to set the TDSVER
to get the test to work at all. I tried to set the default TDSVER during
FreeTDS install, but it didn't seem to take.
The DB server is running MS SQL Server 2012.
Original comment by chris.cs...@gmail.com
on 20 Oct 2014 at 3:46
Original issue reported on code.google.com by
chris.cs...@gmail.com
on 17 Oct 2014 at 4:11