pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Redundant headers in pg_stat_statements
3+ messages / 3 participants
[nested] [flat]

* Redundant headers in pg_stat_statements
@ 2026-09-14 11:14  m.litsarev@postgrespro.ru
  0 siblings, 2 replies; 3+ messages in thread

From: m.litsarev@postgrespro.ru @ 2026-09-14 11:14 UTC (permalink / raw)
  To: pgsql-hackers@lists.postgresql.org

Hi, hackers!

I accidentially found that some headers in pg_stat_statements are 
redundant.
A small patch with removed headers is attached.

Kind regards,
Postgres Professional: http://www.postgrespro.com

Attachments:

v1-0001-Remove-redundant-headers-in-pg_stat_statements.patch (text/x-diff, 1.1K) download From eb03b2d2af0fe7986c23eecd991e2f06fb5867ec Mon Sep 17 00:00:00 2001 From: Mikhail Litsarev <m.litsarev@postgrespro.ru> Date: Mon, 14 Sep 2026 13:55:40 +0300 Subject: [PATCH v1] Remove redundant headers in pg_stat_statements --- contrib/pg_stat_statements/pg_stat_statements.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 4562222c9fc..f85c0f9bb76 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -50,12 +50,9 @@ #include "access/htup_details.h" #include "access/parallel.h" #include "catalog/pg_authid.h" -#include "executor/instrument.h" #include "funcapi.h" #include "jit/jit.h" #include "mb/pg_wchar.h" -#include "miscadmin.h" -#include "nodes/queryjumble.h" #include "optimizer/planner.h" #include "parser/analyze.h" #include "pgstat.h" @@ -67,7 +64,6 @@ #include "tcop/utility.h" #include "utils/acl.h" #include "utils/builtins.h" -#include "utils/memutils.h" #include "utils/timestamp.h" #include "utils/tuplestore.h" -- 2.34.1
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Redundant headers in pg_stat_statements
@ 2026-09-14 11:50  Vaibhav Dalvi <vaibhav.dalvi@enterprisedb.com>
  parent: m.litsarev@postgrespro.ru
  1 sibling, 0 replies; 3+ messages in thread

From: Vaibhav Dalvi @ 2026-09-14 11:50 UTC (permalink / raw)
  To: m.litsarev@postgrespro.ru; +Cc: pgsql-hackers@lists.postgresql.org

Hi,

I applied your patch and it compiles today.
However, three of the four removed headers are not actually unused. The
file still calls functions
declared in them directly, and only keeps compiling because some other
still-included header
happens to drag them back in transitively.

$ pwd
  pg20/contrib/pg_stat_statements
$ make clean
$ make > a.compile
$ make install > a.install
$ make installcheck
echo "# +++ regress install-check in contrib/pg_stat_statements +++" &&
../../src/test/regress/pg_regress --inputdir=.
--bindir='/home/vaibhav/work/workspace/pg/pg20/db/bin'    --temp-config
../../contrib/pg_stat_statements/pg_stat_statements.conf
--dbname=contrib_regression select dml cursors utility level_tracking
planning user_activity wal entry_timestamp privileges extended parallel
plancache squashing cleanup oldextversions
# +++ regress install-check in contrib/pg_stat_statements +++
# using postmaster on Unix socket, default port
ok 1         - select                                     78 ms
ok 2         - dml                                        20 ms
ok 3         - cursors                                    11 ms
ok 4         - utility                                    86 ms
ok 5         - level_tracking                             74 ms
ok 6         - planning                                    9 ms
ok 7         - user_activity                              11 ms
ok 8         - wal                                        10 ms
ok 9         - entry_timestamp                            11 ms
ok 10        - privileges                                 13 ms
ok 11        - extended                                   14 ms
ok 12        - parallel                                   15 ms
ok 13        - plancache                                  17 ms
ok 14        - squashing                                  52 ms
ok 15        - cleanup                                     6 ms
ok 16        - oldextversions                             59 ms
1..16
# All 16 tests passed.
echo "# +++ tap install-check in contrib/pg_stat_statements +++" && rm -rf
'/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements'/tmp_check
&& /usr/bin/mkdir -p
'/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements'/tmp_check
&& cd . &&
TESTLOGDIR='/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements/tmp_check/log'
TESTDATADIR='/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements/tmp_check'
PATH="/home/vaibhav/work/workspace/pg/pg20/db/bin:/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements:$PATH"
PGPORT='65520'
top_builddir='/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements/../..'
PG_REGRESS='/home/vaibhav/work/workspace/pg/pg20/contrib/pg_stat_statements/../../src/test/regress/pg_regress'
share_contrib_dir='/home/vaibhav/work/workspace/pg/pg20/db/share/postgresql/extension'
/usr/bin/prove -I ../../src/test/perl/ -I .  t/*.pl
# +++ tap install-check in contrib/pg_stat_statements +++
t/010_restart.pl .. ok
All tests successful.
Files=1, Tests=3,  2 wallclock secs ( 0.01 usr  0.00 sys +  0.68 cusr  0.10
csys =  0.79 CPU)
Result: PASS

*executor/instrument.h*
Still used directly in the file: BufferUsage, WalUsage, instr_time — used
as function params/locals in pgss_store() and the
ExecutorRun hook
Why it still compiles: Only because jit/jit.h (still included) includes it
for its own JitInstrumentation needs
────────────────────────────────────────
*miscadmin.h*
Still used directly in the file: IsParallelWorker(), IsUnderPostmaster,
MyDatabaseId
Why it still compiles: Only because pgstat.h → utils/backend_status.h
includes it, literally commented /* for BackendType */
in that header i.e. for backend_status.h's own use, not as a re-export
────────────────────────────────────────
*nodes/queryjumble.h*
Still used directly in the file: JumbleState (6 uses: hook signature,
pgss_store(), etc.)
Why it still compiles: Only because parser/analyze.h (still included)
includes it — this pairing is a bit more natural since
that's where the post_parse_analyze_hook signature needing JumbleState
lives, but it's still an indirect dependency
────────────────────────────────────────
*utils/memutils.h*
Still used directly in the file: Nothing. no
MemoryContext/CurrentMemoryContext/etc. symbols found anywhere in the file
Why it still compiles: Genuinely safe to remove

Regards,
Vaibhav Dalvi
EnterpriseDB


On Mon, Sep 14, 2026 at 4:44 PM <m.litsarev@postgrespro.ru> wrote:

> Hi, hackers!
>
> I accidentially found that some headers in pg_stat_statements are
> redundant.
> A small patch with removed headers is attached.
>
> Kind regards,
> Postgres Professional: http://www.postgrespro.com
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Redundant headers in pg_stat_statements
@ 2026-09-14 12:24  Álvaro Herrera <alvherre@kurilemu.de>
  parent: m.litsarev@postgrespro.ru
  1 sibling, 0 replies; 3+ messages in thread

From: Álvaro Herrera @ 2026-09-14 12:24 UTC (permalink / raw)
  To: m.litsarev@postgrespro.ru; +Cc: pgsql-hackers@lists.postgresql.org

On 2026-Sep-14, m.litsarev@postgrespro.ru wrote:

> Hi, hackers!
> 
> I accidentially found that some headers in pg_stat_statements are redundant.
> A small patch with removed headers is attached.

Hi, I'm not sure that this achieves a whole lot -- these headers you
remove are indirectly included by some other header, so removing the
direct inclusions has no practical effect.  See the inclusion graph for
that file here:
https://doxygen.postgresql.org/pg__stat__statements_8c.html

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Most hackers will be perfectly comfortable conceptualizing users as entropy
 sources, so let's move on."                               (Nathaniel Smith)
      https://mail.gnu.org/archive/html/monotone-devel/2007-01/msg00080.html






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-09-14 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14 11:14 Redundant headers in pg_stat_statements m.litsarev@postgrespro.ru
2026-09-14 11:50 ` Vaibhav Dalvi <vaibhav.dalvi@enterprisedb.com>
2026-09-14 12:24 ` Álvaro Herrera <alvherre@kurilemu.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox