summaryrefslogtreecommitdiff
path: root/contrib/intarray
diff options
context:
space:
mode:
authorTom Lane2003-07-24 17:52:50 +0000
committerTom Lane2003-07-24 17:52:50 +0000
commit8fd5b3ed67d91937516d855bd6f225052aa88f2a (patch)
tree5f14c30cb79692b6d35e612ed97feb79f62a155d /contrib/intarray
parentf0c5384d4a21d85198f86281f61d5754bfdca7a5 (diff)
Error message editing in contrib (mostly by Joe Conway --- thanks Joe!)
Diffstat (limited to 'contrib/intarray')
-rw-r--r--contrib/intarray/_int.h8
-rw-r--r--contrib/intarray/_int_bool.c23
-rw-r--r--contrib/intarray/_int_op.c4
-rw-r--r--contrib/intarray/_intbig_gist.c8
-rw-r--r--contrib/intarray/expected/_int.out12
-rw-r--r--contrib/intarray/sql/_int.sql2
6 files changed, 39 insertions, 18 deletions
diff --git a/contrib/intarray/_int.h b/contrib/intarray/_int.h
index 102d9b7903..5decd969e1 100644
--- a/contrib/intarray/_int.h
+++ b/contrib/intarray/_int.h
@@ -6,8 +6,6 @@
#include "access/itup.h"
#include "access/rtree.h"
#include "catalog/pg_type.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
@@ -34,7 +32,11 @@
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
-#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? (elog(ERROR,"Array is not one-dimensional: %d dimensions",ARRNELEMS( x )),1) : 0 ) ) : 0 )
+#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? ( \
+ ereport(ERROR, \
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \
+ errmsg("array must be one-dimensional, not %d dimensions", ARRNELEMS( x )))) \
+ ,1) : 0 ) ) : 0 )
#define SORT(x) \
do { \
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c
index 3e8cfd9342..35d6e6e2c0 100644
--- a/contrib/intarray/_int_bool.c
+++ b/contrib/intarray/_int_bool.c
@@ -177,7 +177,9 @@ makepol(WORKSTATE * state)
else
{
if (lenstack == STACKDEPTH)
- elog(ERROR, "Stack too short");
+ ereport(ERROR,
+ (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
+ errmsg("statement too complex")));
stack[lenstack] = val;
lenstack++;
}
@@ -202,7 +204,9 @@ makepol(WORKSTATE * state)
break;
case ERR:
default:
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
return ERR;
}
@@ -359,7 +363,7 @@ findoprnd(ITEM * ptr, int4 *pos)
{
#ifdef BS_DEBUG
elog(DEBUG3, (ptr[*pos].type == OPR) ?
- "%d %c" : "%d %d ", *pos, ptr[*pos].val);
+ "%d %c" : "%d %d", *pos, ptr[*pos].val);
#endif
if (ptr[*pos].type == VAL)
{
@@ -413,7 +417,9 @@ bqarr_in(PG_FUNCTION_ARGS)
/* make polish notation (postfix, but in reverse order) */
makepol(&state);
if (!state.num)
- elog(ERROR, "Empty query");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
commonlen = COMPUTESIZE(state.num);
query = (QUERYTYPE *) palloc(commonlen);
@@ -548,7 +554,10 @@ bqarr_out(PG_FUNCTION_ARGS)
INFIX nrm;
if (query->size == 0)
- elog(ERROR, "Empty");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
+
nrm.curpol = GETQUERY(query) + query->size - 1;
nrm.buflen = 32;
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
@@ -703,7 +712,9 @@ querytree(PG_FUNCTION_ARGS)
int4 len;
if (query->size == 0)
- elog(ERROR, "Empty");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
q = (ITEM *) palloc(sizeof(ITEM) * query->size);
memcpy((void *) q, GETQUERY(query), sizeof(ITEM) * query->size);
diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c
index 5aa27f039d..9f30bb2173 100644
--- a/contrib/intarray/_int_op.c
+++ b/contrib/intarray/_int_op.c
@@ -243,7 +243,9 @@ sort(PG_FUNCTION_ARGS)
&& (d[3] == 'C' || d[3] == 'c'))
dir = 0;
if (dir == -1)
- elog(ERROR, "Invalid second parameter in function sort. It must be 'ASC' or 'DESC'.");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("second parameter must be \"ASC\" or \"DESC\"")));
QSORT(a, dir);
PG_RETURN_POINTER(a);
}
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index ad1279ced3..e4588a0d4b 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -40,13 +40,17 @@ Datum _intbig_out(PG_FUNCTION_ARGS);
Datum
_intbig_in(PG_FUNCTION_ARGS) {
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("_intbig_in() not implemented")));
PG_RETURN_DATUM(0);
}
Datum
_intbig_out(PG_FUNCTION_ARGS) {
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("_intbig_out() not implemented")));
PG_RETURN_DATUM(0);
}
diff --git a/contrib/intarray/expected/_int.out b/contrib/intarray/expected/_int.out
index 8531c817df..e2efa63f92 100644
--- a/contrib/intarray/expected/_int.out
+++ b/contrib/intarray/expected/_int.out
@@ -1,12 +1,14 @@
--
-- first, define the datatype. Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of _int.sql.
--
\set ECHO none
-psql:_int.sql:13: NOTICE: ProcedureCreate: type query_int is not yet defined
-psql:_int.sql:18: NOTICE: Argument type "query_int" is only a shell
-psql:_int.sql:367: NOTICE: ProcedureCreate: type intbig_gkey is not yet defined
-psql:_int.sql:372: NOTICE: Argument type "intbig_gkey" is only a shell
+psql:_int.sql:13: NOTICE: type query_int is not yet defined
+DETAIL: Creating a shell type definition.
+psql:_int.sql:18: NOTICE: argument type query_int is only a shell
+psql:_int.sql:367: NOTICE: type intbig_gkey is not yet defined
+DETAIL: Creating a shell type definition.
+psql:_int.sql:372: NOTICE: argument type intbig_gkey is only a shell
SELECT intset(1234);
intset
--------
diff --git a/contrib/intarray/sql/_int.sql b/contrib/intarray/sql/_int.sql
index cd05e4a785..5c0d00c67a 100644
--- a/contrib/intarray/sql/_int.sql
+++ b/contrib/intarray/sql/_int.sql
@@ -1,6 +1,6 @@
--
-- first, define the datatype. Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of _int.sql.
--
\set ECHO none
\i _int.sql