![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Helpers for invoking external command-line tools. More...
#include <string>

Go to the source code of this file.
Functions | |
| int | run_external_tool (const std::string &cmdline) |
Run a shell command line, optionally extending PATH. | |
| std::string | find_external_tool (const std::string &name) |
| Locate an external tool by name. | |
| std::string | format_external_tool_status (int rv, const std::string &tool) |
Decode a system() return value into a human-readable message. | |
Helpers for invoking external command-line tools.
run_external_tool() wraps system() so that the provsql.tool_search_path GUC, if set, is prepended to $PATH for the duration of the call. The server's pre-existing PATH is restored afterwards. Used by the d-DNNF compilers (d4, c2d, minic2d, dsharp), the WeightMC model counter, and the graph-easy DOT renderer.
find_external_tool() walks the same locations and reports whether a given binary is present and executable, so callers can fail with an actionable error before composing a command line.
format_external_tool_status() decodes a system() return value into a human-readable message that distinguishes "tool not found" (shell exit 127), "tool not executable" (126), "killed by signal", and "ran and exited nonzero".
In the standalone tdkc build (when TDKC is defined) the GUC layer is unavailable; the helpers degenerate to a plain std::system() call and a no-op find_external_tool.
Definition in file external_tool.h.
| std::string find_external_tool | ( | const std::string & | name | ) |
Locate an external tool by name.
Searches provsql_tool_search_path (colon-separated), then $PATH, for an executable file matching name (via access(X_OK)). Returns the full path on success, or the empty string if nothing matches.
Names containing a slash are treated as paths and tested directly without any directory walk.
| name | Bare executable name (e.g. "d4") or a path. |
"" if name is not found. Definition at line 64 of file external_tool.cpp.


| std::string format_external_tool_status | ( | int | rv, |
| const std::string & | tool ) |
Decode a system() return value into a human-readable message.
| rv | Return value from system() (or run_external_tool()). |
| tool | Tool name, used as the message subject. |
rv indicates success; otherwise a message that distinguishes "not found at runtime" (shell exit 127), "not executable" (126), "killed by
signal N", "exited with status N", or system() itself failing. Definition at line 99 of file external_tool.cpp.

| int run_external_tool | ( | const std::string & | cmdline | ) |
Run a shell command line, optionally extending PATH.
If provsql_tool_search_path is non-empty, it is prepended (with :) to $PATH before system() is called and restored afterwards.
| cmdline | Shell command line, passed verbatim to /bin/sh -c. |
system(). Definition at line 34 of file external_tool.cpp.
