Skip to content

Commit 04fbe0e

Browse files
author
Michael Meskes
committed
Changed order of statements and added an additiona MSVC safeguard to make ecpg
thread test cases work on Windows.
1 parent 2073c64 commit 04fbe0e

File tree

10 files changed

+124
-104
lines changed

10 files changed

+124
-104
lines changed

src/interfaces/ecpg/test/expected/thread-alloc.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,63 +128,65 @@ static void* fn(void* arg)
128128
{
129129
int i;
130130

131-
#ifdef WIN32
132-
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
133-
#endif
134-
135131
/* exec sql begin declare section */
136132

137133

138134

139135

140-
#line 44 "alloc.pgc"
136+
#line 40 "alloc.pgc"
141137
int value ;
142138

143-
#line 45 "alloc.pgc"
139+
#line 41 "alloc.pgc"
144140
char name [ 100 ] ;
145141

146-
#line 46 "alloc.pgc"
142+
#line 42 "alloc.pgc"
147143
char ** r = NULL ;
148144
/* exec sql end declare section */
149-
#line 47 "alloc.pgc"
145+
#line 43 "alloc.pgc"
146+
150147

148+
#ifdef WIN32
149+
#ifdef _MSC_VER /* requires MSVC */
150+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
151+
#endif
152+
#endif
151153

152154
value = (long)arg;
153155
sprintf(name, "Connection: %d", value);
154156

155157
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
156-
#line 52 "alloc.pgc"
158+
#line 54 "alloc.pgc"
157159

158160
if (sqlca.sqlcode < 0) sqlprint();}
159-
#line 52 "alloc.pgc"
161+
#line 54 "alloc.pgc"
160162

161163
{ ECPGsetcommit(__LINE__, "on", NULL);
162-
#line 53 "alloc.pgc"
164+
#line 55 "alloc.pgc"
163165

164166
if (sqlca.sqlcode < 0) sqlprint();}
165-
#line 53 "alloc.pgc"
167+
#line 55 "alloc.pgc"
166168

167169
for (i = 1; i <= REPEATS; ++i)
168170
{
169171
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT,
170172
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
171173
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
172-
#line 56 "alloc.pgc"
174+
#line 58 "alloc.pgc"
173175

174176
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
175-
#line 56 "alloc.pgc"
177+
#line 58 "alloc.pgc"
176178

177179
if (sqlca.sqlcode < 0) sqlprint();}
178-
#line 56 "alloc.pgc"
180+
#line 58 "alloc.pgc"
179181

180182
free(r);
181183
r = NULL;
182184
}
183185
{ ECPGdisconnect(__LINE__, name);
184-
#line 60 "alloc.pgc"
186+
#line 62 "alloc.pgc"
185187

186188
if (sqlca.sqlcode < 0) sqlprint();}
187-
#line 60 "alloc.pgc"
189+
#line 62 "alloc.pgc"
188190

189191

190192
return 0;

src/interfaces/ecpg/test/expected/thread-descriptor.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,24 @@ static void* fn(void* arg)
109109
int i;
110110

111111
#ifdef WIN32
112+
#ifdef _MSC_VER /* requires MSVC */
112113
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
114+
#endif
113115
#endif
114116

115117
for (i = 1; i <= REPEATS; ++i)
116118
{
117119
ECPGallocate_desc(__LINE__, "mydesc");
118-
#line 34 "descriptor.pgc"
120+
#line 36 "descriptor.pgc"
119121

120122
if (sqlca.sqlcode < 0) sqlprint();
121-
#line 34 "descriptor.pgc"
123+
#line 36 "descriptor.pgc"
122124

123125
ECPGdeallocate_desc(__LINE__, "mydesc");
124-
#line 35 "descriptor.pgc"
126+
#line 37 "descriptor.pgc"
125127

126128
if (sqlca.sqlcode < 0) sqlprint();
127-
#line 35 "descriptor.pgc"
129+
#line 37 "descriptor.pgc"
128130

129131
}
130132

