Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#32501 closed defect (worksforme)

erlang @R14B04 +odbc Patch for bug in Erlang ODBC configure scripts

Reported by: chad@… Owned by: ci42
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc:
Port: erlang

Description

Following is an email exchange which clearly describes the issue this patch is intended to fix:

Found the problem. It's a bug in the configure scripts located in lib/odbc of the Erlang source code, which hard code '-liodbc' when $host_os is darwin -- this prevents anyone from being able to properly link against a unixODBC install on OS X, which needs '-lodbc' instead.

In my case, via MacPorts, this apparently meant it was using the MacPorts unixODBC headers, but linking against the default OS X iODBC lib, which I'm guessing is what led to the weird behavior I was seeing.

I've created a patch for the MacPorts version of Erlang, but I'm pretty autoconf clueless, so all it does is hard code '-lodbc' in place of '-liodbc', which is clearly not the right upstream solution. ;)

If there's anything else I can do to help fix this bug, please let me know.

Thanks,

Chad

On Dec 9, 2011, at 6:05 AM, Ingela Andin wrote:

Hi!

Sound like a problem in the odbc-driver (if I remember correctly iodbc is the name of the most common driver on MAC) sql_wvarchar is defined to be Unicode encoded as UTF16 little endian.

Regards Ingela Erlang/OTP team - Ericsson AB

2011/12/1, Chad Phillips -- Apartment Lines <chad@…>:

According to http://www.erlang.org/doc/apps/odbc/databases.html#type, the SQL_WVARCHAR ODBC data type should be translated by Erlang's ODBC driver to "Unicode binary encoded as UTF16 little endian."

This works as expected on Linux, but I'm having issues on OS X, where it appears it's getting translated to UTF32 little endian, instead of UTF16 little endian.

I'm using Erlang R14B04 on both machines, with the exact same database table, does anybody have an idea why this might be occurring, and how to remedy it?

Additional info below for those interested.

Thanks!

Chad

TABLE ON BOTH ARCHITECTURES:

