Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectODBC chr bad argument exception #25

Open
Profpatsch opened this issue Apr 12, 2016 · 11 comments
Open

connectODBC chr bad argument exception #25

Profpatsch opened this issue Apr 12, 2016 · 11 comments

Comments

@Profpatsch
Copy link
Contributor

I‘ve set up a simple postgres database:

nmap localhost
…
5432/tcp open  postgresql

and have the following in ~/.odbc.ini:

[postgres]
Driver = PostgreSQL
ServerName = localhost
Database = postgres

I also created a user user with password foo.

> isql postgres user foo -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

In GHCI though:

Prelude Database.HDBC Database.HDBC.ODBC> connectODBC "DSN=postgres"
*** Exception: SqlError {seState = "[\"*** Exception: Prelude.chr: bad argument: 3670064
Prelude Database.HDBC Database.HDBC.ODBC> connectODBC "DSN=postgres; USR=user; PWD=foo"
*** Exception: SqlError {seState = "[\"*** Exception: Prelude.chr: bad argument: 3670064

Version: 2.5.0.0

@anton-dessiatov
Copy link
Contributor

Thanks for the report! Confirming that I've successfully reproduced an issue an am investigating it currently.

@anton-dessiatov
Copy link
Contributor

Oh, that's an issue with wide characters representation. Seems like it's currently broken on Linux (due to the fact that, at least on my Ubuntu, unixodbc assumes 2-byte wchar_t, while GHC assumes 4-byte one). I'll make a proper fix for this on a weekend.

@Profpatsch
Copy link
Contributor Author

@anton-dessiatov Should it work on 2.4.0.1?

Update: Can confirm it works on 2.4.0.1.

@anton-dessiatov
Copy link
Contributor

@Profpatsch Likely so, although that version (and earlier ones) has multithreading issues.

@abbradar
Copy link

I've stumbled upon this today, too. What would happen if we use ANSI version of the call instead? I'm still not really familiar with ODBC...

Another option would be to use text library to perforn UCS-2 conversion.

@abbradar
Copy link

FWIW I went ahead and implemented this in abbradar@79ffd1f -- works fine for me as a workaround.

@igrep
Copy link
Contributor

igrep commented May 13, 2016

I'm really interested in this issue too.
I confirmed abbradar/hdbc-odbc@79ffd1f works on my environment to connect to Oracle too.
Thanks!

@sanketr
Copy link

sanketr commented Sep 2, 2016

Hello, any idea on when this might be fixed? I run into this issue at random in hdbc-odbc 2.5.0.0 (only in ghci 7.10.3, not ghc). An example below (main calls connectODBC):

*Main> main
"*** Exception: Prelude.chr: bad argument: 5832776

It happens once in a while at random, not consistently. So, I was very surprised as well as concerned when I encountered this.

Is there any workaround such as telling ghci the actual width of wchar_t until this issue is fixed?

@saep
Copy link

saep commented Jul 13, 2017

Using abbradar@79ffd1f to connect to an oracle database works for me as well.

@ciez
Copy link

ciez commented Aug 6, 2017

Prelude.chr: bad argument: 3670064

RHEL7.4, ODBC driver 13 for SQL Server

abbradar/hdbc-odbc@79ffd1f worked for connection to SQL Server 2016 with ODBC 13.1

connection string that worked:
"Driver={ODBC Driver 13 for SQL Server};Network=dbmssocn;ApplicationIntent=ReadWrite;Address={server name};Server={server name};Database=db;UID={login};Pwd={pwd};"

could not connect to non-default instance at the SQL server where default instance is only-Windows authenticated.

@binominus
Copy link

The issue still appears on my system (HDBC-odbc 2.5.0.1, using libmyodbc8w.so as driver). The issue seems to be driver-independent. Now what can I do besides hacking source packages? I mean, this issue is now more than 2 years old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants