![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
SQL surface for the external-tool registry (ToolRegistry.h). More...
#include "postgres.h"#include "fmgr.h"#include "funcapi.h"#include "miscadmin.h"#include "executor/spi.h"#include "catalog/pg_type.h"#include "utils/array.h"#include "utils/builtins.h"#include "compatibility.h"#include "ToolRegistry.h"#include "tool_registry_sync.h"#include "external_tool.h"#include "provsql_error.h"#include <functional>#include <string>#include <vector>
Go to the source code of this file.
Functions | |
| void | provsql_sync_tool_registry () |
| Rebuild the in-memory registry as "compiled seed overlaid with the
provsql.tool_overrides rows". | |
| Datum | tool_registry_list (PG_FUNCTION_ARGS) |
| Set-returning listing of the registry, one row per record. | |
| Datum | tool_registry_register (PG_FUNCTION_ARGS) |
| Register a tool, or replace the record with the same name. | |
| Datum | tool_registry_unregister (PG_FUNCTION_ARGS) |
| Remove a tool record. | |
| static void | persist_tool_change (const char *fn, const std::string &name, const std::function< void(provsql::ToolRecord &)> &mutate) |
Persist a single-field change to an existing tool: load the effective record, apply mutate, and write the full record back. | |
| Datum | tool_registry_set_enabled (PG_FUNCTION_ARGS) |
| Enable or disable a tool. | |
| Datum | tool_registry_set_preference (PG_FUNCTION_ARGS) |
| Set a tool's preference. | |
SQL surface for the external-tool registry (ToolRegistry.h).
Exposes the in-memory catalog to SQL:
tool_registry_list(): set-returning, backs the read-only provsql.tools view; reports each record plus an available flag computed with the same find_external_tool the dispatchers use.tool_registry_register() / tool_registry_unregister() / tool_registry_set_enabled() / tool_registry_set_preference(): mutators, superuser-only.provsql.tool_search_path or dropping a binary on it). The mutators therefore refuse non-superusers; the read-only listing is unrestricted, like tool_available.provsql.tool_overrides table and overlaid on the seed by provsql_sync_tool_registry, which every registry-consuming SQL function calls so changes are seen across sessions and backends. An empty overrides table is exactly the compiled defaults; the table being absent (an extension older than 1.8.0) is treated the same way. Definition in file tool_registry_sql.cpp.
|
static |
Persist a single-field change to an existing tool: load the effective record, apply mutate, and write the full record back.
Errors on an unknown tool name.
Definition at line 408 of file tool_registry_sql.cpp.


| void provsql_sync_tool_registry | ( | ) |
Rebuild the in-memory registry as "compiled seed overlaid with the provsql.tool_overrides rows".
See tool_registry_sync.h.
Definition at line 200 of file tool_registry_sql.cpp.


| Datum tool_registry_list | ( | PG_FUNCTION_ARGS | ) |
Set-returning listing of the registry, one row per record.
Columns: name, kind, binary, operations (text[]), input_formats (text[]), output_format (text), parser (text), preference (int), enabled (bool), argtpl (text), argtpl_circuit (text), available (bool). operations / input_formats / output_format use the KCMCP registry names; parser is the CLI-only decode tag. available is true iff binary (when set) and every dependency resolve via find_external_tool, so the view reflects what a subsequent dispatch would actually find on the backend's PATH.
Definition at line 259 of file tool_registry_sql.cpp.

| Datum tool_registry_register | ( | PG_FUNCTION_ARGS | ) |
Register a tool, or replace the record with the same name.
Args (in order): name text, executable text, kind text, operations text[], input_formats text[], output_format text, parser text, argtpl text, argtpl_circuit text, preference int, enabled bool, endpoint text. A NULL executable defaults to name; a NULL kind defaults to 'cli'; NULL arrays are empty; NULL text fields default to empty; NULL preference is 0 and NULL enabled is true; endpoint is the KCMCP server address for a 'kcmcp' record. Superuser-only.
Definition at line 336 of file tool_registry_sql.cpp.
| Datum tool_registry_set_enabled | ( | PG_FUNCTION_ARGS | ) |
Enable or disable a tool.
Errors on an unknown tool name.
Definition at line 425 of file tool_registry_sql.cpp.

| Datum tool_registry_set_preference | ( | PG_FUNCTION_ARGS | ) |
Set a tool's preference.
Errors on an unknown tool name.
Definition at line 437 of file tool_registry_sql.cpp.

| Datum tool_registry_unregister | ( | PG_FUNCTION_ARGS | ) |
Remove a tool record.
Errors if no tool of that name is currently effective, so a typo fails loudly rather than silently doing nothing. A removed seeded default is recorded as a tombstone; the change persists.
Definition at line 388 of file tool_registry_sql.cpp.
