diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 9005b26..c53ef95 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -1091,6 +1091,23 @@ errhidecontext(bool hide_ctx) return 0; /* return value does not matter */ } +/* + * errhidefromclient --- optionally suppress output of message to client + * + * Only log levels below ERROR can be hidden from the client. + */ +int +errhidefromclient(bool hide_from_client) +{ + ErrorData *edata = &errordata[errordata_stack_depth]; + + /* we don't bother incrementing recursion_depth */ + CHECK_STACK_DEPTH(); + + edata->hide_from_client = hide_from_client; + + return 0; /* return value does not matter */ +} /* * errfunction --- add reporting function name to the current error @@ -1467,7 +1484,7 @@ EmitErrorReport(void) send_message_to_server_log(edata); /* Send to client, if enabled */ - if (edata->output_to_client) + if (edata->output_to_client && !edata->hide_from_client) send_message_to_frontend(edata); MemoryContextSwitchTo(oldcontext); diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 326896f..14b87b7 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -179,6 +179,7 @@ extern int errcontext_msg(const char *fmt,...) pg_attribute_printf(1, 2); extern int errhidestmt(bool hide_stmt); extern int errhidecontext(bool hide_ctx); +extern int errhidefromclient(bool hide_from_client); extern int errfunction(const char *funcname); extern int errposition(int cursorpos); @@ -343,6 +344,7 @@ typedef struct ErrorData bool show_funcname; /* true to force funcname inclusion */ bool hide_stmt; /* true to prevent STATEMENT: inclusion */ bool hide_ctx; /* true to prevent CONTEXT: inclusion */ + bool hide_from_client; /* true to prevent client output */ const char *filename; /* __FILE__ of ereport() call */ int lineno; /* __LINE__ of ereport() call */ const char *funcname; /* __func__ of ereport() call */