postgresql/src/test/modules
Nathan Bossart fe07100e82 Add GetNamedDSA() and GetNamedDSHash().
Presently, the dynamic shared memory (DSM) registry only provides
GetNamedDSMSegment(), which allocates a fixed-size segment.  To use
the DSM registry for more sophisticated things like dynamic shared
memory areas (DSAs) or a hash table backed by a DSA (dshash), users
need to create a DSM segment that stores various handles and LWLock
tranche IDs and to write fairly complicated initialization code.
Furthermore, there is likely little variation in this
initialization code between libraries.

This commit introduces functions that simplify allocating a DSA or
dshash within the DSM registry.  These functions are very similar
to GetNamedDSMSegment().  Notable differences include the lack of
an initialization callback parameter and the prohibition of calling
the functions more than once for a given entry in each backend
(which should be trivially avoidable in most circumstances).  While
at it, this commit bumps the maximum DSM registry entry name length
from 63 bytes to 127 bytes.

Also note that even though one could presumably detach/destroy the
DSAs and dshashes created in the registry, such use-cases are not
yet well-supported, if for no other reason than the associated DSM
registry entries cannot be removed.  Adding such support is left as
a future exercise.

The test_dsm_registry test module contains tests for the new
functions and also serves as a complete usage example.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Florents Tselai <florents.tselai@gmail.com>
Reviewed-by: Rahila Syed <rahilasyed90@gmail.com>
Discussion: https://postgr.es/m/aEC8HGy2tRQjZg_8%40nathan
2025-07-02 11:50:52 -05:00
..
brin Update copyright for 2025 2025-01-01 11:21:55 -05:00
commit_ts Apply more consistent style for command options in TAP tests 2025-03-17 12:42:23 +09:00
delay_execution Remove unstable test suite added by 525392d57 2025-02-22 15:19:23 +09:00
dummy_index_am Rename amcancrosscompare 2025-03-07 11:46:33 +01:00
dummy_seclabel Update copyright for 2025 2025-01-01 11:21:55 -05:00
gin Update copyright for 2025 2025-01-01 11:21:55 -05:00
injection_points meson: Increase minimum version to 0.57.2 2025-07-02 11:14:53 +02:00
ldap_password_func Replace deprecated log_connections values in docs and tests 2025-05-22 17:14:54 -04:00
libpq_pipeline Run pgperltidy 2025-06-29 21:14:21 -04:00
oauth_validator meson: Increase minimum version to 0.57.2 2025-07-02 11:14:53 +02:00
plsample Update copyright for 2025 2025-01-01 11:21:55 -05:00
spgist_name_ops Update copyright for 2025 2025-01-01 11:21:55 -05:00
ssl_passphrase_callback Apply more consistent style for command options in TAP tests 2025-03-17 12:42:23 +09:00
test_aio Run pgperltidy 2025-06-29 21:14:21 -04:00
test_bloomfilter Get rid of our dependency on type "long" for memory size calculations. 2025-01-31 13:52:40 -05:00
test_copy_callbacks Use PRI?64 instead of "ll?" in format strings (continued). 2025-03-29 10:43:57 +01:00
test_custom_rmgrs Remove unnecessary (char *) casts [xlog] 2025-02-13 10:57:07 +01:00
test_ddl_deparse Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_dsa Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_dsm_registry Add GetNamedDSA() and GetNamedDSHash(). 2025-07-02 11:50:52 -05:00
test_escape With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:04 -07:00
test_extensions Make "directory" setting work with extension_control_path 2025-05-02 16:35:48 +02:00
test_ginpostinglist Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_integerset Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_json_parser Allocate JsonLexContexts on the heap to avoid warnings 2025-04-23 11:02:05 +02:00
test_lfind Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_misc Fix catcache invalidation of a list entry that's being built 2025-01-14 14:28:49 +02:00
test_oat_hooks Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_parser Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_pg_dump pg_dump: Add --sequence-data. 2025-03-25 16:02:35 -05:00
test_predtest Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_radixtree Always use the caller-provided context for radix tree leaves 2025-01-06 13:26:02 +07:00
test_rbtree Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_regex Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_resowner Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_rls_hooks Update copyright for 2025 2025-01-01 11:21:55 -05:00
test_shm_mq Use correct DatumGet*() function in test_shm_mq_main(). 2025-06-27 13:37:26 -05:00
test_slru Add support for runtime arguments in injection points 2025-05-10 06:56:26 +09:00
test_tidstore Update copyright for 2025 2025-01-01 11:21:55 -05:00
typcache Update copyright for 2025 2025-01-01 11:21:55 -05:00
unsafe_tests Remove direct handling of reloptions for toast tables 2025-03-14 09:28:51 +01:00
worker_spi pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
xid_wraparound Use PRI?64 instead of "ll?" in format strings (continued). 2025-03-29 10:43:57 +01:00
Makefile aio: Add test_aio module 2025-04-01 13:47:46 -04:00
meson.build aio: Add test_aio module 2025-04-01 13:47:46 -04:00
README Add an enforcement mechanism for global object names in regression tests. 2019-06-29 11:34:00 -04:00

Test extensions and libraries
=============================

src/test/modules contains PostgreSQL extensions that are primarily or entirely
intended for testing PostgreSQL and/or to serve as example code. The extensions
here aren't intended to be installed in a production server and aren't suitable
for "real work".

Furthermore, while you can do "make install" and "make installcheck" in
this directory or its children, it is NOT ADVISABLE to do so with a server
containing valuable data.  Some of these tests may have undesirable
side-effects on roles or other global objects within the tested server.
"make installcheck-world" at the top level does not recurse into this
directory.

Most extensions have their own pg_regress tests or isolationtester specs. Some
are also used by tests elsewhere in the tree.

If you're adding new hooks or other functionality exposed as C-level API this
is where to add the tests for it.