hashtypes
hashtypes
hashtypes : sha1, md5 and other data types for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3750 | hashtypes | hashtypes | 0.1.5 | TYPE | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| See Also | prefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.5 | 18 17 16 15 14 | hashtypes | - |
| RPM | PIGSTY | 0.1.5 | 18 17 16 15 14 | hashtypes_$v | - |
| DEB | PIGSTY | 0.1.5 | 18 17 16 15 14 | postgresql-$v-hashtypes | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
el8.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
el9.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
el9.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
el10.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
el10.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
d12.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
d12.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
d13.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
d13.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
u22.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
u22.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
u24.x86_64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
u24.aarch64 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 | PIGSTY 0.1.5 |
Source
pig build pkg hashtypes; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install hashtypes; # install via package name, for the active PG version
pig install hashtypes -v 18; # install for PG 18
pig install hashtypes -v 17; # install for PG 17
pig install hashtypes -v 16; # install for PG 16
pig install hashtypes -v 15; # install for PG 15
pig install hashtypes -v 14; # install for PG 14Create this extension with:
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.
Last updated on