Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHZt5-0004IK-GJ for pgsql-odbc@arkaria.postgresql.org; Mon, 18 Mar 2013 13:14:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UHZt5-00058c-00 for pgsql-odbc@arkaria.postgresql.org; Mon, 18 Mar 2013 13:14:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHZt3-00057X-O5 for pgsql-odbc@postgresql.org; Mon, 18 Mar 2013 13:14:02 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHZst-0005Jq-L0 for pgsql-odbc@postgresql.org; Mon, 18 Mar 2013 13:14:01 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 7809F28243; Mon, 18 Mar 2013 06:13:50 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 6B17DB06D8; Mon, 18 Mar 2013 06:13:50 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id ED8161219C9; Mon, 18 Mar 2013 06:17:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PG0ge-mQpc9u; Mon, 18 Mar 2013 06:17:39 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id C419312199A; Mon, 18 Mar 2013 06:17:39 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Mon, 18 Mar 2013 06:17:38 -0700 (PDT) Message-ID: <5147130A.7090802@vmware.com> Date: Mon, 18 Mar 2013 15:13:46 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Ben Morgan CC: pgsql-odbc@postgresql.org Subject: Re: Bug: attributes dynamically filled (e.g. xml) truncated References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------000601050700030801090301" X-Pg-Spam-Score: -9.4 (---------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multi-part message in MIME format. --------------000601050700030801090301 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > > 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. 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 --------------000601050700030801090301 Content-Type: text/x-csrc; name="select-test.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="select-test.c" #include #include #include #include #include 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; } --------------000601050700030801090301 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc --------------000601050700030801090301--