Re: SQLExecDirectW returns SQL_SUCCESS even if sql finishes witherror

Поиск
Список
Период
Сортировка
От Inoue, Hiroshi
Тема Re: SQLExecDirectW returns SQL_SUCCESS even if sql finishes witherror
Дата
Msg-id 021b26ab-47ab-a282-72ca-d770d8573dd7@dream.email.ne.jp
обсуждение исходный текст
Ответ на SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error  ("Takahashi, Ryohei" <r.takahashi_2@jp.fujitsu.com>)
Ответы RE: SQLExecDirectW returns SQL_SUCCESS even if sql finishes witherror  ("Takahashi, Ryohei" <r.takahashi_2@jp.fujitsu.com>)
Список 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


В списке pgsql-odbc по дате отправления:

Предыдущее
От: "Takahashi, Ryohei"
Дата:
Сообщение: SQLExecDirectW returns SQL_SUCCESS even if sql finishes with error
Следующее
От: Leonardo De La Cerda
Дата:
Сообщение: Problem compiling in mac os with unix odbc