[erlang-bugs] ODBC problem: varchar column contents truncated to 255 chars
Michael Santos
michael.santos@REDACTED
Sat Apr 16 00:40:30 CEST 2011
On Fri, Apr 15, 2011 at 05:31:40PM +0200, Laura M. Castro wrote:
> Hello,
>
> 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 |
>
> description
> -----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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).
> ok
> 2> {ok,C}=odbc:connect("DSN=postgres",[]).
> {ok,<0.39.0>}
> 3> {selected, Columns, [{ID, LongString}]} = odbc:sql_query(C, "SELECT
> * FROM prueba").
> {selected,["oid","description"],
> [{3,
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}]}
> 4> length(LongString).
> 255
>
> 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.
Works for me with R14B02. dpkg says I'm using unixodbc 2.2.11-16build1
and odbc-postgresql 1:08.01.0200-2.1.
Maybe casting the varchar to text is a workaround:
odbc:sql_query(C, "SELECT description::text FROM prueba").
or:
odbc:sql_query(C, "SELECT CAST(description as TEXT) FROM prueba").
More information about the erlang-bugs
mailing list