Skip to content

inetrange

Range type for PostgreSQL inet values with range operators and GiST indexing support.

inetrange · Range type for PostgreSQL inet values with range operators and GiST indexing support.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100223inetrangeinetrange1.0.2TYPEMITC

Usage

Sources:

inetrange adds a PostgreSQL range type whose subtype is inet. It supports ordinary range containment and overlap operators, GiST indexing, and exclusion constraints for non-overlapping IP address intervals.

CREATE EXTENSION inetrange;
SELECT '1.0.1.1'::inet <@ inetrange('1.0.0.0', '1.1.0.0', '[]');
CREATE TABLE network_block (
  addresses inetrange NOT NULL,
  owner_name text NOT NULL,
  EXCLUDE USING gist (addresses WITH &&)
);

Bounds follow PostgreSQL range rules, while the subtype follows inet ordering across IPv4 and IPv6 values. Choose inclusive and exclusive endpoints deliberately and test canonical application representations before using equality as a business key.

Version 1.0.2 has current source and PGXN distribution but no explicit modern PostgreSQL compatibility matrix. Test GiST index builds, exclusion constraints, mixed address families, dump/restore, and upgrades on the target major before storing long-lived values.

Table reader