Skip to content

Commit 517bf2d

Browse files
committed
Fix compiler warnings in ecpg tests
Under MinGW, when compiling the ecpg test files, you get compiler warnings about the use of %lld in printf(). These files don't use our printf replacement or the c.h porting layer, so determine the appropriate format conversion the hard way. Reviewed-by: Michael Meskes <meskes@postgresql.org> Discussion: https://www.postgresql.org/message-id/flat/760c9dd1-2d80-c223-3f90-609b615f7918%402ndquadrant.com
1 parent d80be6f commit 517bf2d

File tree

3 files changed

+303
-291
lines changed

3 files changed

+303
-291
lines changed

src/interfaces/ecpg/test/expected/sql-sqlda.c

Lines changed: 71 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@ dump_sqlda(sqlda_t *sqlda)
156156
break;
157157
#ifdef HAVE_LONG_LONG_INT
158158
case ECPGt_long_long:
159-
printf("name sqlda descriptor: '%s' value %lld\n", sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
159+
printf(
160+
#ifdef _WIN32
161+
"name sqlda descriptor: '%s' value %I64d\n",
162+
#else
163+
"name sqlda descriptor: '%s' value %lld\n",
164+
#endif
165+
sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
160166
break;
161167
#endif
162168
case ECPGt_double:
@@ -184,19 +190,19 @@ main (void)
184190

185191

186192

187-
#line 67 "sqlda.pgc"
193+
#line 73 "sqlda.pgc"
188194
char * stmt1 = "SELECT * FROM t1" ;
189195

190-
#line 68 "sqlda.pgc"
196+
#line 74 "sqlda.pgc"
191197
char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
192198

193-
#line 69 "sqlda.pgc"
199+
#line 75 "sqlda.pgc"
194200
int rec ;
195201

196-
#line 70 "sqlda.pgc"
202+
#line 76 "sqlda.pgc"
197203
int id ;
198204
/* exec sql end declare section */
199-
#line 71 "sqlda.pgc"
205+
#line 77 "sqlda.pgc"
200206

201207

202208
char msg[128];
@@ -205,42 +211,42 @@ main (void)
205211

206212
strcpy(msg, "connect");
207213
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "regress1", 0);
208-
#line 78 "sqlda.pgc"
214+
#line 84 "sqlda.pgc"
209215

210216
if (sqlca.sqlcode < 0) exit (1);}
211-
#line 78 "sqlda.pgc"
217+
#line 84 "sqlda.pgc"
212218

213219

214220
strcpy(msg, "set");
215221
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
216-
#line 81 "sqlda.pgc"
222+
#line 87 "sqlda.pgc"
217223

218224
if (sqlca.sqlcode < 0) exit (1);}
219-
#line 81 "sqlda.pgc"
225+
#line 87 "sqlda.pgc"
220226

221227

222228
strcpy(msg, "create");
223229
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) , big bigint )", ECPGt_EOIT, ECPGt_EORT);
224-
#line 91 "sqlda.pgc"
230+
#line 97 "sqlda.pgc"
225231

226232
if (sqlca.sqlcode < 0) exit (1);}
227-
#line 91 "sqlda.pgc"
233+
#line 97 "sqlda.pgc"
228234

229235

230236
strcpy(msg, "insert");
231237
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' , 1111111111111111111 ) , ( 2 , null , null , null , null , null ) , ( 3 , 'c' , 0.0 , 3 , 'c' , 3333333333333333333 ) , ( 4 , 'd' , 'NaN' , 4 , 'd' , 4444444444444444444 ) , ( 5 , 'e' , 0.001234 , 5 , 'e' , 5555555555555555555 )", ECPGt_EOIT, ECPGt_EORT);
232-
#line 99 "sqlda.pgc"
238+
#line 105 "sqlda.pgc"
233239

234240
if (sqlca.sqlcode < 0) exit (1);}
235-
#line 99 "sqlda.pgc"
241+
#line 105 "sqlda.pgc"
236242

237243

238244
strcpy(msg, "commit");
239245
{ ECPGtrans(__LINE__, NULL, "commit");
240-
#line 102 "sqlda.pgc"
246+
#line 108 "sqlda.pgc"
241247

242248
if (sqlca.sqlcode < 0) exit (1);}
243-
#line 102 "sqlda.pgc"
249+
#line 108 "sqlda.pgc"
244250

245251

246252
/* SQLDA test for getting all records from a table */
@@ -249,29 +255,29 @@ if (sqlca.sqlcode < 0) exit (1);}
249255

250256
strcpy(msg, "prepare");
251257
{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
252-
#line 109 "sqlda.pgc"
258+
#line 115 "sqlda.pgc"
253259

254260
if (sqlca.sqlcode < 0) exit (1);}
255-
#line 109 "sqlda.pgc"
261+
#line 115 "sqlda.pgc"
256262

