7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
9 #line 1 "thread_implicit.pgc"
16 #include "ecpg_config.h"
18 #ifndef ENABLE_THREAD_SAFETY
22 printf(
"No threading enabled.\n");
34 #line 1 "regression.h"
41 #line 24 "thread_implicit.pgc"
44 void *test_thread(
void *
arg);
60 #line 40 "thread_implicit.pgc"
63 #line 41 "thread_implicit.pgc"
71 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL , NULL, 0); }
72 #line 48 "thread_implicit.pgc"
75 #line 49 "thread_implicit.pgc"
78 #line 50 "thread_implicit.pgc"
80 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,
"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);}
81 #line 55 "thread_implicit.pgc"
84 #line 56 "thread_implicit.pgc"
87 #line 57 "thread_implicit.pgc"
94 fprintf(stderr,
"Cannot alloc memory\n");
100 pthread_create(&threads[n], NULL, test_thread, (
void *) (n + 1));
102 threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) (
void (*) (
void)) test_thread, (
void *) (n+1), 0, NULL);
110 pthread_join(threads[n], NULL);
113 WaitForMultipleObjects(
nthreads, threads, TRUE, INFINITE);
118 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL , NULL, 0); }
119 #line 87 "thread_implicit.pgc"
122 ECPGt_int,&(l_rows),(
long)1,(
long)1,
sizeof(
int),
124 #line 88 "thread_implicit.pgc"
127 #line 89 "thread_implicit.pgc"
130 #line 90 "thread_implicit.pgc"
132 if( l_rows == (
nthreads * iterations) )
135 printf(
"ERROR: Failure - expecting %d rows, got %d.\n",
nthreads * iterations, l_rows);
140 void *test_thread(
void *
arg)
142 long threadnum = (intptr_t)
arg;
148 #line 104 "thread_implicit.pgc"
151 #line 105 "thread_implicit.pgc"
152 char l_connection [ 128 ] ;
154 #line 106 "thread_implicit.pgc"
159 snprintf(l_connection,
sizeof(l_connection),
"thread_%03ld", threadnum);
161 _snprintf(l_connection,
sizeof(l_connection),
"thread_%03ld", threadnum);
164 #line 114 "thread_implicit.pgc"
166 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL , l_connection, 0);
167 #line 115 "thread_implicit.pgc"
170 #line 115 "thread_implicit.pgc"
172 if(
sqlca.sqlcode != 0 )
174 printf(
"%s: ERROR: cannot connect to database!\n", l_connection);
178 #line 121 "thread_implicit.pgc"
181 #line 121 "thread_implicit.pgc"
185 for( l_i = 1; l_i <= iterations; l_i++ )
187 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,
"insert into test_thread ( thread , iteration ) values ( $1 , $2 )",
188 ECPGt_char,(l_connection),(
long)128,(
long)1,(128)*
sizeof(
char),
190 ECPGt_int,&(l_i),(
long)1,(
long)1,
sizeof(
int),
192 #line 126 "thread_implicit.pgc"
195 #line 126 "thread_implicit.pgc"
197 if(
sqlca.sqlcode != 0 )
198 printf(
"%s: ERROR: insert failed!\n", l_connection);
203 #line 132 "thread_implicit.pgc"
206 #line 132 "thread_implicit.pgc"
209 #line 133 "thread_implicit.pgc"
212 #line 133 "thread_implicit.pgc"
bool ECPGdisconnect(int lineno, const char *connection_name)
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)