Re: SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error

From: "Inoue, Hiroshi" <h-inoue(at)dream(dot)email(dot)ne(dot)jp>
To: "Takahashi, Ryohei" <r(dot)takahashi_2(at)jp(dot)fujitsu(dot)com>
Cc: "'pgsql-odbc(at)postgresql(dot)org'" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error
Date: 2018-10-31 08:54:15
Message-ID: 021b26ab-47ab-a282-72ca-d770d8573dd7@dream.email.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi Takahashi-san,

Thanks for the report.

On 2018/10/31 16:53, Takahashi, Ryohei wrote:
> 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.

Why do you set client_min_messages to fatal in the first place?

regards,
Hiroshi Inoue

>
> 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

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Adrian Klaver 2018-10-31 12:51:55 Re: Fwd: Log file
Previous Message Takahashi, Ryohei 2018-10-31 07:53:02 SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error