diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule index c3ec125..5f7fe5b 100644 --- a/src/interfaces/ecpg/test/ecpg_schedule +++ b/src/interfaces/ecpg/test/ecpg_schedule @@ -48,6 +48,7 @@ test: sql/quote test: sql/show test: sql/insupd test: sql/parser +test: sql/declare test: thread/thread test: thread/thread_implicit test: thread/prep diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c index 1f316fb..b4a7c44 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c @@ -241,7 +241,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", + { ECPGopen("mycur1", "st_id1", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 101 "sqlda.pgc" @@ -258,7 +258,7 @@ if (sqlca.sqlcode < 0) exit (1);} while (1) { strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, + { ECPGfetch("mycur1", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 109 "sqlda.pgc" @@ -279,7 +279,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "close"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("mycur1", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); #line 118 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} @@ -316,7 +316,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", + { ECPGopen("mycur2", "st_id2", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 138 "sqlda.pgc" @@ -333,7 +333,7 @@ if (sqlca.sqlcode < 0) exit (1);} while (1) { strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, + { ECPGfetch("mycur2", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 146 "sqlda.pgc" @@ -354,7 +354,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "close"); - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("mycur2", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); #line 155 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c index 9934947..48b9197 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c @@ -158,7 +158,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );} while (1) { - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, + { ECPGfetch("c", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), @@ -244,7 +244,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );} static void openit(void) { - { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", + { ECPGopen("c", NULL, __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", ECPGt_int,&(*( int *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 95 "test_informix.pgc" diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c index ecd2343..2df8353 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c @@ -84,7 +84,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} /* declare cur cursor for select id , d , d from nantest1 */ #line 35 "nan_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); #line 36 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} @@ -92,7 +92,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, + { ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(d),(long)1,(long)1,sizeof(double), @@ -132,14 +132,14 @@ if (sqlca.sqlcode < 0) sqlprint ( );} #line 48 "nan_test.pgc" } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 50 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 50 "nan_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); #line 52 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} @@ -147,7 +147,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, + { ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(d),(long)1,(long)1,sizeof(double), @@ -166,7 +166,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} if (isnan(d)) printf("%d NaN '%s'\n", id, val); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 63 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} @@ -223,7 +223,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} /* declare cur1 cursor for select id , d , d from nantest2 */ #line 77 "nan_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("cur1", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT); #line 78 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} @@ -231,7 +231,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, + { ECPGfetch("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), @@ -247,7 +247,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} break; printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); #line 86 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c index 10ede3e..e3abb29 100644 --- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c +++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c @@ -133,7 +133,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 35 "autoprep.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT); #line 37 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -143,7 +143,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 37 "autoprep.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 39 "autoprep.pgc" @@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("i = %d\n", i); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); #line 42 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 46 "autoprep.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", + { ECPGopen("cur1", "stmt1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 48 "autoprep.pgc" @@ -199,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();} i = 0; while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, + { ECPGfetch("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT); #line 55 "autoprep.pgc" @@ -217,7 +217,7 @@ if (sqlca.sqlcode < 0) sqlprint();} i++; } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); #line 60 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c index f7da753..ad86a56 100644 --- a/src/interfaces/ecpg/test/expected/preproc-cursor.c +++ b/src/interfaces/ecpg/test/expected/preproc-cursor.c @@ -187,7 +187,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", + { ECPGopen(":curname1", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 67 "cursor.pgc" @@ -197,7 +197,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -212,7 +212,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -227,7 +227,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -243,7 +243,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count from"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), @@ -260,7 +260,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "move in"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 in $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 in $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 87 "cursor.pgc" @@ -270,7 +270,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch 1"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -286,7 +286,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", + { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), @@ -303,7 +303,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", + { ECPGclose(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 99 "cursor.pgc" @@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", + { ECPGopen(":curname2", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -337,7 +337,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -352,7 +352,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -367,7 +367,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -383,7 +383,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count from"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), @@ -400,7 +400,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "move"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -414,7 +414,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch 1"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -430,7 +430,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", + { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), @@ -447,7 +447,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", + { ECPGclose(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 140 "cursor.pgc" @@ -483,7 +483,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", + { ECPGopen(":curname3", "st_id1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), @@ -493,7 +493,7 @@ if (sqlca.sqlcode < 0) exit (1);} if (sqlca.sqlcode < 0) exit (1);} #line 153 "cursor.pgc" - { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 cursor for $1", + { ECPGopen(":curname5", "st_id1", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 cursor for $1", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), @@ -505,7 +505,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "fetch $0", + { ECPGfetch(":curname5", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "fetch $0", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -520,7 +520,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -535,7 +535,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -551,7 +551,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count from"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), @@ -568,7 +568,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "move"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 174 "cursor.pgc" @@ -578,7 +578,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch 1"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -594,7 +594,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", + { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), @@ -611,7 +611,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", + { ECPGclose(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 186 "cursor.pgc" @@ -619,7 +619,7 @@ if (sqlca.sqlcode < 0) exit (1);} if (sqlca.sqlcode < 0) exit (1);} #line 186 "cursor.pgc" - { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0", + { ECPGclose(":curname5", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 187 "cursor.pgc" @@ -663,7 +663,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", + { ECPGopen(":curname4", "st_id2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), @@ -675,7 +675,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -690,7 +690,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -705,7 +705,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -721,7 +721,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count from"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), @@ -738,7 +738,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "move"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 226 "cursor.pgc" @@ -748,7 +748,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch 1"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), @@ -764,7 +764,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch :count"); count = 1; - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", + { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), @@ -781,7 +781,7 @@ if (sqlca.sqlcode < 0) exit (1);} printf("%d %s\n", id, t); strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", + { ECPGclose(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 238 "cursor.pgc" diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c index 348e843..23ce610 100644 --- a/src/interfaces/ecpg/test/expected/preproc-outofscope.c +++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.c @@ -201,7 +201,7 @@ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0) static void open_cur1(void) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, + { ECPGopen("mycur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ), ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ), @@ -225,7 +225,7 @@ if (sqlca.sqlcode < 0) exit (1);} static void get_record1(void) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, + { ECPGfetch("mycur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ), ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ), @@ -249,7 +249,7 @@ if (sqlca.sqlcode < 0) exit (1);} static void close_cur1(void) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("mycur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT); #line 58 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c index 7fd03ba..722c02e 100644 --- a/src/interfaces/ecpg/test/expected/preproc-variable.c +++ b/src/interfaces/ecpg/test/expected/preproc-variable.c @@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT); #line 63 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} @@ -206,7 +206,7 @@ if (sqlca.sqlcode < 0) exit (1);} memset(i, 0, sizeof(ind_personal)); while (1) { strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur", ECPGt_EOIT, + { ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur", ECPGt_EOIT, ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)-1,sizeof( struct birthinfo ), ECPGt_int,&(i->ind_name),(long)1,(long)-1,sizeof( struct birthinfo ), ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof( struct birthinfo ), @@ -241,7 +241,7 @@ if (sqlca.sqlcode < 0) exit (1);} } strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 89 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c index b91ab7b..ce64de5 100644 --- a/src/interfaces/ecpg/test/expected/sql-binary.c +++ b/src/interfaces/ecpg/test/expected/sql-binary.c @@ -111,12 +111,12 @@ main (void) /* declare C cursor for select name , accs , byte from empl where idnum = $1 */ #line 58 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", + { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 59 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), @@ -133,7 +133,7 @@ main (void) printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);} + { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);} #line 69 "binary.pgc" @@ -142,12 +142,12 @@ main (void) /* declare B binary cursor for select name , accs , byte from empl where idnum = $1 */ #line 72 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", + { ECPGopen("B", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 73 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch B", ECPGt_EOIT, + { ECPGfetch("B", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch B", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), @@ -162,7 +162,7 @@ main (void) exit (sqlca.sqlcode); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT);} + { ECPGclose("B", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT);} #line 81 "binary.pgc" @@ -176,12 +176,12 @@ main (void) /* declare A binary cursor for select byte from empl where idnum = $1 */ #line 89 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", + { ECPGopen("A", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 90 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch A", ECPGt_EOIT, + { ECPGfetch("A", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch A", ECPGt_EOIT, ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 91 "binary.pgc" @@ -192,7 +192,7 @@ main (void) exit (sqlca.sqlcode); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT);} + { ECPGclose("A", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT);} #line 98 "binary.pgc" diff --git a/src/interfaces/ecpg/test/expected/sql-declare.c b/src/interfaces/ecpg/test/expected/sql-declare.c new file mode 100644 index 0000000..342134b --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-declare.c @@ -0,0 +1,375 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "declare.pgc" +#include +#include +#include + +/* exec sql whenever sqlerror sqlprint ; */ +#line 5 "declare.pgc" + + + +#line 1 "sqlca.h" +#ifndef POSTGRES_SQLCA_H +#define POSTGRES_SQLCA_H + +#ifndef PGDLLIMPORT +#if defined(WIN32) || defined(__CYGWIN__) +#define PGDLLIMPORT __declspec (dllimport) +#else +#define PGDLLIMPORT +#endif /* __CYGWIN__ */ +#endif /* PGDLLIMPORT */ + +#define SQLERRMC_LEN 150 + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct sqlca_t +{ + char sqlcaid[8]; + long sqlabc; + long sqlcode; + struct + { + int sqlerrml; + char sqlerrmc[SQLERRMC_LEN]; + } sqlerrm; + char sqlerrp[8]; + long sqlerrd[6]; + /* Element 0: empty */ + /* 1: OID of processed tuple if applicable */ + /* 2: number of rows processed */ + /* after an INSERT, UPDATE or */ + /* DELETE statement */ + /* 3: empty */ + /* 4: empty */ + /* 5: empty */ + char sqlwarn[8]; + /* Element 0: set to 'W' if at least one other is 'W' */ + /* 1: if 'W' at least one character string */ + /* value was truncated when it was */ + /* stored into a host variable. */ + + /* + * 2: if 'W' a (hopefully) non-fatal notice occurred + */ /* 3: empty */ + /* 4: empty */ + /* 5: empty */ + /* 6: empty */ + /* 7: empty */ + + char sqlstate[5]; +}; + +struct sqlca_t *ECPGget_sqlca(void); + +#ifndef POSTGRES_ECPG_INTERNAL +#define sqlca (*ECPGget_sqlca()) +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +#line 7 "declare.pgc" + + +#line 1 "regression.h" + + + + + + +#line 8 "declare.pgc" + + +#define ARRAY_SZIE 20 + +void execute_test(void); +void commitTable(void); +void reset(void); +void printResult(char *tc_name, int loop); + +/* exec sql begin declare section */ + + + + +#line 18 "declare.pgc" + int f1 [ ARRAY_SZIE ] ; + +#line 19 "declare.pgc" + int f2 [ ARRAY_SZIE ] ; + +#line 20 "declare.pgc" + char f3 [ ARRAY_SZIE ] [ 20 ] ; +/* exec sql end declare section */ +#line 21 "declare.pgc" + + +int main(void) +{ + setlocale(LC_ALL, "C"); + + ECPGdebug(1, stderr); + + { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con1", 0); +#line 29 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 29 "declare.pgc" + + { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "con2", 0); +#line 30 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 30 "declare.pgc" + + + { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT); +#line 32 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 32 "declare.pgc" + + { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT); +#line 33 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 33 "declare.pgc" + + + { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT); +#line 35 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 35 "declare.pgc" + + { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT); +#line 36 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 36 "declare.pgc" + + + { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT); +#line 38 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 38 "declare.pgc" + + { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT); +#line 39 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 39 "declare.pgc" + + + commitTable(); + + execute_test(); + + { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT); +#line 45 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 45 "declare.pgc" + + { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT); +#line 46 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 46 "declare.pgc" + + + commitTable(); + + { ECPGdisconnect(__LINE__, "ALL"); +#line 50 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 50 "declare.pgc" + + + return 0; +} + +/* + * default connection: con2 + * Non-default connection: con1 + * + */ +void execute_test(void) +{ + /* exec sql begin declare section */ + + + +#line 63 "declare.pgc" + int i ; + +#line 64 "declare.pgc" + char * selectString = "SELECT f1,f2,f3 FROM source" ; +/* exec sql end declare section */ +#line 65 "declare.pgc" + + + /* testcase1. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement*/ + reset(); + + { ECPGdeclare(__LINE__, "con1", "stmt_1"); +#line 70 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 70 "declare.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt_1", selectString); +#line 71 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 71 "declare.pgc" + + /* declare cur_1 cursor for $1 */ +#line 72 "declare.pgc" + + { ECPGopen("cur_1", "stmt_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_1 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 73 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 73 "declare.pgc" + + + /* exec sql whenever not found break ; */ +#line 75 "declare.pgc" + + i = 0; + while (1) + { + { ECPGfetch("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_1", ECPGt_EOIT, + ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 79 "declare.pgc" + +if (sqlca.sqlcode == ECPG_NOT_FOUND) break; +#line 79 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 79 "declare.pgc" + + i++; + } + + { ECPGclose("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_1", ECPGt_EOIT, ECPGt_EORT); +#line 83 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 83 "declare.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt_1"); +#line 84 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 84 "declare.pgc" + + /* exec sql whenever not found continue ; */ +#line 85 "declare.pgc" + + + printResult("testcase1", 2); + + /* testcase2. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement*/ + reset(); + + { ECPGdeclare(__LINE__, NULL, "stmt_2"); +#line 92 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 92 "declare.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt_2", selectString); +#line 93 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 93 "declare.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_2", ECPGt_EOIT, + ECPGt_int,(f1),(long)1,(long)ARRAY_SZIE,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_int,(f2),(long)1,(long)ARRAY_SZIE,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(f3),(long)20,(long)ARRAY_SZIE,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 94 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 94 "declare.pgc" + + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt_2"); +#line 96 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 96 "declare.pgc" + + + printResult("testcase2", 2); +} + +void commitTable() +{ + { ECPGtrans(__LINE__, "con1", "commit"); +#line 103 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 103 "declare.pgc" + + { ECPGtrans(__LINE__, "con2", "commit"); +#line 104 "declare.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 104 "declare.pgc" + +} + +/* + * reset all the output variables + */ +void reset() +{ + memset(f1, 0, sizeof(f1)); + memset(f2, 0, sizeof(f2)); + memset(f3, 0, sizeof(f3)); +} + +void printResult(char *tc_name, int loop) +{ + int i; + + if (tc_name) + printf("****%s test results:****\n", tc_name); + + for (i = 0; i < loop; i++) + printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]); + + printf("\n"); +} diff --git a/src/interfaces/ecpg/test/expected/sql-declare.stderr b/src/interfaces/ecpg/test/expected/sql-declare.stderr new file mode 100644 index 0000000..3693f8b --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-declare.stderr @@ -0,0 +1,140 @@ +[NO_PID]: ECPGdebug: set to 1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGconnect: opening database ecpg1_regression on port +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGconnect: opening database ecpg2_regression on port +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 32: query: create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 32: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 32: OK: CREATE TABLE +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 33: query: create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 33: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 33: OK: CREATE TABLE +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 35: query: insert into source values ( 1 , 10 , 'db on con1' ); with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 35: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 35: OK: INSERT 0 1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 36: query: insert into source values ( 2 , 20 , 'db on con1' ); with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 36: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 36: OK: INSERT 0 1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 38: query: insert into source values ( 1 , 10 , 'db on con2' ); with 0 parameter(s) on connection con2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 38: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 38: OK: INSERT 0 1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 39: query: insert into source values ( 2 , 20 , 'db on con2' ); with 0 parameter(s) on connection con2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 39: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 39: OK: INSERT 0 1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGtrans on line 103: action "commit"; connection "con1" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGtrans on line 104: action "commit"; connection "con2" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGdeclare on line 70: declared name stmt_1 on connection: "con1" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: prepare_common on line 71: name stmt_1; query: "SELECT f1,f2,f3 FROM source" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 73: query: declare cur_1 cursor for SELECT f1,f2,f3 FROM source; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 73: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 73: OK: DECLARE CURSOR +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: query: fetch cur_1; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: 1 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: 10 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: db on con1 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: query: fetch cur_1; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: 2 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: 20 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 79: RESULT: db on con1 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: query: fetch cur_1; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 79: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 79: correctly got 0 tuples with 3 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: raising sqlcode 100 on line 79: no data found on line 79 +[NO_PID]: sqlca: code: 100, state: 02000 +[NO_PID]: ecpg_execute on line 83: query: close cur_1; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 83: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 83: OK: CLOSE CURSOR +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: deallocate_one on line 84: name stmt_1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: prepare_common on line 93: name stmt_2; query: "SELECT f1,f2,f3 FROM source" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 94: query: SELECT f1,f2,f3 FROM source; with 0 parameter(s) on connection con2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 94: using PQexecPrepared for "SELECT f1,f2,f3 FROM source" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 94: correctly got 2 tuples with 3 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: 1 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: 2 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: 10 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: 20 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: db on con2 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 94: RESULT: db on con2 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: deallocate_one on line 96: name stmt_2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 45: query: drop table if exists source; with 0 parameter(s) on connection con1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 45: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 45: OK: DROP TABLE +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 46: query: drop table if exists source; with 0 parameter(s) on connection con2 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 46: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 46: OK: DROP TABLE +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGtrans on line 103: action "commit"; connection "con1" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ECPGtrans on line 104: action "commit"; connection "con2" +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_finish: connection con2 closed +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_release_declared_statement: declared name stmt_1 is released +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_finish: connection con1 closed +[NO_PID]: sqlca: code: 0, state: 00000 diff --git a/src/interfaces/ecpg/test/expected/sql-declare.stdout b/src/interfaces/ecpg/test/expected/sql-declare.stdout new file mode 100644 index 0000000..d80d079 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-declare.stdout @@ -0,0 +1,8 @@ +****testcase1 test results:**** +f1=1, f2=10, f3=db on con1 +f1=2, f2=20, f3=db on con1 + +****testcase2 test results:**** +f1=1, f2=10, f3=db on con2 +f1=2, f2=20, f3=db on con2 + diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c index bdd12a5..bcfe1bd 100644 --- a/src/interfaces/ecpg/test/expected/sql-desc.c +++ b/src/interfaces/ecpg/test/expected/sql-desc.c @@ -249,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();} /* declare c1 cursor for $1 */ #line 58 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 cursor for $1", + { ECPGopen("c1", "foo2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_descriptor, "indesc", 1L, 1L, 1L, @@ -260,7 +260,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 59 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c1", ECPGt_EOIT, + { ECPGfetch("c1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c1", ECPGt_EOIT, ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), @@ -273,7 +273,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n", val1output, ind1, val2output, ind2); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("c1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT); #line 65 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -299,7 +299,7 @@ if (sqlca.sqlcode < 0) sqlprint();} /* declare c2 cursor for $1 */ #line 70 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 cursor for $1", + { ECPGopen("c2", "foo3", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo3", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_descriptor, "indesc", 1L, 1L, 1L, @@ -310,7 +310,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 71 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT, + { ECPGfetch("c2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT, ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), @@ -322,7 +322,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("c2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT); #line 76 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c index 2cbc196..dff22aa 100644 --- a/src/interfaces/ecpg/test/expected/sql-dyntest.c +++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c @@ -261,7 +261,7 @@ if (sqlca.sqlcode < 0) error ( );} #line 58 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare MYCURS cursor for $1", + { ECPGopen("MYCURS", "myquery", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare MYCURS cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "myquery", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 60 "dyntest.pgc" @@ -272,7 +272,7 @@ if (sqlca.sqlcode < 0) error ( );} while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, + { ECPGfetch("MYCURS", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, ECPGt_descriptor, "MYDESC", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 64 "dyntest.pgc" @@ -468,7 +468,7 @@ if (sqlca.sqlcode < 0) error ( );} } } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close MYCURS", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("MYCURS", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close MYCURS", ECPGt_EOIT, ECPGt_EORT); #line 194 "dyntest.pgc" if (sqlca.sqlcode < 0) error ( );} diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c index aee3c1b..c511349 100644 --- a/src/interfaces/ecpg/test/expected/sql-execute.c +++ b/src/interfaces/ecpg/test/expected/sql-execute.c @@ -140,7 +140,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 50 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR cursor for $1", + { ECPGopen("CUR", "f", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 52 "execute.pgc" @@ -148,7 +148,7 @@ if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();} #line 52 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, + { ECPGfetch("CUR", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), @@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("CUR", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT); #line 66 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -205,7 +205,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 72 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR2 cursor for $1", + { ECPGopen("CUR2", "f", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_const,"1",(long)1,(long)1,strlen("1"), @@ -215,7 +215,7 @@ if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();} #line 74 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, + { ECPGfetch("CUR2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), @@ -247,7 +247,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR2", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("CUR2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR2", ECPGt_EOIT, ECPGt_EORT); #line 88 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c index b547b25..e6beaf5 100644 --- a/src/interfaces/ecpg/test/expected/sql-fetch.c +++ b/src/interfaces/ecpg/test/expected/sql-fetch.c @@ -99,7 +99,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 26 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT); #line 28 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -113,7 +113,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 30 "fetch.pgc" while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), @@ -135,7 +135,7 @@ if (sqlca.sqlcode < 0) sqlprint();} /* exec sql whenever not found continue ; */ #line 36 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT); + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT); #line 37 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 37 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C", + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), @@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("%d: %s\n", i, str); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); #line 42 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -176,7 +176,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 44 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", + { ECPGopen("D", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", ECPGt_const,"1",(long)1,(long)1,strlen("1"), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 46 "fetch.pgc" @@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 48 "fetch.pgc" while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, + { ECPGfetch("D", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), @@ -210,7 +210,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("%d: %s\n", i, str); } - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("D", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT); #line 53 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.c b/src/interfaces/ecpg/test/expected/sql-oldexec.c index 5b74dda..2e398c2 100644 --- a/src/interfaces/ecpg/test/expected/sql-oldexec.c +++ b/src/interfaces/ecpg/test/expected/sql-oldexec.c @@ -141,7 +141,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 51 "oldexec.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR cursor for $1", + { ECPGopen("CUR", "f", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 53 "oldexec.pgc" @@ -149,7 +149,7 @@ if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();} #line 53 "oldexec.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, + { ECPGfetch("CUR", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), @@ -171,7 +171,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("CUR", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT); #line 65 "oldexec.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 70 "oldexec.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1", + { ECPGopen("CUR3", "f", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_const,"1",(long)1,(long)1,strlen("1"), @@ -200,7 +200,7 @@ if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();} #line 72 "oldexec.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, + { ECPGfetch("CUR3", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), @@ -222,7 +222,7 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("CUR3", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT); #line 84 "oldexec.pgc" if (sqlca.sqlcode < 0) sqlprint();} diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c index 0a3b77c..ec03612 100644 --- a/src/interfaces/ecpg/test/expected/sql-quote.c +++ b/src/interfaces/ecpg/test/expected/sql-quote.c @@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();} #line 43 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT); + { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT); #line 45 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); @@ -178,7 +178,7 @@ if (sqlca.sqlcode < 0) sqlprint();} while (true) { - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, + { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.c b/src/interfaces/ecpg/test/expected/sql-sqlda.c index b470b04..6bfcbe2 100644 --- a/src/interfaces/ecpg/test/expected/sql-sqlda.c +++ b/src/interfaces/ecpg/test/expected/sql-sqlda.c @@ -251,7 +251,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", + { ECPGopen("mycur1", "st_id1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 103 "sqlda.pgc" @@ -268,7 +268,7 @@ if (sqlca.sqlcode < 0) exit (1);} while (1) { strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, + { ECPGfetch("mycur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 111 "sqlda.pgc" @@ -289,7 +289,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("mycur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); #line 120 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} @@ -324,7 +324,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", + { ECPGopen("mycur2", "st_id2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 138 "sqlda.pgc" @@ -334,7 +334,7 @@ if (sqlca.sqlcode < 0) exit (1);} strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, + { ECPGfetch("mycur2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 141 "sqlda.pgc" @@ -357,7 +357,7 @@ if (sqlca.sqlcode < 0) exit (1);} } strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); + { ECPGclose("mycur2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); #line 157 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} diff --git a/src/interfaces/ecpg/test/sql/.gitignore b/src/interfaces/ecpg/test/sql/.gitignore index cd6f342..83bc47e 100644 --- a/src/interfaces/ecpg/test/sql/.gitignore +++ b/src/interfaces/ecpg/test/sql/.gitignore @@ -6,6 +6,8 @@ /code100.c /copystdout /copystdout.c +/declare +/declare.c /define /define.c /desc diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile index 6bc67e9..d313464 100644 --- a/src/interfaces/ecpg/test/sql/Makefile +++ b/src/interfaces/ecpg/test/sql/Makefile @@ -22,7 +22,8 @@ TESTS = array array.c \ parser parser.c \ quote quote.c \ show show.c \ - insupd insupd.c + insupd insupd.c \ + declare declare.c all: $(TESTS) diff --git a/src/interfaces/ecpg/test/sql/declare.pgc b/src/interfaces/ecpg/test/sql/declare.pgc new file mode 100644 index 0000000..f307341 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/declare.pgc @@ -0,0 +1,128 @@ +#include +#include +#include + +EXEC SQL WHENEVER SQLERROR SQLPRINT; + +EXEC SQL INCLUDE sqlca; +EXEC SQL INCLUDE ../regression; + +#define ARRAY_SZIE 20 + +void execute_test(void); +void commitTable(void); +void reset(void); +void printResult(char *tc_name, int loop); + +EXEC SQL BEGIN DECLARE SECTION; +int f1[ARRAY_SZIE]; +int f2[ARRAY_SZIE]; +char f3[ARRAY_SZIE][20]; +EXEC SQL END DECLARE SECTION; + +int main(void) +{ + setlocale(LC_ALL, "C"); + + ECPGdebug(1, stderr); + + EXEC SQL CONNECT TO REGRESSDB1 AS con1; + EXEC SQL CONNECT TO REGRESSDB2 AS con2; + + EXEC SQL AT con1 CREATE TABLE source(f1 integer, f2 integer, f3 varchar(20)); + EXEC SQL AT con2 CREATE TABLE source(f1 integer, f2 integer, f3 varchar(20)); + + EXEC SQL AT con1 INSERT INTO source VALUES(1, 10, 'db on con1'); + EXEC SQL AT con1 INSERT INTO source VALUES(2, 20, 'db on con1'); + + EXEC SQL AT con2 INSERT INTO source VALUES(1, 10, 'db on con2'); + EXEC SQL AT con2 INSERT INTO source VALUES(2, 20, 'db on con2'); + + commitTable(); + + execute_test(); + + EXEC SQL AT con1 DROP TABLE IF EXISTS source; + EXEC SQL AT con2 DROP TABLE IF EXISTS source; + + commitTable(); + + EXEC SQL DISCONNECT ALL; + + return 0; +} + +/* + * default connection: con2 + * Non-default connection: con1 + * + */ +void execute_test(void) +{ + EXEC SQL BEGIN DECLARE SECTION; + int i; + char *selectString = "SELECT f1,f2,f3 FROM source"; + EXEC SQL END DECLARE SECTION; + + /* testcase1. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement*/ + reset(); + + EXEC SQL AT con1 DECLARE stmt_1 STATEMENT; + EXEC SQL PREPARE stmt_1 FROM :selectString; + EXEC SQL DECLARE cur_1 CURSOR FOR stmt_1; + EXEC SQL OPEN cur_1; + + EXEC SQL WHENEVER NOT FOUND DO BREAK; + i = 0; + while (1) + { + EXEC SQL FETCH cur_1 INTO :f1[i], :f2[i], :f3[i]; + i++; + } + + EXEC SQL CLOSE cur_1; + EXEC SQL DEALLOCATE PREPARE stmt_1; + EXEC SQL WHENEVER NOT FOUND CONTINUE; + + printResult("testcase1", 2); + + /* testcase2. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement*/ + reset(); + + EXEC SQL DECLARE stmt_2 STATEMENT; + EXEC SQL PREPARE stmt_2 FROM :selectString; + EXEC SQL EXECUTE stmt_2 INTO :f1, :f2, :f3; + + EXEC SQL DEALLOCATE PREPARE stmt_2; + + printResult("testcase2", 2); +} + +void commitTable() +{ + EXEC SQL AT con1 COMMIT; + EXEC SQL AT con2 COMMIT; +} + +/* + * reset all the output variables + */ +void reset() +{ + memset(f1, 0, sizeof(f1)); + memset(f2, 0, sizeof(f2)); + memset(f3, 0, sizeof(f3)); +} + +void printResult(char *tc_name, int loop) +{ + int i; + + if (tc_name) + printf("****%s test results:****\n", tc_name); + + for (i = 0; i < loop; i++) + printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]); + + printf("\n"); +}