25
25
#line 8 "nan_test.pgc"
26
26
27
27
28
+ #ifdef WIN32
29
+ #define isinf (x ) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
30
+ #define isnan (x ) _isnan(x)
31
+ #endif /* WIN32 */
32
+
28
33
int
29
34
main (void )
30
35
{
@@ -34,54 +39,54 @@ main(void)
34
39
35
40
36
41
37
- #line 14 "nan_test.pgc"
42
+ #line 19 "nan_test.pgc"
38
43
int id ;
39
44
40
- #line 15 "nan_test.pgc"
45
+ #line 20 "nan_test.pgc"
41
46
double d ;
42
47
43
- #line 16 "nan_test.pgc"
48
+ #line 21 "nan_test.pgc"
44
49
numeric * num ;
45
50
46
- #line 17 "nan_test.pgc"
51
+ #line 22 "nan_test.pgc"
47
52
char val [16 ] ;
48
53
/* exec sql end declare section */
49
- #line 18 "nan_test.pgc"
54
+ #line 23 "nan_test.pgc"
50
55
51
56
52
57
ECPGdebug (1 ,stderr );
53
58
/* exec sql whenever sqlerror do sqlprint ( ) ; */
54
- #line 21 "nan_test.pgc"
59
+ #line 26 "nan_test.pgc"
55
60
56
61
57
62
{ECPGconnect (__LINE__ ,0 ,"regress1" ,NULL ,NULL ,NULL ,0 );
58
- #line 23 "nan_test.pgc"
63
+ #line 28 "nan_test.pgc"
59
64
60
65
if (sqlca .sqlcode < 0 )sqlprint ( );}
61
- #line 23 "nan_test.pgc"
66
+ #line 28 "nan_test.pgc"
62
67
63
68
64
69
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"create table nantest1 ( id int4 , d float8 )" ,ECPGt_EOIT ,ECPGt_EORT );
65
- #line 25 "nan_test.pgc"
70
+ #line 30 "nan_test.pgc"
66
71
67
72
if (sqlca .sqlcode < 0 )sqlprint ( );}
68
- #line 25 "nan_test.pgc"
73
+ #line 30 "nan_test.pgc"
69
74
70
75
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )" ,ECPGt_EOIT ,ECPGt_EORT );
71
- #line 26 "nan_test.pgc"
76
+ #line 31 "nan_test.pgc"
72
77
73
78
if (sqlca .sqlcode < 0 )sqlprint ( );}
74
- #line 26 "nan_test.pgc"
79
+ #line 31 "nan_test.pgc"
75
80
76
81
77
82
/* declare cur cursor for select id , d , d from nantest1 */
78
- #line 28 "nan_test.pgc"
83
+ #line 33 "nan_test.pgc"
79
84
80
85
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"declare cur cursor for select id , d , d from nantest1" ,ECPGt_EOIT ,ECPGt_EORT );
81
- #line 29 "nan_test.pgc"
86
+ #line 34 "nan_test.pgc"
82
87
83
88
if (sqlca .sqlcode < 0 )sqlprint ( );}
84
- #line 29 "nan_test.pgc"
89
+ #line 34 "nan_test.pgc"
85
90
86
91
while (1 )
87
92
{
@@ -92,10 +97,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
92
97
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
93
98
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
94
99
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
95
- #line 32 "nan_test.pgc"
100
+ #line 37 "nan_test.pgc"
96
101
97
102
if (sqlca .sqlcode < 0 )sqlprint ( );}
98
- #line 32 "nan_test.pgc"
103
+ #line 37 "nan_test.pgc"
99
104
100
105
if (sqlca .sqlcode )
101
106
break ;
@@ -109,34 +114,34 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
109
114
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
110
115
ECPGt_double ,& (d ),(long )1 ,(long )1 ,sizeof (double ),
111
116
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
112
- #line 40 "nan_test.pgc"
117
+ #line 45 "nan_test.pgc"
113
118
114
119
if (sqlca .sqlcode < 0 )sqlprint ( );}
115
- #line 40 "nan_test.pgc"
120
+ #line 45 "nan_test.pgc"
116
121
117
122
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest1 ( id , d ) values ( $1 + 6 , $2 )" ,
118
123
ECPGt_int ,& (id ),(long )1 ,(long )1 ,sizeof (int ),
119
124
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
120
125
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
121
126
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
122
- #line 41 "nan_test.pgc"
127
+ #line 46 "nan_test.pgc"
123
128
124
129
if (sqlca .sqlcode < 0 )sqlprint ( );}
125
- #line 41 "nan_test.pgc"
130
+ #line 46 "nan_test.pgc"
126
131
127
132
}
128
133
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"close cur" ,ECPGt_EOIT ,ECPGt_EORT );
129
- #line 43 "nan_test.pgc"
134
+ #line 48 "nan_test.pgc"
130
135
131
136
if (sqlca .sqlcode < 0 )sqlprint ( );}
132
- #line 43 "nan_test.pgc"
137
+ #line 48 "nan_test.pgc"
133
138
134
139
135
140
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"declare cur cursor for select id , d , d from nantest1" ,ECPGt_EOIT ,ECPGt_EORT );
136
- #line 45 "nan_test.pgc"
141
+ #line 50 "nan_test.pgc"
137
142
138
143
if (sqlca .sqlcode < 0 )sqlprint ( );}
139
- #line 45 "nan_test.pgc"
144
+ #line 50 "nan_test.pgc"
140
145
141
146
while (1 )
142
147
{
@@ -147,10 +152,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
147
152
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
148
153
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
149
154
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
150
- #line 48 "nan_test.pgc"
155
+ #line 53 "nan_test.pgc"
151
156
152
157
if (sqlca .sqlcode < 0 )sqlprint ( );}
153
- #line 48 "nan_test.pgc"
158
+ #line 53 "nan_test.pgc"
154
159
155
160
if (sqlca .sqlcode )
156
161
break ;
@@ -160,25 +165,25 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
160
165
printf ("%d NaN '%s'\n" ,id ,val );
161
166
}
162
167
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"close cur" ,ECPGt_EOIT ,ECPGt_EORT );
163
- #line 56 "nan_test.pgc"
168
+ #line 61 "nan_test.pgc"
164
169
165
170
if (sqlca .sqlcode < 0 )sqlprint ( );}
166
- #line 56 "nan_test.pgc"
171
+ #line 61 "nan_test.pgc"
167
172
168
173
169
174
num = PGTYPESnumeric_new ();
170
175
171
176
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"create table nantest2 ( id int4 , d numeric )" ,ECPGt_EOIT ,ECPGt_EORT );
172
- #line 60 "nan_test.pgc"
177
+ #line 65 "nan_test.pgc"
173
178
174
179
if (sqlca .sqlcode < 0 )sqlprint ( );}
175
- #line 60 "nan_test.pgc"
180
+ #line 65 "nan_test.pgc"
176
181
177
182
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest2 ( id , d ) values ( 4 , 'nan' :: numeric )" ,ECPGt_EOIT ,ECPGt_EORT );
178
- #line 61 "nan_test.pgc"
183
+ #line 66 "nan_test.pgc"
179
184
180
185
if (sqlca .sqlcode < 0 )sqlprint ( );}
181
- #line 61 "nan_test.pgc"
186
+ #line 66 "nan_test.pgc"
182
187
183
188
184
189
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"select id , d , d from nantest2 where id = 4" ,ECPGt_EOIT ,
@@ -188,39 +193,39 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
188
193
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
189
194
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
190
195
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
191
- #line 63 "nan_test.pgc"
196
+ #line 68 "nan_test.pgc"
192
197
193
198
if (sqlca .sqlcode < 0 )sqlprint ( );}
194
- #line 63 "nan_test.pgc"
199
+ #line 68 "nan_test.pgc"
195
200
196
201
197
202
printf ("%d %s '%s'\n" ,id , (num -> sign == NUMERIC_NAN ?"NaN" :"not NaN" ),val );
198
203
199
204
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest2 ( id , d ) values ( 5 , $1 )" ,
200
205
ECPGt_numeric ,& (num ),(long )1 ,(long )0 ,sizeof (numeric ),
201
206
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
202
- #line 67 "nan_test.pgc"
207
+ #line 72 "nan_test.pgc"
203
208
204
209
if (sqlca .sqlcode < 0 )sqlprint ( );}
205
- #line 67 "nan_test.pgc"
210
+ #line 72 "nan_test.pgc"
206
211
207
212
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest2 ( id , d ) values ( 6 , $1 )" ,
208
213
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
209
214
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
210
- #line 68 "nan_test.pgc"
215
+ #line 73 "nan_test.pgc"
211
216
212
217
if (sqlca .sqlcode < 0 )sqlprint ( );}
213
- #line 68 "nan_test.pgc"
218
+ #line 73 "nan_test.pgc"
214
219
215
220
216
221
/* declare cur1 cursor for select id , d , d from nantest2 */
217
- #line 70 "nan_test.pgc"
222
+ #line 75 "nan_test.pgc"
218
223
219
224
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"declare cur1 cursor for select id , d , d from nantest2" ,ECPGt_EOIT ,ECPGt_EORT );
220
- #line 71 "nan_test.pgc"
225
+ #line 76 "nan_test.pgc"
221
226
222
227
if (sqlca .sqlcode < 0 )sqlprint ( );}
223
- #line 71 "nan_test.pgc"
228
+ #line 76 "nan_test.pgc"
224
229
225
230
while (1 )
226
231
{
@@ -231,33 +236,33 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
231
236
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
232
237
ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
233
238
ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
234
- #line 74 "nan_test.pgc"
239
+ #line 79 "nan_test.pgc"
235
240
236
241
if (sqlca .sqlcode < 0 )sqlprint ( );}
237
- #line 74 "nan_test.pgc"
242
+ #line 79 "nan_test.pgc"
238
243
239
244
if (sqlca .sqlcode )
240
245
break ;
241
246
printf ("%d %s '%s'\n" ,id , (num -> sign == NUMERIC_NAN ?"NaN" :"not NaN" ),val );
242
247
}
243
248
{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"close cur1" ,ECPGt_EOIT ,ECPGt_EORT );
244
- #line 79 "nan_test.pgc"
249
+ #line 84 "nan_test.pgc"
245
250
246
251
if (sqlca .sqlcode < 0 )sqlprint ( );}
247
- #line 79 "nan_test.pgc"
252
+ #line 84 "nan_test.pgc"
248
253
249
254
250
255
{ECPGtrans (__LINE__ ,NULL ,"rollback" );
251
- #line 81 "nan_test.pgc"
256
+ #line 86 "nan_test.pgc"
252
257
253
258
if (sqlca .sqlcode < 0 )sqlprint ( );}
254
- #line 81 "nan_test.pgc"
259
+ #line 86 "nan_test.pgc"
255
260
256
261
{ECPGdisconnect (__LINE__ ,"CURRENT" );
257
- #line 82 "nan_test.pgc"
262
+ #line 87 "nan_test.pgc"
258
263
259
264
if (sqlca .sqlcode < 0 )sqlprint ( );}
260
- #line 82 "nan_test.pgc"
265
+ #line 87 "nan_test.pgc"
261
266
262
267
263
268
return (0 );