Re: Example 31-2. libpq Example Program 2

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Niko Ware <nikowareinc(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Example 31-2. libpq Example Program 2
Date: 2021-03-11 06:39:52
Message-ID: CAKFQuwYa6gYU+x6Nhkt_u+718B_FQ5asxEFziruC0GBf2m+M6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, March 10, 2021, Niko Ware <nikowareinc(at)gmail(dot)com> wrote:

>
>
> I modified the code to include the "extra" member in the following
> statement:
>
> fprintf(stderr,
> "ASYNC NOTIFY of '%s' received from backend PID %d:
> %s\n",
> notify->relname, notify->be_pid, *notify->extra*);
>
> I was unable to locate any example of how to retrieve the payload in C.
>
>
Since psql does it correctly that is a good place to find code.

https://github.com/postgres/postgres/blob/3f0daeb02f8dd605f89de9aa2349137c09cc7fb4/src/bin/psql/common.c#L689

Yes, your modification should work. Looking at the history that extra
field is 18 years old. I’m not in a position to confirm whether or not this
is somehow broken on head but has gone undiscovered, but it seems
unlikely. Only advice I can think of besides waiting for a more
experienced hacker is to check the relevant header files and
breakpoint/trace the code and see what “notify” actually looks like. Or
start from scratch on a clean setup and try again confirming you have
checked out master/head from the official repository.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Anderson 2021-03-11 07:43:19 Re: WAL-files is not removing authomaticaly
Previous Message Niko Ware 2021-03-11 05:25:38 Example 31-2. libpq Example Program 2