1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.33 2009/04/27 16:27:36 momjian Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.34 2009/06/04 18:33:06 tgl Exp $ -->
2
2
3
3
<chapter id="source">
4
4
<title>PostgreSQL Coding Conventions</title>
@@ -181,6 +181,19 @@ ereport(ERROR,
181
181
not worth expending translation effort on.
182
182
</para>
183
183
</listitem>
184
+ <listitem>
185
+ <para>
186
+ <function>errmsg_plural(const char *fmt_singular, const char *fmt_plural,
187
+ unsigned long n, ...)</function> is like <function>errmsg</>, but with
188
+ support for various plural forms of the message.
189
+ <replaceable>fmt_singular</> is the English singular format,
190
+ <replaceable>fmt_plural</> is the English plural format,
191
+ <replaceable>n</> is the integer value that determines which plural
192
+ form is needed, and the remaining arguments are formatted according
193
+ to the selected format string. For more information see
194
+ <xref linkend="nls-guidelines">.
195
+ </para>
196
+ </listitem>
184
197
<listitem>
185
198
<para>
186
199
<function>errdetail(const char *msg, ...)</function> supplies an optional
@@ -201,6 +214,14 @@ ereport(ERROR,
201
214
sent to the client.
202
215
</para>
203
216
</listitem>
217
+ <listitem>
218
+ <para>
219
+ <function>errdetail_plural(const char *fmt_singular, const char *fmt_plural,
220
+ unsigned long n, ...)</function> is like <function>errdetail</>, but with
221
+ support for various plural forms of the message.
222
+ For more information see <xref linkend="nls-guidelines">.
223
+ </para>
224
+ </listitem>
204
225
<listitem>
205
226
<para>
206
227
<function>errhint(const char *msg, ...)</function> supplies an optional
@@ -390,14 +411,14 @@ Hint: the addendum
390
411
<para>
391
412
There are functions in the backend that will double-quote their own output
392
413
at need (for example, <function>format_type_be</>()). Do not put
393
- additional quotes around the output of such functions.
414
+ additional quotes around the output of such functions.
394
415
</para>
395
416
396
417
<para>
397
418
Rationale: Objects can have names that create ambiguity when embedded in a
398
419
message. Be consistent about denoting where a plugged-in name starts and
399
420
ends. But don't clutter messages with unnecessary or duplicate quote
400
- marks.
421
+ marks.
401
422
</para>
402
423
403
424
</simplesect>
@@ -413,7 +434,7 @@ Hint: the addendum
413
434
<para>
414
435
Primary error messages: Do not capitalize the first letter. Do not end a
415
436
message with a period. Do not even think about ending a message with an
416
- exclamation point.
437
+ exclamation point.
417
438
</para>
418
439
419
440
<para>
@@ -430,7 +451,7 @@ Hint: the addendum
430
451
long enough to be more than one sentence, they should be split into
431
452
primary and detail parts.) However, detail and hint messages are longer
432
453
and might need to include multiple sentences. For consistency, they should
433
- follow complete-sentence style even when there's only one sentence.
454
+ follow complete-sentence style even when there's only one sentence.
434
455
</para>
435
456
436
457
</simplesect>
@@ -473,7 +494,7 @@ Hint: the addendum
473
494
<para>
474
495
Use past tense if an attempt to do something failed, but could perhaps
475
496
succeed next time (perhaps after fixing some problem). Use present tense
476
- if the failure is certainly permanent.
497
+ if the failure is certainly permanent.
477
498
</para>
478
499
479
500
<para>
@@ -489,20 +510,20 @@ cannot open file "%s"
489
510
message should give a reason, such as <quote>disk full</quote> or
490
511
<quote>file doesn't exist</quote>. The past tense is appropriate because
491
512
next time the disk might not be full anymore or the file in question might
492
- exist.
513
+ exist.
493
514
</para>
494
515
495
516
<para>
496
517
The second form indicates that the functionality of opening the named file
497
518
does not exist at all in the program, or that it's conceptually
498
519
impossible. The present tense is appropriate because the condition will
499
- persist indefinitely.
520
+ persist indefinitely.
500
521
</para>
501
522
502
523
<para>
503
524
Rationale: Granted, the average user will not be able to draw great
504
525
conclusions merely from the tense of the message, but since the language
505
- provides us with a grammar we should use it correctly.
526
+ provides us with a grammar we should use it correctly.
506
527
</para>
507
528
508
529
</simplesect>
@@ -552,7 +573,7 @@ could not open file %s: %m
552
573
to paste this into a single smooth sentence, so some sort of punctuation
553
574
is needed. Putting the embedded text in parentheses has also been
554
575
suggested, but it's unnatural if the embedded text is likely to be the
555
- most important part of the message, as is often the case.
576
+ most important part of the message, as is often the case.
556
577
</para>
557
578
558
579
</simplesect>
@@ -579,7 +600,7 @@ BETTER: could not open file %s (I/O failure)
579
600
Don't include the name of the reporting routine in the error text. We have
580
601
other mechanisms for finding that out when needed, and for most users it's
581
602
not helpful information. If the error text doesn't make as much sense
582
- without the function name, reword it.
603
+ without the function name, reword it.
583
604
<programlisting>
584
605
BAD: pg_atoi: error in "z": cannot parse "z"
585
606
BETTER: invalid input syntax for integer: "z"
@@ -620,7 +641,7 @@ BETTER: could not open file %s: %m
620
641
<para>
621
642
Error messages like <quote>bad result</quote> are really hard to interpret
622
643
intelligently. It's better to write why the result is <quote>bad</quote>,
623
- e.g., <quote>invalid format</quote>.
644
+ e.g., <quote>invalid format</quote>.
624
645
</para>
625
646
</formalpara>
626
647
@@ -638,7 +659,7 @@ BETTER: could not open file %s: %m
638
659
Try to avoid <quote>unknown</quote>. Consider <quote>error: unknown
639
660
response</quote>. If you don't know what the response is, how do you know
640
661
it's erroneous? <quote>Unrecognized</quote> is often a better choice.
641
- Also, be sure to include the value being complained of.
662
+ Also, be sure to include the value being complained of.
642
663
<programlisting>
643
664
BAD: unknown node type
644
665
BETTER: unrecognized node type: 42
@@ -654,7 +675,7 @@ BETTER: unrecognized node type: 42
654
675
couldn't <quote>find</quote> the resource. If, on the other hand, the
655
676
expected location of the resource is known but the program cannot access
656
677
it there then say that the resource doesn't <quote>exist</quote>. Using
657
- <quote>find</quote> in this case sounds weak and confuses the issue.
678
+ <quote>find</quote> in this case sounds weak and confuses the issue.
658
679
</para>
659
680
</formalpara>
660
681
0 commit comments