pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ODBC - Retrieving info messages - RAISE NOTICE
3+ messages / 3 participants
[nested] [flat]

* ODBC - Retrieving info messages - RAISE NOTICE
@ 2018-02-01 16:45 Wolfgang Apolinarski <wolfgang.apolinarski@googlemail.com>
  2018-02-10 10:18 ` Re: ODBC - Retrieving info messages - RAISE NOTICE Clemens Ladisch <clemens@ladisch.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Wolfgang Apolinarski @ 2018-02-01 16:45 UTC (permalink / raw)
  To: pgsql-odbc

Hi,

When executing a PL/pgsql query using powershell with ODBC (yes, a somehow special setup), it is possible to register to the event "InfoMessage" (with Register-ObjectEvent) to retrieve all messages that are created for example by using "RAISE NOTICE".
While this works fine when using MS SQL and the SqlConnection (all print statements are retrieved), it does not work with Postgres and the OdbcConnection, here, only the last message ("3") is retrieved, when a statement like
DO $$
RAISE NOTICE '1';
RAISE NOTICE '2';
RAISE NOTICE '3';
END$$;
is executed.

Maybe this is a general constraint when using ODBC, but maybe I am doing something terribly wrong (other than using powershell with Postgresql).

Best regards,
Wolfgang





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: ODBC - Retrieving info messages - RAISE NOTICE
  2018-02-01 16:45 ODBC - Retrieving info messages - RAISE NOTICE Wolfgang Apolinarski <wolfgang.apolinarski@googlemail.com>
@ 2018-02-10 10:18 ` Clemens Ladisch <clemens@ladisch.de>
  2018-02-13 22:17   ` Re: ODBC - Retrieving info messages - RAISE NOTICE Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 3+ messages in thread

From: Clemens Ladisch @ 2018-02-10 10:18 UTC (permalink / raw)
  To: pgsql-odbc

Wolfgang Apolinarski wrote:
> only the last message ("3") is retrieved, when a statement like
> DO $$
> RAISE NOTICE '1';
> RAISE NOTICE '2';
> RAISE NOTICE '3';
> END$$;
> is executed.

When receiving a notice from libpq, the driver calls QR_set_notice(),
which replaces any previous notice.  To get all notices separated with
a semicolon, try using QR_add_notice() instead (see the patch below).

> Maybe this is a general constraint when using ODBC

In theory, the ODBC API (SQLGetDiagRec) would allow any number of
messages.


Regards,
Clemens


inline patch 1: psqlodbc/connection.c (+1/-1 lines) download inline-1.patch--- psqlodbc.orig/connection.c +++ psqlodbc/connection.c @@ -894,7 +894,7 @@ handle_pgres_error(ConnectionClass *self { if (QR_command_successful(res)) QR_set_rstatus(res, PORES_NONFATAL_ERROR); /* notice or warning */ - QR_set_notice(res, errmsg); /* will dup this string */ + QR_add_notice(res, errmsg); /* will dup this string */ } goto cleanup; }
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: ODBC - Retrieving info messages - RAISE NOTICE
  2018-02-01 16:45 ODBC - Retrieving info messages - RAISE NOTICE Wolfgang Apolinarski <wolfgang.apolinarski@googlemail.com>
  2018-02-10 10:18 ` Re: ODBC - Retrieving info messages - RAISE NOTICE Clemens Ladisch <clemens@ladisch.de>
@ 2018-02-13 22:17   ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 0 replies; 3+ messages in thread

From: Inoue, Hiroshi @ 2018-02-13 22:17 UTC (permalink / raw)
  To: Clemens Ladisch <clemens@ladisch.de>; wolfgang.apolinarski@googlemail.com; +Cc: pgsql-odbc

Hi,

On 2018/02/10 19:18, Clemens Ladisch wrote:
> Wolfgang Apolinarski wrote:
>> only the last message ("3") is retrieved, when a statement like
>> DO $$
>> RAISE NOTICE '1';
>> RAISE NOTICE '2';
>> RAISE NOTICE '3';
>> END$$;
>> is executed.
> When receiving a notice from libpq, the driver calls QR_set_notice(),
> which replaces any previous notice.  To get all notices separated with
> a semicolon, try using QR_add_notice() instead (see the patch below).

I would take care of the patch.

Thanks.
Hiroshi Inoue

>
>> Maybe this is a general constraint when using ODBC
> In theory, the ODBC API (SQLGetDiagRec) would allow any number of
> messages.
>
>
> Regards,
> Clemens
>
>
> --- psqlodbc.orig/connection.c
> +++ psqlodbc/connection.c
> @@ -894,7 +894,7 @@ handle_pgres_error(ConnectionClass *self
>   		{
>   			if (QR_command_successful(res))
>   				QR_set_rstatus(res, PORES_NONFATAL_ERROR); /* notice or warning */
> -			QR_set_notice(res, errmsg);  /* will dup this string */
> +			QR_add_notice(res, errmsg);  /* will dup this string */
>   		}
>   		goto cleanup;
>   	}




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-02-13 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 16:45 ODBC - Retrieving info messages - RAISE NOTICE Wolfgang Apolinarski <wolfgang.apolinarski@googlemail.com>
2018-02-10 10:18 ` Clemens Ladisch <clemens@ladisch.de>
2018-02-13 22:17   ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>

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