Re: [GENERAL] Notify argument?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Notify argument?
Date: 2002-04-15 00:24:30
Message-ID: 200204150024.g3F0OU327803@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


Here is a patch that implements Tom's suggestion of mallocing the
relation name string as part of PQnotify and not depending on
NAMEDATALEN. Nice trick.

---------------------------------------------------------------------------

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > The breakage will come when we lengthen NAMEDATALEN, which I plan to
> > tackle for 7.3. We will need to re-order the NOTIFY structure and put
> > the NAMEDATALEN string at the end of the struct so differing namedatalen
> > backend/clients will work. If you want to break it, 7.3 would probably
> > be the time to do it. :-) Users will need a recompile pre-7.3 to use
> > notify for 7.3 and later anyway.
>
> If we're going to change the structure anyway, let's fix it to be
> independent of NAMEDATALEN. Instead of
>
> char relname[NAMEDATALEN];
> int be_pid;
>
> let's do
>
> char *relname;
> int be_pid;
>
> This should require no source-level changes in calling C code, thanks
> to C's equivalence between pointers and arrays. We can preserve the
> fact that freeing a PQnotifies result takes only one free() with a
> little hacking to make the string be allocated in the same malloc call:
>
> newNotify = (PGnotify *) malloc(sizeof(PGnotify) + strlen(str) + 1);
> newNotify->relname = (char *) newNotify + sizeof(PGnotify);
> strcpy(newNotify->relname, str);
>
> Thus, with one line of extra ugliness inside the library, we solve the
> problem permanently.
>
> regards, tom lane
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Attachment Content-Type Size
unknown_filename text/plain 2.0 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Geoff Russell 2002-04-15 01:05:32 Re: plpgsql temporary table problem
Previous Message Sean Chittenden 2002-04-14 21:09:19 OT: Re: Scaling postgres

Browse pgsql-hackers by date

  From Date Subject
Next Message Brian Bruns 2002-04-15 00:38:48 Re: 7.3 schedule
Previous Message John Gray 2002-04-14 23:08:26 Re: command.c breakup