PostgreSQL Source Code  git master
compat_informix-rnull.c
Go to the documentation of this file.
1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
3 #include <ecpglib.h>
4 #include <ecpgerrno.h>
5 #include <sqlca.h>
6 /* Needed for informix compatibility */
7 #include <ecpg_informix.h>
8 /* End of automatic include section */
9 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
10 
11 #line 1 "rnull.pgc"
12 #include "sqltypes.h"
13 #include <stdlib.h>
14 
15 
16 #line 1 "regression.h"
17 
18 
19 
20 
21 
22 
23 #line 4 "rnull.pgc"
24 
25 
26 
27 static void
28 test_null(int type, char *ptr)
29 {
30  printf("null: %d\n", risnull(type, ptr));
31 }
32 
33 int main(void)
34 {
35 
36 #line 15 "rnull.pgc"
37  char c [] = "abc" ;
38 
39 #line 15 "rnull.pgc"
40 
41 
42 #line 16 "rnull.pgc"
43  short s = 17 ;
44 
45 #line 16 "rnull.pgc"
46 
47 
48 #line 17 "rnull.pgc"
49  int i = - 74874 ;
50 
51 #line 17 "rnull.pgc"
52 
53 
54 #line 18 "rnull.pgc"
55  bool b = 1 ;
56 
57 #line 18 "rnull.pgc"
58 
59 
60 #line 19 "rnull.pgc"
61  float f = ( float ) 3.71 ;
62 
63 #line 19 "rnull.pgc"
64 
65 
66 #line 20 "rnull.pgc"
67  long l = 487444 ;
68 
69 #line 20 "rnull.pgc"
70 
71 
72 #line 21 "rnull.pgc"
73  double dbl = 404.404 ;
74 
75 #line 21 "rnull.pgc"
76 
77 
78 #line 22 "rnull.pgc"
79  decimal dec ;
80 
81 #line 22 "rnull.pgc"
82 
83 
84 #line 23 "rnull.pgc"
85  date dat ;
86 
87 #line 23 "rnull.pgc"
88 
89 
90 #line 24 "rnull.pgc"
91  timestamp tmp ;
92 
93 #line 24 "rnull.pgc"
94 
95 
96  ECPGdebug(1, stderr);
97  /* exec sql whenever sqlerror do sqlprint ( ) ; */
98 #line 27 "rnull.pgc"
99 
100 
101  { ECPGconnect(__LINE__, 1, "ecpg1_regression" , NULL, NULL , NULL, 0);
102 #line 29 "rnull.pgc"
103 
104 if (sqlca.sqlcode < 0) sqlprint ( );}
105 #line 29 "rnull.pgc"
106 
107 
108  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "create table test ( id int , c char ( 10 ) , s smallint , i int , b bool , f float , l bigint , dbl double precision , dec decimal , dat date , tmp timestamptz )", ECPGt_EOIT, ECPGt_EORT);
109 #line 33 "rnull.pgc"
110 
111 if (sqlca.sqlcode < 0) sqlprint ( );}
112 #line 33 "rnull.pgc"
113 
114  { ECPGtrans(__LINE__, NULL, "commit");
115 #line 34 "rnull.pgc"
116 
117 if (sqlca.sqlcode < 0) sqlprint ( );}
118 #line 34 "rnull.pgc"
119 
120 
121  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl ) values ( 1 , $1 , $2 , $3 , $4 , $5 , $6 , $7 )",
122  ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
123  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
124  ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
125  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
126  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
127  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
128  ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
129  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
130  ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
131  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
132  ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
133  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
134  ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
135  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
136 #line 38 "rnull.pgc"
137 
138 if (sqlca.sqlcode < 0) sqlprint ( );}
139 #line 38 "rnull.pgc"
140 
141  { ECPGtrans(__LINE__, NULL, "commit");
142 #line 39 "rnull.pgc"
143 
144 if (sqlca.sqlcode < 0) sqlprint ( );}
145 #line 39 "rnull.pgc"
146 
147 
148  rsetnull(CCHARTYPE, (char *) c);
149  rsetnull(CSHORTTYPE, (char *) &s);
150  rsetnull(CINTTYPE, (char *) &i);
151  rsetnull(CBOOLTYPE, (char *) &b);
152  rsetnull(CFLOATTYPE, (char *) &f);
153  rsetnull(CLONGTYPE, (char *) &l);
154  rsetnull(CDOUBLETYPE, (char *) &dbl);
155  rsetnull(CDECIMALTYPE, (char *) &dec);
156  rsetnull(CDATETYPE, (char *) &dat);
157  rsetnull(CDTIMETYPE, (char *) &tmp);
158 
159  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values ( 2 , $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 , $9 , $10 )",
160  ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
161  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
162  ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
163  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
164  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
165  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
166  ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
167  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
168  ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
169  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
170  ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
171  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
172  ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
173  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
174  ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
175  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
176  ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
177  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
178  ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
179  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
180 #line 54 "rnull.pgc"
181 
182 if (sqlca.sqlcode < 0) sqlprint ( );}
183 #line 54 "rnull.pgc"
184 
185  { ECPGtrans(__LINE__, NULL, "commit");
186 #line 55 "rnull.pgc"
187 
188 if (sqlca.sqlcode < 0) sqlprint ( );}
189 #line 55 "rnull.pgc"
190 
191 
192  printf("first select\n");
193 
194  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1", ECPGt_EOIT,
195  ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
196  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
197  ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
198  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
199  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
200  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
201  ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
202  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
203  ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
204  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
205  ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
206  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
207  ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
208  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
209  ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
210  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
211  ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
212  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
213  ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
214  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
215 #line 61 "rnull.pgc"
216 
217 if (sqlca.sqlcode < 0) sqlprint ( );}
218 #line 61 "rnull.pgc"
219 
220 
221  test_null(CCHARTYPE, (char *) c);
222  test_null(CSHORTTYPE, (char *) &s);
223  test_null(CINTTYPE, (char *) &i);
224  test_null(CBOOLTYPE, (char *) &b);
225  test_null(CFLOATTYPE, (char *) &f);
226  test_null(CLONGTYPE, (char *) &l);
227  test_null(CDOUBLETYPE, (char *) &dbl);
228  test_null(CDECIMALTYPE, (char *) &dec);
229  test_null(CDATETYPE, (char *) &dat);
230  test_null(CDTIMETYPE, (char *) &tmp);
231 
232  printf("second select\n");
233 
234  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2", ECPGt_EOIT,
235  ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
236  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
237  ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
238  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
239  ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
240  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
241  ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
242  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
243  ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
244  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
245  ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
246  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
247  ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
248  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
249  ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
250  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
251  ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
252  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
253  ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
254  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
255 #line 78 "rnull.pgc"
256 
257 if (sqlca.sqlcode < 0) sqlprint ( );}
258 #line 78 "rnull.pgc"
259 
260 
261  test_null(CCHARTYPE, (char *) c);
262  test_null(CSHORTTYPE, (char *) &s);
263  test_null(CINTTYPE, (char *) &i);
264  test_null(CBOOLTYPE, (char *) &b);
265  test_null(CFLOATTYPE, (char *) &f);
266  test_null(CLONGTYPE, (char *) &l);
267  test_null(CDOUBLETYPE, (char *) &dbl);
268  test_null(CDECIMALTYPE, (char *) &dec);
269  test_null(CDATETYPE, (char *) &dat);
270  test_null(CDTIMETYPE, (char *) &tmp);
271 
272  { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
273 #line 91 "rnull.pgc"
274 
275 if (sqlca.sqlcode < 0) sqlprint ( );}
276 #line 91 "rnull.pgc"
277 
278  { ECPGtrans(__LINE__, NULL, "commit");
279 #line 92 "rnull.pgc"
280 
281 if (sqlca.sqlcode < 0) sqlprint ( );}
282 #line 92 "rnull.pgc"
283 
284 
285  { ECPGdisconnect(__LINE__, "CURRENT");
286 #line 94 "rnull.pgc"
287 
288 if (sqlca.sqlcode < 0) sqlprint ( );}
289 #line 94 "rnull.pgc"
290 
291 
292  return 0;
293 }
static void test_null(int type, char *ptr)
int main(void)
#define ECPGdebug(X, Y)
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:673
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_float
Definition: ecpgtype.h:47
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_decimal
Definition: ecpgtype.h:51
@ ECPGt_timestamp
Definition: ecpgtype.h:54
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_double
Definition: ecpgtype.h:47
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_date
Definition: ecpgtype.h:53
@ ECPGt_bool
Definition: ecpgtype.h:46
@ ECPGt_char
Definition: ecpgtype.h:43
void sqlprint(void)
Definition: error.c:334
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2277
int risnull(int t, const char *ptr)
Definition: informix.c:1049
int rsetnull(int t, char *ptr)
Definition: informix.c:1042
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:160
int b
Definition: isn.c:70
int i
Definition: isn.c:73
long date
Definition: pgtypes_date.h:9
int64 timestamp
#define printf(...)
Definition: port.h:244
char * c
#define sqlca
Definition: sqlca.h:59
#define CFLOATTYPE
Definition: sqltypes.h:10
#define CDECIMALTYPE
Definition: sqltypes.h:12
#define CDOUBLETYPE
Definition: sqltypes.h:11
#define CDTIMETYPE
Definition: sqltypes.h:17
#define CLONGTYPE
Definition: sqltypes.h:9
#define CCHARTYPE
Definition: sqltypes.h:6
#define CSHORTTYPE
Definition: sqltypes.h:7
#define CINTTYPE
Definition: sqltypes.h:8
#define CDATETYPE
Definition: sqltypes.h:15
#define CBOOLTYPE
Definition: sqltypes.h:27
const char * type