Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  Unix ODBC integer value issue

diyu01
Posted: Thu Oct 15, 2009 10:05 pm Reply with quote
Joined: 19 Aug 2009 Posts: 7
Hi, I have compiled Erlang R13B02_1 on a Linux machine using gcc4.1.2 (64bit) and Unix ODBC. Because my 64-bit Unix ODBC library is not in standard locations, I had to manually tweak the lib/odbc/configure file (by adding my location to the end of the "standard locations" list, and substituting "-lodbc -lodbcinst -lddicu" for all "-lodbc" occurrences in that file, is there a way to force Erlang build to use a non-standard location of Unix ODBC?), but eventually it built ok. When I start to use odbc, though, I got a problem: all integer values returned from the database are added 214748364800 (other data types are handled ok). e.g.:

> odbc:sql_query(Conn, "select 1").
{selected,[[]],[{214748364801}]}
> odbc:sql_query(Conn, "select 100").
{selected,[[]],[{214748364900}]}
> odbc:sql_query(Conn, "select 1.0").
{selected,[[]],[{1.0}]}

(My binary Erlang installation on Windows can handle "select 1" without problem)

Could you tell me why this is the case? And what should I do to fix it? Thanks!
View user's profile Send private message
diyu01
Posted: Fri Oct 16, 2009 2:44 pm Reply with quote
Joined: 19 Aug 2009 Posts: 7
It looks like in my version of ODBC, SQLBindCol is only populating the lower 4 bytes of column.buffer in the case of SQL_C_SLONG type even though SQL_INTEGER is 8 bytes long and my ODBC is a 64-bit build, so I have to hack the lib/odbc/c_src/odbcserver.c file to handle this problem:

(1) In encode_column_dyn, change

*(SQLINTEGER*) column.buffer

to

*(int32_t*) column.buffer

so that it can handle negative values correctly (looks like only the lower 4 bytes of buffer are filled, so -1 will be encoded as 0xFFFFFFFFll without this hack)

(2) In safe_malloc and safe_realloc, add

memset(memory, 0, size);

before "return memory", otherwise the high 4 bytes of an SQLINTEGER (8 byte) buffer will have strange contents.

I am not sure why I need to do these hacking, though. Should there be a configuration action checking this behavior? Thanks.
View user's profile Send private message
diyu01
Posted: Fri Oct 16, 2009 4:05 pm Reply with quote
Joined: 19 Aug 2009 Posts: 7
Ok, I found that in order to get my Unix ODBC installation to work correctly, I have to add -DODBC64 to CFLAGS. That solved the problem.
View user's profile Send private message
wuji
Posted: Wed Aug 22, 2012 8:15 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
a link to go to Netflix, you would wind up up jordan 6 up at "BudgetMatch," according to the FBI. The practice is
"click hijacking."Once the FBI got around to fixing the problem problem [h4]cheap jordans[/h4] problem in 2011, it realized it couldn't simply shut down
rogue servers because infected computers would be left without a a cheap replica *beep* a functioning DNS, leaving them virtually Internet-less. So it set
temporary servers to give malware-infected Internet users time to fix fix jordan 6 fix their computers.And time runs out on Monday, July 9.(There
a planned attack this Monday that will shut down the the imitation designer *beep* the Internet; those whose computers are already infected will lose
View user's profile Send private message
trapples
Posted: Wed Aug 22, 2012 8:30 am Reply with quote
User Joined: 02 Apr 2012 Posts: 45
Could you tell me why this is the case? And what should I do to fix it? Thanks!

_________________
music make our life sounds beautiful

View user's profile Send private message Visit poster's website

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum