pg_mockable
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_mockable | 1.1.0 | LANG | PostgreSQL | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3120 | pg_mockable | No | No | No | Yes | No | No | mockable |
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 1817161514 | pg_mockable | - |
| RPM | PIGSTY | 1.1.0 | 1817161514 | pg_mockable_$v | - |
| DEB | PIGSTY | 1.1.0 | 1817161514 | postgresql-$v-pg-mockable | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.1.0 el8.x86_64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.x86_64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.x86_64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.x86_64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.x86_64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el8.noarch.rpm
|
| el8.aarch64 | PIGSTY 1.1.0 el8.aarch64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.aarch64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.aarch64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.aarch64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 1.1.0 el8.aarch64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el8.noarch.rpm
|
| el9.x86_64 | PIGSTY 1.1.0 el9.x86_64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.x86_64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.x86_64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.x86_64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.x86_64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el9.noarch.rpm
|
| el9.aarch64 | PIGSTY 1.1.0 el9.aarch64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.aarch64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.aarch64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.aarch64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 1.1.0 el9.aarch64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el9.noarch.rpm
|
| el10.x86_64 | PIGSTY 1.1.0 el10.x86_64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.x86_64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.x86_64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.x86_64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.x86_64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el10.noarch.rpm
|
| el10.aarch64 | PIGSTY 1.1.0 el10.aarch64.pg18 : pg_mockable_18 pg_mockable_18-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.aarch64.pg17 : pg_mockable_17 pg_mockable_17-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.aarch64.pg16 : pg_mockable_16 pg_mockable_16-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.aarch64.pg15 : pg_mockable_15 pg_mockable_15-1.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 1.1.0 el10.aarch64.pg14 : pg_mockable_14 pg_mockable_14-1.1.0-1PIGSTY.el10.noarch.rpm
|
| d12.x86_64 | PIGSTY 1.1.0 d12.x86_64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.x86_64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.x86_64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.x86_64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.x86_64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
|
| d12.aarch64 | PIGSTY 1.1.0 d12.aarch64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.aarch64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.aarch64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.aarch64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 1.1.0 d12.aarch64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~bookworm_all.deb
|
| d13.x86_64 | PIGSTY 1.1.0 d13.x86_64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.x86_64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.x86_64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.x86_64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.x86_64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
|
| d13.aarch64 | PIGSTY 1.1.0 d13.aarch64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.aarch64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.aarch64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.aarch64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 1.1.0 d13.aarch64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~trixie_all.deb
|
| u22.x86_64 | PIGSTY 1.1.0 u22.x86_64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.x86_64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.x86_64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.x86_64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.x86_64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
|
| u22.aarch64 | PIGSTY 1.1.0 u22.aarch64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.aarch64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.aarch64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.aarch64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 1.1.0 u22.aarch64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~jammy_all.deb
|
| u24.x86_64 | PIGSTY 1.1.0 u24.x86_64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.x86_64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.x86_64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.x86_64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.x86_64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
|
| u24.aarch64 | PIGSTY 1.1.0 u24.aarch64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.aarch64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.aarch64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.aarch64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
| PIGSTY 1.1.0 u24.aarch64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~noble_all.deb
|
| u26.x86_64 | PIGSTY 1.1.0 u26.x86_64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.x86_64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.x86_64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.x86_64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.x86_64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
|
| u26.aarch64 | PIGSTY 1.1.0 u26.aarch64.pg18 : postgresql-18-pg-mockable postgresql-18-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.aarch64.pg17 : postgresql-17-pg-mockable postgresql-17-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.aarch64.pg16 : postgresql-16-pg-mockable postgresql-16-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.aarch64.pg15 : postgresql-15-pg-mockable postgresql-15-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 1.1.0 u26.aarch64.pg14 : postgresql-14-pg-mockable postgresql-14-pg-mockable_1.1.0-1PIGSTY~resolute_all.deb
|
Build
You can build the DEB packages for pg_mockable using pig build:
Install
You can install pg_mockable directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources: pg_mockable upstream README, v1.1.0 tag, PGXN pg_mockable, local source tarball
pg_mockable-1.1.0.tar.gz.
pg_mockable creates mockable wrapper functions for PostgreSQL routines. It is mainly useful in database tests where application code should call a stable wrapper, while tests temporarily replace the wrapper’s return value.
The extension installs into the fixed mockable schema and is not relocatable.
Mock Built-In Time Functions
mockable.now() is pre-created because mocking now() also covers the related current-time wrappers exposed by this extension.
mockable.mock(regprocedure, anyelement) stores the mock value and returns it. mockable.unmock(regprocedure) clears the mock and restores the wrapper to call the original routine.
Wrap Application Functions
Use mockable.wrap_function() to create a thin wrapper in the mockable schema:
The first argument is a regprocedure, so include argument types when the function is overloaded:
If automatic wrapper generation is not sufficient, pass the exact CREATE OR REPLACE FUNCTION statement as the second argument:
Version 1.1.0 also adds optional debug logging for wrapped/mockable routines through raise_debug_messages$ on mockable.wrap_function(...) and the mock_memory.raise_debug_messages column.
Mock Lifetime
The default mock lifetime is transaction-scoped. For values that must survive dump/restore or later transactions, create the wrapper with a persistent lifetime:
Persistent mocks should be explicitly cleared when the test fixture no longer needs them:
Search Path Caveat
Application code must actually call the wrapper, for example mockable.now() or mockable.answer(), for the mock to apply. Some PL/pgSQL code can be redirected by adjusting search_path, but expressions such as table defaults are compiled to function OIDs; adding mockable to search_path later does not rewrite those references. Prefer explicit mockable.* calls in code that is meant to be testable.
Caveats
- Version 1.1.0 supports PostgreSQL 14-18. It is a SQL extension and does not need
shared_preload_libraries. pg_mockableowns themockableschema; installing it in another schema is not supported by the control file.- Wrapper privileges are derived from the wrapped routine. The tests verify that wrapping a private function does not grant execute privilege to roles that could not call the original function.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)