ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
provsql_error.h
Go to the documentation of this file.
1
/**
2
* @file provsql_error.h
3
* @brief Uniform error-reporting macros for ProvSQL.
4
*
5
* Defines four convenience macros that wrap PostgreSQL's @c elog() and
6
* always prefix the user-visible message with @c "ProvSQL: ", giving every
7
* diagnostic a consistent origin tag regardless of which source file emits
8
* it.
9
*
10
* The prefix is inserted by compile-time string-literal concatenation, so
11
* @p fmt **must** be a string literal (not a runtime @c char* variable).
12
*
13
* ### Availability of @c elog()
14
* This header intentionally contains no @c \#include directives. The
15
* caller is responsible for making @c elog() visible before including this
16
* header:
17
* - In normal PostgreSQL extension code, @c elog() comes from
18
* @c <utils/elog.h>, pulled in transitively through @c postgres.h or
19
* @c provsql_utils.h (which already includes this file at its end).
20
* - In the standalone @c tdkc binary, @c BooleanCircuit.cpp defines a
21
* lightweight @c \#define @c elog stub that writes to @c stderr and calls
22
* @c exit() on @c ERROR; @c provsql_error.h is included after that stub.
23
*/
24
25
#ifndef PROVSQL_ERROR_H
26
#define PROVSQL_ERROR_H
27
28
/**
29
* @brief Report a fatal ProvSQL error and abort the current transaction.
30
*
31
* Expands to @c elog(ERROR, "ProvSQL: " fmt, ...). In PostgreSQL, @c ERROR
32
* performs a non-local exit via @c longjmp; the call never returns. In the
33
* standalone @c tdkc build the @c elog stub calls @c exit(EXIT_FAILURE).
34
*
35
* @param fmt A string literal format string (printf-style).
36
* @param ... Optional format arguments.
37
*/
38
#define provsql_error(fmt, ...) elog(ERROR, "ProvSQL: " fmt, ##__VA_ARGS__)
39
40
/**
41
* @brief Emit a ProvSQL warning message (execution continues).
42
*
43
* Expands to @c elog(WARNING, "ProvSQL: " fmt, ...). The message is sent
44
* to the client and server log according to the PostgreSQL
45
* @c log_min_messages / @c client_min_messages settings.
46
*
47
* @param fmt A string literal format string (printf-style).
48
* @param ... Optional format arguments.
49
*/
50
#define provsql_warning(fmt, ...) elog(WARNING, "ProvSQL: " fmt, ##__VA_ARGS__)
51
52
/**
53
* @brief Emit a ProvSQL informational notice (execution continues).
54
*
55
* Expands to @c elog(NOTICE, "ProvSQL: " fmt, ...). Typically used for
56
* progress messages gated on @c provsql.verbose_level.
57
*
58
* @param fmt A string literal format string (printf-style).
59
* @param ... Optional format arguments.
60
*/
61
#define provsql_notice(fmt, ...) elog(NOTICE, "ProvSQL: " fmt, ##__VA_ARGS__)
62
63
/**
64
* @brief Write a ProvSQL message to the server log only.
65
*
66
* Expands to @c elog(LOG, "ProvSQL: " fmt, ...). @c LOG messages go to the
67
* PostgreSQL server log and are not forwarded to the client. Suitable for
68
* background-worker lifecycle events (e.g. worker startup).
69
*
70
* @param fmt A string literal format string (printf-style).
71
* @param ... Optional format arguments.
72
*/
73
#define provsql_log(fmt, ...) elog(LOG, "ProvSQL: " fmt, ##__VA_ARGS__)
74
75
#endif
/* PROVSQL_ERROR_H */
← Back to provsql.org