7
7
#include < math.h>
8
8
9
9
#include " fmgr.h"
10
+ #include " nodes/miscnodes.h"
10
11
#include " utils/builtins.h"
12
+ #include " utils/float.h"
11
13
12
14
#include " segdata.h"
13
15
19
21
#define YYMALLOC palloc
20
22
#define YYFREE pfree
21
23
22
- static float seg_atof (const char *value);
24
+ static bool seg_atof (char *value, float *result, struct Node *escontext );
23
25
24
26
static int sig_digits (const char *value);
25
27
@@ -35,6 +37,7 @@ static char strbuf[25] = {
35
37
36
38
/* BISON Declarations */
37
39
%parse-param {SEG *result}
40
+ %parse-param {struct Node *escontext}
38
41
%expect 0
39
42
%name-prefix=" seg_yy"
40
43
@@ -77,7 +80,7 @@ range: boundary PLUMIN deviation
77
80
result->lower = $1 .val ;
78
81
result->upper = $3 .val ;
79
82
if ( result->lower > result->upper ) {
80
- ereport (ERROR ,
83
+ errsave (escontext ,
81
84
(errcode (ERRCODE_INVALID_PARAMETER_VALUE),
82
85
errmsg (" swapped boundaries: %g is greater than %g" ,
83
86
result->lower , result->upper )));
@@ -121,7 +124,10 @@ range: boundary PLUMIN deviation
121
124
boundary: SEGFLOAT
122
125
{
123
126
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
124
- float val = seg_atof($1 );
127
+ float val;
128
+
129
+ if (!seg_atof ($1 , &val, escontext))
130
+ YYABORT;
125
131
126
132
$$.ext = ' \0 ' ;
127
133
$$.sigd = sig_digits ($1 );
@@ -130,7 +136,10 @@ boundary: SEGFLOAT
130
136
| EXTENSION SEGFLOAT
131
137
{
132
138
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
133
- float val = seg_atof($2 );
139
+ float val;
140
+
141
+ if (!seg_atof ($2 , &val, escontext))
142
+ YYABORT;
134
143
135
144
$$.ext = $1 [0 ];
136
145
$$.sigd = sig_digits ($2 );
@@ -141,7 +150,10 @@ boundary: SEGFLOAT
141
150
deviation: SEGFLOAT
142
151
{
143
152
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
144
- float val = seg_atof($1 );
153
+ float val;
154
+
155
+ if (!seg_atof ($1 , &val, escontext))
156
+ YYABORT;
145
157
146
158
$$.ext = ' \0 ' ;
147
159
$$.sigd = sig_digits ($1 );
@@ -152,13 +164,13 @@ deviation: SEGFLOAT
152
164
%%
153
165
154
166
155
- static float
156
- seg_atof (const char *value)
167
+ static bool
168
+ seg_atof (char *value, float *result, struct Node *escontext )
157
169
{
158
- Datum datum ;
159
-
160
- datum = DirectFunctionCall1 (float4in, CStringGetDatum (value)) ;
161
- return DatumGetFloat4 (datum) ;
170
+ *result = float4in_internal (value, NULL , " seg " , value, escontext) ;
171
+ if ( SOFT_ERROR_OCCURRED (escontext))
172
+ return false ;
173
+ return true ;
162
174
}
163
175
164
176
static int
0 commit comments