PostgreSQL Source Code
git master
miscnodes.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* miscnodes.h
4
* Definitions for hard-to-classify node types.
5
*
6
* Node types declared here are not part of parse trees, plan trees,
7
* or execution state trees. We only assign them NodeTag values because
8
* IsA() tests provide a convenient way to disambiguate what kind of
9
* structure is being passed through assorted APIs, such as function
10
* "context" pointers.
11
*
12
*
13
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
14
* Portions Copyright (c) 1994, Regents of the University of California
15
*
16
* src/include/nodes/miscnodes.h
17
*
18
*-------------------------------------------------------------------------
19
*/
20
#ifndef MISCNODES_H
21
#define MISCNODES_H
22
23
#include "
nodes/nodes.h
"
24
25
/*
26
* ErrorSaveContext -
27
* function call context node for handling of "soft" errors
28
*
29
* A caller wishing to trap soft errors must initialize a struct like this
30
* with all fields zero/NULL except for the NodeTag. Optionally, set
31
* details_wanted = true if more than the bare knowledge that a soft error
32
* occurred is required. The struct is then passed to a SQL-callable function
33
* via the FunctionCallInfo.context field; or below the level of SQL calls,
34
* it could be passed to a subroutine directly.
35
*
36
* After calling code that might report an error this way, check
37
* error_occurred to see if an error happened. If so, and if details_wanted
38
* is true, error_data has been filled with error details (stored in the
39
* callee's memory context!). The ErrorData can be modified (e.g. downgraded
40
* to a WARNING) and reported with ThrowErrorData(). FreeErrorData() can be
41
* called to release error_data, although that step is typically not necessary
42
* if the called code was run in a short-lived context.
43
*/
44
typedef
struct
ErrorSaveContext
45
{
46
NodeTag
type
;
47
bool
error_occurred
;
/* set to true if we detect a soft error */
48
bool
details_wanted
;
/* does caller want more info than that? */
49
ErrorData
*
error_data
;
/* details of error, if so */
50
}
ErrorSaveContext
;
51
52
/* Often-useful macro for checking if a soft error was reported */
53
#define SOFT_ERROR_OCCURRED(escontext) \
54
((escontext) != NULL && IsA(escontext, ErrorSaveContext) && \
55
((ErrorSaveContext *) (escontext))->error_occurred)
56
57
#endif
/* MISCNODES_H */
ErrorSaveContext
struct ErrorSaveContext ErrorSaveContext
nodes.h
NodeTag
NodeTag
Definition:
nodes.h:27
ErrorData
Definition:
elog.h:428
ErrorSaveContext
Definition:
miscnodes.h:45
ErrorSaveContext::details_wanted
bool details_wanted
Definition:
miscnodes.h:48
ErrorSaveContext::error_data
ErrorData * error_data
Definition:
miscnodes.h:49
ErrorSaveContext::error_occurred
bool error_occurred
Definition:
miscnodes.h:47
ErrorSaveContext::type
NodeTag type
Definition:
miscnodes.h:46
src
include
nodes
miscnodes.h
Generated on Fri Dec 6 2024 12:13:24 for PostgreSQL Source Code by
1.9.1