kmoney
kamu-money-pg · Exact scale-18 monetary types with one SQL type per currency.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101891 | kmoney | kamu-money-pg | 0.2.1 | TYPE | MIT | Rust |
PostgreSQL · 15, 16, 17, 18
Usage
Sources:
kmoney supplies fixed-width, scale-18 monetary types whose SQL type encodes an ISO 4217 currency, plus a mixed-currency carrier for interchange.
Enablement
Release 0.2.1 exposes PostgreSQL-major features for 15–18. Install the matching pgrx build, then create the non-relocatable, untrusted extension as a superuser:
No preload or restart is required. Upstream builds through a pgrx fork with feature-gated YugabyteDB adaptations; validate the exact server/kernel artifact before deployment.
Currency-Specific Types
Each currency has a distinct 16-byte type such as kmoney_usd or kmoney_idr. The parser accepts either an untagged amount or the matching currency tag; cross-currency operators do not exist.
kmoney_mixed stores the currency code with the amount for heterogeneous values. It intentionally has no sum aggregate; aggregate a currency-specific column instead.
Division, Allocation, and Indexing
Division returns quotient and residue so rounding loss is explicit. Allocation conserves the original amount across integer weights.
Version 0.2.1 deliberately ships no B-tree or hash operator classes, so these custom types cannot back ordinary B-tree/hash indexes. Values are bounded to the magnitude of numeric(36,18) and reject excess precision instead of silently rounding.
The extension now lives in the dedicated kamu-money-pg repository. The 0.2.1 workspace uses pgrx 0.19.2 through the documented YugabyteDB fork; the PostgreSQL 15–18 type and arithmetic contract remains unchanged.