Commit fcc2fbac authored by Michael Meskes's avatar Michael Meskes

Reverted changes made by pgindent

Made show.pgc set all variables before displaying them.
parent f99a569a
...@@ -13,14 +13,12 @@ ...@@ -13,14 +13,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <sqltypes.h> #include <sqltypes.h>
int int main(void)
main(void)
{ {
char t1[] = "abc def ghi "; char t1[] = "abc def ghi ";
/* 123456789012345 */
/* 123456789012345 */ char buf[50];
char buf[50]; int k;
int k;
printf("t1: _%s_\n", t1); printf("t1: _%s_\n", t1);
rupshift(t1); rupshift(t1);
......
...@@ -44,36 +44,31 @@ TODO: ...@@ -44,36 +44,31 @@ TODO:
ECPG_INFORMIX_BAD_EXPONENT ? ECPG_INFORMIX_BAD_EXPONENT ?
*/ */
char *decs[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", char* decs[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
"2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
".500001", "-.5000001", ".500001", "-.5000001",
"1234567890123456789012345678.91", /* 30 digits should fit into decimal */ "1234567890123456789012345678.91", /* 30 digits should fit
"1234567890123456789012345678.921", /* 31 digits should NOT fit into into decimal */
* decimal */ "1234567890123456789012345678.921", /* 31 digits should NOT
"not a number", fit into decimal */
NULL}; "not a number",
NULL};
static void static void
check_errno(void); check_errno(void);
#define BUFSIZE 200 #define BUFSIZE 200
int int
main(void) main(void)
{ {
decimal *dec, decimal *dec, *din;
*din; char buf[BUFSIZE];
char buf[BUFSIZE]; long l;
long l; int i, j, k, q, r, count = 0;
int i, double dbl;
j, decimal **decarr = (decimal **) calloc(1, sizeof(decimal));
k,
q,
r,
count = 0;
double dbl;
decimal **decarr = (decimal **) calloc(1, sizeof(decimal));
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
...@@ -90,62 +85,52 @@ main(void) ...@@ -90,62 +85,52 @@ main(void)
decarr = realloc(decarr, sizeof(decimal *) * (count + 1)); decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
decarr[count++] = dec; decarr[count++] = dec;
r = dectoasc(dec, buf, BUFSIZE - 1, -1); r = dectoasc(dec, buf, BUFSIZE-1, -1);
if (r < 0) if (r < 0) check_errno();
check_errno();
printf("dec[%d,1]: r: %d, %s\n", i, r, buf); printf("dec[%d,1]: r: %d, %s\n", i, r, buf);
r = dectoasc(dec, buf, BUFSIZE - 1, 0); r = dectoasc(dec, buf, BUFSIZE-1, 0);
if (r < 0) if (r < 0) check_errno();
check_errno();
printf("dec[%d,2]: r: %d, %s\n", i, r, buf); printf("dec[%d,2]: r: %d, %s\n", i, r, buf);
r = dectoasc(dec, buf, BUFSIZE - 1, 1); r = dectoasc(dec, buf, BUFSIZE-1, 1);
if (r < 0) if (r < 0) check_errno();
check_errno();
printf("dec[%d,3]: r: %d, %s\n", i, r, buf); printf("dec[%d,3]: r: %d, %s\n", i, r, buf);
r = dectoasc(dec, buf, BUFSIZE - 1, 2); r = dectoasc(dec, buf, BUFSIZE-1, 2);
if (r < 0) if (r < 0) check_errno();
check_errno();
printf("dec[%d,4]: r: %d, %s\n", i, r, buf); printf("dec[%d,4]: r: %d, %s\n", i, r, buf);
din = PGTYPESdecimal_new(); din = PGTYPESdecimal_new();
r = dectoasc(din, buf, BUFSIZE - 1, 2); r = dectoasc(din, buf, BUFSIZE-1, 2);
if (r < 0) if (r < 0) check_errno();
check_errno();
printf("dec[%d,5]: r: %d, %s\n", i, r, buf); printf("dec[%d,5]: r: %d, %s\n", i, r, buf);
r = dectolong(dec, &l); r = dectolong(dec, &l);
if (r) if (r) check_errno();
check_errno(); printf("dec[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
printf("dec[%d,6]: %ld (r: %d)\n", i, r ? 0L : l, r);
if (r == 0) if (r == 0)
{ {
r = deccvlong(l, din); r = deccvlong(l, din);
if (r) if (r) check_errno();
check_errno(); dectoasc(din, buf, BUFSIZE-1, 2);
dectoasc(din, buf, BUFSIZE - 1, 2);
q = deccmp(dec, din); q = deccmp(dec, din);
printf("dec[%d,7]: %s (r: %d - cmp: %d)\n", i, buf, r, q); printf("dec[%d,7]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
} }
r = dectoint(dec, &k); r = dectoint(dec, &k);
if (r) if (r) check_errno();
check_errno(); printf("dec[%d,8]: %d (r: %d)\n", i, r?0:k, r);
printf("dec[%d,8]: %d (r: %d)\n", i, r ? 0 : k, r);
if (r == 0) if (r == 0)
{ {
r = deccvint(k, din); r = deccvint(k, din);
if (r) if (r) check_errno();
check_errno(); dectoasc(din, buf, BUFSIZE-1, 2);
dectoasc(din, buf, BUFSIZE - 1, 2);
q = deccmp(dec, din); q = deccmp(dec, din);
printf("dec[%d,9]: %s (r: %d - cmp: %d)\n", i, buf, r, q); printf("dec[%d,9]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
} }
r = dectodbl(dec, &dbl); r = dectodbl(dec, &dbl);
if (r) if (r) check_errno();
check_errno(); printf("dec[%d,10]: %g (r: %d)\n", i, r?0.0:dbl, r);
printf("dec[%d,10]: %g (r: %d)\n", i, r ? 0.0 : dbl, r);
PGTYPESdecimal_free(din); PGTYPESdecimal_free(din);
printf("\n"); printf("\n");
...@@ -156,29 +141,23 @@ main(void) ...@@ -156,29 +141,23 @@ main(void)
decarr = realloc(decarr, sizeof(decimal *) * (count + 1)); decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
decarr[count++] = dec; decarr[count++] = dec;
rsetnull(CDECIMALTYPE, (char *) decarr[count - 1]); rsetnull(CDECIMALTYPE, (char *) decarr[count-1]);
printf("dec[%d]: %sNULL\n", count - 1, printf("dec[%d]: %sNULL\n", count-1,
risnull(CDECIMALTYPE, (char *) decarr[count - 1]) ? "" : "NOT "); risnull(CDECIMALTYPE, (char *) decarr[count-1]) ? "" : "NOT ");
printf("dec[0]: %sNULL\n", printf("dec[0]: %sNULL\n",
risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT "); risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT ");
r = dectoasc(decarr[3], buf, -1, -1); r = dectoasc(decarr[3], buf, -1, -1);
check_errno(); check_errno(); printf("dectoasc with len == -1: r: %d\n", r);
printf("dectoasc with len == -1: r: %d\n", r);
r = dectoasc(decarr[3], buf, 0, -1); r = dectoasc(decarr[3], buf, 0, -1);
check_errno(); check_errno(); printf("dectoasc with len == 0: r: %d\n", r);
printf("dectoasc with len == 0: r: %d\n", r);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
for (j = 0; j < count; j++) for (j = 0; j < count; j++)
{ {
decimal a, decimal a, s, m, d;
s, int c;
m,
d;
int c;
c = deccmp(decarr[i], decarr[j]); c = deccmp(decarr[i], decarr[j]);
printf("dec[c,%d,%d]: %d\n", i, j, c); printf("dec[c,%d,%d]: %d\n", i, j, c);
...@@ -190,7 +169,7 @@ main(void) ...@@ -190,7 +169,7 @@ main(void)
} }
else else
{ {
dectoasc(&a, buf, BUFSIZE - 1, -1); dectoasc(&a, buf, BUFSIZE-1, -1);
printf("dec[a,%d,%d]: %s\n", i, j, buf); printf("dec[a,%d,%d]: %s\n", i, j, buf);
} }
...@@ -202,7 +181,7 @@ main(void) ...@@ -202,7 +181,7 @@ main(void)
} }
else else
{ {
dectoasc(&s, buf, BUFSIZE - 1, -1); dectoasc(&s, buf, BUFSIZE-1, -1);
printf("dec[s,%d,%d]: %s\n", i, j, buf); printf("dec[s,%d,%d]: %s\n", i, j, buf);
} }
...@@ -214,7 +193,7 @@ main(void) ...@@ -214,7 +193,7 @@ main(void)
} }
else else
{ {
dectoasc(&m, buf, BUFSIZE - 1, -1); dectoasc(&m, buf, BUFSIZE-1, -1);
printf("dec[m,%d,%d]: %s\n", i, j, buf); printf("dec[m,%d,%d]: %s\n", i, j, buf);
} }
...@@ -226,7 +205,7 @@ main(void) ...@@ -226,7 +205,7 @@ main(void)
} }
else else
{ {
dectoasc(&d, buf, BUFSIZE - 1, -1); dectoasc(&d, buf, BUFSIZE-1, -1);
printf("dec[d,%d,%d]: %s\n", i, j, buf); printf("dec[d,%d,%d]: %s\n", i, j, buf);
} }
} }
...@@ -234,7 +213,7 @@ main(void) ...@@ -234,7 +213,7 @@ main(void)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
dectoasc(decarr[i], buf, BUFSIZE - 1, -1); dectoasc(decarr[i], buf, BUFSIZE-1, -1);
printf("%d: %s\n", i, buf); printf("%d: %s\n", i, buf);
} }
...@@ -244,7 +223,7 @@ main(void) ...@@ -244,7 +223,7 @@ main(void)
static void static void
check_errno(void) check_errno(void)
{ {
switch (errno) switch(errno)
{ {
case 0: case 0:
printf("(no errno set) - "); printf("(no errno set) - ");
......
...@@ -21,16 +21,15 @@ ...@@ -21,16 +21,15 @@
static void static void
check_return(int ret); check_return(int ret);
static void static void
date_test_strdate(char *input) date_test_strdate(char *input)
{ {
static int i; static int i;
date d; date d;
int r, int r, q;
q; char dbuf[11];
char dbuf[11];
r = rstrdate(input, &d); r = rstrdate(input, &d);
printf("r: %d ", r); printf("r: %d ", r);
...@@ -52,11 +51,10 @@ date_test_strdate(char *input) ...@@ -52,11 +51,10 @@ date_test_strdate(char *input)
static void static void
date_test_defmt(char *fmt, char *input) date_test_defmt(char *fmt, char *input)
{ {
static int i; static int i;
char dbuf[11]; char dbuf[11];
date d; date d;
int q, int q, r;
r;
r = rdefmtdate(&d, fmt, input); r = rdefmtdate(&d, fmt, input);
printf("r: %d ", r); printf("r: %d ", r);
...@@ -78,9 +76,9 @@ date_test_defmt(char *fmt, char *input) ...@@ -78,9 +76,9 @@ date_test_defmt(char *fmt, char *input)
static void static void
date_test_fmt(date d, char *fmt) date_test_fmt(date d, char *fmt)
{ {
static int i; static int i;
char buf[200]; char buf[200];
int r; int r;
r = rfmtdate(d, fmt, buf); r = rfmtdate(d, fmt, buf);
printf("r: %d ", r); printf("r: %d ", r);
...@@ -94,10 +92,10 @@ date_test_fmt(date d, char *fmt) ...@@ -94,10 +92,10 @@ date_test_fmt(date d, char *fmt)
int int
main(void) main(void)
{ {
short mdy[3] = {11, 23, 1959}; short mdy[3] = { 11, 23, 1959 };
char dbuf[11]; char dbuf[11];
date d; date d;
int r; int r;
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
...@@ -166,7 +164,7 @@ main(void) ...@@ -166,7 +164,7 @@ main(void)
static void static void
check_return(int ret) check_return(int ret)
{ {
switch (ret) switch(ret)
{ {
case ECPG_INFORMIX_ENOTDMY: case ECPG_INFORMIX_ENOTDMY:
printf("(ECPG_INFORMIX_ENOTDMY)"); printf("(ECPG_INFORMIX_ENOTDMY)");
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
static void static void
check_return(int ret); check_return(int ret);
static void static void
fmtlong(long lng, char *fmt) fmtlong(long lng, char *fmt)
{ {
static int i; static int i;
int r; int r;
char buf[30]; char buf[30];
r = rfmtlong(lng, fmt, buf); r = rfmtlong(lng, fmt, buf);
printf("r: %d ", r); printf("r: %d ", r);
...@@ -62,7 +62,7 @@ main(void) ...@@ -62,7 +62,7 @@ main(void)
static void static void
check_return(int ret) check_return(int ret)
{ {
switch (ret) switch(ret)
{ {
case ECPG_INFORMIX_ENOTDMY: case ECPG_INFORMIX_ENOTDMY:
printf("(ECPG_INFORMIX_ENOTDMY)"); printf("(ECPG_INFORMIX_ENOTDMY)");
......
...@@ -25,199 +25,149 @@ ...@@ -25,199 +25,149 @@
static void openit(void); static void openit(void);
static void static void dosqlprint(void) {
dosqlprint(void)
{
printf("doSQLprint: Error: %s\n", sqlca.sqlerrm.sqlerrmc); printf("doSQLprint: Error: %s\n", sqlca.sqlerrm.sqlerrmc);
} }
int int main(void)
main(void)
{ {
#line 14 "test_informix.pgc" #line 14 "test_informix.pgc"
int i = 14; int i = 14 ;
#line 14 "test_informix.pgc" #line 14 "test_informix.pgc"
#line 15 "test_informix.pgc" #line 15 "test_informix.pgc"
decimal j, decimal j , m , n ;
m,
n;
#line 15 "test_informix.pgc" #line 15 "test_informix.pgc"
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
/* exec sql whenever sqlerror do dosqlprint ( ) ; */ /* exec sql whenever sqlerror do dosqlprint ( ) ; */
#line 18 "test_informix.pgc" #line 18 "test_informix.pgc"
{ { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 1, "regress1", NULL, NULL, NULL, 0);
#line 20 "test_informix.pgc" #line 20 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 20 "test_informix.pgc" #line 20 "test_informix.pgc"
if (sqlca.sqlcode != 0) if (sqlca.sqlcode != 0) exit(1);
exit(1);
{ { ECPGdo(__LINE__, 1, 1, NULL, "create table test ( i int primary key , j int ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "create table test ( i int primary key , j int ) ", ECPGt_EOIT, ECPGt_EORT);
#line 23 "test_informix.pgc" #line 23 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 23 "test_informix.pgc" #line 23 "test_informix.pgc"
/* this INSERT works */ /* this INSERT works */
rsetnull(CDECIMALTYPE, (char *) &j); rsetnull(CDECIMALTYPE, (char *)&j);
{ { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values ( 7 , ? ) ",
ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , ? ) ", ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 27 "test_informix.pgc" #line 27 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 27 "test_informix.pgc" #line 27 "test_informix.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 28 "test_informix.pgc" #line 28 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 28 "test_informix.pgc" #line 28 "test_informix.pgc"
/* this INSERT should fail because i is a unique column */ /* this INSERT should fail because i is a unique column */
{ { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values ( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 31 "test_informix.pgc" #line 31 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 31 "test_informix.pgc" #line 31 "test_informix.pgc"
printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
{
ECPGtrans(__LINE__, NULL, "rollback");
#line 33 "test_informix.pgc" #line 33 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 33 "test_informix.pgc" #line 33 "test_informix.pgc"
{ { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values ( ? , 1 ) ",
ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( ? , 1 ) ", ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 35 "test_informix.pgc" #line 35 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 35 "test_informix.pgc" #line 35 "test_informix.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 36 "test_informix.pgc" #line 36 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 36 "test_informix.pgc" #line 36 "test_informix.pgc"
/* this will fail (more than one row in subquery) */ /* this will fail (more than one row in subquery) */
{ { ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test ) ", ECPGt_EOIT, ECPGt_EORT);
#line 39 "test_informix.pgc" #line 39 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 39 "test_informix.pgc" #line 39 "test_informix.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 40 "test_informix.pgc" #line 40 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 40 "test_informix.pgc" #line 40 "test_informix.pgc"
/* this however should be ok */ /* this however should be ok */
{ { ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test order by i limit 1 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test order by i limit 1 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 43 "test_informix.pgc" #line 43 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 43 "test_informix.pgc" #line 43 "test_informix.pgc"
printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
{
ECPGtrans(__LINE__, NULL, "rollback");
#line 45 "test_informix.pgc" #line 45 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 45 "test_informix.pgc" #line 45 "test_informix.pgc"
ECPG_informix_set_var(0, &(i), __LINE__); ECPG_informix_set_var( 0, &( i ), __LINE__);\
\ /* declare c cursor for select * from test where i <= ? */
/* declare c cursor for select * from test where i <= ? */
#line 47 "test_informix.pgc" #line 47 "test_informix.pgc"
openit(); openit();
deccvint(0, &j); deccvint(0, &j);
while (1) while (1)
{ {
{ { ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT,
ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 54 "test_informix.pgc" #line 54 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 54 "test_informix.pgc" #line 54 "test_informix.pgc"
if (sqlca.sqlcode == 100) if (sqlca.sqlcode == 100) break;
break; else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
else if (sqlca.sqlcode != 0)
printf("Error: %ld\n", sqlca.sqlcode);
if (risnull(CDECIMALTYPE, (char *) &j)) if (risnull(CDECIMALTYPE, (char *)&j))
printf("%d NULL\n", i); printf("%d NULL\n", i);
else else
{ {
int a; int a;
dectoint(&j, &a); dectoint(&j, &a);
printf("%d %d\n", i, a); printf("%d %d\n", i, a);
...@@ -227,94 +177,70 @@ main(void) ...@@ -227,94 +177,70 @@ main(void)
deccvint(7, &j); deccvint(7, &j);
deccvint(14, &m); deccvint(14, &m);
decadd(&j, &m, &n); decadd(&j, &m, &n);
{ { ECPGdo(__LINE__, 1, 1, NULL, "delete from test where i = ? ",
ECPGdo(__LINE__, 1, 1, NULL, "delete from test where i = ? ", ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
ECPGt_decimal, &(n), (long) 1, (long) 1, sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 72 "test_informix.pgc" #line 72 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 72 "test_informix.pgc" #line 72 "test_informix.pgc"
printf("DELETE: %ld\n", sqlca.sqlcode); printf("DELETE: %ld\n", sqlca.sqlcode);
{ { ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 14 ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 14 ", ECPGt_EOIT, ECPGt_EORT);
#line 75 "test_informix.pgc" #line 75 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 75 "test_informix.pgc" #line 75 "test_informix.pgc"
printf("Exists: %ld\n", sqlca.sqlcode); printf("Exists: %ld\n", sqlca.sqlcode);
{ { ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 147 ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 147 ", ECPGt_EOIT, ECPGt_EORT);
#line 78 "test_informix.pgc" #line 78 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 78 "test_informix.pgc" #line 78 "test_informix.pgc"
printf("Does not exist: %ld\n", sqlca.sqlcode); printf("Does not exist: %ld\n", sqlca.sqlcode);
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 81 "test_informix.pgc" #line 81 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 81 "test_informix.pgc" #line 81 "test_informix.pgc"
{ { ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
#line 82 "test_informix.pgc" #line 82 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 82 "test_informix.pgc" #line 82 "test_informix.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 83 "test_informix.pgc" #line 83 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 83 "test_informix.pgc" #line 83 "test_informix.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");
ECPGdisconnect(__LINE__, "CURRENT");
#line 85 "test_informix.pgc" #line 85 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 85 "test_informix.pgc" #line 85 "test_informix.pgc"
return 0; return 0;
} }
static void static void openit(void)
openit(void)
{ {
{ { ECPGdo(__LINE__, 1, 1, NULL, "declare c cursor for select * from test where i <= ? ",
ECPGdo(__LINE__, 1, 1, NULL, "declare c cursor for select * from test where i <= ? ", ECPGt_int,&(*( int *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int),
ECPGt_int, &(*(int *) (ECPG_informix_get_var(0))), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 92 "test_informix.pgc" #line 92 "test_informix.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) dosqlprint ( );}
dosqlprint();
}
#line 92 "test_informix.pgc" #line 92 "test_informix.pgc"
} }
...@@ -79,6 +79,7 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -79,6 +79,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
#line 5 "test_informix2.pgc" #line 5 "test_informix2.pgc"
...@@ -96,79 +97,72 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -96,79 +97,72 @@ struct sqlca_t *ECPGget_sqlca(void);
/* Check SQLCODE, and produce a "standard error" if it's wrong! */ /* Check SQLCODE, and produce a "standard error" if it's wrong! */
static void static void sql_check(char *fn, char *caller, int ignore)
sql_check(char *fn, char *caller, int ignore)
{ {
char errorstring[255]; char errorstring[255];
if (SQLCODE == ignore) if (SQLCODE == ignore)
return; return;
else else
{ {
if (SQLCODE != 0) if (SQLCODE != 0)
{ {
sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]", sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]",
SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc); SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc);
fprintf(stderr, "%s", errorstring); fprintf(stderr, "%s", errorstring);
printf("%s\n", errorstring); printf("%s\n", errorstring);
/* attempt a ROLLBACK */ /* attempt a ROLLBACK */
{ { ECPGtrans(__LINE__, NULL, "rollback");}
ECPGtrans(__LINE__, NULL, "rollback");
}
#line 27 "test_informix2.pgc" #line 27 "test_informix2.pgc"
if (SQLCODE == 0) if (SQLCODE == 0)
{ {
sprintf(errorstring, "Rollback successful.\n"); sprintf(errorstring, "Rollback successful.\n");
} } else {
else sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
{ }
sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
}
fprintf(stderr, "%s", errorstring); fprintf(stderr, "%s", errorstring);
printf("%s\n", errorstring); printf("%s\n", errorstring);
exit(1); exit(1);
} }
} }
} }
int int main(void)
main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 49 "test_informix2.pgc" #line 49 "test_informix2.pgc"
int c; int c ;
#line 50 "test_informix2.pgc" #line 50 "test_informix2.pgc"
timestamp d; timestamp d ;
#line 51 "test_informix2.pgc" #line 51 "test_informix2.pgc"
timestamp e; timestamp e ;
#line 52 "test_informix2.pgc" #line 52 "test_informix2.pgc"
timestamp maxd; timestamp maxd ;
#line 53 "test_informix2.pgc" #line 53 "test_informix2.pgc"
char dbname[30]; char dbname [ 30 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 54 "test_informix2.pgc" #line 54 "test_informix2.pgc"
interval *intvl; interval *intvl;
/* exec sql whenever sqlerror sqlprint ; */ /* exec sql whenever sqlerror sqlprint ; */
#line 58 "test_informix2.pgc" #line 58 "test_informix2.pgc"
...@@ -177,75 +171,57 @@ main(void) ...@@ -177,75 +171,57 @@ main(void)
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
strcpy(dbname, "regress1"); strcpy(dbname, "regress1");
{ { ECPGconnect(__LINE__, 1, dbname , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 1, dbname, NULL, NULL, NULL, 0);
#line 63 "test_informix2.pgc" #line 63 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 63 "test_informix2.pgc" #line 63 "test_informix2.pgc"
sql_check("main", "connect", 0); sql_check("main", "connect", 0);
{ { ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
#line 66 "test_informix2.pgc" #line 66 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 66 "test_informix2.pgc" #line 66 "test_informix2.pgc"
{ { ECPGdo(__LINE__, 1, 1, NULL, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 68 "test_informix2.pgc" #line 68 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 68 "test_informix2.pgc" #line 68 "test_informix2.pgc"
sql_check("main", "create", 0); sql_check("main", "create", 0);
{ { ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 73 "test_informix2.pgc" #line 73 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 73 "test_informix2.pgc" #line 73 "test_informix2.pgc"
sql_check("main", "insert", 0); sql_check("main", "insert", 0);
{ { ECPGdo(__LINE__, 1, 1, NULL, "select max ( timestamp ) from history ", ECPGt_EOIT,
ECPGdo(__LINE__, 1, 1, NULL, "select max ( timestamp ) from history ", ECPGt_EOIT, ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
ECPGt_timestamp, &(maxd), (long) 1, (long) 1, sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 78 "test_informix2.pgc" #line 78 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 78 "test_informix2.pgc" #line 78 "test_informix2.pgc"
sql_check("main", "select max", 100); sql_check("main", "select max", 100);
{ { ECPGdo(__LINE__, 1, 1, NULL, "select customerid , timestamp from history where timestamp = ? limit 1 ",
ECPGdo(__LINE__, 1, 1, NULL, "select customerid , timestamp from history where timestamp = ? limit 1 ", ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
ECPGt_timestamp, &(maxd), (long) 1, (long) 1, sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
ECPGt_int, &(c), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp),
ECPGt_timestamp, &(d), (long) 1, (long) 1, sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 85 "test_informix2.pgc" #line 85 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 85 "test_informix2.pgc" #line 85 "test_informix2.pgc"
sql_check("main", "select", 0); sql_check("main", "select", 0);
...@@ -257,59 +233,44 @@ main(void) ...@@ -257,59 +233,44 @@ main(void)
c++; c++;
{ { ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( ? , ? , 'test' , 'test' ) ",
ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( ? , ? , 'test' , 'test' ) ", ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
ECPGt_int, &(c), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp),
ECPGt_timestamp, &(e), (long) 1, (long) 1, sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 97 "test_informix2.pgc" #line 97 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 97 "test_informix2.pgc" #line 97 "test_informix2.pgc"
sql_check("main", "update", 0); sql_check("main", "update", 0);
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 100 "test_informix2.pgc" #line 100 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 100 "test_informix2.pgc" #line 100 "test_informix2.pgc"
{ { ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
#line 102 "test_informix2.pgc" #line 102 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 102 "test_informix2.pgc" #line 102 "test_informix2.pgc"
sql_check("main", "drop", 0); sql_check("main", "drop", 0);
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 105 "test_informix2.pgc" #line 105 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 105 "test_informix2.pgc" #line 105 "test_informix2.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");
ECPGdisconnect(__LINE__, "CURRENT");
#line 107 "test_informix2.pgc" #line 107 "test_informix2.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 107 "test_informix2.pgc" #line 107 "test_informix2.pgc"
sql_check("main", "disconnect", 0); sql_check("main", "disconnect", 0);
...@@ -319,13 +280,13 @@ main(void) ...@@ -319,13 +280,13 @@ main(void)
exit(0); exit(0);
/* /*
Table "public.history" Table "public.history"
Column | Type | Modifiers Column | Type | Modifiers
--------------+-----------------------------+----------- --------------+-----------------------------+-----------
customerid | integer | not null customerid | integer | not null
timestamp | timestamp without time zone | not null timestamp | timestamp without time zone | not null
action_taken | character(5) | not null action_taken | character(5) | not null
narrative | character varying(100) | narrative | character varying(100) |
*/ */
} }
...@@ -25,184 +25,125 @@ int ...@@ -25,184 +25,125 @@ int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 16 "test1.pgc" #line 16 "test1.pgc"
char db[200]; char db [ 200 ] ;
#line 17 "test1.pgc" #line 17 "test1.pgc"
char pw[200]; char pw [ 200 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 18 "test1.pgc" #line 18 "test1.pgc"
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 22 "test1.pgc" #line 22 "test1.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);
}
#line 23 "test1.pgc" #line 23 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 24 "test1.pgc" #line 24 "test1.pgc"
/* <-- "main" not specified */ /* <-- "main" not specified */
{ { ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb@localhost", NULL, NULL, "main", 0);
}
#line 26 "test1.pgc" #line 26 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 27 "test1.pgc" #line 27 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "@localhost", "connectdb", NULL, "main", 0);
}
#line 29 "test1.pgc" #line 29 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 30 "test1.pgc" #line 30 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb@localhost:55432" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb@localhost:55432", NULL, NULL, "main", 0);
}
#line 32 "test1.pgc" #line 32 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 33 "test1.pgc" #line 33 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "@localhost:55432" , "connectdb" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "@localhost:55432", "connectdb", NULL, "main", 0);
}
#line 35 "test1.pgc" #line 35 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 36 "test1.pgc" #line 36 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb:55432" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb:55432", NULL, NULL, "main", 0);
}
#line 38 "test1.pgc" #line 38 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 39 "test1.pgc" #line 39 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, ":55432" , "connectdb" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, ":55432", "connectdb", NULL, "main", 0);
}
#line 41 "test1.pgc" #line 41 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 42 "test1.pgc" #line 42 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0);
}
#line 44 "test1.pgc" #line 44 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 45 "test1.pgc" #line 45 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/" , "connectdb" , NULL , NULL, 0); }
ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/", "connectdb", NULL, NULL, 0);
}
#line 47 "test1.pgc" #line 47 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 48 "test1.pgc" #line 48 "test1.pgc"
strcpy(pw, "connectpw"); strcpy(pw, "connectpw");
strcpy(db, "tcp:postgresql://localhost:55432/connectdb"); strcpy(db, "tcp:postgresql://localhost:55432/connectdb");
{ { ECPGconnect(__LINE__, 0, db , "connectuser" , pw , NULL, 0); }
ECPGconnect(__LINE__, 0, db, "connectuser", pw, NULL, 0);
}
#line 52 "test1.pgc" #line 52 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 53 "test1.pgc" #line 53 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0);
}
#line 55 "test1.pgc" #line 55 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 56 "test1.pgc" #line 56 "test1.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , NULL , NULL, 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", NULL, NULL, 0);
}
#line 58 "test1.pgc" #line 58 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 59 "test1.pgc" #line 59 "test1.pgc"
/* wrong db */ /* wrong db */
{ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant" , "connectuser" , "connectpw" , NULL, 0); }
ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant", "connectuser", "connectpw", NULL, 0);
}
#line 62 "test1.pgc" #line 62 "test1.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 63 "test1.pgc" #line 63 "test1.pgc"
/* wrong port */ /* wrong port */
{ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb", "connectuser", "connectpw", NULL, 0);
}
#line 66 "test1.pgc" #line 66 "test1.pgc"
/* no disconnect necessary */ /* no disconnect necessary */
/* wrong password */ /* wrong password */
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "wrongpw" , NULL, 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "wrongpw", NULL, 0);
}
#line 70 "test1.pgc" #line 70 "test1.pgc"
/* no disconnect necessary */ /* no disconnect necessary */
......
...@@ -32,15 +32,14 @@ int ...@@ -32,15 +32,14 @@ int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 17 "test2.pgc" #line 17 "test2.pgc"
char id[200]; char id [ 200 ] ;
#line 18 "test2.pgc" #line 18 "test2.pgc"
char res[200]; char res [ 200 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 19 "test2.pgc" #line 19 "test2.pgc"
...@@ -48,78 +47,56 @@ main(void) ...@@ -48,78 +47,56 @@ main(void)
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
strcpy(id, "first"); strcpy(id, "first");
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0);
}
#line 24 "test2.pgc" #line 24 "test2.pgc"
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
}
#line 25 "test2.pgc" #line 25 "test2.pgc"
/* this selects from "second" which was opened last */ /* this selects from "second" which was opened last */
{ { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 28 "test2.pgc" #line 28 "test2.pgc"
{ { ECPGdo(__LINE__, 0, 1, "first", "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, "first", "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 29 "test2.pgc" #line 29 "test2.pgc"
{ { ECPGdo(__LINE__, 0, 1, "second", "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, "second", "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 30 "test2.pgc" #line 30 "test2.pgc"
{ { ECPGsetconn(__LINE__, "first");}
ECPGsetconn(__LINE__, "first");
}
#line 32 "test2.pgc" #line 32 "test2.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 33 "test2.pgc" #line 33 "test2.pgc"
/* this will disconnect from "first" */ /* this will disconnect from "first" */
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 36 "test2.pgc" #line 36 "test2.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 37 "test2.pgc" #line 37 "test2.pgc"
/* error here since "first" is already disconnected */ /* error here since "first" is already disconnected */
{ { ECPGdisconnect(__LINE__, id);}
ECPGdisconnect(__LINE__, id);
}
#line 40 "test2.pgc" #line 40 "test2.pgc"
/* disconnect from "second" */ /* disconnect from "second" */
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 43 "test2.pgc" #line 43 "test2.pgc"
......
...@@ -31,15 +31,14 @@ int ...@@ -31,15 +31,14 @@ int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 16 "test3.pgc" #line 16 "test3.pgc"
char id[200]; char id [ 200 ] ;
#line 17 "test3.pgc" #line 17 "test3.pgc"
char res[200]; char res [ 200 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 18 "test3.pgc" #line 18 "test3.pgc"
...@@ -47,83 +46,60 @@ main(void) ...@@ -47,83 +46,60 @@ main(void)
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
strcpy(id, "first"); strcpy(id, "first");
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0);
}
#line 23 "test3.pgc" #line 23 "test3.pgc"
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
}
#line 24 "test3.pgc" #line 24 "test3.pgc"
/* this selects from "second" which was opened last */ /* this selects from "second" which was opened last */
{ { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 27 "test3.pgc" #line 27 "test3.pgc"
/* will close "second" */ /* will close "second" */
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 30 "test3.pgc" #line 30 "test3.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 31 "test3.pgc" #line 31 "test3.pgc"
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
}
#line 33 "test3.pgc" #line 33 "test3.pgc"
/* will close "second" */ /* will close "second" */
{ { ECPGdisconnect(__LINE__, "DEFAULT");}
ECPGdisconnect(__LINE__, "DEFAULT");
}
#line 35 "test3.pgc" #line 35 "test3.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "second", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "second", 0);
}
#line 37 "test3.pgc" #line 37 "test3.pgc"
{ { ECPGdisconnect(__LINE__, "ALL");}
ECPGdisconnect(__LINE__, "ALL");
}
#line 38 "test3.pgc" #line 38 "test3.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 40 "test3.pgc" #line 40 "test3.pgc"
{ { ECPGdisconnect(__LINE__, "DEFAULT");}
ECPGdisconnect(__LINE__, "DEFAULT");
}
#line 41 "test3.pgc" #line 41 "test3.pgc"
{ { ECPGdisconnect(__LINE__, "ALL");}
ECPGdisconnect(__LINE__, "ALL");
}
#line 42 "test3.pgc" #line 42 "test3.pgc"
/* /*
* exec sql disconnect; exec sql disconnect name; * exec sql disconnect;
* exec sql disconnect name;
* *
* are used in other tests * are used in other tests
*/ */
return (0); return (0);
......
...@@ -28,21 +28,15 @@ main(void) ...@@ -28,21 +28,15 @@ main(void)
{ {
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "main", 0);
}
#line 13 "test4.pgc" #line 13 "test4.pgc"
{ { ECPGsetconn(__LINE__, "main");}
ECPGsetconn(__LINE__, "main");
}
#line 15 "test4.pgc" #line 15 "test4.pgc"
{ { ECPGdisconnect(__LINE__, "DEFAULT");}
ECPGdisconnect(__LINE__, "DEFAULT");
}
#line 17 "test4.pgc" #line 17 "test4.pgc"
......
...@@ -22,181 +22,122 @@ int ...@@ -22,181 +22,122 @@ int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 16 "test5.pgc" #line 16 "test5.pgc"
char db[200]; char db [ 200 ] ;
#line 17 "test5.pgc" #line 17 "test5.pgc"
char id[200]; char id [ 200 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 18 "test5.pgc" #line 18 "test5.pgc"
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 22 "test5.pgc" #line 22 "test5.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);
}
#line 23 "test5.pgc" #line 23 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 24 "test5.pgc" #line 24 "test5.pgc"
/* <-- "main" not specified */ /* <-- "main" not specified */
strcpy(db, "connectdb"); strcpy(db, "connectdb");
strcpy(id, "main"); strcpy(id, "main");
{ { ECPGconnect(__LINE__, 0, db , NULL,NULL , id, 0); }
ECPGconnect(__LINE__, 0, db, NULL, NULL, id, 0);
}
#line 28 "test5.pgc" #line 28 "test5.pgc"
{ { ECPGdisconnect(__LINE__, id);}
ECPGdisconnect(__LINE__, id);
}
#line 29 "test5.pgc" #line 29 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 31 "test5.pgc" #line 31 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 32 "test5.pgc" #line 32 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 34 "test5.pgc" #line 34 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 35 "test5.pgc" #line 35 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 37 "test5.pgc" #line 37 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 38 "test5.pgc" #line 38 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "", "connectdb", NULL, "main", 0);
}
#line 40 "test5.pgc" #line 40 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 41 "test5.pgc" #line 41 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", "connectuser", "connectdb", "main", 0);
}
#line 43 "test5.pgc" #line 43 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 44 "test5.pgc" #line 44 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
}
#line 46 "test5.pgc" #line 46 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 47 "test5.pgc" #line 47 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
}
#line 49 "test5.pgc" #line 49 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 50 "test5.pgc" #line 50 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
}
#line 52 "test5.pgc" #line 52 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 53 "test5.pgc" #line 53 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb", "connectuser", NULL, "main", 0);
}
#line 55 "test5.pgc" #line 55 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 56 "test5.pgc" #line 56 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/", "connectdb", NULL, "main", 0);
}
#line 58 "test5.pgc" #line 58 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 59 "test5.pgc" #line 59 "test5.pgc"
/* connect twice */ /* connect twice */
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 62 "test5.pgc" #line 62 "test5.pgc"
{ { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
}
#line 63 "test5.pgc" #line 63 "test5.pgc"
{ { ECPGdisconnect(__LINE__, "main");}
ECPGdisconnect(__LINE__, "main");
}
#line 64 "test5.pgc" #line 64 "test5.pgc"
/* not connected */ /* not connected */
{ { ECPGdisconnect(__LINE__, "nonexistant");}
ECPGdisconnect(__LINE__, "nonexistant");
}
#line 67 "test5.pgc" #line 67 "test5.pgc"
......
...@@ -25,76 +25,73 @@ ...@@ -25,76 +25,73 @@
#line 8 "dt_test2.pgc" #line 8 "dt_test2.pgc"
char *dates[] = {"19990108foobar", char *dates[] = { "19990108foobar",
"19990108 foobar", "19990108 foobar",
"1999-01-08 foobar", "1999-01-08 foobar",
"January 8, 1999", "January 8, 1999",
"1999-01-08", "1999-01-08",
"1/8/1999", "1/8/1999",
"1/18/1999", "1/18/1999",
"01/02/03", "01/02/03",
"1999-Jan-08", "1999-Jan-08",
"Jan-08-1999", "Jan-08-1999",
"08-Jan-1999", "08-Jan-1999",
"99-Jan-08", "99-Jan-08",
"08-Jan-99", "08-Jan-99",
"08-Jan-06", "08-Jan-06",
"Jan-08-99", "Jan-08-99",
"19990108", "19990108",
"990108", "990108",
"1999.008", "1999.008",
"J2451187", "J2451187",
"January 8, 99 BC", "January 8, 99 BC",
NULL}; NULL };
char *times[] = {"0:04", char *times[] = { "0:04",
"1:59 PDT", "1:59 PDT",
"13:24:40 -8:00", "13:24:40 -8:00",
"13:24:40.495+3", "13:24:40.495+3",
NULL}; NULL };
char *intervals[] = {"1 minute", char *intervals[] = { "1 minute",
"1 12:59:10", "1 12:59:10",
"2 day 12 hour 59 minute 10 second", "2 day 12 hour 59 minute 10 second",
"1 days 12 hrs 59 mins 10 secs", "1 days 12 hrs 59 mins 10 secs",
"1 days 1 hours 1 minutes 1 seconds", "1 days 1 hours 1 minutes 1 seconds",
"1 year 59 mins", "1 year 59 mins",
"1 year 59 mins foobar", "1 year 59 mins foobar",
NULL}; NULL };
int int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 51 "dt_test2.pgc" #line 51 "dt_test2.pgc"
date date1; date date1 ;
#line 52 "dt_test2.pgc" #line 52 "dt_test2.pgc"
timestamp ts1, timestamp ts1 , ts2 ;
ts2;
#line 53 "dt_test2.pgc" #line 53 "dt_test2.pgc"
char *text; char * text ;
#line 54 "dt_test2.pgc" #line 54 "dt_test2.pgc"
interval *i1; interval * i1 ;
#line 55 "dt_test2.pgc" #line 55 "dt_test2.pgc"
date *dc; date * dc ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 56 "dt_test2.pgc" #line 56 "dt_test2.pgc"
int i, int i, j;
j; char *endptr;
char *endptr;
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
...@@ -108,45 +105,38 @@ main(void) ...@@ -108,45 +105,38 @@ main(void)
dc = PGTYPESdate_new(); dc = PGTYPESdate_new();
*dc = date1; *dc = date1;
text = PGTYPESdate_to_asc(*dc); text = PGTYPESdate_to_asc(*dc);
printf("Date of timestamp: %s\n", text); printf("Date of timestamp: %s\n", text);
free(text); free(text);
PGTYPESdate_free(dc); PGTYPESdate_free(dc);
for (i = 0; dates[i]; i++) for (i = 0; dates[i]; i++)
{ {
bool err = false; bool err = false;
date1 = PGTYPESdate_from_asc(dates[i], &endptr); date1 = PGTYPESdate_from_asc(dates[i], &endptr);
if (date1 == INT_MIN) if (date1 == INT_MIN) {
{
err = true; err = true;
} }
text = PGTYPESdate_to_asc(date1); text = PGTYPESdate_to_asc(date1);
printf("Date[%d]: %s (%c - %c)\n", printf("Date[%d]: %s (%c - %c)\n",
i, err ? "-" : text, i, err ? "-" : text,
endptr ? 'N' : 'Y', endptr ? 'N' : 'Y',
err ? 'T' : 'F'); err ? 'T' : 'F');
free(text); free(text);
if (!err) if (!err)
{ {
for (j = 0; times[j]; j++) for (j = 0; times[j]; j++)
{ {
int length = strlen(dates[i]) int length = strlen(dates[i])
+ 1 + 1
+ strlen(times[j]) + strlen(times[j])
+ 1; + 1;
char *t = malloc(length); char* t = malloc(length);
sprintf(t, "%s %s", dates[i], times[j]); sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL); ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1); text = PGTYPEStimestamp_to_asc(ts1);
if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
if (i != 19 || j != 3) /* timestamp as integer or double
* differ for this case */
printf("TS[%d,%d]: %s\n", printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text); i, j, errno ? "-" : text);
free(text); free(text);
} }
} }
...@@ -156,8 +146,7 @@ main(void) ...@@ -156,8 +146,7 @@ main(void)
for (i = 0; intervals[i]; i++) for (i = 0; intervals[i]; i++)
{ {
interval *ic; interval *ic;
i1 = PGTYPESinterval_from_asc(intervals[i], &endptr); i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
if (*endptr) if (*endptr)
printf("endptr set to %s\n", endptr); printf("endptr set to %s\n", endptr);
...@@ -170,14 +159,12 @@ main(void) ...@@ -170,14 +159,12 @@ main(void)
if (j < 0) if (j < 0)
continue; continue;
text = PGTYPESinterval_to_asc(i1); text = PGTYPESinterval_to_asc(i1);
printf("interval[%d]: %s\n", i, text ? text : "-"); printf("interval[%d]: %s\n", i, text ? text : "-");
free(text); free(text);
ic = PGTYPESinterval_new(); ic = PGTYPESinterval_new();
PGTYPESinterval_copy(i1, ic); PGTYPESinterval_copy(i1, ic);
text = PGTYPESinterval_to_asc(i1); text = PGTYPESinterval_to_asc(i1);
printf("interval_copy[%d]: %s\n", i, text ? text : "-"); printf("interval_copy[%d]: %s\n", i, text ? text : "-");
free(text); free(text);
PGTYPESinterval_free(ic); PGTYPESinterval_free(ic);
...@@ -185,3 +172,4 @@ main(void) ...@@ -185,3 +172,4 @@ main(void)
return (0); return (0);
} }
...@@ -34,64 +34,49 @@ NOTE: This file has a different expect file for regression tests on MinGW32 ...@@ -34,64 +34,49 @@ NOTE: This file has a different expect file for regression tests on MinGW32
int int
main(void) main(void)
{ {
char *text = "error\n"; char *text="error\n";
numeric *value1, numeric *value1, *value2, *res;
*value2,
*res;
/* exec sql begin declare section */ /* exec sql begin declare section */
/* = {0, 0, 0, 0, 0, NULL, NULL} ; */ /* = {0, 0, 0, 0, 0, NULL, NULL} ; */
#line 22 "num_test.pgc" #line 22 "num_test.pgc"
numeric *des; numeric * des ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 24 "num_test.pgc" #line 24 "num_test.pgc"
double d; double d;
long l1, long l1, l2;
l2; int i;
int i;
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
/* exec sql whenever sqlerror do sqlprint ( ) ; */ /* exec sql whenever sqlerror do sqlprint ( ) ; */
#line 30 "num_test.pgc" #line 30 "num_test.pgc"
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
#line 32 "num_test.pgc" #line 32 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 32 "num_test.pgc" #line 32 "num_test.pgc"
{ { ECPGsetcommit(__LINE__, "off", NULL);
ECPGsetcommit(__LINE__, "off", NULL);
#line 34 "num_test.pgc" #line 34 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 34 "num_test.pgc" #line 34 "num_test.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 35 "num_test.pgc" #line 35 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 35 "num_test.pgc" #line 35 "num_test.pgc"
value1 = PGTYPESnumeric_new(); value1 = PGTYPESnumeric_new();
PGTYPESnumeric_from_int(1407, value1); PGTYPESnumeric_from_int(1407, value1);
text = PGTYPESnumeric_to_asc(value1, -1); text = PGTYPESnumeric_to_asc(value1, -1);
printf("from int = %s\n", text); printf("from int = %s\n", text);
free(text); free(text);
PGTYPESnumeric_free(value1); PGTYPESnumeric_free(value1);
...@@ -101,28 +86,23 @@ main(void) ...@@ -101,28 +86,23 @@ main(void)
res = PGTYPESnumeric_new(); res = PGTYPESnumeric_new();
PGTYPESnumeric_add(value1, value2, res); PGTYPESnumeric_add(value1, value2, res);
text = PGTYPESnumeric_to_asc(res, -1); text = PGTYPESnumeric_to_asc(res, -1);
printf("add = %s\n", text); printf("add = %s\n", text);
free(text); free(text);
PGTYPESnumeric_sub(res, value2, res); PGTYPESnumeric_sub(res, value2, res);
text = PGTYPESnumeric_to_asc(res, -1); text = PGTYPESnumeric_to_asc(res, -1);
printf("sub = %s\n", text); printf("sub = %s\n", text);
free(text); free(text);
PGTYPESnumeric_free(value2); PGTYPESnumeric_free(value2);
des = PGTYPESnumeric_new(); des = PGTYPESnumeric_new();
PGTYPESnumeric_copy(res, des); PGTYPESnumeric_copy(res, des);
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text , num ) values ( 'test' , ? ) ",
ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text , num ) values( 'test' , ? ) ", ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 60 "num_test.pgc" #line 60 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 60 "num_test.pgc" #line 60 "num_test.pgc"
...@@ -130,21 +110,17 @@ main(void) ...@@ -130,21 +110,17 @@ main(void)
PGTYPESnumeric_mul(value1, value2, res); PGTYPESnumeric_mul(value1, value2, res);
PGTYPESnumeric_free(value2); PGTYPESnumeric_free(value2);
{ { ECPGdo(__LINE__, 0, 1, NULL, "select num from test where text = 'test' ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select num from test where text = 'test' ", ECPGt_EOIT, ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 66 "num_test.pgc" #line 66 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 66 "num_test.pgc" #line 66 "num_test.pgc"
PGTYPESnumeric_mul(res, des, res); PGTYPESnumeric_mul(res, des, res);
text = PGTYPESnumeric_to_asc(res, -1); text = PGTYPESnumeric_to_asc(res, -1);
printf("mul = %s\n", text); printf("mul = %s\n", text);
free(text); free(text);
PGTYPESnumeric_free(des); PGTYPESnumeric_free(des);
...@@ -152,7 +128,6 @@ main(void) ...@@ -152,7 +128,6 @@ main(void)
value2 = PGTYPESnumeric_from_asc("10000", NULL); value2 = PGTYPESnumeric_from_asc("10000", NULL);
PGTYPESnumeric_div(res, value2, res); PGTYPESnumeric_div(res, value2, res);
text = PGTYPESnumeric_to_asc(res, -1); text = PGTYPESnumeric_to_asc(res, -1);
PGTYPESnumeric_to_double(res, &d); PGTYPESnumeric_to_double(res, &d);
printf("div = %s %e\n", text, d); printf("div = %s %e\n", text, d);
...@@ -166,24 +141,19 @@ main(void) ...@@ -166,24 +141,19 @@ main(void)
PGTYPESnumeric_free(value2); PGTYPESnumeric_free(value2);
PGTYPESnumeric_free(res); PGTYPESnumeric_free(res);
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 90 "num_test.pgc" #line 90 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 90 "num_test.pgc" #line 90 "num_test.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");
ECPGdisconnect(__LINE__, "CURRENT");
#line 91 "num_test.pgc" #line 91 "num_test.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint ( );}
sqlprint();
}
#line 91 "num_test.pgc" #line 91 "num_test.pgc"
return (0); return (0);
} }
...@@ -32,149 +32,112 @@ NOTE: This file has a different expect file for regression tests on MinGW32 ...@@ -32,149 +32,112 @@ NOTE: This file has a different expect file for regression tests on MinGW32
*/ */
char *nums[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
"2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
".500001", "-.5000001", ".500001", "-.5000001",
"1234567890123456789012345678.91", /* 30 digits should fit into decimal */ "1234567890123456789012345678.91", /* 30 digits should fit
"1234567890123456789012345678.921", /* 31 digits should NOT fit into into decimal */
* decimal */ "1234567890123456789012345678.921", /* 31 digits should NOT
"not a number", fit into decimal */
NULL}; "not a number",
NULL};
static void static void
check_errno(void); check_errno(void);
int int
main(void) main(void)
{ {
char *text = "error\n"; char *text="error\n";
char *endptr; char *endptr;
numeric *num, numeric *num, *nin;
*nin; decimal *dec;
decimal *dec; long l;
long l; int i, j, k, q, r, count = 0;
int i, double d;
j, numeric **numarr = (numeric **) calloc(1, sizeof(numeric));
k,
q,
r,
count = 0;
double d;
numeric **numarr = (numeric **) calloc(1, sizeof(numeric));
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
for (i = 0; nums[i]; i++) for (i = 0; nums[i]; i++)
{ {
num = PGTYPESnumeric_from_asc(nums[i], &endptr); num = PGTYPESnumeric_from_asc(nums[i], &endptr);
if (!num) if (!num) check_errno();
check_errno();
if (endptr != NULL) if (endptr != NULL)
{ {
printf("endptr of %d is not NULL\n", i); printf("endptr of %d is not NULL\n", i);
if (*endptr != '\0') if (*endptr != '\0')
printf("*endptr of %d is not \\0\n", i); printf("*endptr of %d is not \\0\n", i);
} }
if (!num) if (!num) continue;
continue;
numarr = realloc(numarr, sizeof(numeric *) * (count + 1)); numarr = realloc(numarr, sizeof(numeric *) * (count + 1));
numarr[count++] = num; numarr[count++] = num;
text = PGTYPESnumeric_to_asc(num, -1); text = PGTYPESnumeric_to_asc(num, -1);
if (!text) check_errno();
if (!text) printf("num[%d,1]: %s\n", i, text); free(text);
check_errno();
printf("num[%d,1]: %s\n", i, text);
free(text);
text = PGTYPESnumeric_to_asc(num, 0); text = PGTYPESnumeric_to_asc(num, 0);
if (!text) check_errno();
if (!text) printf("num[%d,2]: %s\n", i, text); free(text);
check_errno();
printf("num[%d,2]: %s\n", i, text);
free(text);
text = PGTYPESnumeric_to_asc(num, 1); text = PGTYPESnumeric_to_asc(num, 1);
if (!text) check_errno();
if (!text) printf("num[%d,3]: %s\n", i, text); free(text);
check_errno();
printf("num[%d,3]: %s\n", i, text);
free(text);
text = PGTYPESnumeric_to_asc(num, 2); text = PGTYPESnumeric_to_asc(num, 2);
if (!text) check_errno();
if (!text) printf("num[%d,4]: %s\n", i, text); free(text);
check_errno();
printf("num[%d,4]: %s\n", i, text);
free(text);
nin = PGTYPESnumeric_new(); nin = PGTYPESnumeric_new();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
if (!text) check_errno();
if (!text) printf("num[%d,5]: %s\n", i, text); free(text);
check_errno();
printf("num[%d,5]: %s\n", i, text);
free(text);
r = PGTYPESnumeric_to_long(num, &l); r = PGTYPESnumeric_to_long(num, &l);
if (r) if (r) check_errno();
check_errno(); printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
printf("num[%d,6]: %ld (r: %d)\n", i, r ? 0L : l, r);
if (r == 0) if (r == 0)
{ {
r = PGTYPESnumeric_from_long(l, nin); r = PGTYPESnumeric_from_long(l, nin);
if (r) if (r) check_errno();
check_errno();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin); q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q); printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text); free(text);
} }
r = PGTYPESnumeric_to_int(num, &k); r = PGTYPESnumeric_to_int(num, &k);
if (r) if (r) check_errno();
check_errno(); printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r);
printf("num[%d,8]: %d (r: %d)\n", i, r ? 0 : k, r);
if (r == 0) if (r == 0)
{ {
r = PGTYPESnumeric_from_int(k, nin); r = PGTYPESnumeric_from_int(k, nin);
if (r) if (r) check_errno();
check_errno();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin); q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q); printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text); free(text);
} }
r = PGTYPESnumeric_to_double(num, &d); r = PGTYPESnumeric_to_double(num, &d);
if (r) if (r) check_errno();
check_errno(); printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
printf("num[%d,10]: %g (r: %d)\n", i, r ? 0.0 : d, r); /* do not test double to numeric because
* - extra digits are different on different architectures
/* * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway
* do not test double to numeric because - extra digits are different
* on different architectures - PGTYPESnumeric_from_double internally
* calls PGTYPESnumeric_from_asc anyway
*/ */
dec = PGTYPESdecimal_new(); dec = PGTYPESdecimal_new();
r = PGTYPESnumeric_to_decimal(num, dec); r = PGTYPESnumeric_to_decimal(num, dec);
if (r) if (r) check_errno();
check_errno(); /* we have no special routine for outputting decimal, it would
* convert to a numeric anyway */
/*
* we have no special routine for outputting decimal, it would convert
* to a numeric anyway
*/
printf("num[%d,11]: - (r: %d)\n", i, r); printf("num[%d,11]: - (r: %d)\n", i, r);
if (r == 0) if (r == 0)
{ {
r = PGTYPESnumeric_from_decimal(dec, nin); r = PGTYPESnumeric_from_decimal(dec, nin);
if (r) if (r) check_errno();
check_errno();
text = PGTYPESnumeric_to_asc(nin, 2); text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin); q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q); printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
free(text); free(text);
...@@ -189,11 +152,10 @@ main(void) ...@@ -189,11 +152,10 @@ main(void)
{ {
for (j = 0; j < count; j++) for (j = 0; j < count; j++)
{ {
numeric *a = PGTYPESnumeric_new(); numeric* a = PGTYPESnumeric_new();
numeric *s = PGTYPESnumeric_new(); numeric* s = PGTYPESnumeric_new();
numeric *m = PGTYPESnumeric_new(); numeric* m = PGTYPESnumeric_new();
numeric *d = PGTYPESnumeric_new(); numeric* d = PGTYPESnumeric_new();
r = PGTYPESnumeric_add(numarr[i], numarr[j], a); r = PGTYPESnumeric_add(numarr[i], numarr[j], a);
if (r) if (r)
{ {
...@@ -203,7 +165,6 @@ main(void) ...@@ -203,7 +165,6 @@ main(void)
else else
{ {
text = PGTYPESnumeric_to_asc(a, 10); text = PGTYPESnumeric_to_asc(a, 10);
printf("num[a,%d,%d]: %s\n", i, j, text); printf("num[a,%d,%d]: %s\n", i, j, text);
free(text); free(text);
} }
...@@ -216,7 +177,6 @@ main(void) ...@@ -216,7 +177,6 @@ main(void)
else else
{ {
text = PGTYPESnumeric_to_asc(s, 10); text = PGTYPESnumeric_to_asc(s, 10);
printf("num[s,%d,%d]: %s\n", i, j, text); printf("num[s,%d,%d]: %s\n", i, j, text);
free(text); free(text);
} }
...@@ -229,7 +189,6 @@ main(void) ...@@ -229,7 +189,6 @@ main(void)
else else
{ {
text = PGTYPESnumeric_to_asc(m, 10); text = PGTYPESnumeric_to_asc(m, 10);
printf("num[m,%d,%d]: %s\n", i, j, text); printf("num[m,%d,%d]: %s\n", i, j, text);
free(text); free(text);
} }
...@@ -242,7 +201,6 @@ main(void) ...@@ -242,7 +201,6 @@ main(void)
else else
{ {
text = PGTYPESnumeric_to_asc(d, 10); text = PGTYPESnumeric_to_asc(d, 10);
printf("num[d,%d,%d]: %s\n", i, j, text); printf("num[d,%d,%d]: %s\n", i, j, text);
free(text); free(text);
} }
...@@ -252,7 +210,6 @@ main(void) ...@@ -252,7 +210,6 @@ main(void)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
text = PGTYPESnumeric_to_asc(numarr[i], -1); text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text); printf("%d: %s\n", i, text);
free(text); free(text);
} }
...@@ -263,7 +220,7 @@ main(void) ...@@ -263,7 +220,7 @@ main(void)
static void static void
check_errno(void) check_errno(void)
{ {
switch (errno) switch(errno)
{ {
case 0: case 0:
printf("(no errno set) - "); printf("(no errno set) - ");
......
...@@ -20,29 +20,24 @@ ...@@ -20,29 +20,24 @@
#line 3 "comment.pgc" #line 3 "comment.pgc"
/* just a test comment */ int i; /* just a test comment */ int i;
/* just a test comment int j*/;
/* just a test comment int j*/ ;
/****************************************************************************/ /****************************************************************************/
/* Test comment */ /* Test comment */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int main(void)
main(void)
{ {
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
}
#line 17 "comment.pgc" #line 17 "comment.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 19 "comment.pgc" #line 19 "comment.pgc"
exit(0); exit (0);
} }
...@@ -30,165 +30,133 @@ ...@@ -30,165 +30,133 @@
/* exec sql type intarray is int [ 6 ] */ /* exec sql type intarray is int [ 6 ] */
#line 13 "define.pgc" #line 13 "define.pgc"
typedef int intarray[6]; typedef int intarray[ 6];
int int
main(void) main(void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
typedef char string[8]; typedef char string [ 8 ] ;
#line 21 "define.pgc" #line 21 "define.pgc"
#line 22 "define.pgc" #line 22 "define.pgc"
intarray amount; intarray amount ;
#line 23 "define.pgc" #line 23 "define.pgc"
char name[6][8]; char name [ 6 ] [ 8 ] ;
#line 24 "define.pgc" #line 24 "define.pgc"
char letter[6][1]; char letter [ 6 ] [ 1 ] ;
#if 0 #if 0
#line 26 "define.pgc" #line 26 "define.pgc"
int not_used; int not_used ;
#endif #endif
/* exec sql end declare section */ /* exec sql end declare section */
#line 29 "define.pgc" #line 29 "define.pgc"
int i, int i,j;
j;
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
#line 34 "define.pgc" #line 34 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 34 "define.pgc" #line 34 "define.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 36 "define.pgc" #line 36 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 36 "define.pgc" #line 36 "define.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 37 "define.pgc" #line 37 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 37 "define.pgc" #line 37 "define.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 39 "define.pgc" #line 39 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 39 "define.pgc" #line 39 "define.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 40 "define.pgc" #line 40 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 40 "define.pgc" #line 40 "define.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 41 "define.pgc" #line 41 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 41 "define.pgc" #line 41 "define.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char),
ECPGt_char, (name), (long) 8, (long) 6, (8) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)6,sizeof(int),
ECPGt_int, (amount), (long) 1, (long) 6, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char),
ECPGt_char, (letter), (long) 1, (long) 6, (1) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 43 "define.pgc" #line 43 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 43 "define.pgc" #line 43 "define.pgc"
for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++) for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 48 "define.pgc" #line 48 "define.pgc"
char n[8], char n [ 8 ] , l = letter [ i ] [ 0 ] ;
l = letter[i][0];
#line 49 "define.pgc" #line 49 "define.pgc"
int a = amount[i]; int a = amount [ i ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 50 "define.pgc" #line 50 "define.pgc"
strncpy(n, name[i], 8); strncpy(n, name[i], 8);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
} }
{ { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
#line 56 "define.pgc" #line 56 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 56 "define.pgc" #line 56 "define.pgc"
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 57 "define.pgc" #line 57 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 57 "define.pgc" #line 57 "define.pgc"
{ { ECPGdisconnect(__LINE__, "CURRENT");
ECPGdisconnect(__LINE__, "CURRENT");
#line 58 "define.pgc" #line 58 "define.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 58 "define.pgc" #line 58 "define.pgc"
......
...@@ -73,22 +73,16 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -73,22 +73,16 @@ struct sqlca_t *ECPGget_sqlca(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
#line 1 "init.pgc" #line 1 "init.pgc"
enum e enum e { ENUM0, ENUM1 };
{ struct sa { int member; };
ENUM0, ENUM1
};
struct sa
{
int member;
};
static int static int fa(void)
fa(void)
{ {
printf("in fa\n"); printf("in fa\n");
return 2; return 2;
...@@ -108,22 +102,19 @@ fc(const char *x) ...@@ -108,22 +102,19 @@ fc(const char *x)
return *x; return *x;
} }
static int static int fd(const char *x,int i)
fd(const char *x, int i)
{ {
printf("in fd (%s, %d)\n", x, i); printf("in fd (%s, %d)\n", x, i);
return (*x) * i; return (*x)*i;
} }
static int static int fe(enum e x)
fe(enum e x)
{ {
printf("in fe (%d)\n", (int) x); printf("in fe (%d)\n", (int) x);
return (int) x; return (int)x;
} }
static void static void sqlnotice(char *notice, short trans)
sqlnotice(char *notice, short trans)
{ {
if (!notice) if (!notice)
notice = "-empty-"; notice = "-empty-";
...@@ -135,79 +126,76 @@ sqlnotice(char *notice, short trans) ...@@ -135,79 +126,76 @@ sqlnotice(char *notice, short trans)
#define YES 1 #define YES 1
#ifdef _cplusplus #ifdef _cplusplus
namespace N namespace N
{ {
static const int i = 2; static const int i=2;
}; };
#endif #endif
int int main(void)
main(void)
{ {
struct sa x = {14}, *y = &x; struct sa x = { 14 },*y = &x;
/* exec sql begin declare section */ /* exec sql begin declare section */
/* = 1L */ /* = 1L */
#line 60 "init.pgc" #line 60 "init.pgc"
int a = (int) 2; int a = ( int ) 2 ;
#line 61 "init.pgc" #line 61 "init.pgc"
int b = 2 + 2; int b = 2 + 2 ;
#line 62 "init.pgc" #line 62 "init.pgc"
int b2 = (14 * 7); int b2 = ( 14 * 7 ) ;
#line 63 "init.pgc" #line 63 "init.pgc"
int d = x.member; int d = x . member ;
#line 64 "init.pgc" #line 64 "init.pgc"
int g = fb(2); int g = fb ( 2 ) ;
#line 65 "init.pgc" #line 65 "init.pgc"
int i = 3 ^ 1; int i = 3 ^ 1 ;
#line 66 "init.pgc" #line 66 "init.pgc"
int j = 1 ? 1 : 2; int j = 1 ? 1 : 2 ;
#line 68 "init.pgc" #line 68 "init.pgc"
int e = y->member; int e = y -> member ;
#line 69 "init.pgc" #line 69 "init.pgc"
int c = 10 >> 2; int c = 10 >> 2 ;
#line 70 "init.pgc" #line 70 "init.pgc"
bool h = 2 || 1; bool h = 2 || 1 ;
#line 71 "init.pgc" #line 71 "init.pgc"
long iay; long iay ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 72 "init.pgc" #line 72 "init.pgc"
int f = fa(); int f=fa();
#ifdef _cplusplus #ifdef _cplusplus
/* exec sql begin declare section */ /* exec sql begin declare section */
/* compile error */ /* compile error */
#line 78 "init.pgc" #line 78 "init.pgc"
int k = N::i; int k = N : : i ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 79 "init.pgc" #line 79 "init.pgc"
#endif #endif
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
...@@ -215,76 +203,58 @@ main(void) ...@@ -215,76 +203,58 @@ main(void)
printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j); printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
iay = 0; iay = 0;
printf("%ld\n", iay); printf("%ld\n", iay);
/* exec sql whenever sqlerror do fa ( ) ; */ /* exec sql whenever sqlerror do fa ( ) ; */
#line 87 "init.pgc" #line 87 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 88 "init.pgc" #line 88 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) fa ( );}
fa();
}
#line 88 "init.pgc" #line 88 "init.pgc"
/* exec sql whenever sqlerror do fb ( 20 ) ; */ /* exec sql whenever sqlerror do fb ( 20 ) ; */
#line 89 "init.pgc" #line 89 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 90 "init.pgc" #line 90 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) fb ( 20 );}
fb(20);
}
#line 90 "init.pgc" #line 90 "init.pgc"
/* exec sql whenever sqlerror do fc ( \"50\" ) ; */ /* exec sql whenever sqlerror do fc ( \"50\" ) ; */
#line 91 "init.pgc" #line 91 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 92 "init.pgc" #line 92 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) fc ( "50" );}
fc("50");
}
#line 92 "init.pgc" #line 92 "init.pgc"
/* exec sql whenever sqlerror do fd ( \"50\" , 1 ) ; */ /* exec sql whenever sqlerror do fd ( \"50\" , 1 ) ; */
#line 93 "init.pgc" #line 93 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 94 "init.pgc" #line 94 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) fd ( "50" , 1 );}
fd("50", 1);
}
#line 94 "init.pgc" #line 94 "init.pgc"
/* exec sql whenever sqlerror do fe ( ENUM0 ) ; */ /* exec sql whenever sqlerror do fe ( ENUM0 ) ; */
#line 95 "init.pgc" #line 95 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 96 "init.pgc" #line 96 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) fe ( ENUM0 );}
fe(ENUM0);
}
#line 96 "init.pgc" #line 96 "init.pgc"
/* exec sql whenever sqlerror do sqlnotice ( NULL , 0 ) ; */ /* exec sql whenever sqlerror do sqlnotice ( NULL , 0 ) ; */
#line 97 "init.pgc" #line 97 "init.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT);
#line 98 "init.pgc" #line 98 "init.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlnotice ( NULL , 0 );}
sqlnotice(NULL, 0);
}
#line 98 "init.pgc" #line 98 "init.pgc"
return 0; return 0;
......
...@@ -21,164 +21,150 @@ ...@@ -21,164 +21,150 @@
#line 4 "type.pgc" #line 4 "type.pgc"
typedef long mmInteger; typedef long mmInteger ;
#line 6 "type.pgc" #line 6 "type.pgc"
#line 6 "type.pgc" #line 6 "type.pgc"
typedef char mmChar; typedef char mmChar ;
#line 7 "type.pgc" #line 7 "type.pgc"
#line 7 "type.pgc" #line 7 "type.pgc"
typedef short mmSmallInt; typedef short mmSmallInt ;
#line 8 "type.pgc" #line 8 "type.pgc"
#line 8 "type.pgc" #line 8 "type.pgc"
/* exec sql type string is char [ 11 ] */ /* exec sql type string is char [ 11 ] */
#line 10 "type.pgc" #line 10 "type.pgc"
typedef char string[11]; typedef char string[11];
/* exec sql type c is char reference */ /* exec sql type c is char reference */
#line 13 "type.pgc" #line 13 "type.pgc"
typedef char *c; typedef char* c;
/* exec sql begin declare section */ /* exec sql begin declare section */
struct TBempl {
struct TBempl
{
#line 19 "type.pgc" #line 19 "type.pgc"
mmInteger idnum; mmInteger idnum ;
#line 20 "type.pgc" #line 20 "type.pgc"
mmChar name[21]; mmChar name [ 21 ] ;
#line 21 "type.pgc" #line 21 "type.pgc"
mmSmallInt accs; mmSmallInt accs ;
}; /* exec sql end declare section */ } ;/* exec sql end declare section */
#line 23 "type.pgc" #line 23 "type.pgc"
int int
main(void) main (void)
{ {
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 29 "type.pgc" #line 29 "type.pgc"
struct TBempl empl; struct TBempl empl ;
#line 30 "type.pgc" #line 30 "type.pgc"
string str; string str ;
#line 31 "type.pgc" #line 31 "type.pgc"
c ptr = NULL; c ptr = NULL ;
#line 36 "type.pgc" #line 36 "type.pgc"
struct varchar_vc struct varchar_vc {
{
#line 34 "type.pgc" #line 34 "type.pgc"
int len; int len ;
#line 35 "type.pgc" #line 35 "type.pgc"
char text [10]; char text [ 10 ] ;
} vc; } vc ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 37 "type.pgc" #line 37 "type.pgc"
/* exec sql var vc is [ 10 ] */ /* exec sql var vc is [ 10 ] */
#line 39 "type.pgc" #line 39 "type.pgc"
ECPGdebug(1, stderr); ECPGdebug (1, stderr);
empl.idnum = 1; empl.idnum = 1;
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
}
#line 43 "type.pgc" #line 43 "type.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode)
{ {
printf("connect error = %ld\n", sqlca.sqlcode); printf ("connect error = %ld\n", sqlca.sqlcode);
exit(sqlca.sqlcode); exit (sqlca.sqlcode);
} }
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);
}
#line 51 "type.pgc" #line 51 "type.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode)
{ {
printf("create error = %ld\n", sqlca.sqlcode); printf ("create error = %ld\n", sqlca.sqlcode);
exit(sqlca.sqlcode); exit (sqlca.sqlcode);
} }
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);
}
#line 58 "type.pgc" #line 58 "type.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode)
{ {
printf("insert error = %ld\n", sqlca.sqlcode); printf ("insert error = %ld\n", sqlca.sqlcode);
exit(sqlca.sqlcode); exit (sqlca.sqlcode);
} }
{ { ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ",
ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char),
ECPGt_char, &(empl.name), (long) 21, (long) 1, (21) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char),
ECPGt_char, (str), (long) 11, (long) 1, (11) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char),
ECPGt_char, &(ptr), (long) 0, (long) 1, (1) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar_vc),
ECPGt_varchar, &(vc), (long) 10, (long) 1, sizeof(struct varchar_vc), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
}
#line 68 "type.pgc" #line 68 "type.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode)
{ {
printf("select error = %ld\n", sqlca.sqlcode); printf ("select error = %ld\n", sqlca.sqlcode);
exit(sqlca.sqlcode); exit (sqlca.sqlcode);
} }
printf("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text); printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
{ { ECPGdisconnect(__LINE__, "CURRENT");}
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 76 "type.pgc" #line 76 "type.pgc"
free(ptr); free(ptr);
exit(0); exit (0);
} }
...@@ -25,245 +25,197 @@ ...@@ -25,245 +25,197 @@
#line 6 "variable.pgc" #line 6 "variable.pgc"
/* exec sql type c is char reference */ /* exec sql type c is char reference */
#line 8 "variable.pgc" #line 8 "variable.pgc"
typedef char *c; typedef char* c;
/* exec sql type ind is union { /* exec sql type ind is union {
#line 11 "variable.pgc" #line 11 "variable.pgc"
int integer ; int integer ;
#line 11 "variable.pgc" #line 11 "variable.pgc"
short smallint ; short smallint ;
} */ } */
#line 11 "variable.pgc" #line 11 "variable.pgc"
typedef union typedef union { int integer; short smallint; } ind;
{
int integer;
short smallint;
} ind;
#define BUFFERSIZ 8 #define BUFFERSIZ 8
/* exec sql type str is [ BUFFERSIZ ] */ /* exec sql type str is [ BUFFERSIZ ] */
#line 15 "variable.pgc" #line 15 "variable.pgc"
/* declare cur cursor for select name , born , age , married , children from family */ /* declare cur cursor for select name , born , age , married , children from family */
#line 18 "variable.pgc" #line 18 "variable.pgc"
int int
main(void) main (void)
{ {
struct birthinfo struct birthinfo {
{
#line 23 "variable.pgc" #line 23 "variable.pgc"
long born; long born ;
#line 23 "variable.pgc" #line 23 "variable.pgc"
short age; short age ;
}; } ;
#line 23 "variable.pgc" #line 23 "variable.pgc"
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 27 "variable.pgc" #line 27 "variable.pgc"
struct personal_struct struct personal_struct {
{
#line 25 "variable.pgc" #line 25 "variable.pgc"
struct varchar_name struct varchar_name { int len; char arr[ BUFFERSIZ ]; } name ;
{
int len;
char arr[BUFFERSIZ];
} name;
#line 26 "variable.pgc" #line 26 "variable.pgc"
struct birthinfo birth; struct birthinfo birth ;
} personal, *p; } personal , * p ;
#line 30 "variable.pgc" #line 30 "variable.pgc"
struct personal_indicator struct personal_indicator {
{
#line 28 "variable.pgc" #line 28 "variable.pgc"
int ind_name; int ind_name ;
#line 29 "variable.pgc" #line 29 "variable.pgc"
struct birthinfo ind_birth; struct birthinfo ind_birth ;
} ind_personal, *i; } ind_personal , * i ;
#line 31 "variable.pgc" #line 31 "variable.pgc"
ind ind_children; ind ind_children ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 32 "variable.pgc" #line 32 "variable.pgc"
#line 34 "variable.pgc" #line 34 "variable.pgc"
char *married = NULL; char * married = NULL ;
#line 34 "variable.pgc" #line 34 "variable.pgc"
#line 35 "variable.pgc" #line 35 "variable.pgc"
long ind_married; long ind_married ;
#line 35 "variable.pgc" #line 35 "variable.pgc"
#line 36 "variable.pgc" #line 36 "variable.pgc"
ind children; ind children ;
#line 36 "variable.pgc" #line 36 "variable.pgc"
char msg[128]; char msg[128];
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
strcpy(msg, "connect"); strcpy(msg, "connect");
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
#line 43 "variable.pgc" #line 43 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 43 "variable.pgc" #line 43 "variable.pgc"
strcpy(msg, "set"); strcpy(msg, "set");
{ { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 46 "variable.pgc" #line 46 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 46 "variable.pgc" #line 46 "variable.pgc"
strcpy(msg, "create"); strcpy(msg, "create");
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT);
#line 49 "variable.pgc" #line 49 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 49 "variable.pgc" #line 49 "variable.pgc"
strcpy(msg, "insert"); strcpy(msg, "insert");
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 52 "variable.pgc" #line 52 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 52 "variable.pgc" #line 52 "variable.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 53 "variable.pgc" #line 53 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 53 "variable.pgc" #line 53 "variable.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 54 "variable.pgc" #line 54 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 54 "variable.pgc" #line 54 "variable.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 55 "variable.pgc" #line 55 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 55 "variable.pgc" #line 55 "variable.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
#line 56 "variable.pgc" #line 56 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 56 "variable.pgc" #line 56 "variable.pgc"
strcpy(msg, "commit"); strcpy(msg, "commit");
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 59 "variable.pgc" #line 59 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 59 "variable.pgc" #line 59 "variable.pgc"
strcpy(msg, "open"); strcpy(msg, "open");
{ { ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT);
#line 62 "variable.pgc" #line 62 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 62 "variable.pgc" #line 62 "variable.pgc"
/* exec sql whenever not found break ; */ /* exec sql whenever not found break ; */
#line 64 "variable.pgc" #line 64 "variable.pgc"
p = &personal; p=&personal;
i = &ind_personal; i=&ind_personal;
memset(i, 0, sizeof(ind_personal)); memset(i, 0, sizeof(ind_personal));
while (1) while (1) {
{
strcpy(msg, "fetch"); strcpy(msg, "fetch");
{ { ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT, ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_name),
ECPGt_varchar, &(p->name), (long) BUFFERSIZ, (long) 1, sizeof(struct varchar_name), ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i->ind_name), (long) 1, (long) 1, sizeof(int), ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long),
ECPGt_long, &(p->birth.born), (long) 1, (long) 1, sizeof(long), ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long),
ECPGt_long, &(i->ind_birth.born), (long) 1, (long) 1, sizeof(long), ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short),
ECPGt_short, &(p->birth.age), (long) 1, (long) 1, sizeof(short), ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short),
ECPGt_short, &(i->ind_birth.age), (long) 1, (long) 1, sizeof(short), ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char),
ECPGt_char, &(married), (long) 0, (long) 1, (1) * sizeof(char), ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long),
ECPGt_long, &(ind_married), (long) 1, (long) 1, sizeof(long), ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int),
ECPGt_int, &(children.integer), (long) 1, (long) 1, sizeof(int), ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
ECPGt_short, &(ind_children.smallint), (long) 1, (long) 1, sizeof(short), ECPGt_EORT);
#line 71 "variable.pgc" #line 71 "variable.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
break;
#line 71 "variable.pgc" #line 71 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 71 "variable.pgc" #line 71 "variable.pgc"
printf("%8.8s", personal.name.arr); printf("%8.8s", personal.name.arr);
...@@ -282,46 +234,34 @@ main(void) ...@@ -282,46 +234,34 @@ main(void)
} }
strcpy(msg, "close"); strcpy(msg, "close");
{ { ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 88 "variable.pgc" #line 88 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 88 "variable.pgc" #line 88 "variable.pgc"
strcpy(msg, "drop"); strcpy(msg, "drop");
{ { ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
#line 91 "variable.pgc" #line 91 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 91 "variable.pgc" #line 91 "variable.pgc"
strcpy(msg, "commit"); strcpy(msg, "commit");
{ { ECPGtrans(__LINE__, NULL, "commit");
ECPGtrans(__LINE__, NULL, "commit");
#line 94 "variable.pgc" #line 94 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 94 "variable.pgc" #line 94 "variable.pgc"
strcpy(msg, "disconnect"); strcpy(msg, "disconnect");
{ { ECPGdisconnect(__LINE__, "CURRENT");
ECPGdisconnect(__LINE__, "CURRENT");
#line 97 "variable.pgc" #line 97 "variable.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 97 "variable.pgc" #line 97 "variable.pgc"
......
...@@ -24,288 +24,221 @@ ...@@ -24,288 +24,221 @@
#line 5 "whenever.pgc" #line 5 "whenever.pgc"
static void static void print(char *msg)
print(char *msg)
{ {
fprintf(stderr, "Error in statement '%s':\n", msg); fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint(); sqlprint();
} }
static void static void print2(void)
print2(void)
{ {
fprintf(stderr, "Found another error\n"); fprintf(stderr, "Found another error\n");
sqlprint(); sqlprint();
} }
static void static void warn(void)
warn(void)
{ {
fprintf(stderr, "Warning: At least one column was truncated\n"); fprintf(stderr, "Warning: At least one column was truncated\n");
} }
int int main(void)
main(void)
{ {
#line 26 "whenever.pgc" #line 26 "whenever.pgc"
int i; int i ;
#line 26 "whenever.pgc" #line 26 "whenever.pgc"
#line 27 "whenever.pgc" #line 27 "whenever.pgc"
char c[6]; char c [ 6 ] ;
#line 27 "whenever.pgc" #line 27 "whenever.pgc"
ECPGdebug(1, stderr); ECPGdebug(1, stderr);
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
#line 31 "whenever.pgc" #line 31 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 31 "whenever.pgc" #line 31 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( i int , c char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "create table test ( i int , c char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 32 "whenever.pgc" #line 32 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 32 "whenever.pgc" #line 32 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 33 "whenever.pgc" #line 33 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 33 "whenever.pgc" #line 33 "whenever.pgc"
/* exec sql whenever sql_warning do warn ( ) ; */ /* exec sql whenever sql_warning do warn ( ) ; */
#line 35 "whenever.pgc" #line 35 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char),
ECPGt_char, (c), (long) 6, (long) 1, (6) * sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 36 "whenever.pgc" #line 36 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 36 "whenever.pgc" #line 36 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 36 "whenever.pgc" #line 36 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 37 "whenever.pgc" #line 37 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 37 "whenever.pgc" #line 37 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 37 "whenever.pgc" #line 37 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 39 "whenever.pgc" #line 39 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 39 "whenever.pgc" #line 39 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 39 "whenever.pgc" #line 39 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 40 "whenever.pgc" #line 40 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 40 "whenever.pgc" #line 40 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) sqlprint();}
sqlprint();
}
#line 40 "whenever.pgc" #line 40 "whenever.pgc"
/* exec sql whenever sqlerror do print ( \"select\" ) ; */ /* exec sql whenever sqlerror do print ( \"select\" ) ; */
#line 42 "whenever.pgc" #line 42 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 43 "whenever.pgc" #line 43 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 43 "whenever.pgc" #line 43 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) print ( "select" );}
print("select");
}
#line 43 "whenever.pgc" #line 43 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 44 "whenever.pgc" #line 44 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 44 "whenever.pgc" #line 44 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) print ( "select" );}
print("select");
}
#line 44 "whenever.pgc" #line 44 "whenever.pgc"
/* exec sql whenever sqlerror call print2 ( ) ; */ /* exec sql whenever sqlerror call print2 ( ) ; */
#line 46 "whenever.pgc" #line 46 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 47 "whenever.pgc" #line 47 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 47 "whenever.pgc" #line 47 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) print2 ( );}
print2();
}
#line 47 "whenever.pgc" #line 47 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 48 "whenever.pgc" #line 48 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 48 "whenever.pgc" #line 48 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) print2 ( );}
print2();
}
#line 48 "whenever.pgc" #line 48 "whenever.pgc"
/* exec sql whenever sqlerror continue ; */ /* exec sql whenever sqlerror continue ; */
#line 50 "whenever.pgc" #line 50 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 51 "whenever.pgc" #line 51 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );}
warn();
}
#line 51 "whenever.pgc" #line 51 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 52 "whenever.pgc" #line 52 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );}
warn();
}
#line 52 "whenever.pgc" #line 52 "whenever.pgc"
/* exec sql whenever sqlerror goto error ; */ /* exec sql whenever sqlerror goto error ; */
#line 54 "whenever.pgc" #line 54 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 55 "whenever.pgc" #line 55 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 55 "whenever.pgc" #line 55 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) goto error;}
goto error;
}
#line 55 "whenever.pgc" #line 55 "whenever.pgc"
printf("Should not be reachable\n"); printf("Should not be reachable\n");
error: error:
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 59 "whenever.pgc" #line 59 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 59 "whenever.pgc" #line 59 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) goto error;}
goto error;
}
#line 59 "whenever.pgc" #line 59 "whenever.pgc"
/* exec sql whenever sqlerror stop ; */ /* exec sql whenever sqlerror stop ; */
#line 61 "whenever.pgc" #line 61 "whenever.pgc"
{ { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT,
ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
#line 62 "whenever.pgc" #line 62 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 62 "whenever.pgc" #line 62 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) exit (1);}
exit(1);
}
#line 62 "whenever.pgc" #line 62 "whenever.pgc"
{ { ECPGtrans(__LINE__, NULL, "rollback");
ECPGtrans(__LINE__, NULL, "rollback");
#line 63 "whenever.pgc" #line 63 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') if (sqlca.sqlwarn[0] == 'W') warn ( );
warn();
#line 63 "whenever.pgc" #line 63 "whenever.pgc"
if (sqlca.sqlcode < 0) if (sqlca.sqlcode < 0) exit (1);}
exit(1);
}
#line 63 "whenever.pgc" #line 63 "whenever.pgc"
exit(0); exit (0);
} }
...@@ -73,6 +73,7 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -73,6 +73,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
#line 1 "code100.pgc" #line 1 "code100.pgc"
...@@ -91,109 +92,73 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -91,109 +92,73 @@ struct sqlca_t *ECPGget_sqlca(void);
int int main(int argc, char **argv)
main(int argc, char **argv) { /* exec sql begin declare section */
{ /* exec sql begin declare section */
#line 9 "code100.pgc" #line 9 "code100.pgc"
int index; int index ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 10 "code100.pgc" #line 10 "code100.pgc"
ECPGdebug(1, stderr); ECPGdebug(1,stderr);
{ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
}
#line 15 "code100.pgc" #line 15 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null ) ", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null ) ", ECPGt_EOIT, ECPGt_EORT);
}
#line 20 "code100.pgc" #line 20 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); { ECPGtrans(__LINE__, NULL, "commit");}
{
ECPGtrans(__LINE__, NULL, "commit");
}
#line 22 "code100.pgc" #line 22 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
for (index=0;index<10;++index)
for (index = 0; index < 10; ++index) { { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload , index ) values ( 0 , ? ) ",
{ ECPGt_int,&(index),(long)1,(long)1,sizeof(int),
{ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload , index ) values( 0 , ? ) ",
ECPGt_int, &(index), (long) 1, (long) 1, sizeof(int),
ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
}
#line 28 "code100.pgc" #line 28 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); }
} { ECPGtrans(__LINE__, NULL, "commit");}
{
ECPGtrans(__LINE__, NULL, "commit");
}
#line 31 "code100.pgc" #line 31 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ ECPGdo(__LINE__, 0, 1, NULL, "update test set payload = payload + 1 where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);}
{
ECPGdo(__LINE__, 0, 1, NULL, "update test set payload = payload + 1 where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);
}
#line 35 "code100.pgc" #line 35 "code100.pgc"
if (sqlca.sqlcode != 100) if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ ECPGdo(__LINE__, 0, 1, NULL, "delete from test where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);}
{
ECPGdo(__LINE__, 0, 1, NULL, "delete from test where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);
}
#line 38 "code100.pgc" #line 38 "code100.pgc"
if (sqlca.sqlcode != 100) if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select * from test where index = - 1 ) ", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select * from test where index = - 1 ) ", ECPGt_EOIT, ECPGt_EORT);
}
#line 41 "code100.pgc" #line 41 "code100.pgc"
if (sqlca.sqlcode != 100) if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);}
ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
}
#line 44 "code100.pgc" #line 44 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); { ECPGtrans(__LINE__, NULL, "commit");}
{
ECPGtrans(__LINE__, NULL, "commit");
}
#line 46 "code100.pgc" #line 46 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
{ ECPGdisconnect(__LINE__, "CURRENT");}
{
ECPGdisconnect(__LINE__, "CURRENT");
}
#line 49 "code100.pgc" #line 49 "code100.pgc"
if (sqlca.sqlcode) if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return 0;
return 0;
} }
Var: Search path: "$user",public Var: Search path: public
Var: WAL buffers: 8
Var: Standard conforming strings: off Var: Standard conforming strings: off
Time Zone: PST8PDT Time Zone: pst8pdt
Transaction isolation level: read committed Transaction isolation level: read committed
This diff is collapsed.
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