summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-07-16 19:27:20 +0000
committerTom Lane2005-07-16 19:27:20 +0000
commit44e7a2ae609d0cbae8ae01ebc03c02b96cacb002 (patch)
tree9df15960facb972e7567f0150473fe2cb339e69a
parent861e3c7a07c5deb8ff2d67e439381516407ffd59 (diff)
Back-patch into 7.2 branch the 7.3 changes that made contrib/cube
error messages reasonably independent of the bison version used to build cubeparse.c. Needed to get this branch passing on buildfarm.
-rw-r--r--contrib/cube/Makefile10
-rw-r--r--contrib/cube/cubeparse.y10
-rw-r--r--contrib/cube/expected/cube.out30
3 files changed, 28 insertions, 22 deletions
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 1bf47b90e96..4fc1185b783 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -1,4 +1,4 @@
-# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $
+# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.6.2.1 2005/07/16 19:27:20 tgl Exp $
subdir = contrib/cube
top_builddir = ../..
@@ -14,11 +14,17 @@ REGRESS = cube
cubeparse.c: cubeparse.h ;
+# The sed hack is so that we can get the same error messages with
+# bison 1.875 and later as we did with earlier bisons. Eventually,
+# I suppose, we should re-standardize on "syntax error" --- in which
+# case flip the sed translation, but don't remove it.
+
cubeparse.h: cubeparse.y
ifdef YACC
$(YACC) -d $(YFLAGS) -p cube_yy $<
- mv -f y.tab.c cubeparse.c
+ sed -e 's/"syntax error/"parse error/' < y.tab.c > cubeparse.c
mv -f y.tab.h cubeparse.h
+ rm -f y.tab.c
else
@$(missing) bison $< $@
endif
diff --git a/contrib/cube/cubeparse.y b/contrib/cube/cubeparse.y
index 33b7c1ef6b0..29c0974bab0 100644
--- a/contrib/cube/cubeparse.y
+++ b/contrib/cube/cubeparse.y
@@ -2,16 +2,15 @@
/* NdBox = [(lowerleft),(upperright)] */
/* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
-#define YYERROR_VERBOSE
#define YYPARSE_PARAM result /* need this to pass a pointer (void *) to yyparse */
#define YYSTYPE char *
#define YYDEBUG 1
-#include <string.h>
+#include "postgres.h"
+
#include "cubedata.h"
#include "buffer.h"
-#include "postgres.h"
#include "utils/palloc.h"
#include "utils/elog.h"
@@ -164,8 +163,9 @@ int cube_yyerror ( char *msg ) {
position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos();
- sprintf(
+ snprintf(
buf,
+ 256,
"%s at or before position %d, character ('%c', \\%03o), input: '%s'\n",
msg,
position,
@@ -175,7 +175,7 @@ int cube_yyerror ( char *msg ) {
);
reset_parse_buffer();
- elog(ERROR, buf);
+ elog(ERROR, "%s", buf);
return 0;
}
diff --git a/contrib/cube/expected/cube.out b/contrib/cube/expected/cube.out
index ed94a25b44c..ba8f29ec0fb 100644
--- a/contrib/cube/expected/cube.out
+++ b/contrib/cube/expected/cube.out
@@ -41,7 +41,7 @@ SELECT '.1'::cube AS cube;
(1 row)
SELECT '-.1'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' or `O_PAREN' or `O_BRACKET' at or before position 2, character ('.', \056), input: '-.1'
+ERROR: parse error at or before position 2, character ('.', \056), input: '-.1'
SELECT '1.0'::cube AS cube;
cube
@@ -217,46 +217,46 @@ SELECT '[(0,0,0,0),(1,0,0,0)]'::cube AS cube;
SELECT ''::cube AS cube;
ERROR: cube_in: can't parse an empty string
SELECT 'ABC'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' or `O_PAREN' or `O_BRACKET' at or before position 1, character ('A', \101), input: 'ABC'
+ERROR: parse error at or before position 1, character ('A', \101), input: 'ABC'
SELECT '()'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 2, character (')', \051), input: '()'
+ERROR: parse error at or before position 2, character (')', \051), input: '()'
SELECT '[]'::cube AS cube;
-ERROR: parse error, expecting `O_PAREN' at or before position 2, character (']', \135), input: '[]'
+ERROR: parse error at or before position 2, character (']', \135), input: '[]'
SELECT '[()]'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 3, character (')', \051), input: '[()]'
+ERROR: parse error at or before position 3, character (')', \051), input: '[()]'
SELECT '[(1)]'::cube AS cube;
-ERROR: parse error, expecting `COMMA' at or before position 5, character (']', \135), input: '[(1)]'
+ERROR: parse error at or before position 5, character (']', \135), input: '[(1)]'
SELECT '[(1),]'::cube AS cube;
-ERROR: parse error, expecting `O_PAREN' at or before position 6, character (']', \135), input: '[(1),]'
+ERROR: parse error at or before position 6, character (']', \135), input: '[(1),]'
SELECT '[(1),2]'::cube AS cube;
-ERROR: parse error, expecting `O_PAREN' at or before position 7, character (']', \135), input: '[(1),2]'
+ERROR: parse error at or before position 7, character (']', \135), input: '[(1),2]'
SELECT '[(1),(2),(3)]'::cube AS cube;
-ERROR: parse error, expecting `C_BRACKET' at or before position 9, character (',', \054), input: '[(1),(2),(3)]'
+ERROR: parse error at or before position 9, character (',', \054), input: '[(1),(2),(3)]'
SELECT '1,'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 2, character (',', \054), input: '1,'
+ERROR: parse error at or before position 2, character (',', \054), input: '1,'
SELECT '1,2,'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 4, character (',', \054), input: '1,2,'
+ERROR: parse error at or before position 4, character (',', \054), input: '1,2,'
SELECT '1,,2'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 3, character (',', \054), input: '1,,2'
+ERROR: parse error at or before position 3, character (',', \054), input: '1,,2'
SELECT '(1,)'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 4, character (')', \051), input: '(1,)'
+ERROR: parse error at or before position 4, character (')', \051), input: '(1,)'
SELECT '(1,2,)'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 6, character (')', \051), input: '(1,2,)'
+ERROR: parse error at or before position 6, character (')', \051), input: '(1,2,)'
SELECT '(1,,2)'::cube AS cube;
-ERROR: parse error, expecting `FLOAT' at or before position 4, character (',', \054), input: '(1,,2)'
+ERROR: parse error at or before position 4, character (',', \054), input: '(1,,2)'
-- invalid input: semantic errors and trailing garbage
SELECT '[(1),(2)],'::cube AS cube; -- 0