Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WIaDl-0006nN-L6 for pgsql-odbc@arkaria.postgresql.org; Wed, 26 Feb 2014 08:52:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WIaDl-0007y0-53 for pgsql-odbc@arkaria.postgresql.org; Wed, 26 Feb 2014 08:52:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WIaDk-0007xu-LF for pgsql-odbc@postgresql.org; Wed, 26 Feb 2014 08:52:04 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WIaDf-0005kn-6n for pgsql-odbc@postgresql.org; Wed, 26 Feb 2014 08:52:03 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 8B13A287E7; Wed, 26 Feb 2014 00:51:55 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 74FE418257; Wed, 26 Feb 2014 00:51:55 -0800 (PST) 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 010C3120032; Wed, 26 Feb 2014 00:51:53 -0800 (PST) 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; Wed, 26 Feb 2014 00:51:52 -0800 (PST) Message-ID: <530DAB26.9000907@vmware.com> Date: Wed, 26 Feb 2014 10:51:50 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: "Inoue, Hiroshi" 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> <530D4139.7090707@tpf.co.jp> In-Reply-To: <530D4139.7090707@tpf.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.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 On 02/26/2014 03:19 AM, Inoue, Hiroshi wrote: > (2014/02/26 1:56), Heikki Linnakangas wrote: >> 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? SQL_C_xxx is a Microsoft-only extension, so it's not guaranteed to work with all SQL/CLI implementations. In practice, unixODBC defines SQL_C_xxx too, so in practice an application using them will work. I think you're advocating for this: SQLINTEGER lEmpID; ... SQLBindCol(hStmt, 1, SQL_C_LONG, (SQLPOINTER) &lEmpID, sizeof(SQLINTEGER), &pIndicators[0]); From a readability point of view, IMHO that's just bizarre. The SQLBindCall call is claiming to the driver that the variable is of type "long", by specifying SQL_C_LONG. But in reality, the variable is of type SQLINTEGER. You can argue that SQL_C_LONG doesn't mean that the variable is of type "long", but "SQLINTEGER", but that's just bizarre. The name SQL_C_LONG very clearly says "long", just like SQL_C_SHORT says "short". It works on Windows, because sizeof(long) == sizeof(SQLINTEGER) on Windows, and it works with unixODBC because unixODBC defines SQL_C_LONG as 32-bits regardless of the actual width of "long". But it's not a good way to write an application. Why use the ODBC extension SQL_C_LONG instead of the SQL_INTEGER type code specified by SQL/CLI? SQL_INTEGER is more clear, and as a bonus, it also complies with SQL/CLI. So while the combination of SQL_C_LONG type code and SQLINTEGER variable works, I would not recommend that. The SQL_INTEGER type code and SQLINTEGER variable combination is more clear. > 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. ODBC is a superset of SQL/CLI [1]. An application written for SQL/CLI works with ODBC libraries and drivers. But not the other way round; an application that's written to the ODBC spec does not necessarily work with other SQL/CLI implementations. The driver already works with both ODBC and SQL/CLI, so there's no need to start a new project for that. Of course, if you don't care about portability of your application, you can write it relying purely on ODBC, and use SQL_C_LONG type code and "long" variables. But if you want to maximize portability, you should stick to the SQL/CLI spec and use SQL_INTEGER type code and SQLINTEGER variables. > > 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. That is not an accident. The ODBC specification is a superset of the SQL/CLI specification. An application written for the SQL/CLI specification also works with ODBC, so for maximum portability you should use the SQL/CLI type codes (SQL_INTEGER etc.). [1] http://msdn.microsoft.com/en-us/library/ms712622%28v=vs.85%29.aspx - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc