PGROUTING  2.5
e_report.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Postgres ereport

Send notice or error to postgreSQL (cleans the char *)

From the C++ err_msg, log_msg, notice_msg are returned as a (char *),

Before exiting the C code the pointers need to be freed:

  • This task can be done when there is no error,
  • Call to ERROR, gives the control back to postgreSQL
    • leaves a leak

on C++ side, the message to be returned;

std::ostringstream log;
log << "the messaage";
log_msg = strdup(log.str().c_str());

The char* messages are cleared. New messages are made with palloc

when there is ERROR then postgreSQL takes over control

Warning
When error: Free all data not created with palloc before calling
void pgr_global_report (char *log_msg, char *notice_msg, char *error_msg)
 notice & error More...
 
void pgr_notice (char *notice_msg)
 notice with no hint More...
 
void pgr_notice2 (char *log_msg, char *notice_msg)
 notice with hint More...
 
void pgr_error (char *error_msg)
 error with no hint More...
 
void pgr_error2 (char *log_msg, char *error_msg)
 error with hint More...
 

Function Documentation

void pgr_error ( char *  error_msg)

error with no hint

if (err_msg) {
pfree(<data>);
}
pgr_error(&error_msg);
precondition: before calling ereport
assert(!*error_msg);

Definition at line 61 of file e_report.c.

References pgr_cstring2char(), and PGR_DBG.

61  {
62  PGR_DBG("Returned error message = %s", err);
63 
64 #if 0
65  char *error = NULL;
66  if (*err_msg) {
67  error = pgr_cstring2char(*err_msg);
68  free(*err_msg);
69  }
70 #endif
71  if (err) {
72  ereport(ERROR,
73  (errmsg_internal("Unexpected"),
74  errhint("%s", err)));
75  }
76 }
#define PGR_DBG(...)
Definition: debug_macro.h:34
char * pgr_cstring2char(const char *inStr)

Here is the call graph for this function:

void pgr_error2 ( char *  log_msg,
char *  error_msg 
)

error with hint

if (err_msg) {
pfree(<data>);
}
pgr_error(&log_msg, &error_msg);
precondition: before calling ereport
assert(!*log_msg);
assert(!*error_msg);

Definition at line 79 of file e_report.c.

References PGR_DBG.

81  {
82  PGR_DBG("Returned log message = %s", log);
83  PGR_DBG("Returned error message = %s", err);
84 
85  if (err) {
86  ereport(ERROR,
87  (errmsg_internal("%s", err),
88  errhint("%s", log)));
89  }
90 }
#define PGR_DBG(...)
Definition: debug_macro.h:34
void pgr_global_report ( char *  log_msg,
char *  notice_msg,
char *  error_msg 
)

notice & error

pgr_notice(&log_msg, &notice_msg, &error_msg);
precondition: before calling ereport
assert(!*log_msg);
assert(!*notice_msg);
assert(!*error_msg);

Definition at line 93 of file e_report.c.

Referenced by compute(), and process().

96  {
97  if (!notice && log) {
98  ereport(DEBUG1,
99  (errmsg_internal("%s", log)));
100  }
101 
102  if (notice) {
103  if (log) {
104  ereport(NOTICE,
105  (errmsg_internal("%s", notice),
106  errhint("%s", log)));
107  } else {
108  ereport(NOTICE,
109  (errmsg_internal("%s", notice)));
110  }
111  }
112 
113  if (err) {
114  if (log) {
115  ereport(ERROR,
116  (errmsg_internal("%s", err),
117  errhint("%s", log)));
118  } else {
119  ereport(ERROR,
120  (errmsg_internal("%s", err)));
121  }
122  }
123 }

Here is the caller graph for this function:

void pgr_notice ( char *  notice_msg)

notice with no hint

pgr_notice(&log_msg, &notice_msg);
precondition: before calling ereport
assert(!log_msg);
assert(!notice_msg);

Definition at line 31 of file e_report.c.

References PGR_DBG.

Referenced by pgr_notice2().

32  {
33  PGR_DBG("Returned notice message = %s", notice);
34 
35  if (notice) {
36  ereport(NOTICE,
37  (errmsg("%s", notice)));
38  }
39 }
#define PGR_DBG(...)
Definition: debug_macro.h:34

Here is the caller graph for this function:

void pgr_notice2 ( char *  log_msg,
char *  notice_msg 
)

notice with hint

pgr_notice(&log_msg, &notice_msg);
precondition: before calling ereport
assert(!log_msg);
assert(!notice_msg);

Definition at line 42 of file e_report.c.

References PGR_DBG, and pgr_notice().

44  {
45  PGR_DBG("Returned log message = %s", log);
46  PGR_DBG("Returned notice message = %s", notice);
47 
48  if (log) {
49  pgr_notice(notice);
50  return;
51  }
52 
53  if (notice) {
54  ereport(NOTICE,
55  (errmsg("%s", notice),
56  errhint("%s", log)));
57  }
58 }
#define PGR_DBG(...)
Definition: debug_macro.h:34
void pgr_notice(char *notice)
notice with no hint
Definition: e_report.c:31

Here is the call graph for this function: