Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8e5a10d

Browse files
author
Neil Conway
committed
This patch makes the error message strings throughout the backend
more compliant with the error message style guide. In particular, errdetail should begin with a capital letter and end with a period, whereas errmsg should not. I also fixed a few related issues in passing, such as fixing the repeated misspelling of "lexeme" in contrib/tsearch2 (per Tom's suggestion).
1 parent 87fa10a commit 8e5a10d

File tree

30 files changed

+129
-139
lines changed

30 files changed

+129
-139
lines changed

contrib/cube/cubeparse.y

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ box:
4444
ereport(ERROR,
4545
(errcode(ERRCODE_SYNTAX_ERROR),
4646
errmsg("bad cube representation"),
47-
errdetail("different point dimensions in (%s) and (%s)",
47+
errdetail("Different point dimensions in (%s) and (%s).",
4848
$2, $4)));
4949
YYABORT;
5050
}
5151
if (dim > CUBE_MAX_DIM) {
5252
ereport(ERROR,
5353
(errcode(ERRCODE_SYNTAX_ERROR),
5454
errmsg("bad cube representation"),
55-
errdetail("more than %d dimensions",
56-
CUBE_MAX_DIM)));
55+
errdetail("A cube cannot have more than %d dimensions.",
56+
CUBE_MAX_DIM)));
5757
YYABORT;
5858
}
5959

@@ -70,15 +70,15 @@ box:
7070
ereport(ERROR,
7171
(errcode(ERRCODE_SYNTAX_ERROR),
7272
errmsg("bad cube representation"),
73-
errdetail("different point dimensions in (%s) and (%s)",
73+
errdetail("Different point dimensions in (%s) and (%s).",
7474
$1, $3)));
7575
YYABORT;
7676
}
7777
if (dim > CUBE_MAX_DIM) {
7878
ereport(ERROR,
7979
(errcode(ERRCODE_SYNTAX_ERROR),
8080
errmsg("bad cube representation"),
81-
errdetail("more than %d dimensions",
81+
errdetail("A cube cannot have more than %d dimensions.",
8282
CUBE_MAX_DIM)));
8383
YYABORT;
8484
}
@@ -95,7 +95,7 @@ box:
9595
ereport(ERROR,
9696
(errcode(ERRCODE_SYNTAX_ERROR),
9797
errmsg("bad cube representation"),
98-
errdetail("more than %d dimensions",
98+
errdetail("A cube cannot have more than %d dimensions.",
9999
CUBE_MAX_DIM)));
100100
YYABORT;
101101
}
@@ -113,7 +113,7 @@ box:
113113
ereport(ERROR,
114114
(errcode(ERRCODE_SYNTAX_ERROR),
115115
errmsg("bad cube representation"),
116-
errdetail("more than %d dimensions",
116+
errdetail("A cube cannot have more than %d dimensions.",
117117
CUBE_MAX_DIM)));
118118
YYABORT;
119119
}
@@ -187,7 +187,8 @@ write_box(unsigned int dim, char *str1, char *str2)
187187
}
188188

189189

190-
static NDBOX * write_point_as_box(char *str, int dim)
190+
static NDBOX *
191+
write_point_as_box(char *str, int dim)
191192
{
192193
NDBOX * bp;
193194
int i, size;

contrib/intarray/_int_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ g_int_compress(PG_FUNCTION_ARGS)
144144
PREPAREARR(r);
145145

146146
if (ARRNELEMS(r) >= 2 * MAXNUMRANGE)
147-
elog(NOTICE, "Input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
147+
elog(NOTICE, "input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
148148
2 * MAXNUMRANGE - 1, ARRNELEMS(r));
149149

150150
retval = palloc(sizeof(GISTENTRY));

contrib/isbn_issn/isbn_issn.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* PostgreSQL type definitions for ISBNs.
33
*
4-
* $PostgreSQL: pgsql/contrib/isbn_issn/isbn_issn.c,v 1.7 2003/11/29 22:39:20 pgsql Exp $
4+
* $PostgreSQL: pgsql/contrib/isbn_issn/isbn_issn.c,v 1.8 2006/03/01 06:30:31 neilc Exp $
55
*/
66

77
#include "postgres.h"
@@ -45,28 +45,23 @@ isbn *
4545
isbn_in(char *str)
4646
{
4747
isbn *result;
48+
int len;
4849

49-
if (strlen(str) != 13)
50-
{
50+
len = strlen(str);
51+
if (len != 13)
5152
ereport(ERROR,
5253
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5354
errmsg("invalid ISBN: \"%s\"", str),
54-
errdetail("incorrect length")));
55+
errdetail("ISBNs must be 13 characters in length.")));
5556

56-
return (NULL);
57-
}
5857
if (isbn_sum(str) != 0)
59-
{
6058
ereport(ERROR,
6159
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6260
errmsg("invalid ISBN: \"%s\"", str),
63-
errdetail("failed checksum")));
64-
return (NULL);
65-
}
61+
errdetail("ISBN failed checksum.")));
6662

6763
result = (isbn *) palloc(sizeof(isbn));
68-
69-
strncpy(result->num, str, 13);
64+
memcpy(result->num, str, len);
7065
memset(result->pad, ' ', 3);
7166
return (result);
7267
}
@@ -239,28 +234,23 @@ issn *
239234
issn_in(char *str)
240235
{
241236
issn *result;
237+
int len;
242238

243-
if (strlen(str) != 9)
244-
{
239+
len = strlen(str);
240+
if (len != 9)
245241
ereport(ERROR,
246242
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
247243
errmsg("invalid ISSN: \"%s\"", str),
248-
errdetail("incorrect length")));
244+
errdetail("ISSNs must be 9 characters in length.")));
249245

250-
return (NULL);
251-
}
252246
if (issn_sum(str) != 0)
253-
{
254247
ereport(ERROR,
255248
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
256249
errmsg("invalid ISSN: \"%s\"", str),
257-
errdetail("failed checksum")));
258-
return (NULL);
259-
}
250+
errdetail("ISSN failed checksum.")));
260251

261252
result = (issn *) palloc(sizeof(issn));
262-
263-
strncpy(result->num, str, 9);
253+
memcpy(result->num, str, len);
264254
memset(result->pad, ' ', 7);
265255
return (result);
266256
}

contrib/ltree/lquery_op.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct
2626
} FieldNot;
2727

2828
static char *
29-
getlexem(char *start, char *end, int *len)
29+
getlexeme(char *start, char *end, int *len)
3030
{
3131
char *ptr;
3232

@@ -45,7 +45,7 @@ getlexem(char *start, char *end, int *len)
4545
}
4646

4747
bool
48-
compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend)
48+
compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend)
4949
{
5050
char *endt = t->name + t->len;
5151
char *endq = qn + len;
@@ -54,11 +54,11 @@ bool
5454
lenq;
5555
bool isok;
5656

57-
while ((qn = getlexem(qn, endq, &lenq)) != NULL)
57+
while ((qn = getlexeme(qn, endq, &lenq)) != NULL)
5858
{
5959
tn = t->name;
6060
isok = false;
61-
while ((tn = getlexem(tn, endt, &lent)) != NULL)
61+
while ((tn = getlexeme(tn, endt, &lent)) != NULL)
6262
{
6363
if (
6464
(
@@ -93,7 +93,7 @@ checkLevel(lquery_level * curq, ltree_level * curt)
9393
{
9494
cmpptr = (curvar->flag & LVAR_INCASE) ? pg_strncasecmp : strncmp;
9595

96-
if (curvar->flag & LVAR_SUBLEXEM)
96+
if (curvar->flag & LVAR_SUBLEXEME)
9797
{
9898
if (compare_subnode(curt, curvar->name, curvar->len, cmpptr, (curvar->flag & LVAR_ANYEND)))
9999
return true;

contrib/ltree/ltree.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct
4040

4141
#define LVAR_ANYEND 0x01
4242
#define LVAR_INCASE 0x02
43-
#define LVAR_SUBLEXEM 0x04
43+
#define LVAR_SUBLEXEME 0x04
4444

4545
typedef struct
4646
{
@@ -58,9 +58,9 @@ typedef struct
5858

5959
#define LQL_NOT 0x10
6060
#ifdef LOWER_NODE
61-
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEM ) ) == 0 )
61+
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
6262
#else
63-
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEM | LVAR_INCASE ) ) == 0 )
63+
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
6464
#endif
6565
#define LQL_CANLOOKSIGN(x) FLG_CANLOOKSIGN( ((lquery_level*)(x))->flag )
6666

contrib/ltree/ltree_io.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ ltree_in(PG_FUNCTION_ARGS)
8080
ereport(ERROR,
8181
(errcode(ERRCODE_NAME_TOO_LONG),
8282
errmsg("name of level is too long"),
83-
errdetail("name length is %d, must " \
84-
"be < 256, in position %d",
83+
errdetail("Name length is %d, must "
84+
"be < 256, in position %d.",
8585
lptr->len, (int) (lptr->start - buf))));
8686

8787
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
@@ -104,8 +104,8 @@ ltree_in(PG_FUNCTION_ARGS)
104104
ereport(ERROR,
105105
(errcode(ERRCODE_NAME_TOO_LONG),
106106
errmsg("name of level is too long"),
107-
errdetail("name length is %d, must " \
108-
"be < 256, in position %d",
107+
errdetail("Name length is %d, must "
108+
"be < 256, in position %d.",
109109
lptr->len, (int) (lptr->start - buf))));
110110

111111
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
@@ -269,37 +269,37 @@ lquery_in(PG_FUNCTION_ARGS)
269269
{
270270
if (lptr->start == ptr)
271271
UNCHAR;
272-
lptr->flag |= LVAR_SUBLEXEM;
273-
curqlevel->flag |= LVAR_SUBLEXEM;
272+
lptr->flag |= LVAR_SUBLEXEME;
273+
curqlevel->flag |= LVAR_SUBLEXEME;
274274
}
275275
else if (*ptr == '|')
276276
{
277277
lptr->len = ptr - lptr->start -
278-
((lptr->flag & LVAR_SUBLEXEM) ? 1 : 0) -
278+
((lptr->flag & LVAR_SUBLEXEME) ? 1 : 0) -
279279
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
280280
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
281281
if (lptr->len > 255)
282282
ereport(ERROR,
283283
(errcode(ERRCODE_NAME_TOO_LONG),
284284
errmsg("name of level is too long"),
285-
errdetail("name length is %d, must " \
286-
"be < 256, in position %d",
285+
errdetail("Name length is %d, must "
286+
"be < 256, in position %d.",
287287
lptr->len, (int) (lptr->start - buf))));
288288

289289
state = LQPRS_WAITVAR;
290290
}
291291
else if (*ptr == '.')
292292
{
293293
lptr->len = ptr - lptr->start -
294-
((lptr->flag & LVAR_SUBLEXEM) ? 1 : 0) -
294+
((lptr->flag & LVAR_SUBLEXEME) ? 1 : 0) -
295295
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
296296
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
297297
if (lptr->len > 255)
298298
ereport(ERROR,
299299
(errcode(ERRCODE_NAME_TOO_LONG),
300300
errmsg("name of level is too long"),
301-
errdetail("name length is %d, must " \
302-
"be < 256, in position %d",
301+
errdetail("Name length is %d, must "
302+
"be < 256, in position %d.",
303303
lptr->len, (int) (lptr->start - buf))));
304304

305305
state = LQPRS_WAITLEVEL;
@@ -398,7 +398,7 @@ lquery_in(PG_FUNCTION_ARGS)
398398
errdetail("Unexpected end of line.")));
399399

400400
lptr->len = ptr - lptr->start -
401-
((lptr->flag & LVAR_SUBLEXEM) ? 1 : 0) -
401+
((lptr->flag & LVAR_SUBLEXEME) ? 1 : 0) -
402402
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
403403
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
404404
if (lptr->len == 0)
@@ -411,8 +411,8 @@ lquery_in(PG_FUNCTION_ARGS)
411411
ereport(ERROR,
412412
(errcode(ERRCODE_NAME_TOO_LONG),
413413
errmsg("name of level is too long"),
414-
errdetail("name length is %d, must " \
415-
"be < 256, in position %d",
414+
errdetail("Name length is %d, must "
415+
"be < 256, in position %d.",
416416
lptr->len, (int) (lptr->start - buf))));
417417
}
418418
else if (state == LQPRS_WAITOPEN)
@@ -539,7 +539,7 @@ lquery_out(PG_FUNCTION_ARGS)
539539
}
540540
memcpy(ptr, curtlevel->name, curtlevel->len);
541541
ptr += curtlevel->len;
542-
if ((curtlevel->flag & LVAR_SUBLEXEM))
542+
if ((curtlevel->flag & LVAR_SUBLEXEME))
543543
{
544544
*ptr = '%';
545545
ptr++;

contrib/ltree/ltxtquery_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1
9595
(*lenval)++;
9696
}
9797
else if (*(state->buf) == '%')
98-
*flag |= LVAR_SUBLEXEM;
98+
*flag |= LVAR_SUBLEXEME;
9999
else if (*(state->buf) == '@')
100100
*flag |= LVAR_INCASE;
101101
else if (*(state->buf) == '*')
@@ -412,7 +412,7 @@ infix(INFIX * in, bool first)
412412
op++;
413413
in->cur++;
414414
}
415-
if (in->curpol->flag & LVAR_SUBLEXEM)
415+
if (in->curpol->flag & LVAR_SUBLEXEME)
416416
{
417417
*(in->cur) = '%';
418418
in->cur++;

contrib/ltree/ltxtquery_op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ checkcondition_str(void *checkval, ITEM * val)
5757
cmpptr = (val->flag & LVAR_INCASE) ? pg_strncasecmp : strncmp;
5858
while (tlen > 0)
5959
{
60-
if (val->flag & LVAR_SUBLEXEM)
60+
if (val->flag & LVAR_SUBLEXEME)
6161
{
6262
if (compare_subnode(level, op, val->length, cmpptr, (val->flag & LVAR_ANYEND)))
6363
return true;

contrib/pg_trgm/trgm_gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ static const uint8 number_of_ones[256] = {
6060
Datum
6161
gtrgm_in(PG_FUNCTION_ARGS)
6262
{
63-
elog(ERROR, "Not implemented");
63+
elog(ERROR, "not implemented");
6464
PG_RETURN_DATUM(0);
6565
}
6666

6767
Datum
6868
gtrgm_out(PG_FUNCTION_ARGS)
6969
{
70-
elog(ERROR, "Not implemented");
70+
elog(ERROR, "not implemented");
7171
PG_RETURN_DATUM(0);
7272
}
7373

contrib/pg_trgm/trgm_op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set_limit(PG_FUNCTION_ARGS)
1313
float4 nlimit = PG_GETARG_FLOAT4(0);
1414

1515
if (nlimit < 0 || nlimit > 1.0)
16-
elog(ERROR, "Wrong limit, should be between 0 and 1");
16+
elog(ERROR, "wrong limit, should be between 0 and 1");
1717
trgm_limit = nlimit;
1818
PG_RETURN_FLOAT4(trgm_limit);
1919
}

contrib/tablefunc/tablefunc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ get_crosstab_tuplestore(char *sql,
894894
ereport(ERROR,
895895
(errcode(ERRCODE_SYNTAX_ERROR),
896896
errmsg("invalid return type"),
897-
errdetail("query-specified return " \
897+
errdetail("Query-specified return " \
898898
"tuple has %d columns but crosstab " \
899-
"returns %d", tupdesc->natts, result_ncols)));
899+
"returns %d.", tupdesc->natts, result_ncols)));
900900

901901
/* allocate space */
902902
values = (char **) palloc(result_ncols * sizeof(char *));
@@ -1531,12 +1531,12 @@ validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial
15311531

15321532
/* check that the type of the fifth column is INT4 */
15331533
if (show_branch && show_serial && tupdesc->attrs[4]->atttypid != INT4OID)
1534-
elog(ERROR, "Query-specified return tuple not valid for Connectby: "
1534+
elog(ERROR, "query-specified return tuple not valid for Connectby: "
15351535
"fifth column must be type %s", format_type_be(INT4OID));
15361536

15371537
/* check that the type of the fifth column is INT4 */
15381538
if (!show_branch && show_serial && tupdesc->attrs[3]->atttypid != INT4OID)
1539-
elog(ERROR, "Query-specified return tuple not valid for Connectby: "
1539+
elog(ERROR, "query-specified return tuple not valid for Connectby: "
15401540
"fourth column must be type %s", format_type_be(INT4OID));
15411541

15421542
/* OK, the tupdesc is valid for our purposes */

0 commit comments

Comments
 (0)