Data type 0x2B is unknown. FreeTDS version?
Closed this issue · 4 comments
I am attempting to execute a stored procedure on my database, and I'm getting the following error:
2014/08/07 15:30:04 Msg 8009, Level 16
General SQL Server error: Check messages from the SQL Server
Msg 8009, Level 16, State 1
Server 'server', Line 1
The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@Parameter1"): Data type 0x2B is unknown.
/home/jackman/code/edge-api/src/rolist/ro.go:34 (rolist.ROList)
Why is this data type unknown? Is the database responding to a reference of data type 0x2B by FreeTDS? I know that my server supports this data type (DateTimeOffset) because that's the expected type of the parameter.
This post mentions/verifies the data type in question:
http://lists.ibiblio.org/pipermail/freetds/2011q2/026938.html
Code snippet:
nullDate := "3/10/1997 12:00:00 AM"
rst, err := conn.ExecSp("Procedure", nullDate, nullDate, 1, 291, 1)
if err != nil {
return rolist, errors.Stack(err)
}
I can successfully perform select statements and other things on the DB.
I thought perhaps my version of FreeTDS is outdated, so I built the latest version locally, and then executed with the following:
jackman@debian:~/code/edge-api$ LD_LIBRARY_PATH=$HOME/opt/lib GOPATH=$PWD:$GOPATH go run ./src/main.go
panic: dbopen error
goroutine 16 [running]:
runtime.panic(0x5010a0, 0xc2080002b0)
/home/jackman/code/go/src/pkg/runtime/panic.c:279 +0xf5
core.connect(0x7cb160)
/home/jackman/code/edge-api/src/core/db.go:21 +0x85
core.init·1()
/home/jackman/code/edge-api/src/core/db.go:14 +0x1e
core.init()
/home/jackman/code/edge-api/src/core/db.go:28 +0x4b
rolist.init()
/home/jackman/code/edge-api/src/rolist/ro.go:40 +0x50
main.init()
/home/jackman/code/edge-api/src/main.go:33 +0x46
goroutine 19 [finalizer wait]:
runtime.park(0x415520, 0x7db678, 0x7cf289)
/home/jackman/code/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x7db678, 0x7cf289)
/home/jackman/code/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/home/jackman/code/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/home/jackman/code/go/src/pkg/runtime/proc.c:1445
goroutine 17 [syscall]:
runtime.goexit()
/home/jackman/code/go/src/pkg/runtime/proc.c:1445
exit status 2
Without more specific output from gofreetds, I don't know how to proceed. Please help. Thank you.
Newer sql server data types was not handled.
I also got the same error when trying to use datetimeoffset type:
'The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@parameter1"): Data type 0x2B is unknown.'
Made a fix (550d514) to pass that params as strings.
Please try with the latest trunk.
Please forgive my ignorance:
Is the data type not handled by FreeTDS or by gofreetds? I'd be happy to contribute if you point me in the right direction. I am much more confident as a Go programmer than a FreeTDS/C hacker.
Thanks for the contribution! I'll test your updated when I get back to work on Monday.
By gofreetds.
Executing stored procedure is done by calling dbrpcinit, dbrpcparam and dbrpcsend freetds functions (http://www.freetds.org/reference/a00285.html).
dbrpcparam is called for each stored procedure param. Each go type need to be transformed into []byte in the tds format. That is done in typeToSqlBuf function in gofretds.
I don't know what is the tds format for datetimeoffset and what is good type in go for datetimeoffset.
Must say that I never used it in sql server.
Currently we are just passing it as string, an reading it as string.
The new gofreetds code fixed my problem. Thank you!