Skip to content
pgmp

pgmp

pgmp : Multiple Precision Arithmetic extension

Overview

ID Extension Package Version Category License Language
3700
pgmp
pgmp
1.0.6
TYPE
LGPL-3.0
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
unit
numeral
pg_rational
uint
uint128
seg
cube

PIGSTY RPM and DEB packages are aligned at 1.0.6 for PostgreSQL 14 through 18.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0.6
18
17
16
15
14
pgmp -
RPM
PIGSTY
1.0.6
18
17
16
15
14
pgmp_$v -
DEB
PIGSTY
1.0.6
18
17
16
15
14
postgresql-$v-pgmp -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
el8.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
el9.x86_64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
el9.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
el10.x86_64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
el10.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
PIGSTY 1.0.6
d12.x86_64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
d12.aarch64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
d13.x86_64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
d13.aarch64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u22.x86_64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u22.aarch64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u24.x86_64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u24.aarch64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u26.x86_64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
u26.aarch64
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
PGDG 1.0.6
Package Version OS ORG SIZE File URL
pgmp_18 1.0.6 el8.x86_64 pigsty 48.1 KiB pgmp_18-1.0.6-1PIGSTY.el8.x86_64.rpm
pgmp_18 1.0.6 el8.x86_64 pgdg 42.7 KiB pgmp_18-1.0.6-1PGDG.rhel8.10.x86_64.rpm
pgmp_18 1.0.5 el8.x86_64 pgdg 41.8 KiB pgmp_18-1.0.5-4PGDG.rhel8.x86_64.rpm
pgmp_18 1.0.6 el8.aarch64 pigsty 45.8 KiB pgmp_18-1.0.6-1PIGSTY.el8.aarch64.rpm
pgmp_18 1.0.6 el8.aarch64 pgdg 40.7 KiB pgmp_18-1.0.6-1PGDG.rhel8.10.aarch64.rpm
pgmp_18 1.0.5 el8.aarch64 pgdg 39.9 KiB pgmp_18-1.0.5-4PGDG.rhel8.aarch64.rpm
pgmp_18 1.0.6 el9.x86_64 pigsty 45.6 KiB pgmp_18-1.0.6-1PIGSTY.el9.x86_64.rpm
pgmp_18 1.0.5 el9.x86_64 pgdg 42.9 KiB pgmp_18-1.0.5-6PGDG.rhel9.8.x86_64.rpm
pgmp_18 1.0.5 el9.x86_64 pgdg 42.9 KiB pgmp_18-1.0.5-4PGDG.rhel9.x86_64.rpm
pgmp_18 1.0.6 el9.aarch64 pigsty 43.3 KiB pgmp_18-1.0.6-1PIGSTY.el9.aarch64.rpm
pgmp_18 1.0.6 el9.aarch64 pgdg 41.6 KiB pgmp_18-1.0.6-1PGDG.rhel9.8.aarch64.rpm
pgmp_18 1.0.5 el9.aarch64 pgdg 41.4 KiB pgmp_18-1.0.5-6PGDG.rhel9.8.aarch64.rpm
pgmp_18 1.0.5 el9.aarch64 pgdg 41.4 KiB pgmp_18-1.0.5-4PGDG.rhel9.aarch64.rpm
pgmp_18 1.0.6 el10.x86_64 pigsty 46.6 KiB pgmp_18-1.0.6-1PIGSTY.el10.x86_64.rpm
pgmp_18 1.0.6 el10.x86_64 pgdg 44.9 KiB pgmp_18-1.0.6-1PGDG.rhel10.2.x86_64.rpm
pgmp_18 1.0.5 el10.x86_64 pgdg 43.9 KiB pgmp_18-1.0.5-6PGDG.rhel10.2.x86_64.rpm
pgmp_18 1.0.5 el10.x86_64 pgdg 44.2 KiB pgmp_18-1.0.5-4PGDG.rhel10.x86_64.rpm
pgmp_18 1.0.6 el10.aarch64 pigsty 44.5 KiB pgmp_18-1.0.6-1PIGSTY.el10.aarch64.rpm
pgmp_18 1.0.6 el10.aarch64 pgdg 42.9 KiB pgmp_18-1.0.6-1PGDG.rhel10.2.aarch64.rpm
pgmp_18 1.0.5 el10.aarch64 pgdg 42.6 KiB pgmp_18-1.0.5-6PGDG.rhel10.2.aarch64.rpm
pgmp_18 1.0.5 el10.aarch64 pgdg 42.9 KiB pgmp_18-1.0.5-4PGDG.rhel10.aarch64.rpm
postgresql-18-pgmp 1.0.6 d12.x86_64 pgdg 101.2 KiB postgresql-18-pgmp_1.0.6-1.pgdg12+1_amd64.deb
postgresql-18-pgmp 1.0.6 d12.x86_64 pigsty 83.7 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgmp 1.0.5 d12.x86_64 pgdg 100.6 KiB postgresql-18-pgmp_1.0.5-5.pgdg12+1_amd64.deb
postgresql-18-pgmp 1.0.5 d12.x86_64 pgdg 100.5 KiB postgresql-18-pgmp_1.0.5-4.pgdg12+1_amd64.deb
postgresql-18-pgmp 1.0.6 d12.aarch64 pgdg 99.7 KiB postgresql-18-pgmp_1.0.6-1.pgdg12+1_arm64.deb
postgresql-18-pgmp 1.0.6 d12.aarch64 pigsty 82.2 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgmp 1.0.5 d12.aarch64 pgdg 99.5 KiB postgresql-18-pgmp_1.0.5-5.pgdg12+1_arm64.deb
postgresql-18-pgmp 1.0.5 d12.aarch64 pgdg 99.4 KiB postgresql-18-pgmp_1.0.5-4.pgdg12+1_arm64.deb
postgresql-18-pgmp 1.0.6 d13.x86_64 pgdg 101.2 KiB postgresql-18-pgmp_1.0.6-1.pgdg13+1_amd64.deb
postgresql-18-pgmp 1.0.6 d13.x86_64 pigsty 83.5 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~trixie_amd64.deb
postgresql-18-pgmp 1.0.5 d13.x86_64 pgdg 100.5 KiB postgresql-18-pgmp_1.0.5-5.pgdg13+1_amd64.deb
postgresql-18-pgmp 1.0.5 d13.x86_64 pgdg 100.6 KiB postgresql-18-pgmp_1.0.5-4.pgdg13+1_amd64.deb
postgresql-18-pgmp 1.0.6 d13.aarch64 pgdg 100.1 KiB postgresql-18-pgmp_1.0.6-1.pgdg13+1_arm64.deb
postgresql-18-pgmp 1.0.6 d13.aarch64 pigsty 82.6 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~trixie_arm64.deb
postgresql-18-pgmp 1.0.5 d13.aarch64 pgdg 99.6 KiB postgresql-18-pgmp_1.0.5-5.pgdg13+1_arm64.deb
postgresql-18-pgmp 1.0.5 d13.aarch64 pgdg 99.5 KiB postgresql-18-pgmp_1.0.5-4.pgdg13+1_arm64.deb
postgresql-18-pgmp 1.0.6 u22.x86_64 pgdg 104.6 KiB postgresql-18-pgmp_1.0.6-1.pgdg22.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u22.x86_64 pigsty 93.2 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~jammy_amd64.deb
postgresql-18-pgmp 1.0.5 u22.x86_64 pgdg 102.8 KiB postgresql-18-pgmp_1.0.5-5.pgdg22.04+1_amd64.deb
postgresql-18-pgmp 1.0.5 u22.x86_64 pgdg 102.7 KiB postgresql-18-pgmp_1.0.5-4.pgdg22.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u22.aarch64 pgdg 102.6 KiB postgresql-18-pgmp_1.0.6-1.pgdg22.04+1_arm64.deb
postgresql-18-pgmp 1.0.6 u22.aarch64 pigsty 91.3 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~jammy_arm64.deb
postgresql-18-pgmp 1.0.5 u22.aarch64 pgdg 100.9 KiB postgresql-18-pgmp_1.0.5-5.pgdg22.04+1_arm64.deb
postgresql-18-pgmp 1.0.5 u22.aarch64 pgdg 100.9 KiB postgresql-18-pgmp_1.0.5-4.pgdg22.04+1_arm64.deb
postgresql-18-pgmp 1.0.6 u24.x86_64 pgdg 101.5 KiB postgresql-18-pgmp_1.0.6-1.pgdg24.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u24.x86_64 pigsty 89.0 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~noble_amd64.deb
postgresql-18-pgmp 1.0.5 u24.x86_64 pgdg 101.1 KiB postgresql-18-pgmp_1.0.5-5.pgdg24.04+1_amd64.deb
postgresql-18-pgmp 1.0.5 u24.x86_64 pgdg 101.0 KiB postgresql-18-pgmp_1.0.5-4.pgdg24.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u24.aarch64 pgdg 100.1 KiB postgresql-18-pgmp_1.0.6-1.pgdg24.04+1_arm64.deb
postgresql-18-pgmp 1.0.6 u24.aarch64 pigsty 88.4 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~noble_arm64.deb
postgresql-18-pgmp 1.0.5 u24.aarch64 pgdg 99.8 KiB postgresql-18-pgmp_1.0.5-5.pgdg24.04+1_arm64.deb
postgresql-18-pgmp 1.0.5 u24.aarch64 pgdg 99.8 KiB postgresql-18-pgmp_1.0.5-4.pgdg24.04+1_arm64.deb
postgresql-18-pgmp 1.0.6 u26.x86_64 pgdg 101.6 KiB postgresql-18-pgmp_1.0.6-1.pgdg26.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u26.x86_64 pigsty 90.0 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~resolute_amd64.deb
postgresql-18-pgmp 1.0.5 u26.x86_64 pgdg 101.3 KiB postgresql-18-pgmp_1.0.5-5.pgdg26.04+1_amd64.deb
postgresql-18-pgmp 1.0.5 u26.x86_64 pgdg 101.3 KiB postgresql-18-pgmp_1.0.5-4.pgdg26.04+1_amd64.deb
postgresql-18-pgmp 1.0.6 u26.aarch64 pgdg 99.8 KiB postgresql-18-pgmp_1.0.6-1.pgdg26.04+1_arm64.deb
postgresql-18-pgmp 1.0.6 u26.aarch64 pigsty 88.6 KiB postgresql-18-pgmp_1.0.6-1PIGSTY~resolute_arm64.deb
postgresql-18-pgmp 1.0.5 u26.aarch64 pgdg 99.7 KiB postgresql-18-pgmp_1.0.5-5.pgdg26.04+1_arm64.deb
postgresql-18-pgmp 1.0.5 u26.aarch64 pgdg 99.9 KiB postgresql-18-pgmp_1.0.5-4.pgdg26.04+1_arm64.deb

