hashlib
Stable hash functions for Postgres
pg_hashlib : Stable hash functions for Postgres
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4400 | hashlib | pg_hashlib | 1.1 |
UTIL | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
build-deps: python3-docutils
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1 |
18 17 16 15 14 | pg_hashlib |
- |
| RPM | PIGSTY | 1.1 |
18 17 16 15 14 | pg_hashlib_$v |
- |
| DEB | PIGSTY | 1.1 |
18 17 16 15 14 | postgresql-$v-pg-hashlib |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el8.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el9.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el9.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el10.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el10.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d12.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d12.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d13.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d13.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u22.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u22.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u24.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u24.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u26.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u26.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
Source
github.com/markokr/pghashlib
pg_hashlib-1.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Provides stable hash functions whose implementations do not change across PostgreSQL versions.
String Hashing (32-bit)
With optional initial value:
String Hashing (64-bit)
String Hashing (128-bit)
Integer Hashing
Available Algorithms
| Algorithm | CPU-indep | Bits | Description |
|---|---|---|---|
crc32 |
yes | 32 | CRC32 |
murmur3 |
no | 32 | MurmurHash v3 |
md5 |
yes | 128 | MD5 |
city64 |
no | 64 | CityHash64 |
city128 |
no | 128 | CityHash128 |
siphash24 |
yes | 64 | SipHash-2-4 |
spooky |
no | 128 | SpookyHash |
lookup2 |
no | 64 | Jenkins lookup2 |
lookup3 |
no | 64 | Jenkins lookup3 CPU-native |
lookup3be |
yes | 64 | Jenkins lookup3 big-endian |
lookup3le |
yes | 64 | Jenkins lookup3 little-endian |
pgsql84 |
no | 64 | Hacked lookup3 in Postgres 8.4+ |
Integer algorithms: wang32, wang32mult, jenkins (32-bit); wang64, wang64to32 (64-bit). All are reversible (1:1 mapping), useful for creating random sort orders over unique IDs.