money type precision depends on locale causing data corruption
criticalconfigurationUpdated Mar 4, 2026
Technologies:
How to detect:
money type precision and formatting depend on lc_monetary locale setting, which can differ between servers or sessions. Transferring money data between databases with different locale settings can silently change values. Has limited precision fixed to locale's currency decimal places.
Recommended action:
Use numeric with explicit precision for monetary amounts: CREATE TABLE transactions (amount numeric(19,4) NOT NULL, currency text NOT NULL CHECK (currency ~ '^[A-Z]{3}$')). numeric(19,4) gives 15 digits before decimal and 4 after, sufficient for virtually any financial application, and is locale-independent.