src/interfaces/ecpg/test/expected/thread-prep.c

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -128,73 +128,75 @@ static void* fn(void* arg)
128128
{
129129
int i;
130130

131-
#ifdef WIN32
132-
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
133-
#endif
134-
135131
/* exec sql begin declare section */
136132

137133

138134

139135

140-
#line 44 "prep.pgc"
136+
#line 40 "prep.pgc"
141137
int value ;
142138

143-
#line 45 "prep.pgc"
139+
#line 41 "prep.pgc"
144140
char name [ 100 ] ;
145141

146-
#line 46 "prep.pgc"
142+
#line 42 "prep.pgc"
147143
char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
148144
/* exec sql end declare section */
149-
#line 47 "prep.pgc"
145+
#line 43 "prep.pgc"
150146

151147

148+
#ifdef WIN32
149+
#ifdef _MSC_VER /* requires MSVC */
150+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
151+
#endif
152+
#endif
153+
152154
value = (long)arg;
153155
sprintf(name, "Connection: %d", value);
154156

155157
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
156-
#line 52 "prep.pgc"
158+
#line 54 "prep.pgc"
157159

158160
if (sqlca.sqlcode < 0) sqlprint();}
159-
#line 52 "prep.pgc"
161+
#line 54 "prep.pgc"
160162

161163
{ ECPGsetcommit(__LINE__, "on", NULL);
162-
#line 53 "prep.pgc"
164+
#line 55 "prep.pgc"
163165

164166
if (sqlca.sqlcode < 0) sqlprint();}
165-
#line 53 "prep.pgc"
167+
#line 55 "prep.pgc"
166168

167169
for (i = 1; i <= REPEATS; ++i)
168170
{
169171
{ ECPGprepare(__LINE__, NULL, 0, "i", query);
170-
#line 56 "prep.pgc"
172+
#line 58 "prep.pgc"
171173

172174
if (sqlca.sqlcode < 0) sqlprint();}
173-
#line 56 "prep.pgc"
175+
#line 58 "prep.pgc"
174176

175177
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i",
176178
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
177179
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
178-
#line 57 "prep.pgc"
180+
#line 59 "prep.pgc"
179181

180182
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
181-
#line 57 "prep.pgc"
183+
#line 59 "prep.pgc"
182184

183185
if (sqlca.sqlcode < 0) sqlprint();}
184-
#line 57 "prep.pgc"
186+
#line 59 "prep.pgc"
185187

186188
}
187189
{ ECPGdeallocate(__LINE__, 0, NULL, "i");
188-
#line 59 "prep.pgc"
190+
#line 61 "prep.pgc"
189191

190192
if (sqlca.sqlcode < 0) sqlprint();}
191-
#line 59 "prep.pgc"
193+
#line 61 "prep.pgc"
192194

193195
{ ECPGdisconnect(__LINE__, name);
194-
#line 60 "prep.pgc"
196+
#line 62 "prep.pgc"
195197

196198
if (sqlca.sqlcode < 0) sqlprint();}
197-
#line 60 "prep.pgc"
199+
#line 62 "prep.pgc"
198200

199201

200202
return 0;
@@ -210,34 +212,34 @@ int main ()
210212
#endif
211213

212214
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
213-
#line 74 "prep.pgc"
215+
#line 76 "prep.pgc"
214216

215217
if (sqlca.sqlcode < 0) sqlprint();}
216-
#line 74 "prep.pgc"
218+
#line 76 "prep.pgc"
217219

218220
{ ECPGsetcommit(__LINE__, "on", NULL);
219-
#line 75 "prep.pgc"
221+
#line 77 "prep.pgc"
220222

221223
if (sqlca.sqlcode < 0) sqlprint();}
222-
#line 75 "prep.pgc"
224+
#line 77 "prep.pgc"
223225

224226
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
225-
#line 76 "prep.pgc"
227+
#line 78 "prep.pgc"
226228

