process "RAISE INFO" via zeoslib

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
iteh
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 22.07.2023, 04:26

process "RAISE INFO" via zeoslib

Post by iteh »

(I use google translate for english, sorry :) )

I want to "catch" RAISE INFO messages from a PostgreSQL 9.6 server (for example, get two RAISE with a level below EXCEPTION after ExecSQL for the query "DO $$ BEGIN RAISE NOTICE 'test1, notice'; RAISE WARNING 'test2, warning'; END $$;")

as I understand it, now (zeoslib r8046) in the dbcZDbcPostgreSql.pas file in TZPostgreSQLConnection.AfterConstruction for FNoticeProcessor the NoticeProcessorDispatcher is set statically, then TZPostgreSQLConnection(..).HandleErrorOrWarning is called from it, but HandleErrorOrWarning checks FPlainDriver.PQerrorMessage(..) and catches only "RAISE EXCEPTION", and RAISE INFO/NOTICE/WARNING does not catch.

the documentation https://postgrespro.ru/docs/postgresql/ ... ng?lang=en says that in the libpq library I can call PQsetNoticeProcessor and specify my handler through it, and such a function (PQsetNoticeProcessor) is in zeoslib (for example, for ZConnection.AfterConnect we can refer to IZPostgreSQLConnection(ZConnection.DbcConnection).GetPlainDriver.PQsetNoticeProcessor ), but how to use it correctly in lazarus 2.2.6 with the latest version of zeoslib, can you show a working example?
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: process "RAISE INFO" via zeoslib

Post by marsupilami »

Hello iteh,

with current Zeos it simply isn't possible to use that mechanism. For me that clearly is a bug. You might want to check into doing your own notice processor or notice dispatcher. Simply replacing Zeos notice dispatcher and notice processor shouldn't do any harm.

With best regards,

Jan
Post Reply