Code Monkey home page Code Monkey logo

odbc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odbc's Issues

do not panic during TestMSSQLType

What steps will reproduce the problem?
1. Ignore Explicit Instructions to modify the Test file to include the 
TDS_Version.
2. Run the tests.

What is the expected output? What do you see instead?

1. I expect to see a list of failed tests with some (maybe even vague) 
explanation.

2. I see:

$ go test -mssrv=internal-db-dev -msdb=test_database -msuser=username 
-mspass=password -run=MS
> --- FAIL: TestMSSQLTypes (0.01 seconds)
> panic: interface conversion: interface is nil, not bool [recovered]
>   panic: interface conversion: interface is nil, not bool
> 
> goroutine 8 [running]:
> testing.func·004()
>   /usr/lib/go/src/pkg/testing/testing.go:348 +0xcd
> code.google.com/p/odbc.func·005(0x4f7b40, 0xc200076f00, 0x1, 0x1)
>   ~/go/src/code.google.com/p/odbc/mssql_test.go:431 +0x239
> code.google.com/p/odbc.TestMSSQLTypes(0xc20009a1b0)
>   ~/go/src/code.google.com/p/odbc/mssql_test.go:636 +0x79e
> testing.tRunner(0xc20009a1b0, 0x811310)
>   /usr/lib/go/src/pkg/testing/testing.go:353 +0x8a
> created by testing.RunTests
>   /usr/lib/go/src/pkg/testing/testing.go:433 +0x86b
> 
> goroutine 1 [chan receive]:
> testing.RunTests(0x580e38, 0x8112e0, 0xd, 0xd, 0x1, ...)
>   /usr/lib/go/src/pkg/testing/testing.go:434 +0x88e
> testing.Main(0x580e38, 0x8112e0, 0xd, 0xd, 0x820360, ...)
>   /usr/lib/go/src/pkg/testing/testing.go:365 +0x8a
> main.main()
>   code.google.com/p/odbc/_test/_testmain.go:69 +0x9a
> 
> goroutine 2 [syscall]:
> exit status 2
> FAIL  code.google.com/p/odbc  0.247s

What version of the product are you using? On what operating system?

Most Recent Version of odbc as of 10/17/2013
Using unixODBC (installed as per your instructions)
Using FreeTDS (installed as per your instructoins)
Using Ubuntu 13.04

Please provide any additional information below.

Replacing all the direct type assertions in `match` from:

     got := a.(ACTUALTYPE)