Source

pig build pkg pgmp;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgmp;		# install via package name, for the active PG version

pig install pgmp -v 18;   # install for PG 18
pig install pgmp -v 17;   # install for PG 17
pig install pgmp -v 16;   # install for PG 16
pig install pgmp -v 15;   # install for PG 15
pig install pgmp -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pgmp;

Usage

Sources:

pgmp exposes GNU MP arithmetic inside PostgreSQL. It adds arbitrary-size integer values through mpz and exact rational values through mpq, together with casts, arithmetic, comparison, aggregate, number-theory, bit, and random-number functions.

Core Workflow

CREATE EXTENSION pgmp;

SELECT '123456789012345678901234567890'::mpz * 2;
SELECT mpq(1::mpz, 3::mpz) + mpq(1::mpz, 6::mpz);
SELECT gcd(48::mpz, 18::mpz);
SELECT nextprime(100000000000000000000::mpz);

mpz is an arbitrary-size integer type, subject to PostgreSQL’s value-size limits. mpq stores a canonical numerator and denominator so fractional arithmetic remains exact until explicitly converted to an approximate type.

Important Objects

  • mpz(text) and casts construct integers in decimal or supported base-prefixed forms.
  • mpq(text) and mpq(mpz, mpz) construct rational values.
  • Both types support ordinary comparisons and btree or hash indexes.
  • Integer helpers include division with explicit rounding modes, powers, roots, primality tests, gcd, lcm, factorials, Fibonacci and Lucas numbers, bit operations, and random-state functions.
  • Rational helpers include numerator and denominator access, inversion, denominator limiting, arithmetic, comparison, and aggregates.
  • gmp_version() and gmp_max_bitcnt() expose library information.

Do not use floating-point input when exact decimal or rational meaning matters; construct values from text, integers, or explicit numerator and denominator values.

Version 1.0.6 Notes

The 1.0.6 distribution adds PostgreSQL 19 build compatibility, sets PostgreSQL 14 as the supported runtime floor in its metadata, and adds missing unsigned-long range checks for the power, Fibonacci, and Lucas-number paths.

The upstream distribution version is 1.0.6, while its tagged pgmp.control currently declares SQL extension version 1.1. Create the extension without forcing a version and inspect the database-reported value before designing an upgrade:

SELECT extversion
FROM pg_extension
WHERE extname = 'pgmp';

pgmp requires the GMP shared library. GMP 4.1 lacks a few functions documented by upstream, including some root, bit, and random-state helpers; use a current GMP release when those objects are required. Large operands can consume substantial backend memory and CPU, so apply statement timeouts and input limits to untrusted arithmetic workloads.

Last updated on