pg_thud
pg_thud · Framework extending pgtap with scaffolding and test-data helpers for database unit tests.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100675 | pg_thud | pg_thud | 0.1.0 | FEAT | PostgreSQL | SQL |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | pgtap |
Usage
Sources:
pg_thud is a test-data factory for PostgreSQL. It registers named SQL queries for a table’s row type and materializes their results on first use, letting tests request repeatable fixture sets. The project is inactive and its prose documentation is only a scaffold, so use the SQL-defined API in isolated test databases.
Core Workflow
Install the declared pgtap dependency, register one or more named data sets, then fetch a set using a typed NULL to identify the target row type:
The first tf.get call creates cached data in the extension’s _test_data schema; later calls reuse it.
API and Objects
tf.test_set: composite value containingset_nameandinsert_sql.tf.register(table_name text, test_sets tf.test_set[]): registers factories for a table.tf.get(anyelement, set_name text) RETURNS SETOF anyelement: returns the named fixture set as the caller’s composite type._tf.test_factory: internal registry;_test_dataholds materialized fixture tables.
Caveats
Both public functions are SECURITY DEFINER, and registration stores SQL text that is later executed to build fixture data. Restrict EXECUTE privileges and never accept untrusted factory SQL. Cached data can become stale when a table definition or factory query changes; the published API does not document a refresh command, so recreate disposable test state when definitions change.
pg_thud creates data for tests but does not itself assert results. Its dependency and source target old PostgreSQL generations, and the upstream project is abandoned. Validate installation against the exact server version and keep it out of production databases.