Commit 517bf2d9 authored by Peter Eisentraut's avatar Peter Eisentraut

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: default avatarMichael Meskes <meskes@postgresql.org>
Discussion: https://www.postgresql.org/message-id/flat/760c9dd1-2d80-c223-3f90-609b615f7918%402ndquadrant.com
parent d80be6f2
......@@ -156,7 +156,13 @@ dump_sqlda(sqlda_t *sqlda)
break;
#ifdef HAVE_LONG_LONG_INT
case ECPGt_long_long:
printf("name sqlda descriptor: '%s' value %lld\n", sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
printf(
#ifdef _WIN32
"name sqlda descriptor: '%s' value %I64d\n",
#else
"name sqlda descriptor: '%s' value %lld\n",
#endif
sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
break;
#endif
case ECPGt_double:
......@@ -184,19 +190,19 @@ main (void)
#line 67 "sqlda.pgc"
#line 73 "sqlda.pgc"
char * stmt1 = "SELECT * FROM t1" ;
#line 68 "sqlda.pgc"
#line 74 "sqlda.pgc"
char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
#line 69 "sqlda.pgc"
#line 75 "sqlda.pgc"
int rec ;
#line 70 "sqlda.pgc"
#line 76 "sqlda.pgc"
int id ;
/* exec sql end declare section */
#line 71 "sqlda.pgc"
#line 77 "sqlda.pgc"
char msg[128];
......@@ -205,42 +211,42 @@ main (void)
strcpy(msg, "connect");
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "regress1", 0);
#line 78 "sqlda.pgc"
#line 84 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 78 "sqlda.pgc"
#line 84 "sqlda.pgc"
strcpy(msg, "set");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 81 "sqlda.pgc"
#line 87 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 81 "sqlda.pgc"
#line 87 "sqlda.pgc"
strcpy(msg, "create");
{ 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);
#line 91 "sqlda.pgc"
#line 97 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 91 "sqlda.pgc"
#line 97 "sqlda.pgc"
strcpy(msg, "insert");
{ 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);
#line 99 "sqlda.pgc"
#line 105 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 99 "sqlda.pgc"
#line 105 "sqlda.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 102 "sqlda.pgc"
#line 108 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 102 "sqlda.pgc"
#line 108 "sqlda.pgc"
/* SQLDA test for getting all records from a table */
......@@ -249,29 +255,29 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "prepare");
{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
#line 109 "sqlda.pgc"
#line 115 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 109 "sqlda.pgc"
#line 115 "sqlda.pgc"
strcpy(msg, "declare");
/* declare mycur1 cursor for $1 */
#line 112 "sqlda.pgc"
#line 118 "sqlda.pgc"
strcpy(msg, "open");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 115 "sqlda.pgc"
#line 121 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 115 "sqlda.pgc"
#line 121 "sqlda.pgc"
/* exec sql whenever not found break ; */
#line 117 "sqlda.pgc"
#line 123 "sqlda.pgc"
rec = 0;
......@@ -281,13 +287,13 @@ if (sqlca.sqlcode < 0) exit (1);}
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 123 "sqlda.pgc"
#line 129 "sqlda.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 123 "sqlda.pgc"
#line 129 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 123 "sqlda.pgc"
#line 129 "sqlda.pgc"
printf("FETCH RECORD %d\n", ++rec);
......@@ -295,23 +301,23 @@ if (sqlca.sqlcode < 0) exit (1);}
}
/* exec sql whenever not found continue ; */
#line 129 "sqlda.pgc"
#line 135 "sqlda.pgc"
strcpy(msg, "close");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
#line 132 "sqlda.pgc"
#line 138 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 132 "sqlda.pgc"
#line 138 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
#line 135 "sqlda.pgc"
#line 141 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 135 "sqlda.pgc"
#line 141 "sqlda.pgc"
free(outp_sqlda);
......@@ -322,35 +328,35 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "prepare");
{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
#line 144 "sqlda.pgc"
#line 150 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 144 "sqlda.pgc"
#line 150 "sqlda.pgc"
strcpy(msg, "declare");
/* declare mycur2 cursor for $1 */
#line 147 "sqlda.pgc"
#line 153 "sqlda.pgc"
strcpy(msg, "open");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 150 "sqlda.pgc"
#line 156 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 150 "sqlda.pgc"
#line 156 "sqlda.pgc"
strcpy(msg, "fetch");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT,
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 153 "sqlda.pgc"
#line 159 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 153 "sqlda.pgc"
#line 159 "sqlda.pgc"
outp_sqlda1 = outp_sqlda;
......@@ -368,18 +374,18 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "close");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
#line 169 "sqlda.pgc"
#line 175 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 169 "sqlda.pgc"
#line 175 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
#line 172 "sqlda.pgc"
#line 178 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 172 "sqlda.pgc"
#line 178 "sqlda.pgc"
/* SQLDA test for getting one record using an input descriptor */
......@@ -403,10 +409,10 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "prepare");
{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
#line 194 "sqlda.pgc"
#line 200 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 194 "sqlda.pgc"
#line 200 "sqlda.pgc"
strcpy(msg, "execute");
......@@ -415,20 +421,20 @@ if (sqlca.sqlcode < 0) exit (1);}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 197 "sqlda.pgc"
#line 203 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 197 "sqlda.pgc"
#line 203 "sqlda.pgc"
dump_sqlda(outp_sqlda);
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
#line 202 "sqlda.pgc"
#line 208 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 202 "sqlda.pgc"
#line 208 "sqlda.pgc"
free(inp_sqlda);
......@@ -439,10 +445,10 @@ if (sqlca.sqlcode < 0) exit (1);}
*/
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con2", 0);
#line 211 "sqlda.pgc"
#line 217 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 211 "sqlda.pgc"
#line 217 "sqlda.pgc"
/*
......@@ -464,10 +470,10 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "prepare");
{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
#line 231 "sqlda.pgc"
#line 237 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 231 "sqlda.pgc"
#line 237 "sqlda.pgc"
strcpy(msg, "execute");
......@@ -476,28 +482,28 @@ if (sqlca.sqlcode < 0) exit (1);}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 234 "sqlda.pgc"
#line 240 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 234 "sqlda.pgc"
#line 240 "sqlda.pgc"
dump_sqlda(outp_sqlda);
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, "con2", "commit");
#line 239 "sqlda.pgc"
#line 245 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 239 "sqlda.pgc"
#line 245 "sqlda.pgc"
strcpy(msg, "deallocate");
{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
#line 242 "sqlda.pgc"
#line 248 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 242 "sqlda.pgc"
#line 248 "sqlda.pgc"
free(inp_sqlda);
......@@ -505,36 +511,36 @@ if (sqlca.sqlcode < 0) exit (1);}
strcpy(msg, "disconnect");
{ ECPGdisconnect(__LINE__, "con2");
#line 248 "sqlda.pgc"
#line 254 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 248 "sqlda.pgc"
#line 254 "sqlda.pgc"
/* End test */
strcpy(msg, "drop");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
#line 253 "sqlda.pgc"
#line 259 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 253 "sqlda.pgc"
#line 259 "sqlda.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 256 "sqlda.pgc"
#line 262 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 256 "sqlda.pgc"
#line 262 "sqlda.pgc"
strcpy(msg, "disconnect");
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 259 "sqlda.pgc"
#line 265 "sqlda.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 259 "sqlda.pgc"
#line 265 "sqlda.pgc"
return 0;
......
......@@ -41,7 +41,13 @@ dump_sqlda(sqlda_t *sqlda)
break;
#ifdef HAVE_LONG_LONG_INT
case ECPGt_long_long:
printf("name sqlda descriptor: '%s' value %lld\n", sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
printf(
#ifdef _WIN32
"name sqlda descriptor: '%s' value %I64d\n",
#else
"name sqlda descriptor: '%s' value %lld\n",
#endif
sqlda->sqlvar[i].sqlname.data, *(long long int *)sqlda->sqlvar[i].sqldata);
break;
#endif
case ECPGt_double:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment