Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2f731c

Browse files
author
Michael Meskes
committed
Make some ecpg test cases more robust against unexpected errors that happen
during development. Test cases themselves should not hang or segfault.
1 parent5c04630 commite2f731c

21 files changed

+408
-487
lines changed

‎src/interfaces/ecpg/test/compat_informix/test_informix.pgc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ int main(void)
5656
{
5757
$fetch forward c into :i, :j, :c;
5858
if (sqlca.sqlcode == 100) break;
59-
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
6059

6160
if (risnull(CDECIMALTYPE, (char *)&j))
6261
printf("%d NULL\n", i);

‎src/interfaces/ecpg/test/compat_informix/test_informix2.pgc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ static void sql_check(const char *fn, const char *caller, int ignore)
4141
}
4242
}
4343

44-
45-
4644
int main(void)
4745
{
4846
EXEC SQL BEGIN DECLARE SECTION;
@@ -55,7 +53,7 @@ int main(void)
5553

5654
interval *intvl;
5755

58-
EXEC SQL whenever sqlerrorsqlprint;
56+
EXEC SQL whenever sqlerrorstop;
5957

6058
ECPGdebug(1, stderr);
6159

‎src/interfaces/ecpg/test/compat_oracle/char_array.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static void warn(void)
1616
int main() {
1717

1818
EXEC SQL WHENEVER SQLWARNING do warn();
19-
EXEC SQL WHENEVER SQLERRORSQLPRINT;
19+
EXEC SQL WHENEVER SQLERRORSTOP;
2020

2121
const char *ppppp = "XXXXX";
2222
int loopcount;

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
171171
#line 57 "test_informix.pgc"
172172

173173
if (sqlca.sqlcode==100)break;
174-
elseif (sqlca.sqlcode!=0)printf ("Error: %ld\n",sqlca.sqlcode);
175174

176175
if (risnull(CDECIMALTYPE, (char*)&j))
177176
printf("%d NULL\n",i);
@@ -190,53 +189,53 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
190189
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"delete from test where i = $1 :: decimal",
191190
ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
192191
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
193-
#line75 "test_informix.pgc"
192+
#line74 "test_informix.pgc"
194193

195194
if (sqlca.sqlcode<0)dosqlprint ( );}
196-
#line75 "test_informix.pgc"
195+
#line74 "test_informix.pgc"
197196

198197
printf("DELETE: %ld\n",sqlca.sqlcode);
199198

200199
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"select 1 from test where i = 14",ECPGt_EOIT,ECPGt_EORT);
201-
#line78 "test_informix.pgc"
200+
#line77 "test_informix.pgc"
202201

203202
if (sqlca.sqlcode<0)dosqlprint ( );}
204-
#line78 "test_informix.pgc"
203+
#line77 "test_informix.pgc"
205204

206205
printf("Exists: %ld\n",sqlca.sqlcode);
207206

208207
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"select 1 from test where i = 147",ECPGt_EOIT,ECPGt_EORT);
209-
#line81 "test_informix.pgc"
208+
#line80 "test_informix.pgc"
210209

211210
if (sqlca.sqlcode<0)dosqlprint ( );}
212-
#line81 "test_informix.pgc"
211+
#line80 "test_informix.pgc"
213212

214213
printf("Does not exist: %ld\n",sqlca.sqlcode);
215214

216215
{ECPGtrans(__LINE__,NULL,"commit");
217-
#line84 "test_informix.pgc"
216+
#line83 "test_informix.pgc"
218217

219218
if (sqlca.sqlcode<0)dosqlprint ( );}
220-
#line84 "test_informix.pgc"
219+
#line83 "test_informix.pgc"
221220

222221
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"drop table test",ECPGt_EOIT,ECPGt_EORT);
223-
#line85 "test_informix.pgc"
222+
#line84 "test_informix.pgc"
224223

225224
if (sqlca.sqlcode<0)dosqlprint ( );}
226-
#line85 "test_informix.pgc"
225+
#line84 "test_informix.pgc"
227226

228227
{ECPGtrans(__LINE__,NULL,"commit");
229-
#line86 "test_informix.pgc"
228+
#line85 "test_informix.pgc"
230229

231230
if (sqlca.sqlcode<0)dosqlprint ( );}
232-
#line86 "test_informix.pgc"
231+
#line85 "test_informix.pgc"
233232

234233

235234
{ECPGdisconnect(__LINE__,"CURRENT");
236-
#line88 "test_informix.pgc"
235+
#line87 "test_informix.pgc"
237236

238237
if (sqlca.sqlcode<0)dosqlprint ( );}
239-
#line88 "test_informix.pgc"
238+
#line87 "test_informix.pgc"
240239

241240

242241
return0;
@@ -247,9 +246,9 @@ static void openit(void)
247246
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"declare c cursor for select * from test where i <= $1 ",
248247
ECPGt_int,&(*(int*)(ECPGget_var(0))),(long)1,(long)1,sizeof(int),
249248
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
250-
#line95 "test_informix.pgc"
249+
#line94 "test_informix.pgc"
251250

252251
if (sqlca.sqlcode<0)dosqlprint ( );}
253-
#line95 "test_informix.pgc"
252+
#line94 "test_informix.pgc"
254253

255254
}

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ DETAIL: Key (i)=(7) already exists.
5555
[NO_PID]: sqlca: code: 0, state: 00000
5656
[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 1 fields
5757
[NO_PID]: sqlca: code: 0, state: 00000
58-
[NO_PID]: ecpg_execute on line95: query: declare c cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection ecpg1_regression
58+
[NO_PID]: ecpg_execute on line94: query: declare c cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection ecpg1_regression
5959
[NO_PID]: sqlca: code: 0, state: 00000
60-
[NO_PID]: ecpg_execute on line95: using PQexecParams
60+
[NO_PID]: ecpg_execute on line94: using PQexecParams
6161
[NO_PID]: sqlca: code: 0, state: 00000
62-
[NO_PID]: ecpg_free_params on line95: parameter 1 = 14
62+
[NO_PID]: ecpg_free_params on line94: parameter 1 = 14
6363
[NO_PID]: sqlca: code: 0, state: 00000
64-
[NO_PID]: ecpg_process_output on line95: OK: DECLARE CURSOR
64+
[NO_PID]: ecpg_process_output on line94: OK: DECLARE CURSOR
6565
[NO_PID]: sqlca: code: 0, state: 00000
6666
[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection ecpg1_regression
6767
[NO_PID]: sqlca: code: 0, state: 00000
@@ -95,39 +95,39 @@ DETAIL: Key (i)=(7) already exists.
9595
[NO_PID]: sqlca: code: 0, state: 00000
9696
[NO_PID]: raising sqlcode 100 on line 57: no data found on line 57
9797
[NO_PID]: sqlca: code: 100, state: 02000
98-
[NO_PID]: ecpg_execute on line75: query: delete from test where i = $1 :: decimal; with 1 parameter(s) on connection ecpg1_regression
98+
[NO_PID]: ecpg_execute on line74: query: delete from test where i = $1 :: decimal; with 1 parameter(s) on connection ecpg1_regression
9999
[NO_PID]: sqlca: code: 0, state: 00000
100-
[NO_PID]: ecpg_execute on line75: using PQexecParams
100+
[NO_PID]: ecpg_execute on line74: using PQexecParams
101101
[NO_PID]: sqlca: code: 0, state: 00000
102-
[NO_PID]: ecpg_free_params on line75: parameter 1 = 21.0
102+
[NO_PID]: ecpg_free_params on line74: parameter 1 = 21.0
103103
[NO_PID]: sqlca: code: 0, state: 00000
104-
[NO_PID]: ecpg_process_output on line75: OK: DELETE 0
104+
[NO_PID]: ecpg_process_output on line74: OK: DELETE 0
105105
[NO_PID]: sqlca: code: 0, state: 00000
106-
[NO_PID]: raising sqlcode 100 on line75: no data found on line75
106+
[NO_PID]: raising sqlcode 100 on line74: no data found on line74
107107
[NO_PID]: sqlca: code: 100, state: 02000
108-
[NO_PID]: ecpg_execute on line78: query: select 1 from test where i = 14; with 0 parameter(s) on connection ecpg1_regression
108+
[NO_PID]: ecpg_execute on line77: query: select 1 from test where i = 14; with 0 parameter(s) on connection ecpg1_regression
109109
[NO_PID]: sqlca: code: 0, state: 00000
110-
[NO_PID]: ecpg_execute on line78: using PQexec
110+
[NO_PID]: ecpg_execute on line77: using PQexec
111111
[NO_PID]: sqlca: code: 0, state: 00000
112-
[NO_PID]: ecpg_process_output on line78: correctly got 1 tuples with 1 fields
112+
[NO_PID]: ecpg_process_output on line77: correctly got 1 tuples with 1 fields
113113
[NO_PID]: sqlca: code: 0, state: 00000
114-
[NO_PID]: ecpg_execute on line81: query: select 1 from test where i = 147; with 0 parameter(s) on connection ecpg1_regression
114+
[NO_PID]: ecpg_execute on line80: query: select 1 from test where i = 147; with 0 parameter(s) on connection ecpg1_regression
115115
[NO_PID]: sqlca: code: 0, state: 00000
116-
[NO_PID]: ecpg_execute on line81: using PQexec
116+
[NO_PID]: ecpg_execute on line80: using PQexec
117117
[NO_PID]: sqlca: code: 0, state: 00000
118-
[NO_PID]: ecpg_process_output on line81: correctly got 0 tuples with 1 fields
118+
[NO_PID]: ecpg_process_output on line80: correctly got 0 tuples with 1 fields
119119
[NO_PID]: sqlca: code: 0, state: 00000
120-
[NO_PID]: raising sqlcode 100 on line81: no data found on line81
120+
[NO_PID]: raising sqlcode 100 on line80: no data found on line80
121121
[NO_PID]: sqlca: code: 100, state: 02000
122-
[NO_PID]: ECPGtrans on line84: action "commit"; connection "ecpg1_regression"
122+
[NO_PID]: ECPGtrans on line83: action "commit"; connection "ecpg1_regression"
123123
[NO_PID]: sqlca: code: 0, state: 00000
124-
[NO_PID]: ecpg_execute on line85: query: drop table test; with 0 parameter(s) on connection ecpg1_regression
124+
[NO_PID]: ecpg_execute on line84: query: drop table test; with 0 parameter(s) on connection ecpg1_regression
125125
[NO_PID]: sqlca: code: 0, state: 00000
126-
[NO_PID]: ecpg_execute on line85: using PQexec
126+
[NO_PID]: ecpg_execute on line84: using PQexec
127127
[NO_PID]: sqlca: code: 0, state: 00000
128-
[NO_PID]: ecpg_process_output on line85: OK: DROP TABLE
128+
[NO_PID]: ecpg_process_output on line84: OK: DROP TABLE
129129
[NO_PID]: sqlca: code: 0, state: 00000
130-
[NO_PID]: ECPGtrans on line86: action "commit"; connection "ecpg1_regression"
130+
[NO_PID]: ECPGtrans on line85: action "commit"; connection "ecpg1_regression"
131131
[NO_PID]: sqlca: code: 0, state: 00000
132132
[NO_PID]: ecpg_finish: connection ecpg1_regression closed
133133
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ static void sql_check(const char *fn, const char *caller, int ignore)
133133
}
134134
}
135135

