Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WITAT-0000bT-2K for pgsql-odbc@arkaria.postgresql.org; Wed, 26 Feb 2014 01:20:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WITAS-0002Vp-Ie for pgsql-odbc@arkaria.postgresql.org; Wed, 26 Feb 2014 01:20:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WITAS-0002VY-1b for pgsql-odbc@postgresql.org; Wed, 26 Feb 2014 01:20:12 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WITAN-00065G-0D for pgsql-odbc@postgresql.org; Wed, 26 Feb 2014 01:20:11 +0000 Received: (qmail 4796 invoked by uid 512); 26 Feb 2014 01:20:02 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.126.1.62) by sd2.tpf-fw-c.co.jp with SMTP; 26 Feb 2014 01:20:02 -0000 Message-ID: <530D4139.7090707@tpf.co.jp> Date: Wed, 26 Feb 2014 10:19:53 +0900 From: "Inoue, Hiroshi" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Heikki Linnakangas CC: Christoph Berg , PostgreSQL ODBC , psqlodbc@packages.debian.org Subject: Re: 09.03.0100 cursor failures on various architectures References: <20140212104524.GA4409@msgid.credativ.de> <52FE1220.9050205@vmware.com> <530C177F.2030906@tpf.co.jp> <530C78F7.5050304@vmware.com> <530CB308.6030507@tpf.co.jp> <530CCB30.8090606@vmware.com> In-Reply-To: <530CCB30.8090606@vmware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 (2014/02/26 1:56), Heikki Linnakangas wrote: > On 02/25/2014 05:13 PM, Hiroshi Inoue wrote: >>> >1. Most applications are written with the assumption that SQL_C_LONG >>> >means the native C data type "long". That's clearly what SQL_C_LONG was >>> >supposed to mean when the ODBC specification was written, and that's >>> >what Microsoft's sample code does. >>> > >>> >2. That's*not* how psqlODBC or unixODBC interprets it. With unixODBC, >>> >you should use the C data type "SQLINTEGER" with SQL_C_LONG. >>> > >>> >3. For maximum portability, an application should avoid using SQL_C_xx. >>> >Instead, always use SQL_INTEGER or SQL_BIGINT, with an SQLINTEGER or >>> >SQLBIGINT variable, and cast to native C types. >>> > >>> >We should document this somewhere, like in the FAQ.. >> Unfortunately I'm not happy with your summary. >> >> My point is simple. >> Use ODBC data type variables instead of native C data ones when calling >> ODBC APIs. > > Hmm, isn't that the same as my point 3? > > I was thinking of something like below for the docs: > > ---- > Don't use SQL_C_xxx. They are not part of the SQL/CLI specification, and > hence not reliably portable across platforms. Why does using SQL_C_XXXX lose portablity? Even though SQL/CLI is a standard, ODBC also has been a (defact?) standard which is older than CLI and widely used. They are different standard. We should begin a project e.g. pgsqlcli when we are to stop using SQL_C_XXXX. > Instead, use the ODBC > variable data types, like SQLINTEGER and SQLBIGINT, and the > corresponding type codes (e.g. SQL_INTEGER and SQL_BIGINT). > > For example, the following code is not portable: > > long empID; > ... > SQLBindCol(stmt, 1, SQL_C_LONG, (SQLPOINTER) &empID, > sizeof(long), &indicator); > > Instead, do this: > > SQLINTEGER empID; > ... > SQLBindCol(stmt, 1, SQL_INTEGER, (SQLPOINTER) &empID, > sizeof(SQLINTEGER), &indicator); Though the code works well, the code is wrong as an ODBC application in principle. The code works as expected simply because SQL_INTEGER has the same value as SQL_C_LONG has fortunately. > And if necessary, cast to the C type: > > long lEmpID = (long) empID; > > > SQL_C_LONG, SQL_C_SLONG and SQL_C_ULONG in particular are known to be a > problem, I see no problem except the naming which should have been SQL_C_INTEGER. regards, Hiroshi Inoue -- I am using the free version of SPAMfighter. SPAMfighter has removed 5330 of my spam emails to date. Get the free SPAMfighter here: http://www.spamfighter.com/len Do you have a slow PC? Try a Free scan http://www.spamfighter.com/SLOW-PCfighter?cid=sigen -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc