Back-patch into 7.2 branch the 7.3 changes that made contrib/cube
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Jul 2005 19:27:20 +0000 (19:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Jul 2005 19:27:20 +0000 (19:27 +0000)
error messages reasonably independent of the bison version used to
build cubeparse.c.  Needed to get this branch passing on buildfarm.

contrib/cube/Makefile
contrib/cube/cubeparse.y
contrib/cube/expected/cube.out

index 1bf47b90e96e9ee884bf8b33d710b3f77f4d6285..4fc1185b783b9a6cbfa5aec520463ccfb247fe6e 100644 (file)
@@ -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
index 33b7c1ef6b0c93ee8e9a67bd97343f4801e81543..29c0974bab086f3b8fbd794e72d146030a274d28 100644 (file)
@@ -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;
 }
 
index ed94a25b44cbe283047a7ed9075ac67bc4d9dcd5..ba8f29ec0fb61761886a83a4f36ade8b173fdeff 100644 (file)
@@ -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