aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-07-27 17:10:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-07-27 17:10:07 +0000
commite8db9b26d03b9e58a30eb26ec2ee21c92293d3a2 (patch)
treec2adf83074db369ea5211b06e5181ebabf1a61d8
parentaeea73d4eceb9b33ff16a69c77bd923a0394a6d0 (diff)
downloadpostgresql-e8db9b26d03b9e58a30eb26ec2ee21c92293d3a2.tar.gz
postgresql-e8db9b26d03b9e58a30eb26ec2ee21c92293d3a2.zip
elog mop-up.
-rw-r--r--contrib/btree_gist/btree_gist.h3
-rw-r--r--contrib/cube/cube.c2
-rw-r--r--contrib/ltree/ltree.h3
-rw-r--r--contrib/rtree_gist/rtree_gist.c4
-rw-r--r--contrib/tsearch/rewrite.c4
-rw-r--r--contrib/tsearch/txtidx.h2
-rw-r--r--contrib/tsearch2/ts_stat.h2
-rw-r--r--contrib/tsearch2/tsvector.h2
-rw-r--r--doc/src/sgml/xtypes.sgml15
-rw-r--r--src/include/access/genam.h4
-rw-r--r--src/include/access/tupmacs.h6
-rw-r--r--src/include/libpq/pqcomm.h4
-rw-r--r--src/include/miscadmin.h10
-rw-r--r--src/include/storage/buf_internals.h4
-rw-r--r--src/pl/plpgsql/src/pl_handler.c6
-rw-r--r--src/port/copydir.c18
-rw-r--r--src/port/dirmod.c28
-rw-r--r--src/tutorial/complex.c8
18 files changed, 62 insertions, 63 deletions
diff --git a/contrib/btree_gist/btree_gist.h b/contrib/btree_gist/btree_gist.h
index 0859002d037..ebcecf4cc53 100644
--- a/contrib/btree_gist/btree_gist.h
+++ b/contrib/btree_gist/btree_gist.h
@@ -3,10 +3,7 @@
#include "access/gist.h"
#include "access/itup.h"
#include "access/nbtree.h"
-
-#include "utils/palloc.h"
#include "utils/geo_decls.h"
-#include "utils/elog.h"
typedef int (*CMPFUNC) (const void *a, const void *b);
typedef void (*BINARY_UNION) (Datum *, char *);
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index b46eb35d3cd..5d8bcf75b5d 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -11,8 +11,6 @@
#include "access/gist.h"
#include "access/rtree.h"
#include "lib/stringinfo.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "cubedata.h"
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index 39bc0cd311d..c732a37fa2d 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -2,8 +2,7 @@
#define __LTREE_H__
#include "postgres.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
+
#include "utils/builtins.h"
typedef struct
diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c
index 5034b9d586f..6836cd25179 100644
--- a/contrib/rtree_gist/rtree_gist.c
+++ b/contrib/rtree_gist/rtree_gist.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.6 2002/09/04 20:31:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.7 2003/07/27 17:10:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,9 +16,7 @@
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/palloc.h"
#include "utils/geo_decls.h"
-#include "utils/elog.h"
typedef Datum (*RDF) (PG_FUNCTION_ARGS);
typedef Datum (*BINARY_UNION) (Datum, Datum, int *);
diff --git a/contrib/tsearch/rewrite.c b/contrib/tsearch/rewrite.c
index 6cd3cb14e78..9d4c885434c 100644
--- a/contrib/tsearch/rewrite.c
+++ b/contrib/tsearch/rewrite.c
@@ -10,8 +10,6 @@
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
@@ -283,7 +281,7 @@ clean_fakeval(ITEM * ptr, int4 *len)
resroot = clean_fakeval_intree(root, &result);
if (result != V_UNKNOWN)
{
- elog(NOTICE, "Query contains only stopword(s) or doesn't contain lexem(s), ignored");
+ elog(NOTICE, "query contains only stopword(s) or doesn't contain lexeme(s), ignored");
*len = 0;
return NULL;
}
diff --git a/contrib/tsearch/txtidx.h b/contrib/tsearch/txtidx.h
index f528cbd5e7c..068f7fb4da2 100644
--- a/contrib/tsearch/txtidx.h
+++ b/contrib/tsearch/txtidx.h
@@ -9,8 +9,6 @@
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
diff --git a/contrib/tsearch2/ts_stat.h b/contrib/tsearch2/ts_stat.h
index c32b17a3f5d..023a83346cb 100644
--- a/contrib/tsearch2/ts_stat.h
+++ b/contrib/tsearch2/ts_stat.h
@@ -5,8 +5,6 @@
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
diff --git a/contrib/tsearch2/tsvector.h b/contrib/tsearch2/tsvector.h
index 31e6a4b02c9..af06e3cf52f 100644
--- a/contrib/tsearch2/tsvector.h
+++ b/contrib/tsearch2/tsvector.h
@@ -9,8 +9,6 @@
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
diff --git a/doc/src/sgml/xtypes.sgml b/doc/src/sgml/xtypes.sgml
index 97688d92621..35112c1c5e2 100644
--- a/doc/src/sgml/xtypes.sgml
+++ b/doc/src/sgml/xtypes.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/xtypes.sgml,v 1.17 2003/04/10 01:22:45 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/xtypes.sgml,v 1.18 2003/07/27 17:10:06 tgl Exp $
-->
<sect1 id="xtypes">
@@ -70,14 +70,15 @@ typedef struct Complex {
Complex *
complex_in(char *str)
{
- double x, y;
- Complex *result;
+ double x,
+ y;
+ Complex *result;
if (sscanf(str, " ( %lf , %lf )", &amp;x, &amp;y) != 2)
- {
- elog(ERROR, "complex_in: error in parsing %s", str);
- return NULL;
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for complex: \"%s\"", str)));
+
result = (Complex *) palloc(sizeof(Complex));
result-&gt;x = x;
result-&gt;y = y;
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index e018bb8007e..934defb8a7b 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: genam.h,v 1.39 2003/02/24 00:57:17 tgl Exp $
+ * $Id: genam.h,v 1.40 2003/07/27 17:10:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
typedef struct IndexVacuumCleanupInfo
{
bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
- int message_level; /* elog level for progress messages */
+ int message_level; /* ereport level for progress messages */
} IndexVacuumCleanupInfo;
/* Struct for heap-or-index scans of system tables */
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index b2bab69b810..85f9b0052e0 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupmacs.h,v 1.22 2002/08/24 15:00:46 tgl Exp $
+ * $Id: tupmacs.h,v 1.23 2003/07/27 17:10:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -155,7 +155,7 @@
*(Datum *) (T) = (newdatum); \
break; \
default: \
- elog(ERROR, "store_att_byval: unsupported byval length %d", \
+ elog(ERROR, "unsupported byval length: %d", \
(int) (attlen)); \
break; \
} \
@@ -177,7 +177,7 @@
*(int32 *) (T) = DatumGetInt32(newdatum); \
break; \
default: \
- elog(ERROR, "store_att_byval: unsupported byval length %d", \
+ elog(ERROR, "unsupported byval length: %d", \
(int) (attlen)); \
break; \
} \
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index caa186b8320..2e41b0896ad 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.90 2003/07/23 23:30:41 tgl Exp $
+ * $Id: pqcomm.h,v 1.91 2003/07/27 17:10:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,7 +21,7 @@
/* workaround for clashing defines of "ERROR" */
#ifdef ELOG_H
#undef ERROR
-#define ERROR (-1)
+#define ERROR PGERROR
#endif
#else /* not WIN32 */
#include <sys/socket.h>
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index cfe065ffcf0..d6ded84abd7 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.126 2003/07/17 00:55:37 tgl Exp $
+ * $Id: miscadmin.h,v 1.127 2003/07/27 17:10:07 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
@@ -53,10 +53,10 @@
*
* A related, but conceptually distinct, mechanism is the "critical section"
* mechanism. A critical section not only holds off cancel/die interrupts,
- * but causes any elog(ERROR) or elog(FATAL) to become elog(PANIC) --- that is,
- * a system-wide reset is forced. Needless to say, only really *critical*
- * code should be marked as a critical section! Currently, this mechanism
- * is only used for XLOG-related code.
+ * but causes any ereport(ERROR) or ereport(FATAL) to become ereport(PANIC)
+ * --- that is, a system-wide reset is forced. Needless to say, only really
+ * *critical* code should be marked as a critical section! Currently, this
+ * mechanism is only used for XLOG-related code.
*
*****************************************************************************/
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 7a0407ffbfe..47a1e06fa24 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf_internals.h,v 1.59 2002/09/04 20:31:45 momjian Exp $
+ * $Id: buf_internals.h,v 1.60 2003/07/27 17:10:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -111,7 +111,7 @@ typedef struct sbufdesc
* Each backend has its own BufferLocks[] array holding flag bits
* showing what locks it has set on each buffer.
*
- * We have to free these locks in elog(ERROR)...
+ * We have to free these locks during ereport(ERROR)...
*/
#define BL_IO_IN_PROGRESS (1 << 0) /* unimplemented */
#define BL_PIN_COUNT_LOCK (1 << 1)
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 81d08ac5122..e77a2f9e0aa 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.14 2003/07/25 23:37:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.15 2003/07/27 17:10:07 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -65,7 +65,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Connect to SPI manager
*/
if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ elog(ERROR, "SPI_connect failed");
/* Find or compile the function */
func = plpgsql_compile(fcinfo);
@@ -84,7 +84,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Disconnect from SPI manager
*/
if (SPI_finish() != SPI_OK_FINISH)
- elog(ERROR, "SPI_finish() failed");
+ elog(ERROR, "SPI_finish failed");
return retval;
}
diff --git a/src/port/copydir.c b/src/port/copydir.c
index 81a36cca4a3..53a819d38df 100644
--- a/src/port/copydir.c
+++ b/src/port/copydir.c
@@ -8,7 +8,7 @@
#undef mkdir /* no reason to use that macro because we ignore the 2nd arg */
-#include "dirent.h"
+#include <dirent.h>
int
@@ -21,14 +21,17 @@ copydir(char *fromdir,char *todir)
if (mkdir(todir) != 0)
{
- elog(ERROR, "could not make directory '%s'",todir);
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not create directory \"%s\": %m", todir)));
return 1;
}
xldir = opendir(fromdir);
if (xldir == NULL)
{
- closedir(xldir);
- elog(ERROR, "could not open directory '%s'",fromdir);
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not open directory \"%s\": %m", fromdir)));
return 1;
}
@@ -38,8 +41,13 @@ copydir(char *fromdir,char *todir)
snprintf(tofl, MAXPGPATH, "%s/%s", todir, xlde->d_name);
if (CopyFile(fromfl,tofl,TRUE) < 0)
{
+ int save_errno = errno;
+
closedir(xldir);
- elog(ERROR,"could not create file %s\n",todir);
+ errno = save_errno;
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not copy file \"%s\": %m", fromfl)));
return 1;
}
}
diff --git a/src/port/dirmod.c b/src/port/dirmod.c
index 21c205a5d0f..6d680a41501 100644
--- a/src/port/dirmod.c
+++ b/src/port/dirmod.c
@@ -1,7 +1,6 @@
/*
* These are replacement versions of unlink and rename that work on
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
- *
*/
#ifndef TEST_VERSION
@@ -11,7 +10,8 @@
#undef rename
#undef unlink
-int pgrename(const char *from, const char *to)
+int
+pgrename(const char *from, const char *to)
{
int loops = 0;
@@ -23,24 +23,27 @@ int pgrename(const char *from, const char *to)
Sleep(100); /* ms */
if (loops == 10)
#ifndef FRONTEND
- elog(LOG, "Unable to rename %s to %s, continuing to try", from, to);
+ elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
+ from, to);
#else
- fprintf(stderr, "Unable to rename %s to %s, continuing to try\n", from, to);
+ fprintf(stderr, "could not rename \"%s\" to \"%s\", continuing to try\n",
+ from, to);
#endif
loops++;
}
if (loops > 10)
#ifndef FRONTEND
- elog(LOG, "Completed rename of %s to %s", from, to);
+ elog(LOG, "completed rename of \"%s\" to \"%s\"", from, to);
#else
- fprintf(stderr, "Completed rename of %s to %s\n", from, to);
+ fprintf(stderr, "completed rename of \"%s\" to \"%s\"\n", from, to);
#endif
return 0;
}
-int pgunlink(const char *path)
+int
+pgunlink(const char *path)
{
int loops = 0;
@@ -52,18 +55,20 @@ int pgunlink(const char *path)
Sleep(100); /* ms */
if (loops == 10)
#ifndef FRONTEND
- elog(LOG, "Unable to unlink %s, continuing to try", path);
+ elog(LOG, "could not unlink \"%s\", continuing to try",
+ path);
#else
- fprintf(stderr, "Unable to unlink %s, continuing to try\n", path);
+ fprintf(stderr, "could not unlink \"%s\", continuing to try\n",
+ path);
#endif
loops++;
}
if (loops > 10)
#ifndef FRONTEND
- elog(LOG, "Completed unlink of %s", path);
+ elog(LOG, "completed unlink of \"%s\"", path);
#else
- fprintf(stderr, "Completed unlink of %s\n", path);
+ fprintf(stderr, "completed unlink of \"%s\"\n", path);
#endif
return 0;
}
@@ -143,4 +148,5 @@ main(int argc, char* argv[])
return 0;
}
+
#endif
diff --git a/src/tutorial/complex.c b/src/tutorial/complex.c
index b95baa2be0e..c8d4cbe320f 100644
--- a/src/tutorial/complex.c
+++ b/src/tutorial/complex.c
@@ -38,10 +38,10 @@ complex_in(char *str)
Complex *result;
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
- {
- elog(ERROR, "complex_in: error in parsing \"%s\"", str);
- return NULL;
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for complex: \"%s\"", str)));
+
result = (Complex *) palloc(sizeof(Complex));
result->x = x;
result->y = y;