to

     got, ok := a.(ACTUALTYPE)
     if !ok {
       return fmt.Errorf("Couldn't Convert Expected Value %s(%T) to %T, a, a, got)
     }

Would fix it and result in a better, more informative test suite. 

Original issue reported on code.google.com by [email protected] on 17 Oct 2013 at 5:36

tests fail with SQL Server Native Client 11.0

... testing with the "msdriver" option of "SQL Server Native Client 11.0" and 
one of the existing tests is failing:
mssql_test.go:530: test "select cast('abc' as varchar(max))" failed: expect 
"abc", but got "\x00\x00\x00"
panic: runtime error: slice bounds out of range [recovered]
        panic: runtime error: slice bounds out of range

It is throwing the panic on column/odbc:217.  If I test with "msdriver" option 
of "SQL Server" then I do not get the error.  Do you want me to try to look 
into it before I submit the code change for review again?  Do you know what 
might be causing it?


Luke

Original issue reported on code.google.com by [email protected] on 25 Apr 2013 at 1:04

pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.

What steps will reproduce the problem?
I don't know how to reproduce.

go-magica-web.go:148 (my file) is :
if err := db.QueryRow("select getdate()").Scan(&timeNow); err != nil {

What is the expected output? What do you see instead?

go-magica-web: pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion 
`mutex->__data.__owner == 0' failed.
SIGABRT: abort
PC=0xb775f424
signal arrived during cgo execution

runtime.cgocall(0x804b7e0, 0x86ffcc3c)
        /usr/local/go/src/pkg/runtime/cgocall.c:149 +0x10c fp=0x86ffcc30
code.google.com/p/odbc/api._Cfunc_SQLNumResultCols(0x827c0e38, 0x97374a20, 0x1)
        code.google.com/p/odbc/api/_obj/_cgo_defun.c:187 +0x31 fp=0x86ffcc3c
code.google.com/p/odbc/api.SQLNumResultCols(0x827c0e38, 0x97374a20, 0x0)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/api/zapi_unix.go:98 +0x30 fp=0x86ffcc4c
code.google.com/p/odbc.(*ODBCStmt).BindColumns(0x97428210, 0x88beb60, 0x0)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/odbcstmt.go:124 +0x42 fp=0x86ffcc90
code.google.com/p/odbc.(*Stmt).Query(0x97375fc0, 0x88beb60, 0x0, 0x0, 0x0, ...)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/stmt.go:91 +0x1dd fp=0x86ffccbc
database/sql.rowsiFromStatement(0xb72d3d38, 0x9734c6c0, 0xb72d3d10, 0x97375fc0, 
0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:1409 +0x1ea fp=0x86ffcd28
database/sql.(*DB).queryConn(0x9734c580, 0x9734c6c0, 0x973749d8, 0x83d2138, 
0x10, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:953 +0x30a fp=0x86ffcda4
database/sql.(*DB).query(0x9734c580, 0x83d2138, 0x10, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:913 +0xaa fp=0x86ffcdd8
database/sql.(*DB).Query(0x9734c580, 0x83d2138, 0x10, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:899 +0x6b fp=0x86ffce10
database/sql.(*DB).QueryRow(0x9734c580, 0x83d2138, 0x10, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:977 +0x50 fp=0x86ffce44
main.SqlNow(0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /opt/go/go-magica-web/go-magica-web.go:148 +0xd1 fp=0x86ffcea8
main.TickAtTime(0x97351800, 0x8440f18)
        /opt/go/go-magica-web/go-magica-web.go:177 +0x2b fp=0x86ffcfc4
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1394 fp=0x86ffcfc8
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2242 +0x80c

goroutine 1 [IO wait]:
net.runtime_pollWait(0xb72d4cf4, 0x72, 0x0)
        /usr/local/go/src/pkg/runtime/netpoll.goc:116 +0x5e
net.(*pollDesc).Wait(0x97351b78, 0x72, 0xb72d3878, 0xb)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:81 +0x32
net.(*pollDesc).WaitRead(0x97351b78, 0xb, 0xb72d3878)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).accept(0x97351b40, 0x844195c, 0x0, 0xb72d3878, 0xb)
        /usr/local/go/src/pkg/net/fd_unix.go:382 +0x227
net.(*TCPListener).AcceptTCP(0x9737ae30, 0x8098c83, 0x86fe8c44, 0x8098c83)
        /usr/local/go/src/pkg/net/tcpsock_posix.go:233 +0x41
net.(*TCPListener).Accept(0x9737ae30, 0xb72d5a70, 0x973874f0, 0x974558c0, 0x0)
        /usr/local/go/src/pkg/net/tcpsock_posix.go:243 +0x28
net/http.(*Server).Serve(0x97353f30, 0xb72d4ed8, 0x9737ae30, 0x0, 0x0)
        /usr/local/go/src/pkg/net/http/server.go:1622 +0x75
net/http.(*Server).ListenAndServe(0x97353f30, 0x97353f30, 0xb72d4e88)
        /usr/local/go/src/pkg/net/http/server.go:1612 +0x83
net/http.ListenAndServe(0x9737ae08, 0x5, 0xb72d4e88, 0x97353db0, 0x1, ...)
        /usr/local/go/src/pkg/net/http/server.go:1677 +0x5f
main.main()
        /opt/go/go-magica-web/go-magica-web.go:2321 +0x12b5

goroutine 3 [syscall]:
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1394

goroutine 4 [chan receive]:
github.com/cupcake/raven-go.(*Client).worker(0x972f5960)
        /opt/go/go-magica-web/GOPATH/src/github.com/cupcake/raven-go/client.go:265 +0x3b
created by github.com/cupcake/raven-go.NewClient
        /opt/go/go-magica-web/GOPATH/src/github.com/cupcake/raven-go/client.go:202 +0xc7

goroutine 5 [chan receive]:
main.func·004()
        /opt/go/go-magica-web/go-magica-web.go:2226 +0x3d
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2231 +0x6c0

goroutine 9 [sleep]:
time.Sleep(0x3d431c00, 0x4e92)
        /usr/local/go/src/pkg/runtime/time.goc:31 +0x39
main.TickAtTime(0x97351840, 0x8440f1c)
        /opt/go/go-magica-web/go-magica-web.go:209 +0x529
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2246 +0x868

goroutine 10 [runnable]:
code.google.com/p/odbc/api._Cfunc_SQLNumResultCols(0x825cd8f0, 0x974423e0, 0x0)
        code.google.com/p/odbc/api/_obj/_cgo_defun.c:187 +0x31
code.google.com/p/odbc/api.SQLNumResultCols(0x825cd8f0, 0x974423e0, 0x9741da60)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/api/zapi_unix.go:98 +0x30
code.google.com/p/odbc.(*ODBCStmt).BindColumns(0x974283f0, 0x97374b38, 0x1)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/odbcstmt.go:124 +0x42
code.google.com/p/odbc.(*Stmt).Query(0x97375160, 0x97374b38, 0x1, 0x1, 0x0, ...)
        /opt/go/go-magica-web/GOPATH/src/code.google.com/p/odbc/stmt.go:91 +0x1dd
database/sql.rowsiFromStatement(0xb72d3d38, 0x9734c740, 0xb72d3d10, 0x97375160, 
0x86ff8e48, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:1409 +0x1ea
database/sql.(*DB).queryConn(0x9734c640, 0x9734c740, 0x97374b18, 0x846c7c8, 
0x14e, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:953 +0x30a
database/sql.(*DB).query(0x9734c640, 0x846c7c8, 0x14e, 0x86ff8e48, 0x1, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:913 +0xaa
database/sql.(*DB).Query(0x9734c640, 0x846c7c8, 0x14e, 0x86ff8e48, 0x1, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:899 +0x6b
main.SuivisV2(0x0, 0x0, 0x0, 0x0)
        /opt/go/go-magica-web/go-magica-web.go:1857 +0x521
main.RefreshSuivisHourly2(0x97353750)
        /opt/go/go-magica-web/go-magica-web.go:237 +0x4e
main.func·007()
        /opt/go/go-magica-web/go-magica-web.go:2253 +0xea
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2259 +0x8a0

goroutine 11 [syscall]:
github.com/alecthomas/gozmq._C2func_zmq_recvmsg(0x88f3f90, 0x97451680, 0x0, 
0x0, 0x9a, ...)
        github.com/alecthomas/gozmq/_obj/_cgo_defun.c:363 +0x31
github.com/alecthomas/gozmq.(*Socket).Recv(0x972c7398, 0x0, 0x0, 0x0, 0x0, ...)
        /opt/go/go-magica-web/GOPATH/src/github.com/alecthomas/gozmq/zmq_3_x.go:191 +0xdf
main.func·008()
        /opt/go/go-magica-web/go-magica-web.go:2265 +0x36
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2269 +0x8ca

goroutine 13 [IO wait]:
net.runtime_pollWait(0xb72d4d60, 0x72, 0x0)
        /usr/local/go/src/pkg/runtime/netpoll.goc:116 +0x5e
net.(*pollDesc).Wait(0x97351938, 0x72, 0xb72d3878, 0xb)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:81 +0x32
net.(*pollDesc).WaitRead(0x97351938, 0xb, 0xb72d3878)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).Read(0x97351900, 0x9740a400, 0x400, 0x400, 0x0, ...)
        /usr/local/go/src/pkg/net/fd_unix.go:204 +0x231
net.(*conn).Read(0x9737ad38, 0x9740a400, 0x400, 0x400, 0x0, ...)
        /usr/local/go/src/pkg/net/net.go:122 +0xa8
main.ListenC(0x9737ad38, 0x97353750)
        /opt/go/go-magica-web/go-magica-web.go:1582 +0x82
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2286 +0xae7

goroutine 14 [select]:
main.(*hub).run(0x88b9530)
        /opt/go/go-magica-web/hub.go:28 +0x1b8
created by main.main
        /opt/go/go-magica-web/go-magica-web.go:2295 +0xbbf

goroutine 2759 [chan receive]:
database/sql.(*DB).connectionOpener(0x9734c640)
        /usr/local/go/src/pkg/database/sql/sql.go:574 +0x3b
created by database/sql.Open
        /usr/local/go/src/pkg/database/sql/sql.go:436 +0x1c7

goroutine 2758 [chan receive]:
database/sql.(*DB).connectionOpener(0x9734c580)
        /usr/local/go/src/pkg/database/sql/sql.go:574 +0x3b
created by database/sql.Open
        /usr/local/go/src/pkg/database/sql/sql.go:436 +0x1c7

goroutine 895 [select]:
github.com/fzzy/sockjs-go/sockjs.(*legacySession).backend(0x972d4c80)
        /opt/go/go-magica-web/GOPATH/src/github.com/fzzy/sockjs-go/sockjs/session.go:141 +0x24e
created by github.com/fzzy/sockjs-go/sockjs.(*legacySession).init
        /opt/go/go-magica-web/GOPATH/src/github.com/fzzy/sockjs-go/sockjs/session.go:133 +0x153

eax     0x0
ebx     0x6d4c
ecx     0x57bd
edx     0x6
edi     0xb766cff4
esi     0x0
ebp     0x57bd
esp     0x814fce54
eip     0xb775f424
eflags  0x202
cs      0x73
fs      0x0
gs      0x33



What version of the product are you using? On what operating system?
go version go1.2 linux/386
Ubuntu 12.04.4 LTS (32-bits)

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Feb 2014 at 4:18

Datetime field overflow

What steps will reproduce the problem?
1.go test -mssrv=SERVERNAME.COM -msdb=DATABASENAME -msuser=USERNAME 
-mspass=YOURPASSWORD -v -run=MS -msdriver="ODBC Driver 11 for SQL Server"

What is the expected output? What do you see instead?
=== RUN TestMSSQLDatetime2Param
--- FAIL: TestMSSQLDatetime2Param (0.43 seconds)
        mssql_test.go:1007: SQLExecute: {22008} [Microsoft][ODBC Driver 11 for SQL Server]Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding.


What version of the product are you using? On what operating system?
Ubuntu 12.04
Windows 7 + SQL Server 2012


Please provide any additional information below.
param.go 114
            // represented as yyyy-mm-dd hh:mm:ss.fff format in ms sql server
            if d.Nanosecond() % 1000000 > 0 {
                decimal = 7
            } else {
                decimal = 3
            }


Original issue reported on code.google.com by [email protected] on 22 Jan 2014 at 5:41

Tests fail due to not-null columns 'canBeNull' and 'data'

What steps will reproduce the problem?
1. go test -run TestMSSQLCreateInsertDelete

What do you see instead?
mssql_test.go:163: SQLExecute: {23000} [FreeTDS][SQL Server]Cannot insert the 
value NULL into column 'canBeNull', table 'gonuts.dbo.temp'; column does not 
allow nulls. INSERT fails.

What version of the product are you using? On what operating system?
Server: MS-SQL 2008
Client: Linux (64-bit), unixodbc, freetds

Please provide any additional information below.
Changing the 'create table' line (mssql_test.go:148) to include explicit 
nullability seems to fix it:
WAS:
exec(t, db, "create table dbo.temp (name varchar(20), age int, isGirl bit, 
weight decimal(5,2), dob datetime, data varbinary(10), canBeNull varchar(10))")

IS NOW:
exec(t, db, "create table dbo.temp (name varchar(20), age int, isGirl bit, 
weight decimal(5,2), dob datetime, data varbinary(10) null, canBeNull 
varchar(10) null)")

Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 5:08

Datetime field overflow with sql server 2008


SQLExecute: {22008} [Microsoft][SQL Server Native Client 11.0]Datetime 
字段溢出。秒的小数精度超出了在参数绑定中指定的小数位��
�。

PATCH:
--- a/param.go  Fri Nov 15 09:34:59 2013 +1100
+++ b/param.go  Tue Dec 10 15:34:00 2013 +0800
@@ -102,7 +102,7 @@
                        Hour:     api.SQLUSMALLINT(d.Hour()),
                        Minute:   api.SQLUSMALLINT(d.Minute()),
                        Second:   api.SQLUSMALLINT(d.Second()),
-                       Fraction: api.SQLUINTEGER(d.Nanosecond()),
+                       Fraction: 0,
                }
                p.Data = &b
                buf = unsafe.Pointer(&b)
@@ -113,7 +113,9 @@
                if decimal <= 0 {
                        // represented as yyyy-mm-dd hh:mm:ss.fff format in ms sql server
                        decimal = 3
+                       b.Fraction = api.SQLUINTEGER(d.Nanosecond() / 
int(time.Millisecond))
                }
                size = 20 + api.SQLULEN(decimal)
        case []byte:


Original issue reported on code.google.com by [email protected] on 10 Dec 2013 at 7:38

go get code.google.com/p/odbc/ Fails in Darwin

When I attempt to get get this library I get:

[kbrandt@glade: ~/src/go/src] go get code.google.com/p/odbc/
# code.google.com/p/odbc/api
code.google.com/p/odbc/api/api.go:13: undefined: SQLSMALLINT
code.google.com/p/odbc/api/api.go:14: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:15: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:19: undefined: SQLSMALLINT
code.google.com/p/odbc/api/api.go:20: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:21: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:22: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:23: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:24: undefined: SQLUSMALLINT
code.google.com/p/odbc/api/api.go:25: undefined: SQLUINTEGER
code.google.com/p/odbc/api/api.go:25: too many errors

Original issue reported on code.google.com by [email protected] on 3 Aug 2013 at 1:41

Datetimes from SQL Server read as time.local regardless of timezone used by Database

When reading from SQL Server Datetime columns the date is always returned as a 
local time, when the database server stores all data in UTC (or some other 
timezone) this is a problem because read dates then have to be reconstructed to 
set the database timezone.

I think this can be traced to the column reading where time.Local is fed to the 
time.Date constructor. e.g.

        case api.SQL_C_TYPE_TIMESTAMP:
                t := (*api.SQL_TIMESTAMP_STRUCT)(p)
                r := time.Date(int(t.Year), time.Month(t.Month), int(t.Day),
                        int(t.Hour), int(t.Minute), int(t.Second), int(t.Fraction),
                        time.Local)


Original issue reported on code.google.com by [email protected] on 1 Apr 2014 at 6:18

odbc SQLExecute: {HY090} errors

run sql exec, occurs SQLExecute: {HY090}  errors

1) when insert column data' length less than 8000bytes, OK, Otherwise occurs 
SQLExecute: {HY090}  errors
2) the field type is image

see more information at: 
https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/8uz8k9xzJ0k


The bug should be here:

https://code.google.com/p/odbc/source/browse/param.go#117

                ctype = api.SQL_C_BINARY
                b := make([]byte, len(d))
                copy(b, d)
                p.Data = b
                buf = unsafe.Pointer(&b[0])
                buflen = api.SQLLEN(len(b))
                plen = p.StoreStrLen_or_IndPtr(buflen)
                size = api.SQLULEN(len(b))
                sqltype = api.SQL_BINARY


Binding Parameters for SQL Character Types [1]
If the SQL data type passed in is a character type, ColumnSize is the size in 
characters (not bytes). If the length of the data string in bytes is greater 
than 8000,ColumnSize should be set to SQL_SS_LENGTH_UNLIMITED, indicating that 
there is no limit to the size of the SQL type.
For instance, if the SQL data type is SQL_WVARCHAR, ColumnSize should not be 
greater than 4000. If the actual data length is greater than 4000, then 
ColumnSizeshould be set to SQL_SS_LENGTH_UNLIMITED so that nvarchar(max) will 
be used by driver.
[1]: http://msdn.microsoft.com/en-us/library/ms131462.aspx


change the code as the following:

        ctype = api.SQL_C_BINARY
        b := make([]byte, len(d))
        copy(b, d)
        p.Data = b
        buf = unsafe.Pointer(&b[0])
        buflen = api.SQLLEN(len(b))
        plen = p.StoreStrLen_or_IndPtr(buflen)
        if len(b) < 8000 {
            size = api.SQLULEN(len(b))
            sqltype = api.SQL_BINARY
        } else {
            size = api.SQLULEN(0)   // SQL_SS_LENGTH_UNLIMITED
            sqltype = api.SQL_VARBINARY
        }

all passed! :)


Original issue reported on code.google.com by [email protected] on 25 Mar 2014 at 2:41

failure with vertica driver

From user report 
https://community.vertica.com/vertica/topics/syntax_error_at_or_near_at_end_of_t
he_query :

I'm trying to use vertica with Golang over ODBC. I can connect OK and am 
getting an error of "Syntax error at or near "\" at character 31"  for the 
query "select * from public.value_ref" - character 31 would be after the last 
letter of the table. No variations to the query have resolved error. This does 
work through JDBC and isql over ODBC with this same DSN.

Also https://groups.google.com/d/msg/golang-nuts/ysqaztTjQaA/Tcfk9f84qCQJ

Alex

Original issue reported on code.google.com by [email protected] on 4 Aug 2014 at 12:30

large string value test failed

What steps will reproduce the problem?
1.go test -mssrv=SERVERNAME.COM -msdb=DATABASENAME -msuser=USERNAME 
-mspass=YOURPASSWORD -v -run=MS -msdriver="ODBC Driver 11 for SQL Server"

What is the expected output? What do you see instead?
=== RUN TestMSSQLTextColumnParamTypes
--- FAIL: TestMSSQLTextColumnParamTypes (0.06 seconds)
        mssql_test.go:1162: large string value test failed: SQLExecute: {07002} [Microsoft][ODBC Driver 11 for SQL Server]COUNT field incorrect or syntax error

What version of the product are you using? On what operating system?
Ubuntu 12.04
Windows Server 2003 R2 + SQL Server 2005

Please provide any additional information below.
param.go 70
        } else if size > 4000 {
            sqltype = api.SQL_WLONGVARCHAR


Original issue reported on code.google.com by [email protected] on 21 Jan 2014 at 10:30

Empty string is converted to NULL

Access sqlserver database through odbc, a table with non-null string field, 
when the field's value is empty string, it will return null when retrieve it's 
value.

It is caused by line 134 of file "column.go". When enter BaseColumn.Value, it 
should not be null, because line 232 of file "column.go" filter out null 
situation.

Modify line 134 of file "column.go" to 'return "", nil' can solve this problem.

Original issue reported on code.google.com by [email protected] on 27 Apr 2014 at 2:54

  • Merged into: #40

empty string in MSSQL NVARCHAR column cause func (r *Row) Scan() to fail

What steps will reproduce the problem?
1. append the attached go code to code.google.com\p\odbc\mssql_test.go
2. run go test


What is the expected output? What do you see instead?

 expect the test to pass, but got the following:

 mssql_test.go:1254: sql: Scan error on column index 0: unsupported driver -> Scan pair: <nil> -> *string


What version of the product are you using? On what operating system?
go version go1.2 windows/amd64
sql server version:
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)   Apr  2 2010 15:48:46  
 Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 
6.1 <X64> (Build 7601: Service Pack 1) 


Please provide any additional information below.

1) the issue exists when column type is NVARCHAR. it works fine when column 
type is VARCHAR
2) inside MSSQL, go string "" is stored as SQL server  '' , so it should be 
able to be read back as string
3) for MS SQL, varchar empty string '' is the same as nvarchar empty string 
N''. this can be proved as SQL below:
select case when ''=N'' then 'equal' else 'not equal' end

4) this issue is critical as NVARCHAR is way more widely used than VARCHAR due 
to VARCHAR does not support unicode well.

your reply is greatly appreciated

Jusong Chen


Original issue reported on code.google.com by [email protected] on 8 May 2014 at 10:26

Attachments:

mssql: weird errors when inserting data

I'm using similar code with multiple databases to test insert speed with 
different styles and today I tried odbc. See 
http://play.golang.org/p/dDXXXHmbt5.

For some reason I sometimes see very strange errors with odbc, e.g.:

i=36127: SQLExecute: {23000} [Microsoft][ODBC SQL Server Driver][SQL 
Server]Violation of PRIMARY KEY constraint 'PK__data__3213E83FE4DDA2C7'. Cannot 
insert duplicate key in object 'dbo.data'. The duplicate key value is (36202).
{01000} [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been 
terminated.

i=60976: SQLExecute: {23000} [Microsoft][ODBC SQL Server Driver][SQL 
Server]Violation of PRIMARY KEY constraint 'PK__data__3213E83FE4DDA2C7'. Cannot 
insert duplicate key in object 'dbo.data'. The duplicate key value is (1).
{01000} [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been 
terminated.

Notice that the value sql server complains does not match the value my program 
is using. Another common error is:

i=28339: SQLExecute: {22003} [Microsoft][SQL Server Native Client 11.0]Numeric 
value out of range

i=36229: SQLExecute: {22003} [Microsoft][ODBC SQL Server 
Driver]Числовое значение выходит за пределы 
допустимого диапазона

Russian text also means "The number value is out of range". It seems like maybe 
there's a race in odbc somewhere? Looks almost like underlying ODBC statements 
are sometimes used from another goroutine entirely...

Original issue reported on code.google.com by [email protected] on 26 Apr 2013 at 4:47

Error on SQL Server 2008 and datetime2

What steps will reproduce the problem?
Connect to a SQL Server 2008 database and perform an insert on a table that has 
a column defined as datetime2(0) using a bind parameter.


What is the expected output? What do you see instead?
Expected - The insert will work
Actual - SQL Execute error 22008 - Datetime field overflow.  Fractional second 
precision exceeds the scale specified in the parameter binding.

What version of the product are you using? On what operating system?
Go 1.1.2 X64 on Windows X64.

Please provide any additional information below.
I modified param.go to always set the value of decimal in the call to 
api.SQLBindParameter to 7 and that seems to resolve the problem.  I would like 
to get the value of supported fractional seconds from the call to 
api.SQLDescribeParam but I don't know if SQLDescribeParam returns that 
information.  If you want, I can submit change request with the fix.


Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 5:05

Panic on VARCHAR column

What steps will reproduce the problem?
1. Add the test case below to the typeTests unit tests
    {"select cast('' as varchar(5))", match("")},

What is the expected output? What do you see instead?
Fails with a panic on this line in func(c *BaseColumn) Value
p := unsafe.Pointer(&buf[0])

In this case, the varchar column's type is length 5 but the actual length of 
the returned data is 0.  The code in the Value() method attempts to get the 
first element of an array that has a length of 0 which causes a panic.

I think the solution is to only initialize p if the length of buf is greater 
than 0.

Original issue reported on code.google.com by [email protected] on 1 May 2013 at 3:54

in windows 8 on not working properly

in windows8 on not working properly, any insert, delete, execute stored 
procedures without any reaction, there is no change data in the database, but I 
did not see any error messages and prompts.


Original issue reported on code.google.com by [email protected] on 13 Jun 2014 at 2:08

unsupported driver -> Scan pair: <nil> -> *string

when select columns from database, if some column's value is '', it will 
occurred error: unsupported driver -> Scan pair: <nil> -> *string,
so I changed the source at: column.go, line 134:
case api.SQL_C_WCHAR:
        if p == nil {
            //return nil, nil
            return "", nil
        }
        s := (*[1 << 20]uint16)(p)[:len(buf)/2]
        return utf16toutf8(s), nil

Original issue reported on code.google.com by [email protected] on 11 Apr 2014 at 3:30

Implementing SQLDataSources and SQLDrivers

To better help and inform the users of our tools it would be nice to be able to 
list the available data sources and see if they use the correct drivers.

This could be done by adding the following two functions to the api:
- SQLDataSources ( 
http://msdn.microsoft.com/en-us/library/ms711004(v=vs.85).aspx )
- SQLDrivers ( http://msdn.microsoft.com/en-us/library/ms712400(v=vs.85).aspx )

I was thinking of adding two package level functions, e.g. odbc.DataSources() 
and odbc.Drivers() (maybe I should use a different name for the latter so it 
won't be confused with sql.Driver?).

Would you be interested in accepting a patch for this feature?

Original issue reported on code.google.com by [email protected] on 6 Aug 2014 at 12:48

empty 'SQLExecute' error

What steps will reproduce the problem?
edit file.go with:

package main

import (
    _ "code.google.com/p/odbc"
    "database/sql"
    "runtime"
)

func mssqlConnect() (db *sql.DB, err error) {
    params := map[string]string{
        "driver":   "freetds",
        "server":   "host",
        "port":     "port",
        "database": "database",
        "uid":      "uid",
        "pwd":      "pwd",
    }
    if runtime.GOOS == "windows" {
        params["driver"] = "sql server"
    }

    var c string
    for n, v := range params {
        c += n + "=" + v + ";"
    }
    db, err = sql.Open("odbc", c)
    if err != nil {
        return nil, err
    }
    return db, nil
}

func main() {
    db, err := mssqlConnect()
    if err != nil {
        panic(err.Error())
    }
    defer db.Close()

    columnName := "DOCUM"

    _, errQuery := db.Query(`SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name = ?
ORDER BY schema_name, table_name;`, columnName)
    if errQuery != nil {
        panic(errQuery.Error())
    }
}

run:
go run file.go

What is the expected output? What do you see instead?
The program should exit without any output but I see the following instead. I 
only see "SQLExecute:" without any details.

panic: SQLExecute:

goroutine 1 [running]:
main.main()
        /home/bbigras/debug-odbc/test.go:50 +0x14b

goroutine 2 [syscall]:
exit status 2

What version of the product are you using? On what operating system?
go version go1.1.2 linux/386
freetds 0.82-6build1
tdsodbc 0.82-6build1
unixodbc 2.2.11-21
Ubuntu 10.04.4 LTS

Please provide any additional information below.
I only have this problem on Linux. It's fine on Windows 7 (64-bits).

Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 8:41

MSSQL datetime insert through code.google.com/p/odbc

What steps will reproduce the problem?
1. Create table in MSSQL with datetime column (e.g. dt1)
2. Try insert into that table value of time.Time type
3. Get error:
SQLExecute: {22008} [Microsoft][SQL Server Native Client 11.0]Datetime field 
overflow. Fractional second precision exceeds the scale specified in the 
parameter binding.

Windows 7 version 6.1 running on x86; Cp1251; ru_RU (goworks)
go 1.2 windows/386

var ctime time.Time
ctime = time.Now()
res, err := DB.Exec(`INSERT INTO tmp_table (dt1) VALUES (?)`, ctime)
->> SQLExecute: {22008} [Microsoft][SQL Server Native Client 11.0]Datetime 
field overflow. Fractional second precision exceeds the scale specified in the 
parameter binding.

Original issue reported on code.google.com by [email protected] on 20 Mar 2014 at 10:08

Error handling and api.SQL_NO_DATA

With a firebird database on windows 7 64bit (not mysql), I get an error in the 
"func (s *ODBCStmt) Exec(args []driver.Value)" if I execute an update or delete 
statement that did not affect any rows:

DELETE FROM myTable WHERE myCol = 'doesntExist';

This is because the function "IsError()" only checks for api.SQL_SUCCESS and 
api.SQL_SUCCESS_WITH_INFO). According to 

http://msdn.microsoft.com/de-de/library/windows/desktop/ms715424%28v=vs.85%29.as
px

the correct return value for the above statement is SQL_NO_DATA, so I think 
firebird is treating this properly.

Would it make sense to modify the function IsError()?

func IsError(ret api.SQLRETURN) bool {
 return !(ret == api.SQL_SUCCESS || ret == api.SQL_SUCCESS_WITH_INFO || ret == api.SQL_NO_DATA)
} 

Or in the Exec-function:

//...
ret := api.SQLExecute(s.h)
if IsError(ret) && ret != api.SQL_NO_DATA {
 return NewError("SQLExecute", s.h)
}

I don't know if this would have any side effects, but both fixes the issue for 
me. I know you don't have firebird installed, but maybe this is a general issue.

Michael

Original issue reported on code.google.com by [email protected] on 5 Jul 2013 at 10:08

SQLDescribeParam: {07009} [Microsoft][ODBC SQL Server Driver]Invalid parameter number

What steps will reproduce the problem?
1. go run test.go -mssrv=W -msdb=X -msuser=Y -mspass=Z
2. fails on line:
stmUpsertUser, err = db.Prepare("EXEC [dbo].[test_test] ?")

What do you see instead?
panic: SQLDescribeParam: {07009} [Microsoft][ODBC SQL Server Driver]Invalid 
parameter number

Windows 7 x64, SQL Server 2008 & 2012, Go 1.2

Original issue reported on code.google.com by [email protected] on 20 Jan 2014 at 1:31

Attachments:

Implement SQLExecDirect

I see in odbcstmt.go you have a comment about using SQLExecDirect.  Now with 
the optional Queryer interface: 
http://tip.golang.org/pkg/database/sql/driver/#Queryer 
I think it would make sense to implement Queryer using SQLExecDirect.  Do you 
have any thoughts on this implementation?

Original issue reported on code.google.com by [email protected] on 27 Apr 2013 at 6:41

SQLDescribeParam: {07009} [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index

I have an "Invalid Descriptor Index" error when I do the query in the attached 
testcase patch.

What steps will reproduce the problem?

D:\rapport\GOPATH\src\code.google.com\p\odbc>go test -v -mssrv=ip -msdb=db 
-msuser=user -mspass=pw -run=MS
=== RUN TestMSSQLCreateInsertDelete
--- PASS: TestMSSQLCreateInsertDelete (0.14 seconds)
=== RUN TestMSSQLTransactions
--- PASS: TestMSSQLTransactions (0.12 seconds)
=== RUN TestMSSQLTypes
--- PASS: TestMSSQLTypes (0.03 seconds)
=== RUN TestMSSQLIntAfterText
--- PASS: TestMSSQLIntAfterText (0.00 seconds)
=== RUN TestMSSQLStmtAndRows
--- PASS: TestMSSQLStmtAndRows (0.03 seconds)
=== RUN TestMSSQLIssue5
--- PASS: TestMSSQLIssue5 (0.27 seconds)
=== RUN TestMSSQLDeleteNonExistent
--- PASS: TestMSSQLDeleteNonExistent (0.02 seconds)
=== RUN TestMSSQLSelectInt
--- FAIL: TestMSSQLSelectInt (0.00 seconds)
        mssql_test.go:886: SQLDescribeParam: {07009} [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
                {42000} [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
FAIL
exit status 1
FAIL    code.google.com/p/odbc  0.969s

What version of the product are you using? On what operating system?
Windows XP and 7 (64-bits)

Please provide any additional information below.
It works fine on Linux.
Microsoft SQL Server 2005 (9.0.3042)
go version go1.1.2 windows/386

The test passes if I do :
if err := db.QueryRow("select 123456;").Scan(&got); err != nil {

Original issue reported on code.google.com by [email protected] on 29 Aug 2013 at 6:40

Attachments:

Querying XML columns from MS SQL server via FreeTDS consumes too much memory.

What steps will reproduce the problem?
1. Create an XML column in an MS SQL server database.
2. Query the column.

What is the expected output? What do you see instead?

It should work with out allocating GBs from the heap. Instead it allocates a 
2GB []byte in NewBindableColumn

What version of the product are you using? On what operating system?

See below.

Please provide any additional information below.

Here is a stack trace copied from /debug/pprof/heap?debug=1 from my application 
shortly before it crashed with an out of memory error.

1: 2147483648 [1: 2147483648] @ 0x42a4d5 0x429fb8 0x42b701 0x42b78a 0x42ecbd 
0x42ebf3 0x4d23a5 0x4d24d4 0x4d1248 0x4d579e 0x4d7a05 0x43fff7 0x43caf5 
0x43c655 0x43c4ad 0x43ce27 0x4af37a 0x402b2c 0x4cf9ea 0x4cf047 0x4024c2 
0x4174da 0x419ca0
#   0x42a4d5    profilealloc+0xb5                       /usr/local/go/src/pkg/runtime/malloc.goc:258
#   0x429fb8    runtime.mallocgc+0x218                      /usr/local/go/src/pkg/runtime/malloc.goc:
197
#   0x42b701    cnew+0xc1                           /usr/local/go/src/pkg/runtime/malloc.goc:836
#   0x42b78a    runtime.cnewarray+0x3a                      /usr/local/go/src/pkg/runtime/malloc.goc:
849
#   0x42ecbd    makeslice1+0x4d                         /usr/local/go/src/pkg/runtime/slice.goc:55
#   0x42ebf3    runtime.makeslice+0xb3                      /usr/local/go/src/pkg/runtime/slice.goc:3
6
#   0x4d23a5    code.google.com/p/odbc.NewBindableColumn+0xd5           /home/chines/go/src/c
ode.google.com/p/odbc/column.go:189
#   0x4d24d4    code.google.com/p/odbc.NewVariableWidthColumn+0xf4      /home/chines/go/s
rc/code.google.com/p/odbc/column.go:211
#   0x4d1248    code.google.com/p/odbc.NewColumn+0x958              /home/chines/go/src/code.go
ogle.com/p/odbc/column.go:89
#   0x4d579e    code.google.com/p/odbc.(*ODBCStmt).BindColumns+0x22e        /home/chines/go
/src/code.google.com/p/odbc/odbcstmt.go:134
#   0x4d7a05    code.google.com/p/odbc.(*Stmt).Query+0x2e5          /home/chines/go/src/code
.google.com/p/odbc/stmt.go:91
#   0x43fff7    database/sql.rowsiFromStatement+0x317               /usr/local/go/src/pkg/databa
se/sql/sql.go:1439
#   0x43caf5    database/sql.(*DB).queryConn+0x465              /usr/local/go/src/pkg/database/
sql/sql.go:969
#   0x43c655    database/sql.(*DB).query+0x105                  /usr/local/go/src/pkg/database/sql
/sql.go:929
#   0x43c4ad    database/sql.(*DB).Query+0xad                   /usr/local/go/src/pkg/database/sql/
sql.go:915
#   0x43ce27    database/sql.(*DB).QueryRow+0x67                /usr/local/go/src/pkg/database/sq
l/sql.go:993
# <snip>

Also, I added this line at the top of NewVariableWidthColumn():
    fmt.Printf("col: %+v  type: %v  width: %v  stack: %v\n", b, ctype, colWidth, stack.Callers())

and it printed this for an XML column on Linux with FreeTDS v0.91:
        col: &{name:INFOXML CType:0}  type: 1  width: 2147483647

but it printed this for the same column on a Windows machine with MS drivers:
        col: &{name:INFOXML CType:0}  type: -8  width: 0

Finally this appears to be a known issue in FreeTDS and I can't find any 
evidence that it's been fixed: 
http://lists.ibiblio.org/pipermail/freetds/2012q3/028050.html

Is there anything that can or should be done to handle this better at the Go 
layer? Do you have any suggested work arounds?

Original issue reported on code.google.com by [email protected] on 17 Oct 2014 at 4:11

MSSQL tests fail when connecting to modern MSSQL Server

More details here:

http://stackoverflow.com/a/19904973/385979

FreeTDS apparently defaults to an old version of the TDS protocol. It might be 
good to add a "TDS_Version" command line parameter to the mssql_test.go since 
the cryptic error message doesn't explain what is wrong with the connection.

For a short-term fix the attached patch seems to fix the problem by letting the 
server decide the protocol version.


Original issue reported on code.google.com by [email protected] on 28 Mar 2014 at 1:24

Attachments:

Can't go get on Mavericks (OS X 10.9)

On OS X 10.9 with xcode 5.0.2 I get the following when trying to go get:

[kbrandt@glade: ~/src/go] go get code.google.com/p/odbc
# code.google.com/p/odbc/api
src/code.google.com/p/odbc/api/api_unix.go:11:11: fatal error: 'sql.h' file not 
found
 #include <sql.h>
          ^
1 error generated.

According to this link Mavericks dropped the sql headers: 
http://stackoverflow.com/questions/20074620/installing-pyodbc-fails-on-osx-10-9-
mavericks 

Original issue reported on code.google.com by [email protected] on 22 Jan 2014 at 8:33

SQL0104 - Message can not be translated successfully.

What steps will reproduce the problem?
1.Execute query on Windows 7 64-bit, Go version 1.3.1 64-bit

2.Sample program:
package main

import (
    _ "code.google.com/p/odbc"
    "database/sql"
    "fmt"
    "log"
)

func main() {
    db, err := sql.Open("odbc", `
        Driver=iSeries Access ODBC Driver;
        System=myhost;
        Uid=myuser;
        Pwd=mypass;`)
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    rows, err := db.Query("SELECT 1 FROM sysibm.sysdummy1")
    if err != nil {
        log.Fatal(err)  // Fails here
    }

    var number int
    for rows.Next() {
        rows.Scan(&number)
    }
    fmt.Println(number)
}


What is the expected output? What do you see instead?
Expected to print 1, instead prints:
2014/09/09 13:12:39 SQLPrepare: {42000} [IBM][System i Access ODBC Driver][DB2 
for i5/OS]SQL0104 - Error message text unavailable.
Message can not be translated successfully.

What version of the product are you using? On what operating system?
Go version 1.3.1, Windows 7 64-bit, odbc library from 8/15/14

Please provide any additional information below.
The exact code works well on Linux (Ubuntu Go version 1.2.1).  Similar code 
using Python/pyodbc works on Windows machine.  I was testing this a while back 
for writing services and I could have sworn it worked on Windows in some early 
testing, that would have been a couple versions of Go earlier.  I opened a 
stack overflow question but after finding that it indeed does work with this 
exact code on Linux have decided it must be an issue I should post here.

Original issue reported on code.google.com by [email protected] on 9 Sep 2014 at 8:28

fatal error: malloc/free - deadlock under high concurrency using same DB handle

What steps will reproduce the problem?
1. Create a single sql.DB handle (db) with sql.Open("odbc", connectionString) 
using the odbc driver
2. Call db.SetMaxIdleConns(0) on the DB handle to disable pooling idle 
connections
3. Spawn a bunch of goroutines querying the DB (with db.Query(someSelectQuery)) 
using the DB handle
4. Observe that eventually the following error is thrown and program is exited
fatal error: malloc/free - deadlock
[signal 0xc0000005 code=0x1 addr=0x2f0 pc=0x41c298]

What is the expected output? What do you see instead?
No deadlocks should happen under high load.

What version of the product are you using? On what operating system?
Go1.1.1 x86 on Windows XP (32-bit)
Remote SQL Server 2000 on Windows Server 2003

Please provide any additional information below.
If I increase the idle pooling size using db.SetMaxIdleConns() to a higher 
number, the program can handle higher number of concurrent users without 
crashing.

Pooling Size, Concurrent User, Crash Time
0, ~18 reqs/s, within 1 minute
50, ~18 reqs/s, can not observe the issue with 10+ hours of runtime

Stack traces attached, all the instance of errors are happening on the call 
stack of code.google.com/p/odbc.(*Stmt).Close() inside 
database/sql.(*DB).queryConn()

Original issue reported on code.google.com by [email protected] on 18 Jul 2013 at 4:23

Attachments:

'invalid UTF-8 in string' with mssql using latin1

I tried to set 'clientcharset' to 'latin1' or 'iso-8859-1' but I have 'invalid 
UTF-8 in string'.

Is your module able to decode the data on the fly like 
github.com/go-sql-driver/mysql does?

What version of the product are you using? On what operating system?
go version go1.1.2 windows/amd64
mssql 2005

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 8:49

SQLDescribeParam Errors

What steps will reproduce the problem?
1. Execute a merge statement like the following on Windows using SQL Server 
2008:
merge tblName
using (select ? as Id, ? as Name) as source
ON tblName.Id = source.Id
WHEN MATCHED THEN
update tblName.Name = source.Name
WHEN NOT MATCHED BY TARGET THEN
insert (name) into tblName(source.Name);

What is the expected output? What do you see instead?
Expected - the SQL statement execute correctly
Actual - DIAG [07009] [Microsoft][SQL Server Native Client 11.0]Invalid 
Descriptor Index (0) 

In this case, the call to SQLNumParams correctly returns 2 but it appears that 
SQLDescribeParam does not work to describe all parameters.  See 
http://msdn.microsoft.com/en-us/library/ms709448.aspx

If I make a change to ExtractParameters to ignore errors returned by 
SQLDescribeParam then the merge statement works correctly.  I think this 
work-around should work because SQLDescribeParam is not even implemented by 
freedts.

Original issue reported on code.google.com by [email protected] on 28 Aug 2013 at 3:32

Encoding of Germanic umlauts with Firebird DB

I dont't know if this is a general issue, but if I connect my go app via ODBC 
to a Firebird database and try to marshal the selected output, I get the error 
'json: invalid UTF-8 in string:' if the string contains a Germanic umlaut (e.g. 
ä, ü, ö, ß). The character set of the connection doesn't matter ('None' and 
'UTF8').

I'm using a Firebird 2.5 64bit server (SuperClassic) with ODBC driver version 
2.0.0.01.152 on Windows 7 64bit.

The following works for me. As desciped on Stackoverflow 
(http://stackoverflow.com/questions/13510458/golang-convert-iso8859-1-to-utf8), 
I have to convert the variable 'buf' in line 116 of column.go to UTF-8.

As mentioned before, I dont't know if it's only my problem. If not, maybe this 
will help others.

Original issue reported on code.google.com by [email protected] on 17 Jun 2013 at 10:04

Error on NVARCHAR columns

To duplicate add the following test in []typeTest:

{"select cast('' as nvarchar(5))", match("")}

The stack trace should be:
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x432ba8]

goroutine 3 [running]:
testing.func┬╖004()
        E:/Go/GoTip/src/pkg/testing/testing.go:348 +0xd0
code.google.com/p/odbc.(*BaseColumn).Value(0xc080098560, 0xc08007dba0, 0x0, 0xc,
 0x1, ...)
        E:/Go/GoExternal/src/code.google.com/p/odbc/column.go:118 +0x7e8
code.google.com/p/odbc.(*BindableColumn).Value(0xc080099540, 0x2b7fb0, 0x0, 0xc0
8007dbb0, 0x41a1bd, ...)
        E:/Go/GoExternal/src/code.google.com/p/odbc/column.go:223 +0x336
code.google.com/p/odbc.(*Rows).Next(0xc080090a28, 0xc08007dbc0, 0x1, 0x1, 0x1, .
..)


I investigated the issue and found that buf(len) is 0 in the case of 
api.SQL_C_WCHAR.  Additionally, in func (c *BindableColumn) Value(...), c.Len 
is 0 but c.Size is 12.  I think c.Size is 12 because 5 unicode characters (10 
bytes) + 1 unicode termination character.  However, why is the length 0?

Original issue reported on code.google.com by [email protected] on 20 May 2013 at 7:48

Panic after batch executing a number of statements

I am using the odbc driver to insert a large amount of records obtained from a 
webservice. I create a prepared statement and then execute that statement for 
every object I receive from the webservice. After a while the program panics 
with the following stack trace.

unexpected fault address 0xc180219d3e
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0xc180219d3e pc=0x7feead01464]

goroutine 1 [syscall]:
[fp=0x3916d8] return()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/asm_amd64.s:508
[fp=0x391720] runtime.cgocall(0x427420, 0x391730)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/cgocall.c:162 +0x133
[fp=0x391768] syscall.Syscall(0x7feeb110f00, 0x1, 0x1cae50, 0x0, 0x0, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/zsyscall_windows_windows_amd64.c:74 +0x55
[fp=0x3917b0] code.google.com/p/odbc/api.SQLExecute(0x1cae50, 0x1cae50)
        Y:/gocode/src/code.google.com/p/odbc/api/zapi_windows.go:89 +0x5e
[fp=0x391848] code.google.com/p/odbc.(*ODBCStmt).Exec(0xc0801d6f00, 
0xc08022c3c0, 0xf, 0xf, 0x494ac0, ...)
        Y:/gocode/src/code.google.com/p/odbc/odbcstmt.go:110 +0x1b4
[fp=0x3918a8] code.google.com/p/odbc.(*Stmt).Exec(0xc080145780, 0xc08022c3c0, 
0xf, 0xf, 0x0, ...)
        Y:/gocode/src/code.google.com/p/odbc/stmt.go:60 +0x203
[fp=0x3919a0] database/sql.resultFromStatement(0xc0800bab10, 0xc0800a92a0, 
0xc08008cfc0, 0xc080145780, 0xc08022c1e0, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/database/sql/sql.go:1077 +0x27b
[fp=0x391a38] database/sql.(*Stmt).Exec(0xc0801a2c00, 0xc08022c1e0, 0xf, 0xf, 
0x0, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/database/sql/sql.go:1056 +0x1c3
[fp=0x391f90] main.main()
        Y:/gocode/src/dbtest/main.go:99+0xb8f
[fp=0x391fb8] runtime.main()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/proc.c:182 +0x99
[fp=0x391fc0] runtime.goexit()
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/proc.c:1223

goroutine 4 [syscall]:
syscall.Syscall6(0x775ca4d0, 0x5, 0x310, 0xc0800e7e60, 0xc080000fa0, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/runtime/zsyscall_windows_windows_amd64.c:97 +0x55
syscall.GetQueuedCompletionStatus(0x310, 0xc0800e7e60, 0xc080000fa0, 
0xc080000f98, 0xffffffff, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/syscall/zsyscall_windows_amd64.go:507 +0x9f
net.(*resultSrv).Run(0xc080000f90)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/fd_windows.go:150 +0x151
created by net.startServer
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/fd_windows.go:285 +0x10f

goroutine 251 [chan receive]:
net/http.(*persistConn).readLoop(0xc080120a00)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/http/transport.go:761 +0x64e
created by net/http.(*Transport).dialConn
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/http/transport.go:511 +0x577

goroutine 264 [chan send]:
dbtest/xsc.Resource.parseObjectStream(0xc0800dfb80, 0xc08010b800, 0x1b, 
0x10001, 0xc0801bd6a0, ...)
        Y:/gocode/src/dbtest/xsc.go:316 +0x65c
created by dbtest/xsc.Resource.Data
        Y:/gocode/src/dbtest/xsc.go:236 +0x212

goroutine 252 [select]:
net/http.(*persistConn).writeLoop(0xc080120a00)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/http/transport.go:774 +0x272
created by net/http.(*Transport).dialConn
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist675583351/go/src/pkg/net/http/transport.go:512 +0x58e


What version of the product are you using? On what operating system?

odbc (commit fdeace4e5288)
go version 1.1.2 windows/amd64
Windows Server 2008 R2 Standard SP1
Microsoft SQL Server 2008

Please provide any additional information below.

So far I haven't found a way to reliably reproduce this problem. The panic 
happens every time (with the same input data), but always with different insert 
values. Sometimes it would crash after a second, sometimes after 10. A 
statement that crashed before was usually successfully executed the next run. 
But the panic always happens at some point.

Since I'm working with some sensitive data I cannot provide the input data nor 
the source code, but I'm working on creating a smaller program that reproduces 
this problem (no luck so far). Since I have not much experience yet with cgo, 
any suggestions or ideas on how to debug this is very much appreciated.

Original issue reported on code.google.com by [email protected] on 5 Sep 2013 at 12:27

Test fails on RedHat Linux 5.9 with unixODBC 2.3.1 and FreeTDS 0.91RC2

What steps will reproduce the problem?
1. Install freetds package with 'yum install'
2. Compile unixODBC 2.3.1 from source
3. Install the package with "go get code.google.com/p/odbc"
4. Run test with go test -mssrv SERVER -msuser USER -mspass PASSWD -msdb DB

What is the expected output? 

All tests pass

What do you see instead?

I see the following runtime error:

panic: runtime error: slice bounds out of range [recovered]
    panic: runtime error: slice bounds out of range

goroutine 4 [running]:
testing.func·004()
    /usr/local/src/go/src/pkg/testing/testing.go:348 +0xcd
code.google.com/p/odbc.(*BindableColumn).Value(0xc200070e40, 0x6b6c050, 0x6, 
0x4f36c0, 0xc200087cc0, ...)
    /home/oracle/gosrc/src/code.google.com/p/odbc/column.go:239 +0x283
code.google.com/p/odbc.(*Rows).Next(0xc2000004c8, 0xc200054540, 0x7, 0x7, 
0x54ee20, ...)
    /home/oracle/gosrc/src/code.google.com/p/odbc/rows.go:34 +0x137
database/sql.(*Rows).Next(0xc20008a300, 0x3)
    /usr/local/src/go/src/pkg/database/sql/sql.go:1310 +0xc1
code.google.com/p/odbc.TestMSSQLCreateInsertDelete(0xc200098000)
    /home/oracle/gosrc/src/code.google.com/p/odbc/mssql_test.go:270 +0x62f
testing.tRunner(0xc200098000, 0x815780)
    /usr/local/src/go/src/pkg/testing/testing.go:353 +0x8a
created by testing.RunTests
    /usr/local/src/go/src/pkg/testing/testing.go:433 +0x86b

goroutine 1 [chan receive]:
testing.RunTests(0x583330, 0x815780, 0xf, 0xf, 0x1, ...)
    /usr/local/src/go/src/pkg/testing/testing.go:434 +0x88e
testing.Main(0x583330, 0x815780, 0xf, 0xf, 0x824580, ...)
    /usr/local/src/go/src/pkg/testing/testing.go:365 +0x8a
main.main()
    code.google.com/p/odbc/_test/_testmain.go:73 +0x9a

goroutine 2 [syscall]:
exit status 2
FAIL    code.google.com/p/odbc  0.101s

What version of the product are you using? On what operating system?

[oracle@custservices odbc]$ go version
go version go1.1.2 linux/amd64
[oracle@custservices odbc]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.9 (Tikanga)
[oracle@custservices odbc]$ uname -a
Linux custservices 2.6.18-348.3.1.el5 #1 SMP Tue Mar 5 13:19:32 EST 2013 x86_64 
x86_64 x86_64 GNU/Linux

Please provide any additional information below.

Original issue reported on code.google.com by victor.kryukov on 12 Nov 2013 at 2:54

Query fails if server restarts after initial DB open.

Connecting to MS SQL Server via ODBC on MS Window.

If SQL Server is restarted while a long running program is running with a 
maintained reference to *database/sql.DB, then any queries after restart will 
fail. The error I receive is:

SQLDescribeParam: {01000} [Microsoft][ODBC SQL Server Driver][DBMSLPCN
]ConnectionWrite (WrapperWrite()). {08S01} [Microsoft][ODBC SQL Server 
Driver][DBMSLPCN]General network error. Check your network documentation.

It would seem sub-optimal to require checking this error after every 
connection. Rather, the intended behavior should be to attempt to re-connect, 
then if that fails, provide a special error type to check against (Connection 
not available).

Original issue reported on code.google.com by [email protected] on 11 Jun 2013 at 4:43

LastInsertId is not implemented result

What is the expected output? What do you see instead?
- I would like to get the id of the last inserted row instead of "not 
implemented" message after the insert command

What version of the product are you using? On what operating system?
- latest odbc ver on both Ubuntu and Windows

Please provide any additional information below.

//result.go:
func (r *Result) LastInsertId() (int64, error) {
    // TODO(brainman): implement (*Resilt).LastInsertId
    return 0, errors.New("not implemented")
}

Original issue reported on code.google.com by [email protected] on 26 Feb 2014 at 3:20

panic: sql: Register called twice for driver odbc when running `go test` on Linux

What steps will reproduce the problem?
1. hg clone https://code.google.com/p/odbc/
2. cd odbc/
3. go test

What is the expected output? What do you see instead?
I see :

panic: sql: Register called twice for driver odbc

goroutine 1 [running]:
database/sql.Register(0x81483d8, 0x4, 0x1834f680, 0x8204060)
        /usr/local/go/src/pkg/database/sql/sql.go:31 +0xe1
_/home/bbigras/odbc.init·1()
        /home/bbigras/odbc/driver.go:74 +0x72
_/home/bbigras/odbc.init()
        /home/bbigras/odbc/mssql_test.go:864 +0x1610
main.init()
        _/home/bbigras/odbc/_test/_testmain.go:34 +0x3e

goroutine 2 [syscall]:
exit status 2
FAIL    _/home/bbigras/odbc     0.093s

What version of the product are you using? On what operating system?
go version go1.1.2 linux/386
freetds 0.82-6build1
tdsodbc 0.82-6build1
unixodbc 2.2.11-21
Ubuntu 10.04.4 LTS

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 8:38

Error saving Null dates to datetime2 field in SQL Server 2008 R2

The goal is as follows:
To be able to insert/update a datetime2 field in a SQL Server 2008 database to 
NULL. Searching the internet I found that people created a NullTime structure 
that implemented the Value and Scan interfaces from the database/sql/driver 
package in the standard library. Doing this will allow a null date to be read, 
but it fails when trying to submit a Null date to the database.

If you set up a database with the following sample table and adjust the 
connection information in the sample code below, you should see how I received 
the following error 'SQLExecute: {07002} [Microsoft][SQL Server Native Client 
11.0]COUNT field incorrect or syntax'

CREATE TABLE [dbo].[Sample](
    [SampleId] [int] IDENTITY(1,1) NOT NULL,
    [SomeDate] [datetime2](7) NULL,
 CONSTRAINT [PK_Sample] PRIMARY KEY CLUSTERED 
(
    [SampleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


The following code was compiled using go 1.2 windows/amd64:

package main

import (
    _ "code.google.com/p/odbc"
    "database/sql"
    "database/sql/driver"
    "log"
    "time"
)

//ConnectionInfo contains the sql server connection information
type ConnectionInfo struct {
    Driver     string
    SrvName    string
    DbName     string
    UseTrusted bool
    UserName   string
    Pwd        string
}

func (ci *ConnectionInfo) GetConnectionString() string {
    var connstr string
    connstr += "Driver={" + ci.Driver + "};"
    connstr += "Server=" + ci.SrvName + ";"
    connstr += "Database=" + ci.DbName + ";"

    if ci.UseTrusted {
        connstr += `Trusted_Connection=yes;`
    } else {
        connstr += `Uid=` + ci.UserName + `;`
        connstr += `Pwd=` + ci.Pwd
    }
    return connstr
}

//NullTime structure will represent a nullable datetime2 field
//within the database
type NullTime struct {
    Time  time.Time
    Valid bool // Valid is true if Time is not NULL
}

// Scan implements the Scanner interface.
func (nt *NullTime) Scan(value interface{}) error {
    nt.Time, nt.Valid = value.(time.Time)
    return nil
}

// Value implements the driver Valuer interface.
func (nt NullTime) Value() (driver.Value, error) {
    if !nt.Valid {
        return nil, nil
    }
    return nt.Time, nil
}

//String implements Stringer interface
func (nt NullTime) String() string {
    if nt.Valid {
        return nt.Time.String()
    }

    return "NULL Date"
}

//Sample is a struct that maps to the sample table
//in the database
type Sample struct {
    SampleId int
    SomeDate NullTime
}

var ci ConnectionInfo

func main() {

    //set connection information
    ci.Driver = "SQL Server Native Client 10.0"
    ci.DbName = "SomeDatabae"
    ci.SrvName = "SomeServer"
    ci.UseTrusted = true
    //ci.UName = "username"
    //ci.Pwd = "password"

    //connect to database
    db, err := sql.Open("odbc", ci.GetConnectionString())

    if err != nil {
        log.Fatalln("Unable to open database! ", err)
    } else {
        log.Println("Connected to database")
    }
    defer db.Close()

    //add sample data
    var sql string
    //sample row with date
    sql = "insert into dbo.Sample ([SomeDate]) values(GetDate())"
    _, err = db.Exec(sql)
    if err != nil {
        log.Println("Cannot save sample data. ", err)
    }

    //sample row without date
    sql = "insert into dbo.Sample ([SomeDate]) values(Null)"
    _, err = db.Exec(sql)
    if err != nil {
        log.Println("Cannot save sample data. ", err)
    }

    //now there should be two rows. one with a date and one wil NULL.
    //We will read from the database and display the results.
    //the NullTime structure works just fine here.

    sql = "select [SampleId], [SomeDate] from dbo.Sample"

    if rows, err := db.Query(sql); err != nil {
        log.Println("Cannot execute query! ", err)
    } else {
        var results []Sample
        //scan rows
        for rows.Next() {
            var row Sample
            err = rows.Scan(&row.SampleId, &row.SomeDate)
            if err != nil {
                log.Println("Error during row scan! ", err)
            }
            results = append(results, row)
        }
        //print rows to screen
        for _, r := range results {
            log.Println("Row in Database:", r.SampleId, r.SomeDate)
        }

    }

    //now lets submit some new rows using the Sample structure

    //With a date
    var withDate Sample
    withDate.SomeDate.Time = time.Now()
    withDate.SomeDate.Valid = true

    sql = "insert into dbo.Sample ([SomeDate]) values(?)"

    _, err = db.Exec(sql, withDate.SomeDate)
    if err != nil {
        log.Println("Cannot add a new row with a date! ", err)
    }

    //Without a date
    var noDate Sample //the zero value of the struct is what we want to use
    _, err = db.Exec(sql, noDate.SomeDate)
    if err != nil {
        log.Fatalln("Cannot add a new row without a date! ", err)
        //at this point we should see the error
        //SQLExecute: {07002} [Microsoft][SQL Server Native Client 10.0]COUNT field incorrect or syntax error
    }

}

Original issue reported on code.google.com by [email protected] on 18 Dec 2013 at 8:01

Attachments:

error in utf16toutf8

What steps will reproduce the problem?

1. Download and restore Northwind database 
(http://northwinddatabase.codeplex.com/releases/view/71634) in MS SQL Server.
2. Create a folder TestMSSQL, "cd TestMSSQL", put there the attached file, "go 
get", "go build"
3. Run TestMSSQL.exe

What is the expected output? What do you see instead?

Expect: formatted data from Products table

Instead:
--------
panic: runtime error: index out of range

goroutine 1 [running]:
unicode/utf8.EncodeRune(0x20050d80, 0x1, 0x4, 0xe4, 0x20050d80, ...)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist465310315/go/src/pkg/unicode/utf8/utf8.go:339 +0x85
code.google.com/p/odbc.utf16toutf8(0x2008f0c0, 0x13, 0x100000, 0x50, 0x1, ...)
        C:/App/Go/src/code.google.com/p/odbc/utf16.go:49 +0x1f9
code.google.com/p/odbc.(*BaseColumn).Value(0x20089280, 0x2008f0c0, 0x26, 0x52, 
0x48bfe0, ...)
        C:/App/Go/src/code.google.com/p/odbc/column.go:137 +0x66f
code.google.com/p/odbc.(*BindableColumn).Value(0x20078450, 0x1ad2890, 0x1, 
0x48bfe0, 0x16, ...)
        C:/App/Go/src/code.google.com/p/odbc/column.go:239 +0x211
code.google.com/p/odbc.(*Rows).Next(0x200502f8, 0x2007a500, 0xa, 0xa, 0x1, ...)
        C:/App/Go/src/code.google.com/p/odbc/rows.go:34 +0xfe
database/sql.(*Rows).Next(0x20078780, 0x1)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist465310315/go/src/pkg/database/sql/sql.go:1310 +0xb1
main.main()
        C:/App/Go/src/TestMSSQL/main.go:54 +0x403
-------

What version of the product are you using? On what operating system?

Go 1.1.2, Windows 7 (both 32&64)

Please provide any additional information below.

The odbc package fails on fetching unicode string ("Gustaf's Knäckebröd"). 

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 10:15

Attachments:

crash on Linux (64bit)

I have a small question about your odbc lib - I am running into the below on 
Linux (64bit):

Doesnt happen from windows, or with smaller queries.

Any idea? Thanks,

Kees

panic: unexpected handle type api.SQLHANDLE [recovered]
        panic: unexpected handle type api.SQLHANDLE

goroutine 4 [running]:
testing.func·004()
        /usr/local/go/src/pkg/testing/testing.go:348 +0xcd
code.google.com/p/odbc.ToHandleAndType(0x5de600, 0x1293d70, 0x0, 0x0)
        /home/kees/go/src/code.google.com/p/odbc/handle.go:28 +0x20d
code.google.com/p/odbc.NewError(0x69ca50, 0xd, 0x5de600, 0x1293d70, 0x8, ...)
        /home/kees/go/src/code.google.com/p/odbc/error.go:42 +0x40
code.google.com/p/odbc.releaseHandle(0x5de720, 0x1293d70, 0x49b19f, 0x0)
        /home/kees/go/src/code.google.com/p/odbc/handle.go:40 +0x191
code.google.com/p/odbc.(*ODBCStmt).releaseHandle(0xc2000a85a0, 0xc2000acd80, 
0x0)
        /home/kees/go/src/code.google.com/p/odbc/odbcstmt.go:89 +0x39
code.google.com/p/odbc.(*ODBCStmt).closeByStmt(0xc2000a85a0, 0x0, 0x0)
        /home/kees/go/src/code.google.com/p/odbc/odbcstmt.go:62 +0xc3
code.google.com/p/odbc.(*Stmt).Close(0xc2000abea0, 0xc2000abf30, 0xc2000acd80)
        /home/kees/go/src/code.google.com/p/odbc/stmt.go:40 +0xc4
database/sql.(*DB).queryConn(0xc2000ca240, 0xc2000accc0, 0xc2000bd4e0, 
0x6f6ad0, 0x618, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:697 +0x44f
database/sql.(*DB).query(0xc2000ca240, 0x6f6ad0, 0x618, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:652 +0x124
database/sql.(*DB).Query(0xc2000ca240, 0x6f6ad0, 0x618, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/database/sql/sql.go:636 +0x89
mro/portal.TestOdbc(0xc2000c1000)
        /home/kees/go/src/mro/portal/portal_test.go:31 +0x19b
testing.tRunner(0xc2000c1000, 0x9f4180)
        /usr/local/go/src/pkg/testing/testing.go:353 +0x8a
created by testing.RunTests
        /usr/local/go/src/pkg/testing/testing.go:433 +0x86b

goroutine 1 [chan receive]:
testing.RunTests(0x6f1620, 0x9f4180, 0x1, 0x1, 0x1, ...)
        /usr/local/go/src/pkg/testing/testing.go:434 +0x88e
testing.Main(0x6f1620, 0x9f4180, 0x1, 0x1, 0xa0e160, ...)
        /usr/local/go/src/pkg/testing/testing.go:365 +0x8a
main.main()
        mro/portal/_test/_testmain.go:43 +

Original issue reported on code.google.com by [email protected] on 21 Apr 2013 at 11:52

MIN & MAX isn't working

Hey,

I'm using your ODBC driver with unixODBC on Ubuntu-Desktop 12.10 (64bit) to 
connect to a SAP Hana database. 
Unfortunately the MIN and MAX function doesn't work.
With isql I can query the following Statement:
SELECT "SalesOrder"."id", min("SalesOrderLineItem"."promisedate") FROM 
"Golang"."SalesOrder", "Golang"."SalesOrderLineItem" WHERE 
"SalesOrderLineItem"."salesorderid" = "SalesOrder"."id" Group BY 
"SalesOrder"."id" ORDER BY  "SalesOrder"."id" asc LIMIT 10 OFFSET 0

The result:
+------------+-----------------+
| id         | MIN(promisedate)|
+------------+-----------------+
| 1          | 2011-04-12      |
| 2          | 2012-06-16      |
| 3          | 2012-06-16      |
| 4          | 2012-04-24      |
| 5          | 2012-01-26      |
| 6          | 2011-12-18      |
| 7          | 2012-07-28      |
| 8          | 2011-07-28      |
| 9          | 2012-08-03      |
| 10         | 2011-10-17      |
+------------+-----------------+

In Go it just fills the id column, not the MIN one:
[id MIN(promisedate)] <nil>
[[1 ] [2 ] [3 ] [4 ] [5 ] [6 ] [7 ] [8 ] [9 ] [10 ]]

Any idea to solve this?

Best regards
Frank

(using,go1.0.3, unixodbc 2.2.14p2-5ubuntu4, unixodbc-dev 2.2.14p2-5ubuntu4, 
newest ODBC go package)

Original issue reported on code.google.com by [email protected] on 13 Mar 2013 at 3:19

Transaction-test (EndTran) fails on Linux

I am not sure this is actually a problem of odbc, it might be a freetds thing 
but I'm not capable enough to find out.

What steps will reproduce the problem?
1. go test -run TestMSSQLTransactions

What do you see instead?
The test blocks until the test runtime terminates it after 10 minutes.
It blocks in zapi_unix.go on line 64:
r := C.SQLEndTran(C.SQLSMALLINT(handleType), C.SQLHANDLE(handle), 
C.SQLSMALLINT(completionType))

What version of the product are you using? On what operating system?
DB Server:
MS-SQL 2008 server, empty database.
Client:
Linux (Debian Wheezy, 64 bit), unixodbc (2.2.14p2-5) and freetds (0.91-2).

Please provide any additional information below.
I can provide access details to the server I used to test it with (on 24/7). If 
it would help, I could also probably provide ssh access to the client machine.

Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 5:14

TestMSSQLTextColumnParamTypes fails on linux

# hg id
c2f63436f757 tip
# go test -mssrv=xxxxxxxx -msdb=xxxx -msuser=xxxx -mspass=xxxx -v -run=ParamT
=== RUN TestMSSQLTextColumnParamTypes
--- FAIL: TestMSSQLTextColumnParamTypes (0.18 seconds)
        mssql_test.go:1206: empty string wrong return value: have " "; want ""
        mssql_test.go:1206: empty unicode string wrong return value: have " "; want ""
        mssql_test.go:1206: empty unicode null string wrong return value: have " "; want ""
        mssql_test.go:1206: very large string value wrong return value: have "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ... (4000 bytes long)"; want "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ... (10000 bytes long)"
        mssql_test.go:1211: very large image wrong return value: have [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] (8000 bytes long); want [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] (10000 bytes long)
FAIL
exit status 1
FAIL    code.google.com/p/odbc  0.186s
#

Original issue reported on code.google.com by [email protected] on 9 May 2014 at 2:14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.