Skip to content

Function reference

Every supported (stable) function, grouped by task. All live in the pgrdf schema. The running server can list them itself: SELECT * FROM pgrdf.surface() WHERE class = 'stable'.

A graph argument (g, graph_id, src, dst) is a numeric graph id. Get one with pgrdf.graph_id(iri). Several functions also accept IRIs directly, as listed.

Graphs

FunctionReturnsPurpose
add_graph(iri text)bigintCreate a graph (or find the existing one) and return its id.
graph_id(iri text)bigintId for an IRI, or NULL if there is no such graph.
graph_iri(id bigint)textIRI for an id, or NULL.
graph_inventory()tableEvery graph: graph_id, iri, asserted, inferred, locked, lock_reason, materialization.
count_quads(g bigint DEFAULT 0)bigintAsserted + inferred triples in one graph.
clear_graph(id bigint) · clear_graph(iri text)bigintRemove all triples; keep the graph.
copy_graph(src bigint, dst bigint) · copy_graph(src_iri text, dst_iri text)bigintAppend src into dst, inferred triples included. The IRI form needs dst to exist.
move_graph(src bigint, dst bigint) · move_graph(src_iri text, dst_iri text)bigintMove into an empty dst, then remove src.
drop_graph(id bigint, cascade boolean DEFAULT true) · drop_graph(iri text, cascade boolean DEFAULT true)bigintRemove a graph. With cascade => false, refuses if it holds inferred triples.
carve_graph(src bigint, predicate text, dst bigint)bigintCopy every triple using one predicate.
carve_graph(src bigint, seeds text[], dst bigint, max_hops integer DEFAULT 1)bigintCopy the neighbourhood of seed IRIs, up to max_hops steps.
lock_graph(graph_id bigint, reason text)booleanMake a graph read-only for every write path.
unlock_graph(graph_id bigint, reason text)booleanRelease a lock.
graph_integrity(graph_id bigint)jsonbCheck every triple is well-formed.
orphan_partitions()tableStorage partitions with no graph. Normally empty.

Guide: Managing graphs

Loading

FunctionReturnsPurpose
parse_turtle(content text, graph_id bigint, base_iri text DEFAULT NULL)bigintLoad Turtle or N-Triples from a string.
parse_turtle_verbose(content text, graph_id bigint, base_iri text DEFAULT NULL)jsonbSame, with a load report.
parse_trig(content text, default_graph_id bigint DEFAULT 0, strict boolean DEFAULT false)jsonbLoad TriG. Named graphs in the data are created as needed; with strict => true they must already exist.
parse_nquads(content text, default_graph_id bigint DEFAULT 0, strict boolean DEFAULT false)jsonbLoad N-Quads, same rules.
load_turtle(path text, graph_id bigint, base_iri text DEFAULT NULL, bulk_load boolean DEFAULT false)bigintLoad a file from the server's filesystem.
load_turtle_verbose(path text, graph_id bigint, base_iri text DEFAULT NULL, bulk_load boolean DEFAULT false)jsonbSame, with a load report.
load_turtle_streaming(path text, graph_id bigint, window_triples integer DEFAULT 20000000, id_reserve_block integer DEFAULT 1000000, base_iri text DEFAULT NULL)jsonbWindowed load for files larger than memory.
load_turtle_staged_run(path text, graph_id bigint, n_workers integer DEFAULT 0)jsonbParallel multi-worker load of a large N-Triples file into an empty database.
load_turtle_staged(path text, graph_id bigint, n_workers integer DEFAULT 0)procedureSame, as a CALL-able procedure.

Guide: Loading RDF

Querying

FunctionReturnsPurpose
sparql(query text)SETOF jsonbSELECT, ASK and SPARQL UPDATE.
construct(query text)SETOF jsonbCONSTRUCT: one row per triple.
describe(query text)SETOF jsonbDESCRIBE: one row per triple.
sparql_parse(query text)jsonbParse without running; lists unsupported parts.
sparql_sql(query text)textThe SQL a query would run.
last_call_stats()jsonbCompleteness figures for this session's last query.
get_term(id bigint)textText of a term id.

Guide: Querying

Reasoning and validation

FunctionReturnsPurpose
materialize(graph_id bigint, profile text DEFAULT 'owl-rl')jsonbCompute and store inferred triples. Profiles: 'owl-rl', 'rdfs'.
validate(data_graph_id bigint, shapes_graph_id bigint, mode text DEFAULT 'native', strict boolean DEFAULT true)jsonbSHACL validation report. Modes: 'native', 'pgrdf', 'sparql'.

Guides: Reasoning · Validation

Identity and export

FunctionReturnsPurpose
graph_digest(graph_id bigint)textCanonical graph identity (rdfc-1.0-sha256).
structural_digest(graph_id bigint)textFirst-degree structural digest (pgrdf-fd1-sha256). An unequal result proves the graphs differ.
export_graph(graph_id bigint)SETOF textAsserted triples as sorted canonical N-Triples.
graph_manifest(graph_id bigint)jsonbDigests, counts, engine version, and what a copy doesn't carry.

Guide: Identity and export

Server and diagnostics

FunctionReturnsPurpose
version()textExtension version.
build_id()textWhich build of that version is loaded.
surface()tableEvery function with its stability class and a usage note.
stats()jsonbCumulative server-wide counters (caches, truncations).
shmem_reset()voidReset the shared term cache. Only needed after dropping and re-creating the extension on a running server.

Guide: Errors and diagnostics

Not listed here

surface() also shows functions in the internal class (low-level building blocks) and the spike class (benchmarks). They are not part of the supported API and may change without notice.

pgRDF is released under the MIT license. Documentation built with VitePress, served via GitHub Pages.