]> granicus.if.org Git - postgresql/commitdiff
Add an errdetail_internal() ereport auxiliary routine.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Jul 2011 17:41:48 +0000 (13:41 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Jul 2011 18:22:15 +0000 (14:22 -0400)
This function supports untranslated detail messages, in the same way that
errmsg_internal supports untranslated primary messages.  We've needed this
for some time IMO, but discussion of some cases in the SSI code provided
the impetus to actually add it.

Kevin Grittner, with minor adjustments by me

doc/src/sgml/sources.sgml
src/backend/utils/error/elog.c
src/include/utils/elog.h

index ac8f462de0ea9d92f3d6ab765ed87ba704fdc8b1..4ed83d6189b932c87037692c53eb93c8678e980b 100644 (file)
@@ -214,13 +214,12 @@ ereport(ERROR,
    </listitem>
    <listitem>
     <para>
-     <function>errdetail_log(const char *msg, ...)</function> is the same as
-     <function>errdetail</> except that this string goes only to the server
-     log, never to the client.  If both <function>errdetail</> and
-     <function>errdetail_log</> are used then one string goes to the client
-     and the other to the log.  This is useful for error details that are
-     too security-sensitive or too bulky to include in the report
-     sent to the client.
+     <function>errdetail_internal(const char *msg, ...)</function> is the same
+     as <function>errdetail</>, except that the message string will not be
+     translated nor included in the internationalization message dictionary.
+     This should be used for detail messages that are not worth expending
+     translation effort on, for instance because they are too technical to be
+     useful to most users.
     </para>
    </listitem>
    <listitem>
@@ -231,6 +230,18 @@ ereport(ERROR,
      For more information see <xref linkend="nls-guidelines">.
     </para>
    </listitem>
+   <listitem>
+    <para>
+     <function>errdetail_log(const char *msg, ...)</function> is the same as
+     <function>errdetail</> except that this string goes only to the server
+     log, never to the client.  If both <function>errdetail</> (or one of
+     its equivalents above) and
+     <function>errdetail_log</> are used then one string goes to the client
+     and the other to the log.  This is useful for error details that are
+     too security-sensitive or too bulky to include in the report
+     sent to the client.
+    </para>
+   </listitem>
    <listitem>
     <para>
      <function>errhint(const char *msg, ...)</function> supplies an optional
index 337b875fe20ca92c2711371b4aa1964ca0fed4e2..7c7927509b54c870ec99b60d20c51a8b57f5088a 100644 (file)
@@ -842,6 +842,33 @@ errdetail(const char *fmt,...)
 }
 
 
+/*
+ * errdetail_internal --- add a detail error message text to the current error
+ *
+ * This is exactly like errdetail() except that strings passed to
+ * errdetail_internal are not translated, and are customarily left out of the
+ * internationalization message dictionary.  This should be used for detail
+ * messages that seem not worth translating for one reason or another
+ * (typically, that they don't seem to be useful to average users).
+ */
+int
+errdetail_internal(const char *fmt,...)
+{
+       ErrorData  *edata = &errordata[errordata_stack_depth];
+       MemoryContext oldcontext;
+
+       recursion_depth++;
+       CHECK_STACK_DEPTH();
+       oldcontext = MemoryContextSwitchTo(ErrorContext);
+
+       EVALUATE_MESSAGE(detail, false, false);
+
+       MemoryContextSwitchTo(oldcontext);
+       recursion_depth--;
+       return 0;                                       /* return value does not matter */
+}
+
+
 /*
  * errdetail_log --- add a detail_log error message text to the current error
  */
index 4a3bd02689515cf2de974232cc412e1265e420de..93b141d68391564321ac77f12594a98ddf98d290 100644 (file)
@@ -146,6 +146,12 @@ errdetail(const char *fmt,...)
    the supplied arguments. */
 __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
 
+extern int
+errdetail_internal(const char *fmt,...)
+/* This extension allows gcc to check the format string for consistency with
+   the supplied arguments. */
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+
 extern int
 errdetail_log(const char *fmt,...)
 /* This extension allows gcc to check the format string for consistency with