[erlang-bugs] ODBC problem: varchar column contents truncated to 255 chars

Laura M. Castro <>
Fri Apr 15 17:31:40 CEST 2011


   When accessing a data source using the ODBC application, retrieved
contents of columns with type 'varchar' are truncated to 255 chars.
Here's an example:

   PostgreSQL table 'prueba':

postgres=# \d prueba
            Table "public.prueba"
   Column    |       Type        | Modifiers
 oid         | integer           |
 description | character varying |

   Table 'prueba' contains a single row, which 'description' field is
300 chars long:

postgres=# select * from prueba;
 oid |

   1 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(1 row)

   But when the field is retrieved using Erlang+ODBC, only 255 chars
are returned:

Erlang R14A (erts-5.8) [source] [64-bit] [smp:4:4] [rq:4]
[async-threads:0] [kernel-poll:false]
Eshell V5.8  (abort with ^G)
1> application:start(odbc).
2> {ok,C}=odbc:connect("DSN=postgres",[]).
3> {selected, Columns, [{ID, LongString}]} = odbc:sql_query(C, "SELECT
* FROM prueba").
4> length(LongString).

   Accessing the same data source using other tools that also use the
underlying ODBC driver (unixODBC), such as Squirrel-SQL or OpenOffice
Base, data is retrieved correctly.

   I have reproduced this behaviour on the following environments:

Debian GNU/Linux 2.6.38-2-amd64 #1 SMP x86_64 GNU/Linux
Erlang R14A (SMP,ASYNC_THREADS) (BEAM) emulator version 5.8
unixODBC 2.2.14p2-2

Ubuntu GNU/Linux 2.6.35-28-generic #49-Ubuntu SMP x86_64 GNU/Linux
Erlang R13B03 (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.7.4
unixODBC 2.2.14p2-1ubuntu1

Red Hat Linux 5 2.6.18-164.el5 #1 SMP i686 i386 GNU/Linux
Erlang R12B-5.6.el5.1 (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.6.5
unixODBC 2.2.11-7.1

Red Hat Linux 2.6.18-194.11.1.el5 #1 SMP i686 i386 GNU/Linux
Erlang R12B-5.6.el5.1 (THREADS,HIPE) (BEAM) emulator version 5.4.9
unixODBC 2.2.11-7.1

Laura M. Castro
Department of Computer Science
University of A Coruña

More information about the erlang-bugs mailing list