Skip to content

libversion

Version string comparison functions and versiontext type using libversion

postgresql-libversion · Version string comparison functions and versiontext type using libversion

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100302libversionpostgresql-libversion2.0.0TYPEMITC

PostgreSQL · 10, 11, 12, 13, 14, 15, 16

Usage

Sources:

libversion compares package-style version strings through the external libversion library. It provides comparison functions and a versiontext type whose equality and ordering use version semantics rather than lexical text order.

CREATE EXTENSION libversion;
SELECT version_compare2('1.10', '1.2');
SELECT '1.10'::versiontext > '1.2'::versiontext;
SELECT '1.0'::versiontext = '1.0.0'::versiontext;

version_compare4 accepts a flag for each operand; helper functions expose libversion flags such as VERSIONFLAG_P_IS_PATCH, VERSIONFLAG_LOWER_BOUND, and VERSIONFLAG_UPPER_BOUND.

The extension requires the matching libversion development and runtime library. Its cataloged compatibility ends at PostgreSQL 16, so validate source and binary builds on newer majors. A versiontext index depends on this comparison behavior: keep library versions consistent across primary, replicas, dump/restore targets, and logical subscribers to avoid ordering disagreement.

Table reader