Skip to main content
Card numbers, IMEI codes, barcodes, and Canadian social insurance numbers all carry a Luhn check digit, and a wrong digit is the most common way a typed identifier goes bad. vsql_luhn checks that digit and generates it, so a CHECK constraint can refuse a bad number before it reaches a row.
A third party writes and maintains this extension. VillageSQL does not build, test, or ship it, and the description below follows the maintainer’s own documentation. Read that documentation before you rely on it.

Install

Build it from the repository, then install it into the server:

What it adds

Because luhn_valid answers 0 instead of failing on text that is not a number, it drops straight into a WHERE clause over a column of unvalidated input.

See also