isn

data types for international product numbering standards

Overview

PackageVersionCategoryLicenseLanguage
isn1.2TYPEPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
3930isnNoYesNoYesYesNo-
Relatedprefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap

Version

PG18PG17PG16PG15PG14
1.21.21.21.21.2

Install

Note: This is a built-in contrib extension of PostgreSQL

CREATE EXTENSION isn;

Usage

isn: ISBN, ISSN, EAN, UPC product number types

The isn extension provides data types for international product numbering standards with validation and check-digit verification.

CREATE EXTENSION isn;

Data Types

TypeDescription
EAN13European Article Numbers (always 13-digit)
ISBN13International Standard Book Numbers (13-digit)
ISMN13International Standard Music Numbers (13-digit)
ISSN13International Standard Serial Numbers (13-digit)
ISBNBook numbers (10-digit short format when possible)
ISMNMusic numbers (10-digit short format when possible)
ISSNSerial numbers (10-digit short format when possible)
UPCUniversal Product Codes

Examples

SELECT isbn('978-0-393-04002-9');
SELECT isbn13('0901690546');
SELECT issn('1436-4522');

-- Create table with ISBN column
CREATE TABLE books (id isbn);
INSERT INTO books VALUES ('9780393040029');

-- Auto-calculate check digit with ?
INSERT INTO books VALUES ('220500896?');

-- Type casting
SELECT ean13('0901690546'::isbn);

Weak Mode

Enable weak mode to accept invalid check digits (useful for OCR/data cleanup):

SET isn.weak TO true;
INSERT INTO books VALUES ('978-0-11-000533-4');
SET isn.weak TO false;

-- Find invalid entries
SELECT id FROM books WHERE NOT is_valid(id);

-- Fix invalid entries
UPDATE books SET id = make_valid(id) WHERE id = '2-205-00876-X!';

Functions

FunctionDescription
is_valid(isn)Check if value has valid check digit
make_valid(isn)Clear the invalid-check-digit flag
isn_weak()Return current weak mode status
isn_weak(boolean)Set weak mode

Operators and Indexing

Standard comparison operators (=, <, >, <=, >=, <>) with B-tree and hash index support.


Last Modified 2026-03-12: add pg extension catalog (95749bf)