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

Commit e8db9b2

Browse files
committed
elog mop-up.
1 parent aeea73d commit e8db9b2

File tree

18 files changed

+62
-63
lines changed

18 files changed

+62
-63
lines changed

contrib/btree_gist/btree_gist.h

-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#include "access/gist.h"
44
#include "access/itup.h"
55
#include "access/nbtree.h"
6-
7-
#include "utils/palloc.h"
86
#include "utils/geo_decls.h"
9-
#include "utils/elog.h"
107

118
typedef int (*CMPFUNC) (const void *a, const void *b);
129
typedef void (*BINARY_UNION) (Datum *, char *);

contrib/cube/cube.c

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include "access/gist.h"
1212
#include "access/rtree.h"
1313
#include "lib/stringinfo.h"
14-
#include "utils/elog.h"
15-
#include "utils/palloc.h"
1614
#include "utils/builtins.h"
1715

1816
#include "cubedata.h"

contrib/ltree/ltree.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#define __LTREE_H__
33

44
#include "postgres.h"
5-
#include "utils/elog.h"
6-
#include "utils/palloc.h"
5+
76
#include "utils/builtins.h"
87

98
typedef struct

contrib/rtree_gist/rtree_gist.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.6 2002/09/04 20:31:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.7 2003/07/27 17:10:06 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -16,9 +16,7 @@
1616
#include "access/gist.h"
1717
#include "access/itup.h"
1818
#include "access/rtree.h"
19-
#include "utils/palloc.h"
2019
#include "utils/geo_decls.h"
21-
#include "utils/elog.h"
2220

2321
typedef Datum (*RDF) (PG_FUNCTION_ARGS);
2422
typedef Datum (*BINARY_UNION) (Datum, Datum, int *);

contrib/tsearch/rewrite.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "access/gist.h"
1111
#include "access/itup.h"
1212
#include "access/rtree.h"
13-
#include "utils/elog.h"
14-
#include "utils/palloc.h"
1513
#include "utils/array.h"
1614
#include "utils/builtins.h"
1715
#include "storage/bufpage.h"
@@ -283,7 +281,7 @@ clean_fakeval(ITEM * ptr, int4 *len)
283281
resroot = clean_fakeval_intree(root, &result);
284282
if (result != V_UNKNOWN)
285283
{
286-
elog(NOTICE, "Query contains only stopword(s) or doesn't contain lexem(s), ignored");
284+
elog(NOTICE, "query contains only stopword(s) or doesn't contain lexeme(s), ignored");
287285
*len = 0;
288286
return NULL;
289287
}

contrib/tsearch/txtidx.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include "access/gist.h"
1111
#include "access/itup.h"
12-
#include "utils/elog.h"
13-
#include "utils/palloc.h"
1412
#include "utils/builtins.h"
1513
#include "storage/bufpage.h"
1614

contrib/tsearch2/ts_stat.h

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include "access/gist.h"
77
#include "access/itup.h"
8-
#include "utils/elog.h"
9-
#include "utils/palloc.h"
108
#include "utils/builtins.h"
119
#include "storage/bufpage.h"
1210

contrib/tsearch2/tsvector.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include "access/gist.h"
1111
#include "access/itup.h"
12-
#include "utils/elog.h"
13-
#include "utils/palloc.h"
1412
#include "utils/builtins.h"
1513
#include "storage/bufpage.h"
1614

doc/src/sgml/xtypes.sgml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/xtypes.sgml,v 1.17 2003/04/10 01:22:45 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/xtypes.sgml,v 1.18 2003/07/27 17:10:06 tgl Exp $
33
-->
44

55
<sect1 id="xtypes">
@@ -70,14 +70,15 @@ typedef struct Complex {
7070
Complex *
7171
complex_in(char *str)
7272
{
73-
double x, y;
74-
Complex *result;
73+
double x,
74+
y;
75+
Complex *result;
7576

7677
if (sscanf(str, " ( %lf , %lf )", &amp;x, &amp;y) != 2)
77-
{
78-
elog(ERROR, "complex_in: error in parsing %s", str);
79-
return NULL;
80-
}
78+
ereport(ERROR,
79+
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
80+
errmsg("invalid input syntax for complex: \"%s\"", str)));
81+
8182
result = (Complex *) palloc(sizeof(Complex));
8283
result-&gt;x = x;
8384
result-&gt;y = y;

src/include/access/genam.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: genam.h,v 1.39 2003/02/24 00:57:17 tgl Exp $
10+
* $Id: genam.h,v 1.40 2003/07/27 17:10:06 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -45,7 +45,7 @@ typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
4545
typedef struct IndexVacuumCleanupInfo
4646
{
4747
bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
48-
int message_level; /* elog level for progress messages */
48+
int message_level; /* ereport level for progress messages */
4949
} IndexVacuumCleanupInfo;
5050

5151
/* Struct for heap-or-index scans of system tables */

src/include/access/tupmacs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: tupmacs.h,v 1.22 2002/08/24 15:00:46 tgl Exp $
10+
* $Id: tupmacs.h,v 1.23 2003/07/27 17:10:07 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -155,7 +155,7 @@
155155
*(Datum *) (T) = (newdatum); \
156156
break; \
157157
default: \
158-
elog(ERROR, "store_att_byval: unsupported byval length %d", \
158+
elog(ERROR, "unsupported byval length: %d", \
159159
(int) (attlen)); \
160160
break; \
161161
} \
@@ -177,7 +177,7 @@
177177
*(int32 *) (T) = DatumGetInt32(newdatum); \
178178
break; \
179179
default: \
180-
elog(ERROR, "store_att_byval: unsupported byval length %d", \
180+
elog(ERROR, "unsupported byval length: %d", \
181181
(int) (attlen)); \
182182
break; \
183183
} \

src/include/libpq/pqcomm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: pqcomm.h,v 1.90 2003/07/23 23:30:41 tgl Exp $
12+
* $Id: pqcomm.h,v 1.91 2003/07/27 17:10:07 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -21,7 +21,7 @@
2121
/* workaround for clashing defines of "ERROR" */
2222
#ifdef ELOG_H
2323
#undef ERROR
24-
#define ERROR (-1)
24+
#define ERROR PGERROR
2525
#endif
2626
#else /* not WIN32 */
2727
#include <sys/socket.h>

src/include/miscadmin.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.126 2003/07/17 00:55:37 tgl Exp $
15+
* $Id: miscadmin.h,v 1.127 2003/07/27 17:10:07 tgl Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file should be moved to
@@ -53,10 +53,10 @@
5353
*
5454
* A related, but conceptually distinct, mechanism is the "critical section"
5555
* mechanism. A critical section not only holds off cancel/die interrupts,
56-
* but causes any elog(ERROR) or elog(FATAL) to become elog(PANIC) --- that is,
57-
* a system-wide reset is forced. Needless to say, only really *critical*
58-
* code should be marked as a critical section! Currently, this mechanism
59-
* is only used for XLOG-related code.
56+
* but causes any ereport(ERROR) or ereport(FATAL) to become ereport(PANIC)
57+
* --- that is, a system-wide reset is forced. Needless to say, only really
58+
* *critical* code should be marked as a critical section! Currently, this
59+
* mechanism is only used for XLOG-related code.
6060
*
6161
*****************************************************************************/
6262

src/include/storage/buf_internals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: buf_internals.h,v 1.59 2002/09/04 20:31:45 momjian Exp $
10+
* $Id: buf_internals.h,v 1.60 2003/07/27 17:10:07 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -111,7 +111,7 @@ typedef struct sbufdesc
111111
* Each backend has its own BufferLocks[] array holding flag bits
112112
* showing what locks it has set on each buffer.
113113
*
114-
* We have to free these locks in elog(ERROR)...
114+
* We have to free these locks during ereport(ERROR)...
115115
*/
116116
#define BL_IO_IN_PROGRESS (1 << 0) /* unimplemented */
117117
#define BL_PIN_COUNT_LOCK (1 << 1)

src/pl/plpgsql/src/pl_handler.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.14 2003/07/25 23:37:29 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.15 2003/07/27 17:10:07 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -65,7 +65,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
6565
* Connect to SPI manager
6666
*/
6767
if (SPI_connect() != SPI_OK_CONNECT)
68-
elog(ERROR, "could not connect to SPI manager");
68+
elog(ERROR, "SPI_connect failed");
6969

7070
/* Find or compile the function */
7171
func = plpgsql_compile(fcinfo);
@@ -84,7 +84,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
8484
* Disconnect from SPI manager
8585
*/
8686
if (SPI_finish() != SPI_OK_FINISH)
87-
elog(ERROR, "SPI_finish() failed");
87+
elog(ERROR, "SPI_finish failed");
8888

8989
return retval;
9090
}

src/port/copydir.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#undef mkdir /* no reason to use that macro because we ignore the 2nd arg */
1010

11-
#include "dirent.h"
11+
#include <dirent.h>
1212

1313

1414
int
@@ -21,14 +21,17 @@ copydir(char *fromdir,char *todir)
2121

2222
if (mkdir(todir) != 0)
2323
{
24-
elog(ERROR, "could not make directory '%s'",todir);
24+
ereport(ERROR,
25+
(errcode_for_file_access(),
26+
errmsg("could not create directory \"%s\": %m", todir)));
2527
return 1;
2628
}
2729
xldir = opendir(fromdir);
2830
if (xldir == NULL)
2931
{
30-
closedir(xldir);
31-
elog(ERROR, "could not open directory '%s'",fromdir);
32+
ereport(ERROR,
33+
(errcode_for_file_access(),
34+
errmsg("could not open directory \"%s\": %m", fromdir)));
3235
return 1;
3336
}
3437

@@ -38,8 +41,13 @@ copydir(char *fromdir,char *todir)
3841
snprintf(tofl, MAXPGPATH, "%s/%s", todir, xlde->d_name);
3942
if (CopyFile(fromfl,tofl,TRUE) < 0)
4043
{
44+
int save_errno = errno;
45+
4146
closedir(xldir);
42-
elog(ERROR,"could not create file %s\n",todir);
47+
errno = save_errno;
48+
ereport(ERROR,
49+
(errcode_for_file_access(),
50+
errmsg("could not copy file \"%s\": %m", fromfl)));
4351
return 1;
4452
}
4553
}

src/port/dirmod.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* These are replacement versions of unlink and rename that work on
33
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
4-
*
54
*/
65

76
#ifndef TEST_VERSION
@@ -11,7 +10,8 @@
1110
#undef rename
1211
#undef unlink
1312

14-
int pgrename(const char *from, const char *to)
13+
int
14+
pgrename(const char *from, const char *to)
1515
{
1616
int loops = 0;
1717

@@ -23,24 +23,27 @@ int pgrename(const char *from, const char *to)
2323
Sleep(100); /* ms */
2424
if (loops == 10)
2525
#ifndef FRONTEND
26-
elog(LOG, "Unable to rename %s to %s, continuing to try", from, to);
26+
elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
27+
from, to);
2728
#else
28-
fprintf(stderr, "Unable to rename %s to %s, continuing to try\n", from, to);
29+
fprintf(stderr, "could not rename \"%s\" to \"%s\", continuing to try\n",
30+
from, to);
2931
#endif
3032
loops++;
3133
}
3234

3335
if (loops > 10)
3436
#ifndef FRONTEND
35-
elog(LOG, "Completed rename of %s to %s", from, to);
37+
elog(LOG, "completed rename of \"%s\" to \"%s\"", from, to);
3638
#else
37-
fprintf(stderr, "Completed rename of %s to %s\n", from, to);
39+
fprintf(stderr, "completed rename of \"%s\" to \"%s\"\n", from, to);
3840
#endif
3941
return 0;
4042
}
4143

4244

43-
int pgunlink(const char *path)
45+
int
46+
pgunlink(const char *path)
4447
{
4548
int loops = 0;
4649

@@ -52,18 +55,20 @@ int pgunlink(const char *path)
5255
Sleep(100); /* ms */
5356
if (loops == 10)
5457
#ifndef FRONTEND
55-
elog(LOG, "Unable to unlink %s, continuing to try", path);
58+
elog(LOG, "could not unlink \"%s\", continuing to try",
59+
path);
5660
#else
57-
fprintf(stderr, "Unable to unlink %s, continuing to try\n", path);
61+
fprintf(stderr, "could not unlink \"%s\", continuing to try\n",
62+
path);
5863
#endif
5964
loops++;
6065
}
6166

6267
if (loops > 10)
6368
#ifndef FRONTEND
64-
elog(LOG, "Completed unlink of %s", path);
69+
elog(LOG, "completed unlink of \"%s\"", path);
6570
#else
66-
fprintf(stderr, "Completed unlink of %s\n", path);
71+
fprintf(stderr, "completed unlink of \"%s\"\n", path);
6772
#endif
6873
return 0;
6974
}
@@ -143,4 +148,5 @@ main(int argc, char* argv[])
143148

144149
return 0;
145150
}
151+
146152
#endif

src/tutorial/complex.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ complex_in(char *str)
3838
Complex *result;
3939

4040
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
41-
{
42-
elog(ERROR, "complex_in: error in parsing \"%s\"", str);
43-
return NULL;
44-
}
41+
ereport(ERROR,
42+
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
43+
errmsg("invalid input syntax for complex: \"%s\"", str)));
44+
4545
result = (Complex *) palloc(sizeof(Complex));
4646
result->x = x;
4747
result->y = y;

0 commit comments

Comments
 (0)