ajversion
ajversion · Semantic version type for PostgreSQL backed by compact integer storage.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100249 | ajversion | ajversion | 0.0.1 | TYPE | PostgreSQL | C |
Usage
Sources:
ajversion 0.0.1 defines a compact, sortable version type for values with up to three numeric components. It is useful for storing and indexing simple major.minor.patch values, but it is not a complete Semantic Versioning implementation: prerelease identifiers, build metadata, and strict input validation are not supported.
Core Workflow
The default B-tree and hash operator classes allow ordinary comparison indexes:
Main Objects
ajversion: a four-byte version value.major(ajversion),minor(ajversion),patch(ajversion): extract components.=,<>,<,<=,>,>=: compare packed values numerically.btree_ajversion_ops,hash_ajversion_ops: default B-tree and hash operator classes.- Casts from
integer,numeric,real, anddouble precision: convert numeric input toajversion.
Parsing and Range Boundaries
The representation reserves 12 bits for the major component and 10 bits each for minor and patch. The valid ranges are therefore major 0..4095 and minor/patch 0..1023; larger components raise an error.
Input parsing is intentionally permissive. It scans for at most three digit sequences among arbitrary nonnumeric characters, fills missing components with zero, and normalizes output to three components. For example, '15' becomes 15.0.0, while text with no digits becomes 0.0.0. Validate input separately when malformed text must be rejected, and do not use ajversion for SemVer precedence involving prerelease or build fields.