PGROUTING  3.2
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 message";
*log_msg = pgr_msg(log.str().c_str());

when there is ERROR then postgreSQL takes over control The char* messages are cleared automaticalyy with pfree.

Warning
When error: Free all data not created with palloc before calling
void pgr_error (char *error_msg)
 error with no hint More...
 
void pgr_error2 (char *log_msg, char *error_msg)
 error with hint More...
 
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...
 

Function Documentation

◆ pgr_error()

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.

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 }

References pgr_cstring2char(), and PGR_DBG.

◆ pgr_error2()

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.

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 }

References PGR_DBG.

◆ pgr_global_report()

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.

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 }

Referenced by compute(), compute_trsp(), process(), and process_combinations().

◆ pgr_notice()

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.

32  {
33  PGR_DBG("Returned notice message = %s", notice);
34 
35  if (notice) {
36  ereport(NOTICE,
37  (errmsg("%s", notice)));
38  }
39 }

References PGR_DBG.

Referenced by pgr_notice2().

◆ pgr_notice2()

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.

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 }

References PGR_DBG, and pgr_notice().

pgr_cstring2char
char * pgr_cstring2char(const char *inStr)
Definition: postgres_connection.c:53
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
PGR_DBG
#define PGR_DBG(...)
Definition: debug_macro.h:34
pgr_notice
void pgr_notice(char *notice)
notice with no hint
Definition: e_report.c:31
pgr_error
void pgr_error(char *err)
error with no hint
Definition: e_report.c:61