Re: The ultimate extension hook.

From: Daniel Wood <hexexpert(at)comcast(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: The ultimate extension hook.
Date: 2020-09-24 05:40:52
Message-ID: 474049858.67831.1600926053256@connect.xfinity.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On 09/23/2020 9:26 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> ...
> > The hook I'd like to see would be in the PostgresMain() loop
> > for the API "firstchar" messages.
>
> What, to invent your own protocol? Where will you find client libraries
> buying into that?

No API/client changes are needed for:
1) API tracing/filtering; or
3) custom SQL like commands through a trivial modification to Simple Query 'Q'. Purely optional as you'll see at the end.

Yes, (2) API extension "case 'A'" could be used to roll ones own protocol. When pondering API hooking, in general, I thought of this also but don't let it be a distraction.

> I'm not really convinced that any of the specific use-cases you suggest
> are untenable to approach via the existing function fastpath mechanism,
> anyway.

Certainly (3) is just a command level way to execute a function instead of 'select myfunc()'. But it does go through the SQL machinery and SQL argument type lookup and processing. I like fast and direct things. And (3) is so trivial to implement.

However, even fastpath doesn't provide a protocol hook function where tracing could be done. If I had that alone I could do my own 'Q' hook and do the "!cmd" processing in my extension even if I sold the idea just based on tracing/filtering.

We hook all kinds of things in PG. Think big. Why should the protocol processing not have a hook? I'll bet some others will think of things I haven't even yet thought of that would leverage this.

- Dan Wood

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hou, Zhijie 2020-09-24 05:45:33 A little enhancement for hashdisk testset
Previous Message Amit Langote 2020-09-24 05:26:04 Re: problem with RETURNING and update row movement