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

Commit 8fd5b3e

Browse files
committed
Error message editing in contrib (mostly by Joe Conway --- thanks Joe!)
1 parent f0c5384 commit 8fd5b3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1459
-658
lines changed

contrib/btree_gist/btree_num.c.in

+8-2
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,20 @@ __BTREE_GIST_TYPE2__key_cmp(const void *a, const void *b)
247247
Datum
248248
__BTREE_GIST_TYPE2__key_in(PG_FUNCTION_ARGS)
249249
{
250-
elog(ERROR, "Not implemented");
250+
ereport(ERROR,
251+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
252+
errmsg("<datatype>key_in() not implemented")));
253+
251254
PG_RETURN_POINTER(NULL);
252255
}
253256

254257
Datum
255258
__BTREE_GIST_TYPE2__key_out(PG_FUNCTION_ARGS)
256259
{
257-
elog(ERROR, "Not implemented");
260+
ereport(ERROR,
261+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
262+
errmsg("<datatype>key_out() not implemented")));
263+
258264
PG_RETURN_POINTER(NULL);
259265
}
260266

contrib/btree_gist/btree_ts.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,19 @@ tskey_cmp(const void *a, const void *b)
270270
Datum
271271
tskey_in(PG_FUNCTION_ARGS)
272272
{
273-
elog(ERROR, "Not implemented");
273+
ereport(ERROR,
274+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
275+
errmsg("feature not implemented")));
276+
274277
PG_RETURN_POINTER(NULL);
275278
}
276279

277280
Datum
278281
tskey_out(PG_FUNCTION_ARGS)
279282
{
280-
elog(ERROR, "Not implemented");
283+
ereport(ERROR,
284+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
285+
errmsg("feature not implemented")));
286+
281287
PG_RETURN_POINTER(NULL);
282288
}

contrib/btree_gist/expected/btree_gist.out

+18-12
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
-- does not depend on contents of btree_gist.sql.
44
--
55
\set ECHO none
6-
psql:btree_gist.sql:8: NOTICE: ProcedureCreate: type int2key is not yet defined
7-
psql:btree_gist.sql:13: NOTICE: Argument type "int2key" is only a shell
8-
psql:btree_gist.sql:25: NOTICE: ProcedureCreate: type int4key is not yet defined
9-
psql:btree_gist.sql:30: NOTICE: Argument type "int4key" is only a shell
10-
psql:btree_gist.sql:42: NOTICE: ProcedureCreate: type int8key is not yet defined
11-
psql:btree_gist.sql:47: NOTICE: Argument type "int8key" is only a shell
12-
psql:btree_gist.sql:59: NOTICE: ProcedureCreate: type float4key is not yet defined
13-
psql:btree_gist.sql:64: NOTICE: Argument type "float4key" is only a shell
14-
psql:btree_gist.sql:77: NOTICE: ProcedureCreate: type float8key is not yet defined
15-
psql:btree_gist.sql:82: NOTICE: Argument type "float8key" is only a shell
16-
psql:btree_gist.sql:392: NOTICE: ProcedureCreate: type tskey is not yet defined
17-
psql:btree_gist.sql:397: NOTICE: Argument type "tskey" is only a shell
6+
psql:btree_gist.sql:8: NOTICE: type int2key is not yet defined
7+
DETAIL: Creating a shell type definition.
8+
psql:btree_gist.sql:13: NOTICE: argument type int2key is only a shell
9+
psql:btree_gist.sql:25: NOTICE: type int4key is not yet defined
10+
DETAIL: Creating a shell type definition.
11+
psql:btree_gist.sql:30: NOTICE: argument type int4key is only a shell
12+
psql:btree_gist.sql:42: NOTICE: type int8key is not yet defined
13+
DETAIL: Creating a shell type definition.
14+
psql:btree_gist.sql:47: NOTICE: argument type int8key is only a shell
15+
psql:btree_gist.sql:59: NOTICE: type float4key is not yet defined
16+
DETAIL: Creating a shell type definition.
17+
psql:btree_gist.sql:64: NOTICE: argument type float4key is only a shell
18+
psql:btree_gist.sql:77: NOTICE: type float8key is not yet defined
19+
DETAIL: Creating a shell type definition.
20+
psql:btree_gist.sql:82: NOTICE: argument type float8key is only a shell
21+
psql:btree_gist.sql:392: NOTICE: type tskey is not yet defined
22+
DETAIL: Creating a shell type definition.
23+
psql:btree_gist.sql:397: NOTICE: argument type tskey is only a shell
1824
CREATE TABLE int4tmp (b int4);
1925
\copy int4tmp from 'data/test_btree.data'
2026
CREATE TABLE int8tmp (b int8);

contrib/chkpass/chkpass.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* darcy@druid.net
55
* http://www.druid.net/darcy/
66
*
7-
* $Id: chkpass.c,v 1.9 2002/10/26 15:00:59 tgl Exp $
7+
* $Id: chkpass.c,v 1.10 2003/07/24 17:52:12 tgl Exp $
88
* best viewed with tabs set to 4
99
*/
1010

@@ -84,8 +84,10 @@ chkpass_in(PG_FUNCTION_ARGS)
8484

8585
if (verify_pass(str) != 0)
8686
{
87-
elog(ERROR, "chkpass_in: purported CHKPASS \"%s\" is a weak password",
88-
str);
87+
ereport(ERROR,
88+
(errcode(ERRCODE_DATA_EXCEPTION),
89+
errmsg("password \"%s\" is weak", str)));
90+
8991
PG_RETURN_POINTER(NULL);
9092
}
9193

contrib/cube/buffer.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include "postgres.h"
44

5-
#include "utils/elog.h"
6-
75
static char *PARSE_BUFFER;
86
static char *PARSE_BUFFER_PTR;
97
static unsigned int PARSE_BUFFER_SIZE;
@@ -26,7 +24,10 @@ set_parse_buffer(char *s)
2624
PARSE_BUFFER = s;
2725
PARSE_BUFFER_SIZE = strlen(s);
2826
if (PARSE_BUFFER_SIZE == 0)
29-
elog(ERROR, "cube_in: can't parse an empty string");
27+
ereport(ERROR,
28+
(errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
29+
errmsg("can't parse an empty string")));
30+
3031
PARSE_BUFFER_PTR = PARSE_BUFFER;
3132
SCANNER_POS = 0;
3233
}

contrib/cube/cubeparse.y

+66-17
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include "cubedata.h"
1212
#include "buffer.h"
1313

14-
#include "utils/palloc.h"
15-
#include "utils/elog.h"
16-
1714
#undef yylex /* falure to redefine yylex will result in a call to the */
1815
#define yylex cube_yylex /* wrong scanner when running inside the postgres backend */
1916

@@ -48,19 +45,31 @@ box:
4845
if ( c != '\0' ) {
4946
/* Not at EOF */
5047
reset_parse_buffer();
51-
elog(ERROR, "(0) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
48+
ereport(ERROR,
49+
(errcode(ERRCODE_SYNTAX_ERROR),
50+
errmsg("bad cube representation"),
51+
errdetail("garbage at or before char %d, ('%c', \\%03o)",
52+
pos, c, c)));
5253
YYERROR;
5354
}
5455

5556
dim = delim_count($2, ',') + 1;
5657
if ( (delim_count($4, ',') + 1) != dim ) {
5758
reset_parse_buffer();
58-
elog(ERROR, "(1) bad cube representation; different point dimensions in (%s) and (%s)\n", $2, $4);
59+
ereport(ERROR,
60+
(errcode(ERRCODE_SYNTAX_ERROR),
61+
errmsg("bad cube representation"),
62+
errdetail("different point dimensions in (%s) and (%s)",
63+
$2, $4)));
5964
YYABORT;
6065
}
6166
if (dim > CUBE_MAX_DIM) {
6267
reset_parse_buffer();
63-
elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
68+
ereport(ERROR,
69+
(errcode(ERRCODE_SYNTAX_ERROR),
70+
errmsg("bad cube representation"),
71+
errdetail("more than %d dimensions",
72+
CUBE_MAX_DIM)));
6473
YYABORT;
6574
}
6675

@@ -75,20 +84,32 @@ box:
7584

7685
if ( c != '\0' ) { /* Not at EOF */
7786
reset_parse_buffer();
78-
elog(ERROR, "(2) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
87+
ereport(ERROR,
88+
(errcode(ERRCODE_SYNTAX_ERROR),
89+
errmsg("bad cube representation"),
90+
errdetail("garbage at or before char %d, ('%c', \\%03o)",
91+
pos, c, c)));
7992
YYABORT;
8093
}
8194

8295
dim = delim_count($1, ',') + 1;
8396

8497
if ( (delim_count($3, ',') + 1) != dim ) {
8598
reset_parse_buffer();
86-
elog(ERROR, "(3) bad cube representation; different point dimensions in (%s) and (%s)\n", $1, $3);
99+
ereport(ERROR,
100+
(errcode(ERRCODE_SYNTAX_ERROR),
101+
errmsg("bad cube representation"),
102+
errdetail("different point dimensions in (%s) and (%s)",
103+
$1, $3)));
87104
YYABORT;
88105
}
89106
if (dim > CUBE_MAX_DIM) {
90107
reset_parse_buffer();
91-
elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
108+
ereport(ERROR,
109+
(errcode(ERRCODE_SYNTAX_ERROR),
110+
errmsg("bad cube representation"),
111+
errdetail("more than %d dimensions",
112+
CUBE_MAX_DIM)));
92113
YYABORT;
93114
}
94115

@@ -103,21 +124,33 @@ box:
103124

104125
if ( c != '\0') { /* Not at EOF */
105126
reset_parse_buffer();
106-
elog(ERROR, "(4) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
127+
ereport(ERROR,
128+
(errcode(ERRCODE_SYNTAX_ERROR),
129+
errmsg("bad cube representation"),
130+
errdetail("garbage at or before char %d, ('%c', \\%03o)",
131+
pos, c, c)));
107132
YYABORT;
108133
}
109134

110135
if ( yychar != YYEOF) {
111136
/* There's still a lookahead token to be parsed */
112137
reset_parse_buffer();
113-
elog(ERROR, "(5) bad cube representation; garbage at or before char %d, ('end of input', \\%03o)\n", pos, c);
138+
ereport(ERROR,
139+
(errcode(ERRCODE_SYNTAX_ERROR),
140+
errmsg("bad cube representation"),
141+
errdetail("garbage at or before char %d, ('end of input', \\%03o)",
142+
pos, c)));
114143
YYABORT;
115144
}
116145

117146
dim = delim_count($1, ',') + 1;
118147
if (dim > CUBE_MAX_DIM) {
119148
reset_parse_buffer();
120-
elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
149+
ereport(ERROR,
150+
(errcode(ERRCODE_SYNTAX_ERROR),
151+
errmsg("bad cube representation"),
152+
errdetail("more than %d dimensions",
153+
CUBE_MAX_DIM)));
121154
YYABORT;
122155
}
123156

@@ -133,21 +166,33 @@ box:
133166

134167
if ( c != '\0') { /* Not at EOF */
135168
reset_parse_buffer();
136-
elog(ERROR, "(6) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c);
169+
ereport(ERROR,
170+
(errcode(ERRCODE_SYNTAX_ERROR),
171+
errmsg("bad cube representation"),
172+
errdetail("garbage at or before char %d, ('%c', \\%03o)",
173+
pos, c, c)));
137174
YYABORT;
138175
}
139176

140177
if ( yychar != YYEOF) {
141178
/* There's still a lookahead token to be parsed */
142179
reset_parse_buffer();
143-
elog(ERROR, "(7) bad cube representation; garbage at or before char %d, ('end of input', \\%03o)\n", pos, c);
180+
ereport(ERROR,
181+
(errcode(ERRCODE_SYNTAX_ERROR),
182+
errmsg("bad cube representation"),
183+
errdetail("garbage at or before char %d, ('end of input', \\%03o)",
184+
pos, c)));
144185
YYABORT;
145186
}
146187

147188
dim = delim_count($1, ',') + 1;
148189
if (dim > CUBE_MAX_DIM) {
149190
reset_parse_buffer();
150-
elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
191+
ereport(ERROR,
192+
(errcode(ERRCODE_SYNTAX_ERROR),
193+
errmsg("bad cube representation"),
194+
errdetail("more than %d dimensions",
195+
CUBE_MAX_DIM)));
151196
YYABORT;
152197
}
153198
*((void **)result) = write_point_as_box($1, dim);
@@ -191,7 +236,7 @@ int cube_yyerror ( char *msg ) {
191236
snprintf(
192237
buf,
193238
256,
194-
"%s at or before position %d, character ('%c', \\%03o), input: '%s'\n",
239+
"%s at or before position %d, character ('%c', \\%03o), input: '%s'",
195240
msg,
196241
position,
197242
parse_buffer()[position - 1],
@@ -200,7 +245,11 @@ int cube_yyerror ( char *msg ) {
200245
);
201246

202247
reset_parse_buffer();
203-
elog(ERROR, "%s", buf);
248+
ereport(ERROR,
249+
(errcode(ERRCODE_SYNTAX_ERROR),
250+
errmsg("bad cube representation"),
251+
errdetail("%s", buf)));
252+
204253
return 0;
205254
}
206255

0 commit comments

Comments
 (0)