257263

258264
strcpy(msg, "declare");
259265
/* declare mycur1 cursor for $1 */
260-
#line 112 "sqlda.pgc"
266+
#line 118 "sqlda.pgc"
261267

262268

263269
strcpy(msg, "open");
264270
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
265271
ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
266272
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
267-
#line 115 "sqlda.pgc"
273+
#line 121 "sqlda.pgc"
268274

269275
if (sqlca.sqlcode < 0) exit (1);}
270-
#line 115 "sqlda.pgc"
276+
#line 121 "sqlda.pgc"
271277

272278

273279
/* exec sql whenever not found break ; */
274-
#line 117 "sqlda.pgc"
280+
#line 123 "sqlda.pgc"
275281

276282

277283
rec = 0;
@@ -281,37 +287,37 @@ if (sqlca.sqlcode < 0) exit (1);}
281287
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
282288
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
283289
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
284-
#line 123 "sqlda.pgc"
290+
#line 129 "sqlda.pgc"
285291

286292
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
287-
#line 123 "sqlda.pgc"
293+
#line 129 "sqlda.pgc"
288294

289295
if (sqlca.sqlcode < 0) exit (1);}
290-
#line 123 "sqlda.pgc"
296+
#line 129 "sqlda.pgc"
291297

292298

293299
printf("FETCH RECORD %d\n", ++rec);
294300
dump_sqlda(outp_sqlda);
295301
}
296302

297303
/* exec sql whenever not found continue ; */
298-
#line 129 "sqlda.pgc"
304+
#line 135 "sqlda.pgc"
299305

300306

301307
strcpy(msg, "close");
302308
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
303-
#line 132 "sqlda.pgc"
309+
#line 138 "sqlda.pgc"
304310

305311
if (sqlca.sqlcode < 0) exit (1);}
306-
#line 132 "sqlda.pgc"
312+
#line 138 "sqlda.pgc"
307313

308314

309315
strcpy(msg, "deallocate");
310316
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
311-
#line 135 "sqlda.pgc"
317+
#line 141 "sqlda.pgc"
312318

313319
if (sqlca.sqlcode < 0) exit (1);}
314-
#line 135 "sqlda.pgc"
320+
#line 141 "sqlda.pgc"
315321

316322

317323
free(outp_sqlda);
@@ -322,35 +328,35 @@ if (sqlca.sqlcode < 0) exit (1);}
322328

323329
strcpy(msg, "prepare");
324330
{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
325-
#line 144 "sqlda.pgc"
331+
#line 150 "sqlda.pgc"
326332

327333
if (sqlca.sqlcode < 0) exit (1);}
328-
#line 144 "sqlda.pgc"
334+
#line 150 "sqlda.pgc"
329335

330336

331337
strcpy(msg, "declare");
332338
/* declare mycur2 cursor for $1 */
333-
#line 147 "sqlda.pgc"
339+
#line 153 "sqlda.pgc"
334340

335341

336342
strcpy(msg, "open");
337343
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
338344
ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
339345
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
340-
#line 150 "sqlda.pgc"
346+
#line 156 "sqlda.pgc"
341347

342348
if (sqlca.sqlcode < 0) exit (1);}
343-
#line 150 "sqlda.pgc"
349+
#line 156 "sqlda.pgc"
344350

345351

346352
strcpy(msg, "fetch");
347353
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT,
348354
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
349355
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
350-
#line 153 "sqlda.pgc"
356+
#line 159 "sqlda.pgc"
351357

352358
if (sqlca.sqlcode < 0) exit (1);}
353-
#line 153 "sqlda.pgc"
359+
#line 159 "sqlda.pgc"
354360

355361

356362
outp_sqlda1 = outp_sqlda;
@@ -368,18 +374,18 @@ if (sqlca.sqlcode < 0) exit (1);}
368374

369375
strcpy(msg, "close");
370376
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
371-
#line 169 "sqlda.pgc"
377+
#line 175 "sqlda.pgc"
372378

373379
if (sqlca.sqlcode < 0) exit (1);}
374-
#line 169 "sqlda.pgc"
380+
#line 175 "sqlda.pgc"
375381

376382

377383
strcpy(msg, "deallocate");
378384
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
379-
#line 172 "sqlda.pgc"
385+
#line 178 "sqlda.pgc"
380386

381387
if (sqlca.sqlcode < 0) exit (1);}
382-
#line 172 "sqlda.pgc"
388+
#line 178 "sqlda.pgc"
383389

384390

385391
/* SQLDA test for getting one record using an input descriptor */
@@ -403,10 +409,10 @@ if (sqlca.sqlcode < 0) exit (1);}
403409

