From: Heikki Linnakangas <hlinnaka@iki.fi>
To: PSequel Support <support@psequel.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Bug in the SQLGetDiagRec function of psqlodbc
Date: Fri, 18 Sep 2015 09:32:58 +0300
Message-ID: <55FBB01A.1070004@iki.fi> (raw)
In-Reply-To: <CABqkTWTBFTy1jXXCp5Ly1+eOPyUufd2krQe8T0ya=EWN9dZ4PQ@mail.gmail.com>
References: <CABqkTWTt-rWuOndACMk9tabjT9=dJLFE+sngv_AjzikZXmSiPQ@mail.gmail.com>
<55F9625D.6040001@iki.fi>
<CABqkTWTBFTy1jXXCp5Ly1+eOPyUufd2krQe8T0ya=EWN9dZ4PQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>
On 09/18/2015 08:13 AM, PSequel Support wrote:
> Thanks for your reply! Actually I've tried calling SQLFreeStmt after each
> query, but it doesn't seem to change anything. See the example code below.
>
> #include <stdio.h>#include <sql.h>#include <sqlext.h>
> void printError(SQLHANDLE handle) {
> char message[256];
> SQLSMALLINT i = 0;
> while (SQLGetDiagRec(SQL_HANDLE_DBC, handle, ++i, NULL, NULL,
> (SQLCHAR*)message, sizeof(message), NULL) != SQL_NO_DATA) {
> printf("%s\n", message);
> }}
> ...
Oh, you're getting the diagnostic from the *connection* handle, not the
statement handle. According to the documentation of SQLExecDirect(), it
sets the diagnostics on the statement handle.
I agree that psqlODBC's behaviour here is pretty strange, and probably
incorrect. I wouldn't expect SQLExecDirect to set any diagnostics on the
connection handle, at least for a syntax error. But if it does, the
second call probably should do so as well, and overwrite the previous
error message.
But the immediate fix for your application would be to get the
diagnostics from the statement handle instead of the connection handle.
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
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: hlinnaka@iki.fi, support@psequel.com
Subject: Re: Bug in the SQLGetDiagRec function of psqlodbc
In-Reply-To: <55FBB01A.1070004@iki.fi>
References: <CABqkTWTt-rWuOndACMk9tabjT9=dJLFE+sngv_AjzikZXmSiPQ@mail.gmail.com> <55F9625D.6040001@iki.fi> <CABqkTWTBFTy1jXXCp5Ly1+eOPyUufd2krQe8T0ya=EWN9dZ4PQ@mail.gmail.com> <55FBB01A.1070004@iki.fi>
* 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