Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug: attributes dynamically filled (e.g. xml) truncated

2 views
Skip to first unread message

Ben Morgan

unread,
Mar 18, 2013, 4:12:55 AM3/18/13
to
Hi,

I have found what I think might be a bug. I am using the ODBC driver
in conjunction with AnySQL. After submitting this bug report to them,
they said they think that it is a problem with the driver, because “it
just displays values returned by the driver.” So here we go! :-)

The text type in PostgreSQL is of unlimited length. When accessing a
view in PostgreSQL, some of the attributes contain data generated
dynamically that is longer than 255 characters, but it would seem that
the driver truncates this to 255 characters.

Steps to reproduce:

drop view if exists "public"."too_short_view";

drop table if exists "public"."too_short";

create table "public"."too_short" (id serial primary key, name text not null);

insert into "public"."too_short" (name) values ('
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc
tempor risus sit amet nibh venenatis sit amet vehicula augue
suscipit. Vivamus augue magna, lacinia vel dapibus nec,
tincidunt quis eros. Duis vehicula hendrerit dui, ut cursus ligula volutpat.
This is now at least 255 characters long, but this part will be truncated.');

create view "public"."too_short_view" as select id, xmlelement(name
xml, name) from "public"."too_short";

select * from "public"."too_short_view";

Thanks for your time!
Ben


--
Sent via pgsql-odbc mailing list (pgsql...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc

Heikki Linnakangas

unread,
Mar 18, 2013, 9:13:46 AM3/18/13
to
On 18.03.2013 10:12, Ben Morgan wrote:
> The text type in PostgreSQL is of unlimited length. When accessing a
> view in PostgreSQL, some of the attributes contain data generated
> dynamically that is longer than 255 characters, but it would seem that
> the driver truncates this to 255 characters.
>
> Steps to reproduce:
>
> drop view if exists "public"."too_short_view";
>
> drop table if exists "public"."too_short";
>
> create table "public"."too_short" (id serial primary key, name text not null);
>
> insert into "public"."too_short" (name) values ('
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc
> tempor risus sit amet nibh venenatis sit amet vehicula augue
> suscipit. Vivamus augue magna, lacinia vel dapibus nec,
> tincidunt quis eros. Duis vehicula hendrerit dui, ut cursus ligula volutpat.
> This is now at least 255 characters long, but this part will be truncated.');
>
> create view "public"."too_short_view" as select id, xmlelement(name
> xml, name) from "public"."too_short";
>
> select * from "public"."too_short_view";

Works for me with the attached test program. It prints the whole field
without truncation:

> connected
> <xml>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc
> tempor risus sit amet nibh venenatis sit amet vehicula augue
> suscipit. Vivamus augue magna, lacinia vel dapibus nec,
> tincidunt quis eros. Duis vehicula hendrerit dui, ut cursus ligula volutpat.
> This is now at least 255 characters long, but this part will be truncated.</xml>

I think the driver will return 255 as the max length of a text field,
when the application asks for the field length with the SQLGetTypeInfo()
function. Maybe some other functions, too, I'm not sure. That's just an
arbitrary number, because the driver has to return something, and it can
be changed by setting the MaxVarcharSize setting in the ODBC driver
configuration (odbc.ini). You could try setting that to higher value.

- Heikki
select-test.c

Barry Bell

unread,
Mar 18, 2013, 10:21:54 AM3/18/13
to
Try changing some settings on the ODBC driver.
Maxvarchar(B0) setting, default is 254 , anything less then 254 is a varchar, anything more is a CLOB/Memo(anysql equivalent)

Add these setting to your connection string:

;BI=2;TextAsLongVarchar=1;UnknownSizes=2;UseServerSidePrepare=1;comment=POSTGRESS;B0=254;B7=0;

Thanks
Barry Bell, IT Department
Office: 954-429-3771 x267 Fax: 954-281-1464 email Barry...@harte-hanks.com

Inoue, Hiroshi

unread,
Mar 19, 2013, 7:57:11 PM3/19/13
to
Hi,

(2013/03/18 17:12), Ben Morgan wrote:
> Hi,
>
> I have found what I think might be a bug. I am using the ODBC driver
> in conjunction with AnySQL. After submitting this bug report to them,
> they said they think that it is a problem with the driver, because “it
> just displays values returned by the driver.” So here we go! :-)
>
> The text type in PostgreSQL is of unlimited length. When accessing a
> view in PostgreSQL, some of the attributes contain data generated
> dynamically that is longer than 255 characters, but it would seem that
> the driver truncates this to 255 characters.

Please try to turn on the *Text as LongVarChar* option.

regards,
Hiroshi Inoue

Ben Morgan

unread,
Mar 20, 2013, 7:36:51 AM3/20/13
to
Hi guys,

it started working properly when I set

*Max VarChar* and *Max LongVarChar* both to 0.
They were 255 and 8190, respectively.

Thanks for your help!
Ben
0 new messages