diff options
| author | Michael Meskes <meskes@postgresql.org> | 2007-03-29 12:02:24 +0000 |
|---|---|---|
| committer | Michael Meskes <meskes@postgresql.org> | 2007-03-29 12:02:24 +0000 |
| commit | ddcb5bbf76dd991b5a7024bc3d4e212b97d27936 (patch) | |
| tree | 0b6247677e8a9cf3ea60df6ae5474225f4e11ecb /src/interfaces/ecpg/test/expected/thread-thread_implicit.c | |
| parent | fba8113c1b74b9508cf2e6b7a18b0fb3637d9ba0 (diff) | |
- Added patch by Magnus Hagander <magnus@hagander.net> to use native
win32 threads.
- Fixed regression tests to run threading tests.
Diffstat (limited to 'src/interfaces/ecpg/test/expected/thread-thread_implicit.c')
| -rw-r--r-- | src/interfaces/ecpg/test/expected/thread-thread_implicit.c | 79 |
1 files changed, 33 insertions, 46 deletions
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c index c004a7d1167..1fd3faa48d5 100644 --- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c +++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c @@ -14,19 +14,18 @@ */ #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" @@ -35,7 +34,7 @@ main(void) -#line 20 "thread_implicit.pgc" +#line 19 "thread_implicit.pgc" void *test_thread(void *arg); @@ -50,36 +49,34 @@ int main(int argc, char *argv[]) /* exec sql begin declare section */ -#line 32 "thread_implicit.pgc" +#line 31 "thread_implicit.pgc" int l_rows ; /* exec sql end declare section */ -#line 33 "thread_implicit.pgc" - +#line 32 "thread_implicit.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 42 "thread_implicit.pgc" +#line 39 "thread_implicit.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);} -#line 43 "thread_implicit.pgc" +#line 40 "thread_implicit.pgc" /* DROP might fail */ { ECPGtrans(__LINE__, NULL, "commit");} -#line 44 "thread_implicit.pgc" +#line 41 "thread_implicit.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 49 "thread_implicit.pgc" +#line 46 "thread_implicit.pgc" { ECPGtrans(__LINE__, NULL, "commit");} -#line 50 "thread_implicit.pgc" +#line 47 "thread_implicit.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} -#line 51 "thread_implicit.pgc" +#line 48 "thread_implicit.pgc" /* create, and start, threads */ @@ -103,18 +100,18 @@ int main(int argc, char *argv[]) /* and check results */ { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } -#line 73 "thread_implicit.pgc" +#line 70 "thread_implicit.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 74 "thread_implicit.pgc" +#line 71 "thread_implicit.pgc" { ECPGtrans(__LINE__, NULL, "commit");} -#line 75 "thread_implicit.pgc" +#line 72 "thread_implicit.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} -#line 76 "thread_implicit.pgc" +#line 73 "thread_implicit.pgc" if( l_rows == (nthreads * iterations) ) printf("Success.\n"); @@ -131,25 +128,25 @@ void *test_thread(void *arg) -#line 89 "thread_implicit.pgc" +#line 86 "thread_implicit.pgc" int l_i ; -#line 90 "thread_implicit.pgc" +#line 87 "thread_implicit.pgc" char l_connection [ 128 ] ; /* exec sql end declare section */ -#line 91 "thread_implicit.pgc" +#line 88 "thread_implicit.pgc" /* build up connection name, and connect to database */ snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); /* exec sql whenever sqlerror sqlprint ; */ -#line 95 "thread_implicit.pgc" +#line 92 "thread_implicit.pgc" { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , l_connection, 0); -#line 96 "thread_implicit.pgc" +#line 93 "thread_implicit.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 96 "thread_implicit.pgc" +#line 93 "thread_implicit.pgc" if( sqlca.sqlcode != 0 ) { @@ -157,52 +154,42 @@ if (sqlca.sqlcode < 0) sqlprint();} return( NULL ); } { ECPGtrans(__LINE__, NULL, "begin transaction "); -#line 102 "thread_implicit.pgc" +#line 99 "thread_implicit.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 102 "thread_implicit.pgc" +#line 99 "thread_implicit.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, NULL, "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 110 "thread_implicit.pgc" +#line 104 "thread_implicit.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 110 "thread_implicit.pgc" +#line 104 "thread_implicit.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__, NULL, "commit"); -#line 120 "thread_implicit.pgc" +#line 110 "thread_implicit.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 120 "thread_implicit.pgc" +#line 110 "thread_implicit.pgc" { ECPGdisconnect(__LINE__, l_connection); -#line 121 "thread_implicit.pgc" +#line 111 "thread_implicit.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 121 "thread_implicit.pgc" +#line 111 "thread_implicit.pgc" -#ifdef DEBUG - printf("%s: done!\n", l_connection); -#endif return( NULL ); } #endif /* ENABLE_THREAD_SAFETY */ |
