PostgreSQL Source Code git master
preproc-whenever.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/* 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
27static void print(const char *msg)
28{
29 fprintf(stderr, "Error in statement '%s':\n", msg);
30 sqlprint();
31}
32
33static void print2(void)
34{
35 fprintf(stderr, "Found another error\n");
36 sqlprint();
37}
38
39static void warn(void)
40{
41 fprintf(stderr, "Warning: At least one column was truncated\n");
42}
43
44int 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
64if (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
70if (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
76if (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
90if (sqlca.sqlwarn[0] == 'W') warn ( );
91#line 36 "whenever.pgc"
92
93if (sqlca.sqlcode < 0) sqlprint();}
94#line 36 "whenever.pgc"
95
96 { ECPGtrans(__LINE__, NULL, "rollback");
97#line 37 "whenever.pgc"
98
99if (sqlca.sqlwarn[0] == 'W') warn ( );
100#line 37 "whenever.pgc"
101
102if (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
111if (sqlca.sqlwarn[0] == 'W') warn ( );
112#line 39 "whenever.pgc"
113
114if (sqlca.sqlcode < 0) sqlprint();}
115#line 39 "whenever.pgc"
116
117 { ECPGtrans(__LINE__, NULL, "rollback");
118#line 40 "whenever.pgc"
119
120if (sqlca.sqlwarn[0] == 'W') warn ( );
121#line 40 "whenever.pgc"
122
123if (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
135if (sqlca.sqlwarn[0] == 'W') warn ( );
136#line 43 "whenever.pgc"
137
138if (sqlca.sqlcode < 0) print ( "select" );}
139#line 43 "whenever.pgc"
140
141 { ECPGtrans(__LINE__, NULL, "rollback");
142#line 44 "whenever.pgc"
143
144if (sqlca.sqlwarn[0] == 'W') warn ( );
145#line 44 "whenever.pgc"
146
147if (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
159if (sqlca.sqlwarn[0] == 'W') warn ( );
160#line 47 "whenever.pgc"
161
162if (sqlca.sqlcode < 0) print2 ( );}
163#line 47 "whenever.pgc"
164
165 { ECPGtrans(__LINE__, NULL, "rollback");
166#line 48 "whenever.pgc"
167
168if (sqlca.sqlwarn[0] == 'W') warn ( );
169#line 48 "whenever.pgc"
170
171if (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
183if (sqlca.sqlwarn[0] == 'W') warn ( );}
184#line 51 "whenever.pgc"
185
186 { ECPGtrans(__LINE__, NULL, "rollback");
187#line 52 "whenever.pgc"
188
189if (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
201if (sqlca.sqlwarn[0] == 'W') warn ( );
202#line 55 "whenever.pgc"
203
204if (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
213if (sqlca.sqlwarn[0] == 'W') warn ( );
214#line 59 "whenever.pgc"
215
216if (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
230if (sqlca.sqlwarn[0] == 'W') warn ( );
231#line 64 "whenever.pgc"
232
233if (sqlca.sqlcode < 0) exit (1);}
234#line 64 "whenever.pgc"
235
236 { ECPGtrans(__LINE__, NULL, "rollback");
237#line 65 "whenever.pgc"
238
239if (sqlca.sqlwarn[0] == 'W') warn ( );
240#line 65 "whenever.pgc"
241
242if (sqlca.sqlcode < 0) exit (1);}
243#line 65 "whenever.pgc"
244
245 exit (0);
246}
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
#define fprintf(file, fmt, msg)
Definition: cubescan.l:21
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ 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:2275
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:160
int i
Definition: isn.c:74
#define printf(...)
Definition: port.h:245
char * c
static void warn(void)
int main(void)
static void print2(void)
#define ECPGdebug(X, Y)
static void print(const char *msg)
static void error(void)
Definition: sql-dyntest.c:147
#define sqlca
Definition: sqlca.h:59