136-
137-
138136
intmain(void)
139137
{
140138
/* exec sql begin declare section */
@@ -144,71 +142,71 @@ int main(void)
144142

145143

146144

147-
#line49 "test_informix2.pgc"
145+
#line47 "test_informix2.pgc"
148146
intc ;
149147

150-
#line50 "test_informix2.pgc"
148+
#line48 "test_informix2.pgc"
151149
timestampd ;
152150

153-
#line51 "test_informix2.pgc"
151+
#line49 "test_informix2.pgc"
154152
timestampe ;
155153

156-
#line52 "test_informix2.pgc"
154+
#line50 "test_informix2.pgc"
157155
timestampmaxd ;
158156

159-
#line53 "test_informix2.pgc"
157+
#line51 "test_informix2.pgc"
160158
chardbname [30 ] ;
161159
/* exec sql end declare section */
162-
#line54 "test_informix2.pgc"
160+
#line52 "test_informix2.pgc"
163161

164162

165163
interval*intvl;
166164

167-
/* exec sql whenever sqlerrorsqlprint ; */
168-
#line58 "test_informix2.pgc"
165+
/* exec sql whenever sqlerrorstop ; */
166+
#line56 "test_informix2.pgc"
169167

170168

171169
ECPGdebug(1,stderr);
172170

173171
strcpy(dbname,"ecpg1_regression");
174172
{ECPGconnect(__LINE__,1,dbname ,NULL,NULL ,NULL,0);
175-
#line63 "test_informix2.pgc"
173+
#line61 "test_informix2.pgc"
176174

177-
if (sqlca.sqlcode<0)sqlprint();}
178-
#line63 "test_informix2.pgc"
175+
if (sqlca.sqlcode<0)exit (1);}
176+
#line61 "test_informix2.pgc"
179177

180178
sql_check("main","connect",0);
181179

