numeric_domains
Custom numeric domains for PostgreSQL
numeric_domains · Custom numeric domains for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100247 | numeric_domains | numeric_domains | 1.0 | TYPE | MIT | SQL |
PostgreSQL · 10
Usage
Sources:
numeric_domains installs reusable sign-constrained domains over smallint, integer, bigint, and numeric, plus bounded latitude and longitude domains. It is a compact way to put simple numeric invariants into PostgreSQL’s type system.
Core Workflow
Create the extension, then use the domains in columns or function signatures:
An out-of-range non-null value fails its domain check:
Installed Domains
Each of smallint, integer, bigint, and numeric has negative_*, nonpositive_*, nonzero_*, nonnegative_*, and positive_* variants. latitude accepts values from -90 through 90, and longitude accepts -180 through 180.
Semantic Caveats
- None of the domains is declared
NOT NULL. A domainCHECKevaluates to unknown forNULL, which passes; add a column-levelNOT NULLconstraint when absence is invalid. - These are domains, not distinct arithmetic types. Expressions generally use the underlying numeric type, and assignments back to a domain recheck its constraint.
- Bounds are inclusive for
latitudeandlongitude; the extension does not define coordinate reference systems, axis order, normalization, or geospatial operators. - The install SQL contains copy/paste errors in several
COMMENT ON DOMAINtargets, overwriting comments onnegative_*domains. The checks remain correctly attached, but catalog descriptions may be misleading. - Before adopting the global unqualified names, check for collisions with existing domains and decide which schema should own them; the extension is relocatable at installation time.