pg_postal_code_ca
pg_postal_code_ca · an efficient, validated, formatted Canadian postal code type
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100263 | pg_postal_code_ca | pg_postal_code_ca | 1.0 | TYPE | PostgreSQL | C |
Usage
Sources:
pg_postal_code_ca provides a compact, validated Canadian postal-code type with canonical output and B-tree ordering. The authoritative version 1.0 SQL names the type postal_code_ca; the upstream README still shows the older name canadian_postal_code and should not be copied literally.
Core Workflow
Use the type for fields that must reject malformed postal codes and display them consistently:
Input without a space is normalized to uppercase canonical form such as H2E 3F1. Invalid letter/digit placement is rejected during the cast.
Objects
postal_code_ca: fixed-length C type with input/output functions.<,<=,=,<>,>=, and>: comparison operators.postal_code_ca_cmp(postal_code_ca, postal_code_ca): three-way comparison support function.postal_code_ca_ops: default B-tree operator class, enabling ordered indexes, equality lookups, range predicates, and sorting.
Caveats
This type validates the extension’s implemented Canadian postal-code grammar; it does not prove that a code is assigned, deliverable, or current. Validate against an authoritative address data source when existence matters.
The README/type-name mismatch reflects an upstream rename: use postal_code_ca from the installed SQL and verify existing schemas before migration. Comparison order is the extension’s byte-level postal-code order, not geographic proximity or routing distance.