1010#include <stdio.h>
1111#include <stdlib.h>
1212#include <math.h>
13+ #include <float.h>
1314#include <pgtypes_numeric.h>
1415#include <decimal.h>
1516
2122
2223
2324
24- #line 7 "nan_test.pgc"
25+ #line 8 "nan_test.pgc"
2526
2627
2728int
@@ -33,54 +34,54 @@ main(void)
3334
3435
3536
36- #line 13 "nan_test.pgc"
37+ #line 14 "nan_test.pgc"
3738int id ;
3839
39- #line 14 "nan_test.pgc"
40+ #line 15 "nan_test.pgc"
4041double d ;
4142
42- #line 15 "nan_test.pgc"
43+ #line 16 "nan_test.pgc"
4344numeric * num ;
4445
45- #line 16 "nan_test.pgc"
46+ #line 17 "nan_test.pgc"
4647char val [16 ] ;
4748/* exec sql end declare section */
48- #line 17 "nan_test.pgc"
49+ #line 18 "nan_test.pgc"
4950
5051
5152ECPGdebug (1 ,stderr );
5253/* exec sql whenever sqlerror do sqlprint ( ) ; */
53- #line 20 "nan_test.pgc"
54+ #line 21 "nan_test.pgc"
5455
5556
5657{ECPGconnect (__LINE__ ,0 ,"regress1" ,NULL ,NULL ,NULL ,0 );
57- #line 22 "nan_test.pgc"
58+ #line 23 "nan_test.pgc"
5859
5960if (sqlca .sqlcode < 0 )sqlprint ( );}
60- #line 22 "nan_test.pgc"
61+ #line 23 "nan_test.pgc"
6162
6263
6364{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"
6566
6667if (sqlca .sqlcode < 0 )sqlprint ( );}
67- #line 24 "nan_test.pgc"
68+ #line 25 "nan_test.pgc"
6869
6970{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"
7172
7273if (sqlca .sqlcode < 0 )sqlprint ( );}
73- #line 25 "nan_test.pgc"
74+ #line 26 "nan_test.pgc"
7475
7576
7677/* declare cur cursor for select id , d , d from nantest1 */
77- #line 27 "nan_test.pgc"
78+ #line 28 "nan_test.pgc"
7879
7980{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"
8182
8283if (sqlca .sqlcode < 0 )sqlprint ( );}
83- #line 28 "nan_test.pgc"
84+ #line 29 "nan_test.pgc"
8485
8586while (1 )
8687{
@@ -91,10 +92,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
9192ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
9293ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
9394ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
94- #line 31 "nan_test.pgc"
95+ #line 32 "nan_test.pgc"
9596
9697if (sqlca .sqlcode < 0 )sqlprint ( );}
97- #line 31 "nan_test.pgc"
98+ #line 32 "nan_test.pgc"
9899
99100if (sqlca .sqlcode )
100101break ;
@@ -108,34 +109,34 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
108109ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
109110ECPGt_double ,& (d ),(long )1 ,(long )1 ,sizeof (double ),
110111ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
111- #line 39 "nan_test.pgc"
112+ #line 40 "nan_test.pgc"
112113
113114if (sqlca .sqlcode < 0 )sqlprint ( );}
114- #line 39 "nan_test.pgc"
115+ #line 40 "nan_test.pgc"
115116
116117{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest1 ( id , d ) values ( $1 + 6 , $2 )" ,
117118ECPGt_int ,& (id ),(long )1 ,(long )1 ,sizeof (int ),
118119ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
119120ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
120121ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
121- #line 40 "nan_test.pgc"
122+ #line 41 "nan_test.pgc"
122123
123124if (sqlca .sqlcode < 0 )sqlprint ( );}
124- #line 40 "nan_test.pgc"
125+ #line 41 "nan_test.pgc"
125126
126127}
127128{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"
129130
130131if (sqlca .sqlcode < 0 )sqlprint ( );}
131- #line 42 "nan_test.pgc"
132+ #line 43 "nan_test.pgc"
132133
133134
134135{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"
136137
137138if (sqlca .sqlcode < 0 )sqlprint ( );}
138- #line 44 "nan_test.pgc"
139+ #line 45 "nan_test.pgc"
139140
140141while (1 )
141142{
@@ -146,10 +147,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
146147ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
147148ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
148149ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
149- #line 47 "nan_test.pgc"
150+ #line 48 "nan_test.pgc"
150151
151152if (sqlca .sqlcode < 0 )sqlprint ( );}
152- #line 47 "nan_test.pgc"
153+ #line 48 "nan_test.pgc"
153154
154155if (sqlca .sqlcode )
155156break ;
@@ -159,25 +160,25 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
159160printf ("%d NaN '%s'\n" ,id ,val );
160161}
161162{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"
163164
164165if (sqlca .sqlcode < 0 )sqlprint ( );}
165- #line 55 "nan_test.pgc"
166+ #line 56 "nan_test.pgc"
166167
167168
168169num = PGTYPESnumeric_new ();
169170
170171{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"
172173
173174if (sqlca .sqlcode < 0 )sqlprint ( );}
174- #line 59 "nan_test.pgc"
175+ #line 60 "nan_test.pgc"
175176
176177{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"
178179
179180if (sqlca .sqlcode < 0 )sqlprint ( );}
180- #line 60 "nan_test.pgc"
181+ #line 61 "nan_test.pgc"
181182
182183
183184{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 ( );}
187188ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
188189ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
189190ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
190- #line 62 "nan_test.pgc"
191+ #line 63 "nan_test.pgc"
191192
192193if (sqlca .sqlcode < 0 )sqlprint ( );}
193- #line 62 "nan_test.pgc"
194+ #line 63 "nan_test.pgc"
194195
195196
196197printf ("%d %s '%s'\n" ,id , (num -> sign == NUMERIC_NAN ?"NaN" :"not NaN" ),val );
197198
198199{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest2 ( id , d ) values ( 5 , $1 )" ,
199200ECPGt_numeric ,& (num ),(long )1 ,(long )0 ,sizeof (numeric ),
200201ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
201- #line 66 "nan_test.pgc"
202+ #line 67 "nan_test.pgc"
202203
203204if (sqlca .sqlcode < 0 )sqlprint ( );}
204- #line 66 "nan_test.pgc"
205+ #line 67 "nan_test.pgc"
205206
206207{ECPGdo (__LINE__ ,0 ,1 ,NULL ,0 ,ECPGst_normal ,"insert into nantest2 ( id , d ) values ( 6 , $1 )" ,
207208ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
208209ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EOIT ,ECPGt_EORT );
209- #line 67 "nan_test.pgc"
210+ #line 68 "nan_test.pgc"
210211
211212if (sqlca .sqlcode < 0 )sqlprint ( );}
212- #line 67 "nan_test.pgc"
213+ #line 68 "nan_test.pgc"
213214
214215
215216/* declare cur1 cursor for select id , d , d from nantest2 */
216- #line 69 "nan_test.pgc"
217+ #line 70 "nan_test.pgc"
217218
218219{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"
220221
221222if (sqlca .sqlcode < 0 )sqlprint ( );}
222- #line 70 "nan_test.pgc"
223+ #line 71 "nan_test.pgc"
223224
224225while (1 )
225226{
@@ -230,33 +231,33 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
230231ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,
231232ECPGt_char ,(val ),(long )16 ,(long )1 ,(16 )* sizeof (char ),
232233ECPGt_NO_INDICATOR ,NULL ,0L ,0L ,0L ,ECPGt_EORT );
233- #line 73 "nan_test.pgc"
234+ #line 74 "nan_test.pgc"
234235
235236if (sqlca .sqlcode < 0 )sqlprint ( );}
236- #line 73 "nan_test.pgc"
237+ #line 74 "nan_test.pgc"
237238
238239if (sqlca .sqlcode )
239240break ;
240241printf ("%d %s '%s'\n" ,id , (num -> sign == NUMERIC_NAN ?"NaN" :"not NaN" ),val );
241242}
242243{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"
244245
245246if (sqlca .sqlcode < 0 )sqlprint ( );}
246- #line 78 "nan_test.pgc"
247+ #line 79 "nan_test.pgc"
247248
248249
249250{ECPGtrans (__LINE__ ,NULL ,"rollback" );
250- #line 80 "nan_test.pgc"
251+ #line 81 "nan_test.pgc"
251252
252253if (sqlca .sqlcode < 0 )sqlprint ( );}
253- #line 80 "nan_test.pgc"
254+ #line 81 "nan_test.pgc"
254255
255256{ECPGdisconnect (__LINE__ ,"CURRENT" );
256- #line 81 "nan_test.pgc"
257+ #line 82 "nan_test.pgc"
257258
258259if (sqlca .sqlcode < 0 )sqlprint ( );}
259- #line 81 "nan_test.pgc"
260+ #line 82 "nan_test.pgc"
260261
261262
262263return (0 );