404410
strcpy(msg, "prepare");
405411
{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
406-
#line 194 "sqlda.pgc"
412+
#line 200 "sqlda.pgc"
407413

408414
if (sqlca.sqlcode < 0) exit (1);}
409-
#line 194 "sqlda.pgc"
415+
#line 200 "sqlda.pgc"
410416

411417

412418
strcpy(msg, "execute");
@@ -415,20 +421,20 @@ if (sqlca.sqlcode < 0) exit (1);}
415421
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
416422
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
417423
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
418-
#line 197 "sqlda.pgc"
424+
#line 203 "sqlda.pgc"
419425

420426
if (sqlca.sqlcode < 0) exit (1);}
421-
#line 197 "sqlda.pgc"
427+
#line 203 "sqlda.pgc"
422428

423429

424430
dump_sqlda(outp_sqlda);
425431

426432
strcpy(msg, "deallocate");
427433
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
428-
#line 202 "sqlda.pgc"
434+
#line 208 "sqlda.pgc"
429435

430436
if (sqlca.sqlcode < 0) exit (1);}
431-
#line 202 "sqlda.pgc"
437+
#line 208 "sqlda.pgc"
432438

433439

434440
free(inp_sqlda);
@@ -439,10 +445,10 @@ if (sqlca.sqlcode < 0) exit (1);}
439445
*/
440446

441447
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con2", 0);
442-
#line 211 "sqlda.pgc"
448+
#line 217 "sqlda.pgc"
443449

444450
if (sqlca.sqlcode < 0) exit (1);}
445-
#line 211 "sqlda.pgc"
451+
#line 217 "sqlda.pgc"
446452

447453

448454
/*
@@ -464,10 +470,10 @@ if (sqlca.sqlcode < 0) exit (1);}
464470

465471
strcpy(msg, "prepare");
466472
{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
467-
#line 231 "sqlda.pgc"
473+
#line 237 "sqlda.pgc"
468474

469475
if (sqlca.sqlcode < 0) exit (1);}
470-
#line 231 "sqlda.pgc"
476+
#line 237 "sqlda.pgc"
471477

472478

473479
strcpy(msg, "execute");
@@ -476,65 +482,65 @@ if (sqlca.sqlcode < 0) exit (1);}
476482
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
477483
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
478484
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
479-
#line 234 "sqlda.pgc"
485+
#line 240 "sqlda.pgc"
480486

481487
if (sqlca.sqlcode < 0) exit (1);}
482-
#line 234 "sqlda.pgc"
488+
#line 240 "sqlda.pgc"
483489

484490

485491
dump_sqlda(outp_sqlda);
486492

487493
strcpy(msg, "commit");
488494
{ ECPGtrans(__LINE__, "con2", "commit");
489-
#line 239 "sqlda.pgc"
495+
#line 245 "sqlda.pgc"
490496

491497
if (sqlca.sqlcode < 0) exit (1);}
492-
#line 239 "sqlda.pgc"
498+
#line 245 "sqlda.pgc"
493499

494500

495501
strcpy(msg, "deallocate");
496502
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
497-
#line 242 "sqlda.pgc"
503+
#line 248 "sqlda.pgc"
498504

499505
if (sqlca.sqlcode < 0) exit (1);}
500-
#line 242 "sqlda.pgc"
506+
#line 248 "sqlda.pgc"
501507

502508

503509
free(inp_sqlda);
504510
free(outp_sqlda);
505511

506512
strcpy(msg, "disconnect");
507513
{ ECPGdisconnect(__LINE__, "con2");
508-
#line 248 "sqlda.pgc"
514+
#line 254 "sqlda.pgc"
509515

510516
if (sqlca.sqlcode < 0) exit (1);}
511-
#line 248 "sqlda.pgc"
517+
#line 254 "sqlda.pgc"
512518

513519

514520
/* End test */
515521

516522
strcpy(msg, "drop");
517523
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
518-
#line 253 "sqlda.pgc"
524+
#line 259 "sqlda.pgc"
519525

520526
if (sqlca.sqlcode < 0) exit (1);}
521-
#line 253 "sqlda.pgc"
527+
#line 259 "sqlda.pgc"
522528

523529

524530
strcpy(msg, "commit");
525531
{ ECPGtrans(__LINE__, NULL, "commit");
526-
#line 256 "sqlda.pgc"
532+
#line 262 "sqlda.pgc"
527533

528534
if (sqlca.sqlcode < 0) exit (1);}
529-
#line 256 "sqlda.pgc"
535+
#line 262 "sqlda.pgc"
530536

531537

532538
strcpy(msg, "disconnect");
533539
{ ECPGdisconnect(__LINE__, "CURRENT");
534-
#line 259 "sqlda.pgc"
540+
#line 265 "sqlda.pgc"
535541

536542
if (sqlca.sqlcode < 0) exit (1);}
537-
#line 259 "sqlda.pgc"
543+
#line 265 "sqlda.pgc"
538544

539545

540546
return 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy