{"id":20644042,"url":"https://github.com/adjust/pg-base62","last_synced_at":"2026-04-18T08:03:52.116Z","repository":{"id":66824980,"uuid":"502883147","full_name":"adjust/pg-base62","owner":"adjust","description":"Base62 extension for PostgreSQL","archived":false,"fork":false,"pushed_at":"2024-03-01T11:41:13.000Z","size":43,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-01-17T09:11:57.206Z","etag":null,"topics":["adjust-kpis-team","adjust-pg-extension"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adjust.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-13T09:07:19.000Z","updated_at":"2024-11-22T02:55:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9e77870-7eab-40d2-8ab6-477aa3ae66e7","html_url":"https://github.com/adjust/pg-base62","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-base62","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-base62/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-base62/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-base62/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adjust","download_url":"https://codeload.github.com/adjust/pg-base62/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242705599,"owners_count":20172325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adjust-kpis-team","adjust-pg-extension"],"created_at":"2024-11-16T16:14:37.350Z","updated_at":"2026-04-18T08:03:47.072Z","avatar_url":"https://github.com/adjust.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/adjust/pg-base62/workflows/CI/badge.svg)\n\n# pg-base62\nBase62 extension for PostgreSQL. The extension provides data types to encode and\ndecode values using base62 encoding scheme.\n\nBase62 uses 62 ASCII characters: `0 - 9`, `A - Z` and `a - z`.\n\nMore information about base62 encoding scheme:\n- Wikipedia page: https://en.wikipedia.org/wiki/Base62\n- A blog post: https://helloacm.com/base62/\n\n## Types\n\n### `base62`\n\n`base62` stores encoded value in 4 bytes integer. The maximum length of string\nrepresentation is 6 characters and maximum value of numeric representation is\n2147483647.\n\n```sql\n-- Cast from text\n=# select '2LKcb1'::base62::int;\n    int4    \n------------\n 2147483647\n\n-- Cast from integer\n=# select 2147483647::base62;\n base62 \n--------\n 2LKcb1\n\n=# select '1111111'::base62::int;\nERROR:  value \"1111111\" is out of range for type base62\n\n-- The type is case sensitive\n=# select '2lkcb'::base62::int, '2lkcb'::base62, '2LKCB'::base62::int, '2LKCB'::base62;\n   int4   | base62 |   int4   | base62 \n----------+--------+----------+--------\n 40933305 | 2lkcb  | 34635195 | 2LKCB\n```\n\n### `bigbase62`\n\n`bigbase62` stores encoded value in 8 bytes integer. The maxiumum length of\nstring representation is 11 characters and the maximum value of numeric\nrepresentation is 9223372036854775807.\n\n```sql\n-- Cast from text\n=# select 'AzL8n0Y58m7'::bigbase62::bigint;\n        int8         \n---------------------\n 9223372036854775807\n\n-- Cast from integer\n=# select 9223372036854775807::bigbase62;\n  bigbase62  \n-------------\n AzL8n0Y58m7\n\n=# select '111111111111'::bigbase62::bigint;\nERROR:  value \"111111111111\" is out of range for type bigbase62\n\n-- The type is case sensitive\n=# select '2lkcb1'::bigbase62::bigint, '2lkcb1'::bigbase62, '2LKCB1'::bigbase62::bigint, '2LKCB1'::bigbase62;\n    int8    | bigbase62 |    int8    | bigbase62 \n------------+-----------+------------+-----------\n 2537864911 | 2lkcb1    | 2147382091 | 2LKCB1\n```\n\n### `hugebase62`\n\n`hugebase62` stores encoded value in 16 bytes integer. The maximum length of\nstring representation is 20 characters.\n\nIt doesn't support casting from/to numeric type. Instead it support casting\nfrom/to `bytea` type. This is useful for applications to work with `hugebase62`.\n\n```sql\n-- Cast from text\n=# select 'AzL8n0Y58m7AzL8n0Y58'::hugebase62;\n      hugebase62      \n----------------------\n AzL8n0Y58m7AzL8n0Y58\n\n=# select 'AzL8n0Y58m7AzL8n0Y58'::hugebase62::bytea;\n               bytea                \n------------------------------------\n \\x960c06065a6ed8ffff1e7149f40b1800\n\n-- Cast from bytea\n=# select '\\x960c06065a6ed8ffff1e7149f40b1800'::bytea::hugebase62;\n      hugebase62      \n----------------------\n AzL8n0Y58m7AzL8n0Y58\n\n=# select '111111111111111111111'::hugebase62;\nERROR:  value \"111111111111111111111\" is out of range for type hugebase62\n\n-- The type is case sensitive\n=# select '2lkcb1'::hugebase62::bytea, '2lkcb1'::hugebase62, '2LKCB1'::hugebase62::bytea, '2LKCB1'::hugebase62;\n               bytea                | hugebase62 |               bytea                | hugebase62 \n------------------------------------+------------+------------------------------------+------------\n \\xcfbe4497000000000000000000000000 | 2lkcb1     | \\x4b73fe7f000000000000000000000000 | 2LKCB1\n```\n\n### Index support\n\nAll types support `btree` and `hash` indexes.\n\n## Installation from source codes\n\nTo install `base62`, execute this in the extension's directory:\n\n```shell\nmake install\n```\n\n\u003e **Notice:** Don't forget to set the `PG_CONFIG` variable (`make PG_CONFIG=...`)\n\u003e in case you want to test `base62` on a non-default or custom build of PostgreSQL.\n\u003e Read more [here](https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules).\n\n\u003e **Important:** To compile `base62` your compiler should support 128-bit integers,\n\u003e otherwise it will fail during compilation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadjust%2Fpg-base62","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadjust%2Fpg-base62","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadjust%2Fpg-base62/lists"}