pg_primal
pg_primal · Primal database extension used by the Primal Nostr cache server.
Overview
PostgreSQL · 11, 12, 13, 14, 15, 16
Usage
Sources:
pg_primal is the small PostgreSQL helper extension used by Primal Server, a Nostr cache service. It provides Nostr identifier parsing and construction of Primal’s media-cache URL; it does not install the server’s large application schema or run the Nostr service itself.
Core Workflow
Function Index
nostr_parse(text) RETURNS byteaasks the Nostr SDK to parse the input as a public key first and then as an event ID. A recognized identifier becomes its 32-byte representation; an unrecognized value returnsNULL.cdn_url(text, text, boolean) RETURNS textbuilds a URL under Primal’shttps://primal.b-cdn.net/media-cacheendpoint. The first character of the size argument becomes thesparameter, the animation flag becomesa=1ora=0, and the source URL is percent-encoded intou.
Boundaries
The extension manifest advertises PostgreSQL 11 through 16 build features and version 0.0.0; it has no preload requirement. Both functions are application-specific helpers. cdn_url unwraps all three arguments and reads the first size character, so pass non-NULL values and a non-empty size string. The Nostr cache database schema and websocket API are initialized and operated by Primal Server’s separate setup workflow.