Exception: Prelude.chr: bad argument: 5046345
Opened this issue · 5 comments
I'm consistently getting the following exception when running code talking to Hive through ODBC both from a binary and from GHCi:
*** Exception: Prelude.chr: bad argument: 5046345
On a different system, we got the same exception with a different number:
*** Exception: Prelude.chr: bad argument: 5832776
This is on GHC 8.0.1 on OS X with the latest version of HDBC and HDBC-odbc. The problem comes up at some initial part of the connection process because I get the exception even if I don't have the ODBC drivers installed or a DSN entry—it's not even trying to connect.
Here's the smallest example that causes the error. (It doesn't work with a correctly configured database either.):
main = connectODBC ""
Here's a stack trace:
ghc-iserv-prof: Prelude.chr: bad argument: 5046345
CallStack (from -prof):
Database.HDBC.ODBC.Api.Errors.raiseError (Database/HDBC/ODBC/Api/Errors.hs:(22,1)-(33,61))
Database.HDBC.ODBC.Api.Errors.checkError (Database/HDBC/ODBC/Api/Errors.hs:(18,1)-(19,50))
Control.Concurrent.ReadWriteLock.withRead (Control/Concurrent/ReadWriteLock.hs:222:1-50)
Control.Concurrent.ReadWriteVar.with (Control/Concurrent/ReadWriteVar.hs:118:1-58)
Database.HDBC.ODBC.Wrappers.withMaybeDbc (Database/HDBC/ODBC/Wrappers.hs:120:1-36)
Database.HDBC.ODBC.Wrappers.withDbcOrDie (Database/HDBC/ODBC/Wrappers.hs:(123,1)-(132,9))
Database.HDBC.ODBC.Connection.connectODBC (Database/HDBC/ODBC/Connection.hsc:(77,1)-(92,17))
ghc: ghc-iserv terminated (1)
Leaving GHCi.
I got the same. Tested with GHC 8.0.1
and 7.10.3
.
I got the same using the included stack.yaml and the hdbc-odbc repo as of 00edd61 by following the example in the Readme to test hdbc-odbc using sqlite3.
resolver: lts-3.17
extra-deps:
- HDBC-2.4.0.1
System info:
unixodbc-dev version: 2.3.1-4.1
@TikhonJelvis and @dmvianna I fixed this by ensuring I had DSN=
prepending the DSN name.
λ> connectODBC
connectODBC :: String -> IO Connection
λ> conn <- connectODBC "testsqlite3"
*** Exception: SqlError {seState = "[\"*** Exception: Prelude.chr: bad argument: 5046345
λ> conn <- connectODBC "DSN=testsqlite3"
λ> hdbcDriverName conn
"odbc"
Same with #25 ?
And can you avoid it by #25 (comment)
@igrep It didn't work for me:
λ> odbcTest
*** Exception: SqlError {seState = "[\"08001\",\"01000\"]", seNativeError = -1, seErrorMsg = "connectODBC/sqlDriverConnect: [\"0: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source\",\"20002: [unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed\"]"}
The error I got could be from other things though.