182180
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"set DateStyle to 'DMY'",ECPGt_EOIT,ECPGt_EORT);
183-
#line66 "test_informix2.pgc"
181+
#line64 "test_informix2.pgc"
184182

185-
if (sqlca.sqlcode<0)sqlprint();}
186-
#line66 "test_informix2.pgc"
183+
if (sqlca.sqlcode<0)exit (1);}
184+
#line64 "test_informix2.pgc"
187185

188186

189187
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) )",ECPGt_EOIT,ECPGt_EORT);
190-
#line68 "test_informix2.pgc"
188+
#line66 "test_informix2.pgc"
191189

192-
if (sqlca.sqlcode<0)sqlprint();}
193-
#line68 "test_informix2.pgc"
190+
if (sqlca.sqlcode<0)exit (1);}
191+
#line66 "test_informix2.pgc"
194192

195193
sql_check("main","create",0);
196194

197195
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )",ECPGt_EOIT,ECPGt_EORT);
198-
#line73 "test_informix2.pgc"
196+
#line71 "test_informix2.pgc"
199197

200-
if (sqlca.sqlcode<0)sqlprint();}
201-
#line73 "test_informix2.pgc"
198+
if (sqlca.sqlcode<0)exit (1);}
199+
#line71 "test_informix2.pgc"
202200

203201
sql_check("main","insert",0);
204202

205203
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"select max ( timestamp ) from history",ECPGt_EOIT,
206204
ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
207205
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
208-
#line78 "test_informix2.pgc"
206+
#line76 "test_informix2.pgc"
209207

210-
if (sqlca.sqlcode<0)sqlprint();}
211-
#line78 "test_informix2.pgc"
208+
if (sqlca.sqlcode<0)exit (1);}
209+
#line76 "test_informix2.pgc"
212210

213211
sql_check("main","select max",100);
214212

@@ -219,10 +217,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
219217
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
220218
ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp),
221219
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
222-
#line85 "test_informix2.pgc"
220+
#line83 "test_informix2.pgc"
223221

224-
if (sqlca.sqlcode<0)sqlprint();}
225-
#line85 "test_informix2.pgc"
222+
if (sqlca.sqlcode<0)exit (1);}
223+
#line83 "test_informix2.pgc"
226224

227225
sql_check("main","select",0);
228226

@@ -238,40 +236,40 @@ if (sqlca.sqlcode < 0) sqlprint();}
238236
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
239237
ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp),
240238
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
241-
#line97 "test_informix2.pgc"
239+
#line95 "test_informix2.pgc"
242240

243-
if (sqlca.sqlcode<0)sqlprint();}
244-
#line97 "test_informix2.pgc"
241+
if (sqlca.sqlcode<0)exit (1);}
242+
#line95 "test_informix2.pgc"
245243

246244
sql_check("main","update",0);
247245

248246
{ECPGtrans(__LINE__,NULL,"commit");
249-
#line100 "test_informix2.pgc"
247+
#line98 "test_informix2.pgc"
250248

251-
if (sqlca.sqlcode<0)sqlprint();}
252-
#line100 "test_informix2.pgc"
249+
if (sqlca.sqlcode<0)exit (1);}
250+
#line98 "test_informix2.pgc"
253251

254252

255253
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"drop table history",ECPGt_EOIT,ECPGt_EORT);
256-
#line102 "test_informix2.pgc"
254+
#line100 "test_informix2.pgc"
257255

258-
if (sqlca.sqlcode<0)sqlprint();}
259-
#line102 "test_informix2.pgc"
256+
if (sqlca.sqlcode<0)exit (1);}
257+
#line100 "test_informix2.pgc"
260258

261259
sql_check("main","drop",0);
262260

263261
{ECPGtrans(__LINE__,NULL,"commit");
264-
#line105 "test_informix2.pgc"
262+
#line103 "test_informix2.pgc"
265263

266-
if (sqlca.sqlcode<0)sqlprint();}
267-
#line105 "test_informix2.pgc"
264+
if (sqlca.sqlcode<0)exit (1);}
265+
#line103 "test_informix2.pgc"
268266

269267

270268
{ECPGdisconnect(__LINE__,"CURRENT");
271-
#line107 "test_informix2.pgc"
269+
#line105 "test_informix2.pgc"
272270

273-
if (sqlca.sqlcode<0)sqlprint();}
274-
#line107 "test_informix2.pgc"
271+
if (sqlca.sqlcode<0)exit (1);}
272+
#line105 "test_informix2.pgc"
275273

276274
sql_check("main","disconnect",0);
277275

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp