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