1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Use PG_MODULE_MAGIC_EXT in our installable shared libraries.

It seems potentially useful to label our shared libraries with version
information, now that a facility exists for retrieving that.  This
patch labels them with the PG_VERSION string.  There was some
discussion about using semantic versioning conventions, but that
doesn't seem terribly helpful for modules with no SQL-level presence;
and for those that do have SQL objects, we typically expect them
to support multiple revisions of the SQL definitions, so it'd still
not be very helpful.

I did not label any of src/test/modules/.  It seems unnecessary since
we don't install those, and besides there ought to be someplace that
still provides test coverage for the original PG_MODULE_MAGIC macro.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/dd4d1b59-d0fe-49d5-b28f-1e463b68fa32@gmail.com
This commit is contained in:
Tom Lane
2025-03-26 11:11:02 -04:00
parent 9324c8c580
commit 55527368bd
89 changed files with 356 additions and 89 deletions

View File

@ -42,7 +42,10 @@
#include "utils/snapmgr.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "amcheck",
.version = PG_VERSION
);
/*
* A B-Tree cannot possibly have this many levels, since there must be one

View File

@ -16,7 +16,10 @@
#include "libpq/auth.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "auth_delay",
.version = PG_VERSION
);
/* GUC Variables */
static int auth_delay_milliseconds = 0;

View File

@ -18,7 +18,10 @@
#include "utils/acl.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "basebackup_to_shell",
.version = PG_VERSION
);
typedef struct bbsink_shell
{

View File

@ -37,7 +37,10 @@
#include "storage/fd.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "basic_archive",
.version = PG_VERSION
);
static char *archive_directory = NULL;

View File

@ -22,7 +22,10 @@
#include "utils/memutils.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "bloom",
.version = PG_VERSION
);
/*
* State of bloom index build. We accumulate one page data here before

View File

@ -4,7 +4,10 @@
#include "plperl.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "bool_plperl",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(bool_to_plperl);

View File

@ -14,7 +14,10 @@
#include "utils/timestamp.h"
#include "utils/uuid.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "btree_gin",
.version = PG_VERSION
);
typedef struct QueryInfo
{

View File

@ -7,7 +7,10 @@
#include "access/stratnum.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "btree_gist",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(gbt_decompress);
PG_FUNCTION_INFO_V1(gbtreekey_in);

View File

@ -10,7 +10,10 @@
#include "utils/varlena.h"
#include "varatt.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "citext",
.version = PG_VERSION
);
/*
* ====================

View File

@ -17,7 +17,10 @@
#include "utils/array.h"
#include "utils/float.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "cube",
.version = PG_VERSION
);
/*
* Taken from the intarray contrib header

View File

@ -65,7 +65,10 @@
#include "utils/varlena.h"
#include "utils/wait_event.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "dblink",
.version = PG_VERSION
);
typedef struct remoteConn
{

View File

@ -15,7 +15,10 @@
#include "commands/defrem.h"
#include "tsearch/ts_public.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "dict_int",
.version = PG_VERSION
);
typedef struct
{

View File

@ -20,7 +20,10 @@
#include "tsearch/ts_public.h"
#include "utils/formatting.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "dict_xsyn",
.version = PG_VERSION
);
typedef struct
{

View File

@ -11,7 +11,10 @@
#define M_PI 3.14159265358979323846
#endif
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "earthdistance",
.version = PG_VERSION
);
/* Earth's radius is in statute miles. */
static const double EARTH_RADIUS = 3958.747716;

View File

@ -42,7 +42,10 @@
#include "utils/sampling.h"
#include "utils/varlena.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "file_fdw",
.version = PG_VERSION
);
/*
* Describes the valid options for objects that use this wrapper.

View File

@ -44,7 +44,10 @@
#include "utils/varlena.h"
#include "varatt.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "fuzzystrmatch",
.version = PG_VERSION
);
/*
* Soundex

View File

@ -21,7 +21,10 @@
#include "utils/memutils.h"
#include "utils/typcache.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "hstore",
.version = PG_VERSION
);
/* old names for C functions */
HSTORE_POLLUTE(hstore_from_text, tconvert);

View File

@ -4,7 +4,10 @@
#include "hstore/hstore.h"
#include "plperl.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "hstore_plperl",
.version = PG_VERSION
);
/* Linkage to functions in hstore module */
typedef HStore *(*hstoreUpgrade_t) (Datum orig);

View File

@ -5,7 +5,10 @@
#include "plpy_typeio.h"
#include "plpython.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "hstore_plpython",
.version = PG_VERSION
);
/* Linkage to functions in plpython module */
typedef char *(*PLyObject_AsString_t) (PyObject *plrv);

View File

@ -5,7 +5,10 @@
#include "_int.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "intarray",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(_int_different);
PG_FUNCTION_INFO_V1(_int_same);

View File

@ -23,7 +23,10 @@
#include "isn.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "isn",
.version = PG_VERSION
);
#ifdef USE_ASSERT_CHECKING
#define ISN_DEBUG 1

View File

@ -7,7 +7,10 @@
#include "utils/fmgrprotos.h"
#include "utils/jsonb.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "jsonb_plperl",
.version = PG_VERSION
);
static SV *Jsonb_to_SV(JsonbContainer *jsonb);
static JsonbValue *SV_to_JsonbValue(SV *obj, JsonbParseState **ps, bool is_elem);

View File

@ -7,7 +7,10 @@
#include "utils/jsonb.h"
#include "utils/numeric.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "jsonb_plpython",
.version = PG_VERSION
);
/* for PLyObject_AsString in plpy_typeio.c */
typedef char *(*PLyObject_AsString_t) (PyObject *plrv);

View File

@ -12,7 +12,10 @@
#include "utils/fmgrprotos.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "lo",
.version = PG_VERSION
);
/*

View File

@ -13,7 +13,10 @@
#include "utils/selfuncs.h"
#include "varatt.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "ltree",
.version = PG_VERSION
);
/* compare functions */
PG_FUNCTION_INFO_V1(ltree_cmp);

View File

@ -4,7 +4,10 @@
#include "ltree/ltree.h"
#include "plpython.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "ltree_plpython",
.version = PG_VERSION
);
/* Linkage to functions in plpython module */
typedef PyObject *(*PLyUnicode_FromStringAndSize_t) (const char *s, Py_ssize_t size);

View File

@ -29,7 +29,10 @@
#include "utils/rel.h"
#include "utils/varlena.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pageinspect",
.version = PG_VERSION
);
static bytea *get_raw_page_internal(text *relname, ForkNumber forknum,
BlockNumber blkno);

View File

@ -25,7 +25,10 @@
#include "fmgr.h"
#include "libpq/crypt.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "passwordcheck",
.version = PG_VERSION
);
/* Saved hook value */
static check_password_hook_type prev_check_password_hook = NULL;

View File

@ -20,7 +20,10 @@
#define NUM_BUFFERCACHE_SUMMARY_ELEM 5
#define NUM_BUFFERCACHE_USAGE_COUNTS_ELEM 4
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_buffercache",
.version = PG_VERSION
);
/*
* Record structure holding the to be exposed cache data.

View File

@ -12,7 +12,10 @@
#include "fmgr.h"
#include "storage/freespace.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_freespacemap",
.version = PG_VERSION
);
/*
* Returns the amount of free space on a given page, according to the

View File

@ -18,7 +18,10 @@
#include "utils/builtins.h"
#include "utils/pg_lsn.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_logicalinspect",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(pg_get_logical_snapshot_meta);
PG_FUNCTION_INFO_V1(pg_get_logical_snapshot_info);

View File

@ -26,7 +26,10 @@
#include "utils/lsyscache.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_prewarm",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(pg_prewarm);

View File

@ -71,7 +71,10 @@
#include "utils/memutils.h"
#include "utils/timestamp.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_stat_statements",
.version = PG_VERSION
);
/* Location of permanent stats file (valid when database is shut down) */
#define PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_statements.stat"

View File

@ -23,7 +23,10 @@
#include "utils/array.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_surgery",
.version = PG_VERSION
);
/* Options to forcefully change the state of a heap tuple. */
typedef enum HeapTupleForceOption

View File

@ -18,7 +18,10 @@
#include "utils/memutils.h"
#include "utils/pg_crc.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_trgm",
.version = PG_VERSION
);
/* GUC variables */
double similarity_threshold = 0.3f;

View File

@ -25,7 +25,10 @@
#include "storage/smgr.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_visibility",
.version = PG_VERSION
);
typedef struct vbits
{

View File

@ -29,7 +29,10 @@
* give a thought about doing the same in pg_waldump tool as well.
*/
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pg_walinspect",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(pg_get_wal_block_info);
PG_FUNCTION_INFO_V1(pg_get_wal_record_info);

View File

@ -41,7 +41,10 @@
#include "utils/guc.h"
#include "varatt.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pgcrypto",
.version = PG_VERSION
);
/* private stuff */

View File

@ -42,7 +42,10 @@
#include "utils/snapmgr.h"
#include "utils/varlena.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pgrowlocks",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(pgrowlocks);

View File

@ -38,7 +38,10 @@
#include "storage/lmgr.h"
#include "utils/varlena.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "pgstattuple",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(pgstattuple);
PG_FUNCTION_INFO_V1(pgstattuple_v1_5);

View File

@ -49,7 +49,10 @@
#include "utils/sampling.h"
#include "utils/selfuncs.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "postgres_fdw",
.version = PG_VERSION
);
/* Default CPU cost to start up a foreign query. */
#define DEFAULT_FDW_STARTUP_COST 100.0

View File

@ -28,7 +28,10 @@
#define GIST_QUERY_DEBUG
*/
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "seg",
.version = PG_VERSION
);
/*
* Auxiliary data structure for picksplit method.

View File

@ -25,7 +25,10 @@
#include "utils/guc.h"
#include "utils/queryenvironment.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "sepgsql",
.version = PG_VERSION
);
/*
* Declarations

View File

@ -11,7 +11,10 @@
#include "utils/builtins.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "autoinc",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(autoinc);

View File

@ -14,7 +14,10 @@
#include "utils/builtins.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "insert_username",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(insert_username);

View File

@ -22,7 +22,10 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com>
#include "utils/fmgrprotos.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "moddatetime",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(moddatetime);

View File

@ -15,7 +15,10 @@
#include "utils/memutils.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "refint",
.version = PG_VERSION
);
typedef struct
{

View File

@ -19,7 +19,10 @@
#include "miscadmin.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "sslinfo",
.version = PG_VERSION
);
static Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName);
static Datum ASN1_STRING_to_text(ASN1_STRING *str);

View File

@ -44,7 +44,10 @@
#include "miscadmin.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "tablefunc",
.version = PG_VERSION
);
static HTAB *load_categories_hash(char *cats_sql, MemoryContext per_query_ctx);
static Tuplestorestate *get_crosstab_tuplestore(char *sql,

View File

@ -23,7 +23,10 @@
#include "utils/rel.h"
#include "utils/syscache.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "tcn",
.version = PG_VERSION
);
/*
* Copy from s (for source) to r (for result), wrapping with q (quote)

View File

@ -22,7 +22,10 @@
#include "utils/memutils.h"
#include "utils/rel.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "test_decoding",
.version = PG_VERSION
);
typedef struct
{

View File

@ -34,7 +34,10 @@
#include "optimizer/optimizer.h"
#include "utils/sampling.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "tsm_system_rows",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(tsm_system_rows_handler);

View File

@ -33,7 +33,10 @@
#include "utils/sampling.h"
#include "utils/spccache.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "tsm_system_time",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(tsm_system_time_handler);

View File

@ -23,7 +23,10 @@
#include "utils/lsyscache.h"
#include "utils/syscache.h"
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "unaccent",
.version = PG_VERSION
);
/*
* An unaccent dictionary uses a trie to find a string to replace. Each node

View File

@ -102,7 +102,10 @@ do { \
#endif /* !HAVE_UUID_OSSP */
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "uuid-ossp",
.version = PG_VERSION
);
PG_FUNCTION_INFO_V1(uuid_nil);
PG_FUNCTION_INFO_V1(uuid_ns_dns);

View File

@ -22,7 +22,10 @@
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
PG_MODULE_MAGIC;
PG_MODULE_MAGIC_EXT(
.name = "xml2",
.version = PG_VERSION
);
/* exported for use by xslt_proc.c */