SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error

From: "Takahashi, Ryohei" <r(dot)takahashi_2(at)jp(dot)fujitsu(dot)com>
To: "'pgsql-odbc(at)postgresql(dot)org'" <pgsql-odbc(at)postgresql(dot)org>
Subject: SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error
Date: 2018-10-31 07:53:02
Message-ID: EE586BE92A4AFB45B03310C2A0C0565D6D0EFC17@G01JPEXMBKW03
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi,

I have a problem in psqlODBC.

SQLExecDirectW() returns SQL_SUCCESS even if sql finishes with error when client_min_messages = fatal.
It works correctly when client_min_messages = error.

I think the cause is following.

connection.c
CC_send_query_append()

...
while (self->pqconn && (pgres = PQgetResult(self->pqconn)) != NULL) // (1)
{
int status = PQresultStatus(pgres); // (2)

if (discardTheRest)
continue;
switch (status)
{
...
case PGRES_BAD_RESPONSE:
case PGRES_FATAL_ERROR:
handle_pgres_error(self, pgres, "send_query", res, TRUE); // (3)
...

When client_min_messages = error and sql finishes with error,
PostgreSQL server sends 'E' message to the client.
(https://www.postgresql.org/docs/11/static/protocol-message-formats.html)

In this case, PQgetResult() returns non-NULL in (1) and PQresultStatus() returns PGRES_FATAL_ERROR in (2).
Then, handle_pgres_error() is called in (3) and finally SQLExecDirectW() returns SQL_ERROR.

However, when client_min_messages = fatal and sql finishes with error,
PostgreSQL server sends only 'Z' message to the client.

In this case, PQgetResult() returns NULL in (1) and handle_pgres_error() is never called in (3).
Then, SQLExecDirectW() returns SQL_SUCCESS.

Is this right?

Regards,
Ryohei Takahashi

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Inoue, Hiroshi 2018-10-31 08:54:15 Re: SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error
Previous Message Laurenz Albe 2018-10-31 07:00:21 Re: Fwd: Log file