pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Ben Morgan <neembi@gmail.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Bug: attributes dynamically filled (e.g. xml) truncated
Date: Mon, 18 Mar 2013 15:13:46 +0200
Message-ID: <5147130A.7090802@vmware.com> (raw)
In-Reply-To: <CA+pT-SVEPjaWk3k5TYu6CKFzZ6q71ZFus1qoL7+Hbspx=tHGBA@mail.gmail.com>
References: <CA+pT-SVEPjaWk3k5TYu6CKFzZ6q71ZFus1qoL7+Hbspx=tHGBA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

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

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

Attachments:

select-test.c (text/x-csrc, 1.3K) download #include <string.h> #include <stdio.h> #include <stdlib.h> #include <sql.h> #include <sqlext.h> int main(int argc, char **argv) { HSTMT hstmt = SQL_NULL_HSTMT; SQLRETURN ret; SQLCHAR str[1024]; SQLSMALLINT strl; SQLHENV env; SQLHDBC conn; char buf[1000]; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); ret = SQLDriverConnect(conn, NULL, "DSN=psqlodbc_test_dsn;", SQL_NTS, str, sizeof(str), &strl, SQL_DRIVER_COMPLETE); if (SQL_SUCCEEDED(ret)) { printf("connected\n"); } else { printf("failed to connect\n"); exit(1); } ret = SQLAllocStmt(conn, &hstmt); if (!SQL_SUCCEEDED(ret)) { printf("failed to allocate stmt handle"); exit(1); } ret = SQLExecDirect(hstmt, (SQLCHAR *) "select * from public.too_short_view;", SQL_NTS); if (!SQL_SUCCEEDED(ret)) { printf("select failed"); exit(1); } ret = SQLFetch(hstmt); if (ret != SQL_SUCCESS) { printf("SQLFetch failed\n"); exit(1); } ret = SQLGetData(hstmt, 2, SQL_C_CHAR, buf, sizeof(buf), NULL); if (!SQL_SUCCEEDED(ret)) { printf("SQLGetData failed"); exit(1); } printf("%s\n",buf); return 0; }

view thread (5+ messages)  latest in thread

Message-ID: <5147130A.7090802@vmware.com>
Permalink:  ../5147130A.7090802@vmware.com/
Also on:    postgresql.org/message-id/5147130A.7090802@vmware.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: hlinnakangas@vmware.com, neembi@gmail.com
  Subject: Re: Bug: attributes dynamically filled (e.g. xml) truncated
  In-Reply-To: <5147130A.7090802@vmware.com>
  References: <CA+pT-SVEPjaWk3k5TYu6CKFzZ6q71ZFus1qoL7+Hbspx=tHGBA@mail.gmail.com> <5147130A.7090802@vmware.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox