summaryrefslogtreecommitdiff
path: root/contrib/seg
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/seg
parentf0c5384d4a21d85198f86281f61d5754bfdca7a5 (diff)
Error message editing in contrib (mostly by Joe Conway --- thanks Joe!)
Diffstat (limited to 'contrib/seg')
-rw-r--r--contrib/seg/buffer.c6
-rw-r--r--contrib/seg/expected/seg.out31
-rw-r--r--contrib/seg/seg.c6
-rw-r--r--contrib/seg/segparse.y18
4 files changed, 38 insertions, 23 deletions
diff --git a/contrib/seg/buffer.c b/contrib/seg/buffer.c
index baeba5e5152..b38e4fcaf24 100644
--- a/contrib/seg/buffer.c
+++ b/contrib/seg/buffer.c
@@ -2,8 +2,6 @@
#include "postgres.h"
-#include "utils/elog.h"
-
static char *PARSE_BUFFER;
static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
@@ -26,7 +24,9 @@ set_parse_buffer(char *s)
PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s);
if (PARSE_BUFFER_SIZE == 0)
- elog(ERROR, "seg_in: can't parse an empty string");
+ ereport(ERROR,
+ (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
+ errmsg("can't parse an empty string")));
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
}
diff --git a/contrib/seg/expected/seg.out b/contrib/seg/expected/seg.out
index 5c0c1fceaa8..d0c68218a77 100644
--- a/contrib/seg/expected/seg.out
+++ b/contrib/seg/expected/seg.out
@@ -6,8 +6,9 @@
-- does not depend on contents of seg.sql.
--
\set ECHO none
-psql:seg.sql:10: NOTICE: ProcedureCreate: type seg is not yet defined
-psql:seg.sql:15: NOTICE: Argument type "seg" is only a shell
+psql:seg.sql:10: NOTICE: type seg is not yet defined
+DETAIL: Creating a shell type definition.
+psql:seg.sql:15: NOTICE: argument type seg is only a shell
--
-- testing the input and output functions
--
@@ -393,30 +394,38 @@ SELECT '100(+-)1'::seg AS seg;
-- invalid input
SELECT ''::seg AS seg;
-ERROR: seg_in: can't parse an empty string
+ERROR: can't parse an empty string
SELECT 'ABC'::seg AS seg;
-ERROR: syntax error at or near position 1, character ('A', \101), input: 'ABC'
+ERROR: syntax error
+DETAIL: syntax error at or near position 1, character ('A', \101), input: 'ABC'
SELECT '1ABC'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('A', \101), input: '1ABC'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('A', \101), input: '1ABC'
SELECT '1.'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('.', \056), input: '1.'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('.', \056), input: '1.'
SELECT '1.....'::seg AS seg;
-ERROR: syntax error at or near position 6, character ('.', \056), input: '1.....'
+ERROR: syntax error
+DETAIL: syntax error at or near position 6, character ('.', \056), input: '1.....'
SELECT '.1'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('1', \061), input: '.1'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('1', \061), input: '.1'
SELECT '1..2.'::seg AS seg;
-ERROR: syntax error at or near position 5, character ('.', \056), input: '1..2.'
+ERROR: syntax error
+DETAIL: syntax error at or near position 5, character ('.', \056), input: '1..2.'
SELECT '1 e7'::seg AS seg;
-ERROR: syntax error at or near position 3, character ('e', \145), input: '1 e7'
+ERROR: syntax error
+DETAIL: syntax error at or near position 3, character ('e', \145), input: '1 e7'
SELECT '1e700'::seg AS seg;
-ERROR: numeric value 1e700 unrepresentable
+ERROR: syntax error
+DETAIL: numeric value 1e700 unrepresentable
--
-- testing the operators
--
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index d7eea9cadd7..443fe3f5a26 100644
--- a/contrib/seg/seg.c
+++ b/contrib/seg/seg.c
@@ -10,8 +10,6 @@
#include "access/gist.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "segdata.h"
@@ -798,7 +796,7 @@ seg_cmp(SEG * a, SEG * b)
if (b->l_ext == '~')
return 1;
/* can't get here unless data is corrupt */
- elog(ERROR, "seg_cmp: bogus lower boundary types %d %d",
+ elog(ERROR, "bogus lower boundary types %d %d",
(int) a->l_ext, (int) b->l_ext);
}
@@ -857,7 +855,7 @@ seg_cmp(SEG * a, SEG * b)
if (b->u_ext == '~')
return -1;
/* can't get here unless data is corrupt */
- elog(ERROR, "seg_cmp: bogus upper boundary types %d %d",
+ elog(ERROR, "bogus upper boundary types %d %d",
(int) a->u_ext, (int) b->u_ext);
}
diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y
index 67f5b9f43dd..9c69efede63 100644
--- a/contrib/seg/segparse.y
+++ b/contrib/seg/segparse.y
@@ -4,8 +4,6 @@
#include "postgres.h"
#include <math.h>
-
-#include "utils/elog.h"
#include "segdata.h"
#include "buffer.h"
@@ -75,7 +73,11 @@ range:
((SEG *)result)->upper = $3.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
reset_parse_buffer();
- elog(ERROR, "swapped boundaries: %g is greater than %g", ((SEG *)result)->lower, ((SEG *)result)->upper );
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("swapped boundaries: %g is greater than %g",
+ ((SEG *)result)->lower, ((SEG *)result)->upper)));
+
YYERROR;
}
((SEG *)result)->l_sigd = $1.sigd;
@@ -144,7 +146,10 @@ float seg_atof ( char *value ) {
if ( errno ) {
snprintf(buf, 256, "numeric value %s unrepresentable", value);
reset_parse_buffer();
- elog(ERROR, "%s", buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("%s", buf)));
}
return result;
@@ -175,7 +180,10 @@ int seg_yyerror ( char *msg ) {
);
reset_parse_buffer();
- elog(ERROR, "%s", buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("%s", buf)));
return 0;
}