Re: Avoid circular header file dependency

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid circular header file dependency
Date: 2025-04-26 18:55:51
Message-ID: 95208.1745693751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> writes:
> On Sat, Apr 26, 2025 at 01:20:56AM -0400, Tom Lane wrote:
>> Whatever it contains, we need to kill it with fire before the problem
>> metastasizes like it did the last time. (yeah, yeah, badly mixed
>> metaphors) I can take a look at this one over the weekend if nobody
>> beats me to it.

> I had a look at it, what do you think about 0002 attached? (Not 100% sure
> that's the best approach though).

After looking at this, I think the actual problem is that plpython.h
does this:

/*
* Used throughout, so it's easier to just include it everywhere.
*/
#include "plpy_util.h"

which is exactly the sort of cowboy modularity violation that hurts
when you have to clean it up. Taking that out requires having to
manually include plpy_util.h in all the relevant .c files, but on
the other hand we can remove their vestigial direct inclusions of
plpython.h. It was always pretty silly to #include that after
including some plpy_foo.h files, so let's stop doing so. The attached
patch therefore boils down in most places to s/plpython.h/plpy_util.h/.

(A small number of these files still compiled without that, indicating
that they're not actually using plpy_util.h today. But I figured we
might as well just do it uniformly.)

regards, tom lane

Attachment Content-Type Size
v2-dont-include-plpy_util.h-in-plpython.h.patch text/x-diff 6.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-04-26 18:57:27 Re: [BUG] temporary file usage report with extended protocol and unnamed portals
Previous Message Amit Kapila 2025-04-26 12:07:38 Re: Fix slot synchronization with two_phase decoding enabled