Skip to content

pgrdf

RDF, SPARQL, SHACL, and OWL reasoning for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
pgrdf0.6.40FEATMITRust
IDExtensionBinLibLoadCreateTrustRelocSchema
2640pgrdfNoYesYesYesNoNopgrdf

Production hook/cache deployments should preload pgrdf.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.6.401817161514pgrdf-
RPMPIGSTY0.6.401817161514pgrdf_$v-
DEBPIGSTY0.6.401817161514postgresql-$v-pgrdf-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
u22.x86_64
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
u22.aarch64
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
u24.x86_64
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
u24.aarch64
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
PIGSTY 0.6.39
u26.x86_64
u26.aarch64

Build

You can build the RPM / DEB packages for pgrdf using pig build:

pig build pkg pgrdf         # build RPM / DEB packages

Install

You can install pgrdf 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:

Install
pig install pgrdf;          # Install for current active PG version
pig
pig ext install -y pgrdf -v 18  # PG 18
pig ext install -y pgrdf -v 17  # PG 17
pig ext install -y pgrdf -v 16  # PG 16
pig ext install -y pgrdf -v 15  # PG 15
pig ext install -y pgrdf -v 14  # PG 14
dnf
dnf install -y pgrdf_18       # PG 18
dnf install -y pgrdf_17       # PG 17
dnf install -y pgrdf_16       # PG 16
dnf install -y pgrdf_15       # PG 15
dnf install -y pgrdf_14       # PG 14
apt
apt install -y postgresql-18-pgrdf   # PG 18
apt install -y postgresql-17-pgrdf   # PG 17
apt install -y postgresql-16-pgrdf   # PG 16
apt install -y postgresql-15-pgrdf   # PG 15
apt install -y postgresql-14-pgrdf   # PG 14

Preload:

shared_preload_libraries = 'pgrdf';

Create Extension:

CREATE EXTENSION pgrdf;

Usage

Sources:

pgrdf 0.6.40 stores RDF graphs in PostgreSQL with Turtle/TriG/N-Quads ingestion, SPARQL queries and updates, SHACL validation, and RDFS/OWL reasoning. Preload pgrdf and restart before creating the extension as a superuser.

Core Workflow

shared_preload_libraries = 'pgrdf'
CREATE EXTENSION pgrdf;
SELECT pgrdf.add_graph('http://example.org/people');
SELECT pgrdf.parse_turtle(
  '@prefix ex: <http://example.org/> . ex:alice ex:name "Alice" .',
  pgrdf.graph_id('http://example.org/people'));
SELECT * FROM pgrdf.sparql('SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10');
SELECT * FROM pgrdf.surface();

Operational Boundaries

The fixed pgrdf schema provides add_graph, graph_id, parse_turtle, load_turtle, sparql, materialize, validate, stats and surface. File loaders read server-side paths; grant access deliberately. can_clear_graphs() reports graph-clear privileges. Non-owner graph writes require the documented underlying table grants; graph locks still apply. shacl_capability() reports the supported validation surface, and path-depth/truncation settings bound traversal. Source features cover PostgreSQL 14–18; published Linux binaries target PG18. Version 0.6.39 allocates graph IDs from a non-reusing sequence; the IRI is the graph identity, and gaps are normal. After installing the matching library, run ALTER EXTENSION pgrdf UPDATE in each database. A newer library rejects old SQL with SQLSTATE 55000. Do not use the broken 0.6.35–0.6.38 PGXN source archives. Preserve graph/dictionary data together in verified backups.

Ownership Repair in 0.6.40

The 0.6.39 upgrade could leave _pgrdf_graph_id_seq owned by the upgrade executor after storage tables had been transferred to another role, preventing new graph creation. Version 0.6.40 aligns that sequence with the owner of _pgrdf_quads; granting sequence usage alone is insufficient. pgrdf.ownership_drift() reports mismatched storage owners and proposed repair commands. Review them before applying role changes. Upgrade SQL in each database after installing matching binaries; versions 0.6.34–0.6.38 can upgrade directly to 0.6.40.

Was this page helpful?