hashtypes
sha1, md5 and other data types for PostgreSQL
Repository
adjust/hashtypes
https://github.com/adjust/hashtypes/
Source
hashtypes-0.1.5.tar.gz
hashtypes-0.1.5.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
hashtypes | 0.1.5 | TYPE | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3750 | hashtypes | No | Yes | No | Yes | No | No | - |
| Related | prefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.5 | 1817161514 | hashtypes | - |
| RPM | PIGSTY | 0.1.5 | 1817161514 | hashtypes_$v | - |
| DEB | PIGSTY | 0.1.5 | 1817161514 | postgresql-$v-hashtypes | - |
Build
You can build the RPM / DEB packages for hashtypes using pig build:
pig build pkg hashtypes # build RPM / DEB packages
Install
You can install hashtypes directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install hashtypes; # Install for current active PG version
pig ext install -y hashtypes -v 18 # PG 18
pig ext install -y hashtypes -v 17 # PG 17
pig ext install -y hashtypes -v 16 # PG 16
pig ext install -y hashtypes -v 15 # PG 15
pig ext install -y hashtypes -v 14 # PG 14
dnf install -y hashtypes_18 # PG 18
dnf install -y hashtypes_17 # PG 17
dnf install -y hashtypes_16 # PG 16
dnf install -y hashtypes_15 # PG 15
dnf install -y hashtypes_14 # PG 14
apt install -y postgresql-18-hashtypes # PG 18
apt install -y postgresql-17-hashtypes # PG 17
apt install -y postgresql-16-hashtypes # PG 16
apt install -y postgresql-15-hashtypes # PG 15
apt install -y postgresql-14-hashtypes # PG 14
Create Extension:
CREATE EXTENSION hashtypes;
Usage
The hashtypes extension provides native data types for storing hash values and checksums in their binary representation, saving storage compared to text.
CREATE EXTENSION hashtypes;
Data Types
| Type | Storage | Description |
|---|---|---|
sha1 | 20 bytes | SHA-1 hash (160-bit) |
sha224 | 28 bytes | SHA-224 hash (224-bit) |
sha256 | 32 bytes | SHA-256 hash (256-bit) |
sha384 | 48 bytes | SHA-384 hash (384-bit) |
sha512 | 64 bytes | SHA-512 hash (512-bit) |
crc32 | 4 bytes | CRC-32 checksum |
Usage
CREATE TABLE objects (
hash sha256 PRIMARY KEY,
data bytea
);
INSERT INTO objects VALUES (
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
'\x'
);
SELECT * FROM objects WHERE hash = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
Operators
All types support comparison operators: =, <>, <, >, <=, >=.
Index Support
Btree and hash index operator classes are provided for all types.
Casts
All types support bidirectional casts to/from text and bytea.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.