Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d7a6a9

Browse files
committed
Move ERRCODE_XXX macros into their own header file.
1 parentaec57ea commit2d7a6a9

File tree

3 files changed

+329
-295
lines changed

3 files changed

+329
-295
lines changed

‎doc/src/sgml/sources.sgml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/sources.sgml,v 2.10 2003/07/22 19:00:07 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/sources.sgml,v 2.11 2003/07/27 18:37:52 tgl Exp $
33
-->
44

55
<chapter id="source">
@@ -115,7 +115,7 @@ less -x4
115115
</programlisting>
116116
This specifies error severity level <literal>ERROR</> (a run-of-the-mill
117117
error). The <function>errcode</> call specifies the SQLSTATE error code
118-
using a macro defined in <filename>src/include/utils/elog.h</>. The
118+
using a macro defined in <filename>src/include/utils/errcodes.h</>. The
119119
<function>errmsg</> call provides the primary message text. Notice the
120120
extra set of parentheses surrounding the auxiliary function calls ---
121121
these are annoying but syntactically necessary.
@@ -144,7 +144,7 @@ less -x4
144144
<function>errcode</>(sqlerrcode) specifies the SQLSTATE error identifier
145145
code for the condition. If this routine is not called, the error
146146
identifier defaults to
147-
<literal>ERRCODE_INTERNAL_ERROR</> when the error level is
147+
<literal>ERRCODE_INTERNAL_ERROR</> when the errorseveritylevel is
148148
<literal>ERROR</> or higher, <literal>ERRCODE_WARNING</> when the
149149
error level is <literal>WARNING</>, otherwise (for <literal>NOTICE</>
150150
and below) <literal>ERRCODE_SUCCESSFUL_COMPLETION</>.
@@ -245,11 +245,23 @@ less -x4
245245
</para>
246246

247247
<para>
248-
You may also see uses of the older function <function>elog</>. This
249-
is equivalent to an <function>ereport</> call specifying only severity
250-
level and primary message. <function>elog</> should only be used if
251-
the default errcode assignment is appropriate; this generally restricts
252-
its use to internal errors and debug logging output.
248+
There is an older function <function>elog</> that is still heavily used.
249+
An <function>elog</> call
250+
<programlisting>
251+
elog(level, "format string", ...);
252+
</programlisting>
253+
is exactly equivalent to
254+
<programlisting>
255+
ereport(level, (errmsg_internal("format string", ...)));
256+
</programlisting>
257+
Notice that the SQLSTATE errcode is always defaulted, and the message
258+
string is not included in the internationalization message dictionary.
259+
Therefore, <function>elog</> should be used only for internal errors and
260+
low-level debug logging. Any message that is likely to be of interest to
261+
ordinary users should go through <function>ereport</>. Nonetheless,
262+
there are enough internal <quote>can't happen</> error checks in the
263+
system that <function>elog</> is still widely used; it is preferred for
264+
those messages for its notational simplicity.
253265
</para>
254266

255267
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp