#209 Integer values from postgres/ODBC are corrupted when using odbc_import on 64 bit Linux

wrong answer
open
nobody
None
5
2014-08-14
2013-11-05
Stephen A. Goss
No

SELECT statements done through normal odbc_sql or findall_odbc_sql predicates yield the correct value for integer fields, but predicates made through odbc_import/2, return crazy values that look like the most significant bits of the integer are some other random bits instead of 0s.

correct:

| ?- findall_odbc_sql([],'SELECT * FROM foo',Res).
odbc_sql_i(38681312,[],SELECT * FROM foo,_h215)

Res = [1,steve,steve@example.org];

Res = [2,frank,frank@example.org];

no

incorrect:

| ?- odbc_import('foo'('id','name','email'),foo).

yes
| ?- foo(Id,Name,Email).
odbc_sql_i(38681312,[],[ SELECT , ,rel1,.,id, ,,, ,rel1,.,name, ,,, ,rel1,.,email, , FROM , ,foo, ,rel1, ],[_h159,_h173,_h187])

Id = 140411070840833
Name = steve
Email = steve@example.org;

Id = 140411070840834
Name = frank
Email = frank@example.org;

no

I'm using Postgres ODBC connection. Same results with XSB 3.3.7 and 3.4.0. Configured thusly ./configure --with-odbc on Ubuntu 13.10 64 bit.

Discussion

  • Interesting. Both seem to be going through the similar odbc_sql_i call, which does the retrieval of data from the DB. The queries are a little different, though, so maybe that's a problem.
    Could you try:
    | ?- findall_odbc_sql([],'SELECT id,name,email FROM foo',[Id,Name,Email]).

    It's possible that the slightly different form of the sql query might make a difference.
    -David

     
  • That one seems to work fine:

    | ?- findall_odbc_sql([],'SELECT id, name, email FROM foo', [Id, Name, Email]).
    odbc_sql_i(28303072,[],SELECT id, name, email FROM foo,_h281)
    
    Id = 1
    Name = steve
    Email = steve@example.org;
    
    Id = 2
    Name = frank
    Email = frank@example.org;