Re: ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001 Already connected."

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Hong06' <honghe06(at)gmail(dot)com>, "pgsql-odbc(at)postgresql(dot)org" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001 Already connected."
Date: 2016-10-03 03:19:48
Message-ID: 0A3221C70F24FB45833433255569204D1F5F4C46@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hello,

Looking at the code, That seems to be a psqlODBC's bug. psqlODBC tries to execute "SET SESSION ... ISOLATION LEVEL ..." upon the call to SQLSetSetConnectAttr(), which fails because the connection is not established yet. The driver should run the SET query after establishing the connection. FYI, even though SQLSetConnectAttr() for other isolation levels returns SQL_SUCCESS, it doesn't set the isolation level correctly.

The workaround is to call SQLSetConnectAttr() after SQLDriverConnect(). Anyway, I'll consider fixing the bug.

Regards
Takayuki Tsunakawa

> -----Original Message-----
> From: pgsql-odbc-owner(at)postgresql(dot)org
> [mailto:pgsql-odbc-owner(at)postgresql(dot)org] On Behalf Of Hong06
> Sent: Friday, September 30, 2016 10:41 PM
> To: pgsql-odbc(at)postgresql(dot)org
> Subject: [ODBC] ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001
> Already connected."
>
> Hello everyone,
>
> I just ran into following issue with a big surprise that it does not work
> in ODBC.
>
> What I am doing is:
> - set the isolation level to: SQL_TXN_SERIALIZABLE
> - then connect to postgres database via ODBC function SQLDriverConnect()
>
> Example code:
>
> ret = SQLSetConnectAttr(hDbc, SQL_ATTR_TXN_ISOLATION,
> (SQLPOINTER)SQL_TXN_SERIALIZABLE, SQL_IS_INTEGER);
>
> ret = SQLDriverConnect(hConnect,
> 0,
> (SQLCHAR*)connString,
> ustrlen((unsigned char *)connString),
> NULL,
> 0,
> NULL,
> SQL_DRIVER_NOPROMPT);
>
> Then SQLDriverConnect() returns -1 with error code: "08001 Already
> connected."
>
> With other isolation level like SQL_TXN_READ_COMMITTED, it works fine.
>
> Any idea to solve this problem? Or is this a Postgres ODBC bug? I couldn't
> find anything here or on Google.

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Hong06 2016-10-03 09:04:52 Re: ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001 Already connected."
Previous Message Hong06 2016-09-30 13:41:26 ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001 Already connected."