CREATE TABLE `foo` (
`bar` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


LINUX ERLANG SESSION:

(alaem@scratch)1> odbc:start().
ok
(alaem@scratch)2> {ok, Ref} = odbc:connect("DSN=testing;Option=3", []).
{ok,<0.90.0>}
(alaem@scratch)3> odbc:describe_table(Ref, "foo").
{ok,[{"bar",{sql_wvarchar,255}}]}
(alaem@scratch)4> odbc:select_count(Ref, "SELECT * FROM foo").
{ok,1}
(alaem@scratch)5> {selected, Columns, [{Bar}]} = odbc:next(Ref).
{selected,["bar"],[{<<98,0,97,0,122,0>>}]}
(alaem@scratch)6> unicode:characters_to_list(Bar, {utf16, little}).
"baz"
(alaem@scratch)7> unicode:characters_to_list(Bar, {utf32, little}).
{error,[],<<98,0,97,0,122,0>>}

OS X ERLANG SESSION:

(alaem@colossus)1> odbc:start().
ok
(alaem@colossus)2> {ok, Ref} = odbc:connect("DSN=testing;Option=3", []).
{ok,<0.90.0>}
(alaem@colossus)3> odbc:describe_table(Ref, "foo").
{ok,[{"bar",{sql_wvarchar,255}}]}
(alaem@colossus)4> odbc:select_count(Ref, "SELECT * FROM foo").
{ok,1}
(alaem@colossus)5> {selected, Columns, [{Bar}]} = odbc:next(Ref).
{selected,["bar"],[{<<98,0,0,0,97,0,0,0,122,0,0,0>>}]}
(alaem@colossus)6> unicode:characters_to_list(Bar, {utf16, little}).
[98,0,97,0,122,0]
(alaem@colossus)7> unicode:characters_to_list(Bar, {utf32, little}).
"baz"

Attachments (4)

erlang-portfile-odbc-linking-fix.patch (3.1 KB) - added by chad@… 13 years ago.
Adds patches for ODBC configure scripts when +odbc variant is invoked.
Portfile.patch (452 bytes) - added by chad@… 10 years ago.
Patch to portfile for applying other patches
patch-lib_odbc_configure.diff (1.7 KB) - added by chad@… 10 years ago.
configure patch
patch-lib_odbc_configure.in.diff (490 bytes) - added by chad@… 10 years ago.
configure.in patch

Download all attachments as: .zip

Change History (12)

Changed 13 years ago by chad@…

Adds patches for ODBC configure scripts when +odbc variant is invoked.

comment:1 Changed 13 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to bfulgham@…

comment:2 Changed 12 years ago by jmroot (Joshua Root)

Is this still needed with R15B01?

comment:3 in reply to:  2 Changed 12 years ago by chad@…

I submitted the bug report upstream and the developer did put in a fix for it, but I have not tested to see if his change actually fixed the problem. It's probably ok to take this patch out, I can report back if it's still broken when I get around to upgrading.

comment:4 Changed 12 years ago by bfulgham@…

Resolution: fixed
Status: newclosed

The contents of this patch are part of the R15B1 source base. Consequently, I'm closing this bug as fixed by upstream.

Thanks for your help!

comment:5 Changed 10 years ago by chad@…

Resolution: fixed
Status: closedreopened

Ok, the R15B1 source code may have had a fix for this issue, but it's busted again in 17.1. Posting updated patches in a few seconds...

Changed 10 years ago by chad@…

Attachment: Portfile.patch added

Patch to portfile for applying other patches

Changed 10 years ago by chad@…

configure patch

Changed 10 years ago by chad@…

configure.in patch

comment:6 in reply to:  5 Changed 10 years ago by ci42

Owner: changed from bfulgham@… to ciserlohn@…
Status: reopenednew

Replying to chad@…:

Ok, the R15B1 source code may have had a fix for this issue, but it's busted again in 17.1. Posting updated patches in a few seconds...

I'm not able to reproduce your problem on my 10.9.4 machine using:

erlang @17.1_0+hipe+odbc+ssl+wxwidgets
unixODBC @2.3.1_0
mysql-connector-odbc @5.1.8_1
mysql5-server @5.1.72_0

It works as expected:

10> h().
1: odbc:start()
-> ok
2: {ok,Ref} = odbc:connect("DSN=MySQL-test;Option=3", [])
-> {ok,<0.40.0>}
3: Ref
-> <0.40.0>
4: odbc:describe_table(Ref, "foo")
-> {ok,[{"bar",{sql_wvarchar,255}}]}
5: odbc:select_count(Ref, "SELECT * FROM foo")
-> {ok,0}
6: odbc:select_count(Ref, "SELECT * FROM foo")
-> {ok,1}
7: {selected,Columns,[{Bar}]} = odbc:next(Ref)
-> {selected,["bar"],[{<<98,0,97,0,122,0>>}]}
8: unicode:characters_to_list(Bar, {utf16,little})
-> "baz"
9: unicode:characters_to_list(Bar, {utf32,little})
-> {error,[],<<98,0,97,0,122,0>>}

Erlang links against the MacPorts provided unixODBC without your patch:

bash-4.3$ otool -L /opt/local/lib/erlang/lib/odbc-2.10.20/priv/bin/odbcserver
/opt/local/lib/erlang/lib/odbc-2.10.20/priv/bin/odbcserver:
	/opt/local/lib/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0)

And the README from R15B1 doesn't mention anything the sounds like your bug. R15B01 doesn't even have any odbc related bugfixes at all.

comment:7 Changed 10 years ago by ci42

Resolution: worksforme
Status: newclosed

I'll close this bug as worksforme.

@Chad: Feel free to reopen the bug if you can give precise instructions how to reproduce the bug.

comment:8 Changed 10 years ago by chad@…

reinstalled latest versions of unixODBC, mysql-connector-odbc, mysql56-server and erlang, working perfectly now. no idea why it worked the second time around...

thanks for investigating the problem!

Note: See TracTickets for help on using tickets.