pgsql: Remove circular #include's between plpython.h and plpy_util.h.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove circular #include's between plpython.h and plpy_util.h.
Date: 2025-04-27 15:43:10
Message-ID: E1u949t-0023IV-3C@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove circular #include's between plpython.h and plpy_util.h.

plpython.h included plpy_util.h, simply on the grounds that "it's
easier to just include it everywhere". However, plpy_util.h must
include plpython.h, or it won't pass headerscheck. While the
resulting circularity doesn't have any immediate bad effect,
it's poor design. We have seen serious messes arise in the past
from overly-broad inclusion footprints created by such circularities,
so let's establish a project policy against it.

To fix, just replace *.c files' inclusions of plpython.h with
plpy_util.h. They'll pull in plpython.h indirectly; indeed, almost
all have already done so via inclusions of other plpy_xxx.h headers.
(Any extensions using plpython.h can do likewise without breaking
the compatibility of their code with prior Postgres versions.)

Reported-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/aAxQ6fcY5QQV1lo3@ip-10-97-1-34.eu-west-3.compute.internal

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2311f193ea7db23f68f5471ae2c35940fc0d4794

Modified Files
--------------
contrib/hstore_plpython/hstore_plpython.c | 2 +-
contrib/jsonb_plpython/jsonb_plpython.c | 2 +-
contrib/ltree_plpython/ltree_plpython.c | 2 +-
src/pl/plpython/plpy_cursorobject.c | 2 +-
src/pl/plpython/plpy_elog.c | 2 +-
src/pl/plpython/plpy_exec.c | 2 +-
src/pl/plpython/plpy_main.c | 2 +-
src/pl/plpython/plpy_planobject.c | 2 +-
src/pl/plpython/plpy_plpymodule.c | 2 +-
src/pl/plpython/plpy_procedure.c | 2 +-
src/pl/plpython/plpy_resultobject.c | 2 +-
src/pl/plpython/plpy_spi.c | 2 +-
src/pl/plpython/plpy_subxactobject.c | 2 +-
src/pl/plpython/plpy_typeio.c | 2 +-
src/pl/plpython/plpy_util.c | 1 -
src/pl/plpython/plpython.h | 9 ++++-----
16 files changed, 18 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2025-04-27 15:50:02 Re: clang-tidy complaints
Previous Message Bertrand Drouvot 2025-04-27 08:25:53 Re: clang-tidy complaints