diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2025-03-26 10:59:42 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2025-03-26 11:06:12 -0400 |
commit | 9324c8c580655800331b0582b770e88c01b7a5c4 (patch) | |
tree | 7abf1f4eebd29cb26fa05fc984db644fb174328d /doc/src | |
parent | e92c0632c1473fe57383c58f0dfdde3bae7044f4 (diff) | |
download | postgresql-9324c8c580655800331b0582b770e88c01b7a5c4.tar.gz postgresql-9324c8c580655800331b0582b770e88c01b7a5c4.zip |
Introduce PG_MODULE_MAGIC_EXT macro.
This macro allows dynamically loaded shared libraries (modules) to
provide a wired-in module name and version, and possibly other
compile-time-constant fields in future. This information can be
retrieved with the new pg_get_loaded_modules() function.
This feature is expected to be particularly useful for modules
that do not have any exposed SQL functionality and thus are
not associated with a SQL-level extension object. But even for
modules that do belong to extensions, being able to verify the
actual code version can be useful.
Author: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Yurii Rashkovskii <yrashk@omnigres.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/dd4d1b59-d0fe-49d5-b28f-1e463b68fa32@gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 22 | ||||
-rw-r--r-- | doc/src/sgml/xfunc.sgml | 27 |
2 files changed, 49 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 907c9ef7efa..5bf6656deca 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -25043,6 +25043,28 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n); <row> <entry role="func_table_entry"><para role="func_signature"> <indexterm> + <primary>pg_get_loaded_modules</primary> + </indexterm> + <function>pg_get_loaded_modules</function> () + <returnvalue>setof record</returnvalue> + ( <parameter>module_name</parameter> <type>text</type>, + <parameter>version</parameter> <type>text</type>, + <parameter>file_name</parameter> <type>text</type> ) + </para> + <para> + Returns a list of the loadable modules that are loaded into the + current server session. The <parameter>module_name</parameter> + and <parameter>version</parameter> fields are NULL unless the + module author supplied values for them using + the <literal>PG_MODULE_MAGIC_EXT</literal> macro. + The <parameter>file_name</parameter> field gives the file + name of the module (shared library). + </para></entry> + </row> + + <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> <primary>pg_my_temp_schema</primary> </indexterm> <function>pg_my_temp_schema</function> () diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 9f22dacac7d..35d34f224ef 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1954,6 +1954,9 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision <indexterm zone="xfunc-c-dynload"> <primary>magic block</primary> </indexterm> + <indexterm zone="xfunc-c-dynload"> + <primary><literal>PG_MODULE_MAGIC</literal></primary> + </indexterm> <para> To ensure that a dynamically loaded object file is not loaded into an @@ -1968,6 +1971,30 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision <programlisting> PG_MODULE_MAGIC; </programlisting> +or +<programlisting> +PG_MODULE_MAGIC_EXT(<replaceable>parameters</replaceable>); +</programlisting> + </para> + + <para> + The <literal>PG_MODULE_MAGIC_EXT</literal> variant allows the specification + of additional information about the module; currently, a name and/or a + version string can be added. (More fields might be allowed in future.) + Write something like this: + +<programlisting> +PG_MODULE_MAGIC_EXT( + .name = "my_module_name", + .version = "1.2.3" +); +</programlisting> + + Subsequently the name and version can be examined via + the <function>pg_get_loaded_modules()</function> function. + The meaning of the version string is not restricted + by <productname>PostgreSQL</productname>, but use of semantic versioning + rules is recommended. </para> <para> |