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 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8 
9 #line 1 "whenever.pgc"
10 #include <stdlib.h>
11 
12 
13 #line 1 "regression.h"
14 
15 
16 
17 
18 
19 
20 #line 3 "whenever.pgc"
21 
22 
23 /* exec sql whenever sqlerror  sqlprint ; */
24 #line 5 "whenever.pgc"
25 
26 
print(const char * msg)27 static void print(const char *msg)
28 {
29         fprintf(stderr, "Error in statement '%s':\n", msg);
30         sqlprint();
31 }
32 
print2(void)33 static void print2(void)
34 {
35         fprintf(stderr, "Found another error\n");
36         sqlprint();
37 }
38 
warn(void)39 static void warn(void)
40 {
41         fprintf(stderr, "Warning: At least one column was truncated\n");
42 }
43 
main(void)44 int main(void)
45 {
46 
47 #line 26 "whenever.pgc"
48  int i ;
49 
50 #line 26 "whenever.pgc"
51 
52 
53 #line 27 "whenever.pgc"
54  char c [ 6 ] ;
55 
56 #line 27 "whenever.pgc"
57 
58 
59 	ECPGdebug(1, stderr);
60 
61 	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
62 #line 31 "whenever.pgc"
63 
64 if (sqlca.sqlcode < 0) sqlprint();}
65 #line 31 "whenever.pgc"
66 
67 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( i int , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
68 #line 32 "whenever.pgc"
69 
70 if (sqlca.sqlcode < 0) sqlprint();}
71 #line 32 "whenever.pgc"
72 
73 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 1 , 'abcdefghij' )", ECPGt_EOIT, ECPGt_EORT);
74 #line 33 "whenever.pgc"
75 
76 if (sqlca.sqlcode < 0) sqlprint();}
77 #line 33 "whenever.pgc"
78 
79 
80 	/* exec sql whenever sql_warning  do warn ( ) ; */
81 #line 35 "whenever.pgc"
82 
83 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT,
84 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
85 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
86 	ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char),
87 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
88 #line 36 "whenever.pgc"
89 
90 if (sqlca.sqlwarn[0] == 'W') warn ( );
91 #line 36 "whenever.pgc"
92 
93 if (sqlca.sqlcode < 0) sqlprint();}
94 #line 36 "whenever.pgc"
95 
96 	{ ECPGtrans(__LINE__, NULL, "rollback");
97 #line 37 "whenever.pgc"
98 
99 if (sqlca.sqlwarn[0] == 'W') warn ( );
100 #line 37 "whenever.pgc"
101 
102 if (sqlca.sqlcode < 0) sqlprint();}
103 #line 37 "whenever.pgc"
104 
105 
106 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistent", ECPGt_EOIT,
107 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
108 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
109 #line 39 "whenever.pgc"
110 
111 if (sqlca.sqlwarn[0] == 'W') warn ( );
112 #line 39 "whenever.pgc"
113 
114 if (sqlca.sqlcode < 0) sqlprint();}
115 #line 39 "whenever.pgc"
116 
117 	{ ECPGtrans(__LINE__, NULL, "rollback");
118 #line 40 "whenever.pgc"
119 
120 if (sqlca.sqlwarn[0] == 'W') warn ( );
121 #line 40 "whenever.pgc"
122 
123 if (sqlca.sqlcode < 0) sqlprint();}
124 #line 40 "whenever.pgc"
125 
126 
127 	/* exec sql whenever sqlerror  do print ( \"select\" ) ; */
128 #line 42 "whenever.pgc"
129 
130 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistent", ECPGt_EOIT,
131 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
132 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
133 #line 43 "whenever.pgc"
134 
135 if (sqlca.sqlwarn[0] == 'W') warn ( );
136 #line 43 "whenever.pgc"
137 
138 if (sqlca.sqlcode < 0) print ( "select" );}
139 #line 43 "whenever.pgc"
140 
141 	{ ECPGtrans(__LINE__, NULL, "rollback");
142 #line 44 "whenever.pgc"
143 
144 if (sqlca.sqlwarn[0] == 'W') warn ( );
145 #line 44 "whenever.pgc"
146 
147 if (sqlca.sqlcode < 0) print ( "select" );}
148 #line 44 "whenever.pgc"
149 
150 
151 	/* exec sql whenever sqlerror  call print2 ( ) ; */
152 #line 46 "whenever.pgc"
153 
154 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistent", ECPGt_EOIT,
155 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
156 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
157 #line 47 "whenever.pgc"
158 
159 if (sqlca.sqlwarn[0] == 'W') warn ( );
160 #line 47 "whenever.pgc"
161 
162 if (sqlca.sqlcode < 0) print2 ( );}
163 #line 47 "whenever.pgc"
164 
165 	{ ECPGtrans(__LINE__, NULL, "rollback");
166 #line 48 "whenever.pgc"
167 
168 if (sqlca.sqlwarn[0] == 'W') warn ( );
169 #line 48 "whenever.pgc"
170 
171 if (sqlca.sqlcode < 0) print2 ( );}
172 #line 48 "whenever.pgc"
173 
174 
175 	/* exec sql whenever sqlerror  continue ; */
176 #line 50 "whenever.pgc"
177 
178 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistent", ECPGt_EOIT,
179 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
180 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
181 #line 51 "whenever.pgc"
182 
183 if (sqlca.sqlwarn[0] == 'W') warn ( );}
184 #line 51 "whenever.pgc"
185 
186 	{ ECPGtrans(__LINE__, NULL, "rollback");
187 #line 52 "whenever.pgc"
188 
189 if (sqlca.sqlwarn[0] == 'W') warn ( );}
190 #line 52 "whenever.pgc"
191 
192 
193 	/* exec sql whenever sqlerror  goto  error ; */
194 #line 54 "whenever.pgc"
195 
196 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistent", ECPGt_EOIT,
197 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
198 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
199 #line 55 "whenever.pgc"
200 
201 if (sqlca.sqlwarn[0] == 'W') warn ( );
202 #line 55 "whenever.pgc"
203 
204 if (sqlca.sqlcode < 0) goto error;}
205 #line 55 "whenever.pgc"
206 
207 	printf("Should not be reachable\n");
208 
209 	error:
210 	{ ECPGtrans(__LINE__, NULL, "rollback");
211 #line 59 "whenever.pgc"
212 
213 if (sqlca.sqlwarn[0] == 'W') warn ( );
214 #line 59 "whenever.pgc"
215 
216 if (sqlca.sqlcode < 0) goto error;}
217 #line 59 "whenever.pgc"
218 
219 
220 	/* exec sql whenever sqlerror  stop ; */
221 #line 61 "whenever.pgc"
222 
223 	/* This cannot fail, thus we don't get an exit value not equal 0. */
224 	/* However, it still test the precompiler output. */
225 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1", ECPGt_EOIT,
226 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
227 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
228 #line 64 "whenever.pgc"
229 
230 if (sqlca.sqlwarn[0] == 'W') warn ( );
231 #line 64 "whenever.pgc"
232 
233 if (sqlca.sqlcode < 0) exit (1);}
234 #line 64 "whenever.pgc"
235 
236 	{ ECPGtrans(__LINE__, NULL, "rollback");
237 #line 65 "whenever.pgc"
238 
239 if (sqlca.sqlwarn[0] == 'W') warn ( );
240 #line 65 "whenever.pgc"
241 
242 if (sqlca.sqlcode < 0) exit (1);}
243 #line 65 "whenever.pgc"
244 
245 	exit (0);
246 }
247