Reduce presence of syscache.h in src/include/

ee642cccc4 has added syscache.h in inval.h and objectaddress.h,
enlarging by a lot the footprint of this header, particularly via
objectaddress.h.  A change in syscache.h would cause a lot more files to
be recompiled.

This commit reduces the presence of syscache.h by switching to a direct
use of syscache_ids.h in inval.h and objectaddress.h, where the enum
SysCacheIdentifier is defined.  genbki.pl gains an #ifndef block for
this header, so as its inclusion is more controlled.

Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/vlcexdcimsmvu3aplt2yxpfndkgtuvjsrms2fdl46rbw3k2kug@drspkoxlaije
This commit is contained in:
Michael Paquier 2026-04-09 08:49:36 +09:00
parent 2cff363715
commit e0fa5bd146
3 changed files with 10 additions and 4 deletions

View file

@ -795,7 +795,10 @@ print $fk_info "};\n\n#endif\t\t\t\t\t\t\t/* SYSTEM_FK_INFO_H */\n";
# Now generate syscache info
print_boilerplate($syscache_ids_fh, "syscache_ids.h", "SysCache identifiers");
print $syscache_ids_fh "typedef enum SysCacheIdentifier
print $syscache_ids_fh "#ifndef SYSCACHE_IDS_H
#define SYSCACHE_IDS_H
typedef enum SysCacheIdentifier
{
\tSYSCACHEID_INVALID = -1,\n";
@ -833,7 +836,10 @@ foreach my $syscache (sort keys %syscaches)
}
print $syscache_ids_fh "} SysCacheIdentifier;\n";
print $syscache_ids_fh "#define SysCacheSize ($last_syscache + 1)\n";
print $syscache_ids_fh "#define SysCacheSize ($last_syscache + 1)\n\n";
# Closing boilerplate for syscache_ids.h
print $syscache_ids_fh "#endif\t\t\t\t\t\t\t/* SYSCACHE_IDS_H */\n";
print $syscache_info_fh "};\n";

View file

@ -14,10 +14,10 @@
#define OBJECTADDRESS_H
#include "access/htup.h"
#include "catalog/syscache_ids.h"
#include "nodes/parsenodes.h"
#include "storage/lockdefs.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
/*
* An ObjectAddress represents a database object of any type.

View file

@ -15,9 +15,9 @@
#define INVAL_H
#include "access/htup.h"
#include "catalog/syscache_ids.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
extern PGDLLIMPORT int debug_discard_caches;