Re: Clarify planner_hook calling convention

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrey V(dot) Lepikhov" <a(dot)lepikhov(at)postgrespro(dot)ru>
Cc: PostgreSQL-Dev <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clarify planner_hook calling convention
Date: 2022-01-03 15:59:46
Message-ID: 3560243.1641225586@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Andrey V. Lepikhov" <a(dot)lepikhov(at)postgrespro(dot)ru> writes:
> planner hook is frequently used in monitoring and advising extensions.

Yeah.

> The call to this hook is implemented in the way, that the
> standard_planner routine must be called at least once in the hook's call
> chain.
> But, as I see in [1], it should allow us "... replace the planner
> altogether".
> In such situation it haven't sense to call standard_planner at all.

That's possible in theory, but who's going to do it in practice?
There is a monstrous amount of code you'd have to replace.
Moreover, if you felt compelled to do it, it's likely because you
are making fundamental changes elsewhere too, which means you are
more likely going to end up with a fork not an extension.

> But, maybe more simple solution is to describe requirements to such kind
> of extensions in the code and documentation (See patch in attachment)?
> + * 2. If your extension implements some planning activity, write in the extension
> + * docs a requirement to set the extension at the begining of shared libraries list.

This advice seems pretty unhelpful. If more than one extension is
getting into the planner_hook, they can't all be first.

(Also, largely the same issue applies to very many of our other
hooks.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gunnar "Nick" Bluth 2022-01-03 16:00:45 Re: [PATCH] pg_stat_toast v0.4
Previous Message Nikhil Benesch 2022-01-03 15:57:47 Re: Remove inconsistent quotes from date_part error