227229
if (sqlca.sqlcode < 0) sqlprint();}
228-
#line 76 "prep.pgc"
230+
#line 78 "prep.pgc"
229231

230232
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
231-
#line 77 "prep.pgc"
233+
#line 79 "prep.pgc"
232234

233235
if (sqlca.sqlcode < 0) sqlprint();}
234-
#line 77 "prep.pgc"
236+
#line 79 "prep.pgc"
235237

236238
{ ECPGdisconnect(__LINE__, "CURRENT");
237-
#line 78 "prep.pgc"
239+
#line 80 "prep.pgc"
238240

239241
if (sqlca.sqlcode < 0) sqlprint();}
240-
#line 78 "prep.pgc"
242+
#line 80 "prep.pgc"
241243

242244

243245
#ifdef WIN32

src/interfaces/ecpg/test/expected/thread-thread.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,24 @@ void *test_thread(void *arg)
140140
{
141141
long threadnum = (long)arg;
142142

143-
#ifdef WIN32
144-
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
145-
#endif
146-
147143
/* exec sql begin declare section */
148144

149145

150146

151-
#line 107 "thread.pgc"
147+
#line 103 "thread.pgc"
152148
int l_i ;
153149

154-
#line 108 "thread.pgc"
150+
#line 104 "thread.pgc"
155151
char l_connection [ 128 ] ;
156152
/* exec sql end declare section */
157-
#line 109 "thread.pgc"
153+
#line 105 "thread.pgc"
154+
158155

156+
#ifdef WIN32
157+
#ifdef _MSC_VER /* requires MSVC */
158+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
159+
#endif
160+
#endif
159161

160162
/* build up connection name, and connect to database */
161163
#ifndef _MSC_VER
@@ -164,24 +166,24 @@ void *test_thread(void *arg)
164166
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
165167
#endif
166168
/* exec sql whenever sqlerror sqlprint ; */
167-
#line 117 "thread.pgc"
169+
#line 119 "thread.pgc"
168170

169171
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
170-
#line 118 "thread.pgc"
172+
#line 120 "thread.pgc"
171173

172174
if (sqlca.sqlcode < 0) sqlprint();}
173-
#line 118 "thread.pgc"
175+
#line 120 "thread.pgc"
174176

175177
if( sqlca.sqlcode != 0 )
176178
{
177179
printf("%s: ERROR: cannot connect to database!\n", l_connection);
178180
return( NULL );
179181
}
180182
{ ECPGtrans(__LINE__, l_connection, "begin");
181-
#line 124 "thread.pgc"
183+
#line 126 "thread.pgc"
182184

183185
if (sqlca.sqlcode < 0) sqlprint();}
184-
#line 124 "thread.pgc"
186+
#line 126 "thread.pgc"
185187

186188

187189
/* insert into test_thread table */
@@ -192,27 +194,27 @@ if (sqlca.sqlcode < 0) sqlprint();}
192194
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
193195
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
194196
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
195-
#line 129 "thread.pgc"
197+
#line 131 "thread.pgc"
196198

197199
if (sqlca.sqlcode < 0) sqlprint();}
198-
#line 129 "thread.pgc"
200+
#line 131 "thread.pgc"
199201

200202
if( sqlca.sqlcode != 0 )
201203
printf("%s: ERROR: insert failed!\n", l_connection);
202204
}
203205

204206
/* all done */
205207
{ ECPGtrans(__LINE__, l_connection, "commit");
206-
#line 135 "thread.pgc"
208+
#line 137 "thread.pgc"
207209

208210
if (sqlca.sqlcode < 0) sqlprint();}
209-
#line 135 "thread.pgc"
211+
#line 137 "thread.pgc"
210212

211213
{ ECPGdisconnect(__LINE__, l_connection);
212-
#line 136 "thread.pgc"
214+
#line 138 "thread.pgc"
213215

214216
if (sqlca.sqlcode < 0) sqlprint();}
215-
#line 136 "thread.pgc"
217+
#line 138 "thread.pgc"
216218

217219
return( NULL );
218220
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy