Re: libpq object hooks - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: libpq object hooks
Date
Msg-id 20080514043313.GS6966@alvh.no-ip.org
Whole thread Raw
In response to Re: libpq object hooks  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: libpq object hooks  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
Andrew Dunstan escribió:

> The thing that is a bit disturbing is that the whole style of this
> scheme is very different from the fairly simple APIs that the rest of
> libpq presents. It's going to make libpq look rather odd, I think. I
> would have felt happier if the authors had been able to come up with a
> simple scheme to add API calls to export whatever information they
> needed, rather than using this callback scheme.

I'm not sure I understand this point.  Remember that this is here to
support the libpqtypes library.  There doesn't seem to be a way for an
API such as you describe to work.

> Second, the hook names are compared case insensitively and by linear
> search. I don't see any justification for using case insensitive names
> for hooks in a C program, so I think that part should go. And if we
> expect to keep anything other than trivial numbers of hooks we should
> look at some sort of binary or hashed search.

Keep in mind that the original patch supported a single hook being
registered.  Perhaps we could dream about having a couple of hooks
registered, but turning into hashed search would seem to be overkill, at
least for now.  (If hooking into libpq is truly successful we can always
improve it later -- it's not an exported detail of the API after all.)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: libpq object hooks
Next
From: Magnus Hagander
Date:
Subject: Re: stored procedure stats in collector