diff options
Diffstat (limited to 'src/interfaces/ecpg/test/expected/thread-thread.c')
-rw-r--r-- | src/interfaces/ecpg/test/expected/thread-thread.c | 79 |
1 files changed, 33 insertions, 46 deletions
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.c b/src/interfaces/ecpg/test/expected/thread-thread.c index ae720f4d6e..5011640b32 100644 --- a/src/interfaces/ecpg/test/expected/thread-thread.c +++ b/src/interfaces/ecpg/test/expected/thread-thread.c @@ -13,19 +13,18 @@ * by Philip Yarra & Lee Kindness. */ #include <stdlib.h> +#include "ecpg_config.h" + #ifndef ENABLE_THREAD_SAFETY int main(void) { - printf("Success.\n"); + printf("No threading enabled.\n"); return 0; } #else #include <pthread.h> -#undef DEBUG - - #line 1 "regression.h" @@ -34,7 +33,7 @@ main(void) -#line 19 "thread.pgc" +#line 18 "thread.pgc" void *test_thread(void *arg); @@ -49,36 +48,34 @@ int main(int argc, char *argv[]) /* exec sql begin declare section */ -#line 31 "thread.pgc" +#line 30 "thread.pgc" int l_rows ; /* exec sql end declare section */ -#line 32 "thread.pgc" - +#line 31 "thread.pgc" - /* Switch off debug output for regression tests. The threads get executed in + /* Do not switch on debug output for regression tests. The threads get executed in * more or less random order */ - ECPGdebug(0, stderr); - + /* ECPGdebug(1, stderr); */ /* setup test_thread table */ { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } -#line 41 "thread.pgc" +#line 38 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);} -#line 42 "thread.pgc" +#line 39 "thread.pgc" /* DROP might fail */ { ECPGtrans(__LINE__, NULL, "commit");} -#line 43 "thread.pgc" +#line 40 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "create table test_thread ( tstamp timestamp not null default cast( timeofday () as timestamp ) , thread TEXT not null , iteration integer not null , primary key( thread , iteration ) ) ", ECPGt_EOIT, ECPGt_EORT);} -#line 48 "thread.pgc" +#line 45 "thread.pgc" { ECPGtrans(__LINE__, NULL, "commit");} -#line 49 "thread.pgc" +#line 46 "thread.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} -#line 50 "thread.pgc" +#line 47 "thread.pgc" /* create, and start, threads */ @@ -102,18 +99,18 @@ int main(int argc, char *argv[]) /* and check results */ { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } -#line 72 "thread.pgc" +#line 69 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "select count (*) from test_thread ", ECPGt_EOIT, ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "thread.pgc" +#line 70 "thread.pgc" { ECPGtrans(__LINE__, NULL, "commit");} -#line 74 "thread.pgc" +#line 71 "thread.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} -#line 75 "thread.pgc" +#line 72 "thread.pgc" if( l_rows == (nthreads * iterations) ) printf("Success.\n"); @@ -130,25 +127,25 @@ void *test_thread(void *arg) -#line 88 "thread.pgc" +#line 85 "thread.pgc" int l_i ; -#line 89 "thread.pgc" +#line 86 "thread.pgc" char l_connection [ 128 ] ; /* exec sql end declare section */ -#line 90 "thread.pgc" +#line 87 "thread.pgc" /* build up connection name, and connect to database */ snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); /* exec sql whenever sqlerror sqlprint ; */ -#line 94 "thread.pgc" +#line 91 "thread.pgc" { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , l_connection, 0); -#line 95 "thread.pgc" +#line 92 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 95 "thread.pgc" +#line 92 "thread.pgc" if( sqlca.sqlcode != 0 ) { @@ -156,52 +153,42 @@ if (sqlca.sqlcode < 0) sqlprint();} return( NULL ); } { ECPGtrans(__LINE__, l_connection, "begin transaction "); -#line 101 "thread.pgc" +#line 98 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 101 "thread.pgc" +#line 98 "thread.pgc" /* insert into test_thread table */ for( l_i = 1; l_i <= iterations; l_i++ ) { -#ifdef DEBUG - printf("%s: inserting %d\n", l_connection, l_i); -#endif { ECPGdo(__LINE__, 0, 1, l_connection, "insert into test_thread ( thread , iteration ) values ( ? , ? ) ", ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); -#line 109 "thread.pgc" +#line 103 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 109 "thread.pgc" +#line 103 "thread.pgc" -#ifdef DEBUG - if( sqlca.sqlcode == 0 ) - printf("%s: insert done\n", l_connection); - else + if( sqlca.sqlcode != 0 ) printf("%s: ERROR: insert failed!\n", l_connection); -#endif } /* all done */ { ECPGtrans(__LINE__, l_connection, "commit"); -#line 119 "thread.pgc" +#line 109 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 119 "thread.pgc" +#line 109 "thread.pgc" { ECPGdisconnect(__LINE__, l_connection); -#line 120 "thread.pgc" +#line 110 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 120 "thread.pgc" +#line 110 "thread.pgc" -#ifdef DEBUG - printf("%s: done!\n", l_connection); -#endif return( NULL ); } #endif /* ENABLE_THREAD_SAFETY */ |