mirror of https://github.com/postgres/postgres
Back-patch into 7.2 branch the 7.3 changes that made contrib/seg
error messages reasonably independent of the bison version used to build segparse.c. Needed to get this branch passing on buildfarm.
This commit is contained in:
parent
44e7a2ae60
commit
84e5ce7eb9
|
@ -1,4 +1,4 @@
|
|||
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.6.2.1 2005/07/16 19:48:15 tgl Exp $
|
||||
|
||||
subdir = contrib/seg
|
||||
top_builddir = ../..
|
||||
|
@ -13,11 +13,17 @@ REGRESS = seg
|
|||
|
||||
segparse.c: segparse.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.
|
||||
|
||||
segparse.h: segparse.y
|
||||
ifdef YACC
|
||||
$(YACC) -d $(YFLAGS) -p seg_yy $<
|
||||
mv -f y.tab.c segparse.c
|
||||
sed -e 's/"syntax error/"parse error/' < y.tab.c > segparse.c
|
||||
mv -f y.tab.h segparse.h
|
||||
rm -f y.tab.c
|
||||
else
|
||||
@$(missing) bison $< $@
|
||||
endif
|
||||
|
|
|
@ -393,25 +393,25 @@ SELECT '100(+-)1'::seg AS seg;
|
|||
SELECT ''::seg AS seg;
|
||||
ERROR: seg_in: can't parse an empty string
|
||||
SELECT 'ABC'::seg AS seg;
|
||||
ERROR: parse error, expecting `FLOAT' or `RANGE' or `EXTENSION' at or near position 1, character ('A', \101), input: 'ABC'
|
||||
ERROR: parse error at or near position 1, character ('A', \101), input: 'ABC'
|
||||
|
||||
SELECT '1ABC'::seg AS seg;
|
||||
ERROR: expecting end of input at or near position 2, character ('A', \101), input: '1ABC'
|
||||
ERROR: parse error at or near position 2, character ('A', \101), input: '1ABC'
|
||||
|
||||
SELECT '1.'::seg AS seg;
|
||||
ERROR: expecting end of input at or near position 2, character ('.', \056), input: '1.'
|
||||
ERROR: parse error at or near position 2, character ('.', \056), input: '1.'
|
||||
|
||||
SELECT '1.....'::seg AS seg;
|
||||
ERROR: expecting end of input at or near position 6, character ('.', \056), input: '1.....'
|
||||
ERROR: parse error at or near position 6, character ('.', \056), input: '1.....'
|
||||
|
||||
SELECT '.1'::seg AS seg;
|
||||
ERROR: parse error, expecting `FLOAT' or `RANGE' or `EXTENSION' at or near position 2, character ('1', \061), input: '.1'
|
||||
ERROR: parse error at or near position 2, character ('1', \061), input: '.1'
|
||||
|
||||
SELECT '1..2.'::seg AS seg;
|
||||
ERROR: expecting end of input at or near position 5, character ('.', \056), input: '1..2.'
|
||||
ERROR: parse error at or near position 5, character ('.', \056), input: '1..2.'
|
||||
|
||||
SELECT '1 e7'::seg AS seg;
|
||||
ERROR: expecting end of input at or near position 3, character ('e', \145), input: '1 e7'
|
||||
ERROR: parse error at or near position 3, character ('e', \145), input: '1 e7'
|
||||
|
||||
SELECT '1e700'::seg AS seg;
|
||||
ERROR: numeric value 1e700 unrepresentable
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
%{
|
||||
#define YYERROR_VERBOSE
|
||||
#define YYPARSE_PARAM result /* need this to pass a pointer (void *) to yyparse */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "postgres.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "utils/elog.h"
|
||||
|
||||
#include "segdata.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#include "postgres.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#define HUGE HUGE_VAL
|
||||
#endif /* __CYGWIN__ */
|
||||
|
@ -147,9 +146,9 @@ float seg_atof ( char *value ) {
|
|||
sscanf(value, "%f", &result);
|
||||
|
||||
if ( errno ) {
|
||||
sprintf(buf, "numeric value %s unrepresentable", value);
|
||||
snprintf(buf, 256, "numeric value %s unrepresentable", value);
|
||||
reset_parse_buffer();
|
||||
elog(ERROR, buf);
|
||||
elog(ERROR, "%s", buf);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -168,8 +167,9 @@ int seg_yyerror ( char *msg ) {
|
|||
|
||||
position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos();
|
||||
|
||||
sprintf(
|
||||
snprintf(
|
||||
buf,
|
||||
256,
|
||||
"%s at or near position %d, character ('%c', \\%03o), input: '%s'\n",
|
||||
msg,
|
||||
position,
|
||||
|
@ -179,7 +179,7 @@ int seg_yyerror ( char *msg ) {
|
|||
);
|
||||
|
||||
reset_parse_buffer();
|
||||
elog(ERROR, buf);
|
||||
elog(ERROR, "%s", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue