Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit839ee18

Browse files
author
Michael Meskes
committed
Make setlocale in ECPG test cases thread aware on Windows.
Fix threaded test cases on Windows not to crash in setlocale() which can beglobal or local to a thread on Windows.Author: Christian Ullrich
1 parente5c8d43 commit839ee18

File tree

10 files changed

+163
-109
lines changed

10 files changed

+163
-109
lines changed

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ main(void)
2222
#defineWIN32_LEAN_AND_MEAN
2323
#include<windows.h>
2424
#include<process.h>
25+
#include<locale.h>
2526
#else
2627
#include<pthread.h>
2728
#endif
@@ -99,7 +100,7 @@ struct sqlca_t *ECPGget_sqlca(void);
99100

100101
#endif
101102

102-
#line24 "alloc.pgc"
103+
#line25 "alloc.pgc"
103104

104105

105106
#line 1 "regression.h"
@@ -109,14 +110,14 @@ struct sqlca_t *ECPGget_sqlca(void);
109110

110111

111112

112-
#line25 "alloc.pgc"
113+
#line26 "alloc.pgc"
113114

114115

115116
/* exec sql whenever sqlerror sqlprint ; */
116-
#line27 "alloc.pgc"
117+
#line28 "alloc.pgc"
117118

118119
/* exec sql whenever not found sqlprint ; */
119-
#line28 "alloc.pgc"
120+
#line29 "alloc.pgc"
120121

121122

122123
#ifdefWIN32
@@ -127,59 +128,63 @@ static void* fn(void* arg)
127128
{
128129
inti;
129130

131+
#ifdefWIN32
132+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
133+
#endif
134+
130135
/* exec sql begin declare section */
131136

132137

133138

134139

135-
#line39 "alloc.pgc"
140+
#line44 "alloc.pgc"
136141
intvalue ;
137142

138-
#line40 "alloc.pgc"
143+
#line45 "alloc.pgc"
139144
charname [100 ] ;
140145

141-
#line41 "alloc.pgc"
146+
#line46 "alloc.pgc"
142147
char**r=NULL ;
143148
/* exec sql end declare section */
144-
#line42 "alloc.pgc"
149+
#line47 "alloc.pgc"
145150

146151

147152
value= (long)arg;
148153
sprintf(name,"Connection: %d",value);
149154

150155
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,name,0);
151-
#line47 "alloc.pgc"
156+
#line52 "alloc.pgc"
152157

153158
if (sqlca.sqlcode<0)sqlprint();}
154-
#line47 "alloc.pgc"
159+
#line52 "alloc.pgc"
155160

156161
{ECPGsetcommit(__LINE__,"on",NULL);
157-
#line48 "alloc.pgc"
162+
#line53 "alloc.pgc"
158163

159164
if (sqlca.sqlcode<0)sqlprint();}
160-
#line48 "alloc.pgc"
165+
#line53 "alloc.pgc"
161166

162167
for (i=1;i <=REPEATS;++i)
163168
{
164169
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"select relname from pg_class where relname = 'pg_class'",ECPGt_EOIT,
165170
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
166171
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
167-
#line51 "alloc.pgc"
172+
#line56 "alloc.pgc"
168173

169174
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
170-
#line51 "alloc.pgc"
175+
#line56 "alloc.pgc"
171176

172177
if (sqlca.sqlcode<0)sqlprint();}
173-
#line51 "alloc.pgc"
178+
#line56 "alloc.pgc"
174179

175180
free(r);
176181
r=NULL;
177182
}
178183
{ECPGdisconnect(__LINE__,name);
179-
#line55 "alloc.pgc"
184+
#line60 "alloc.pgc"
180185

181186
if (sqlca.sqlcode<0)sqlprint();}
182-
#line55 "alloc.pgc"
187+
#line60 "alloc.pgc"
183188

184189

185190
return0;

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#defineWIN32_LEAN_AND_MEAN
1313
#include<windows.h>
1414
#include<process.h>
15+
#include<locale.h>
1516
#else
1617
#include<pthread.h>
1718
#endif
@@ -90,13 +91,13 @@ struct sqlca_t *ECPGget_sqlca(void);
9091

9192
#endif
9293

93-
#line15 "descriptor.pgc"
94+
#line16 "descriptor.pgc"
9495

9596
/* exec sql whenever sqlerror sqlprint ; */
96-
#line16 "descriptor.pgc"
97+
#line17 "descriptor.pgc"
9798

9899
/* exec sql whenever not found sqlprint ; */
99-
#line17 "descriptor.pgc"
100+
#line18 "descriptor.pgc"
100101

101102

102103
#if defined(ENABLE_THREAD_SAFETY)&& defined(WIN32)
@@ -107,19 +108,23 @@ static void* fn(void* arg)
107108
{
108109
inti;
109110

111+
#ifdefWIN32
112+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
113+
#endif
114+
110115
for (i=1;i <=REPEATS;++i)
111116
{
112117
ECPGallocate_desc(__LINE__,"mydesc");
113-
#line29 "descriptor.pgc"
118+
#line34 "descriptor.pgc"
114119

115120
if (sqlca.sqlcode<0)sqlprint();
116-
#line29 "descriptor.pgc"
121+
#line34 "descriptor.pgc"
117122

118123
ECPGdeallocate_desc(__LINE__,"mydesc");
119-
#line30 "descriptor.pgc"
124+
#line35 "descriptor.pgc"
120125

121126
if (sqlca.sqlcode<0)sqlprint();
122-
#line30 "descriptor.pgc"
127+
#line35 "descriptor.pgc"
123128

124129
}
125130

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

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ main(void)
2222
#defineWIN32_LEAN_AND_MEAN
2323
#include<windows.h>
2424
#include<process.h>
25+
#include<locale.h>
2526
#else
2627
#include<pthread.h>
2728
#endif
@@ -99,7 +100,7 @@ struct sqlca_t *ECPGget_sqlca(void);
99100

100101
#endif
101102

102-
#line24 "prep.pgc"
103+
#line25 "prep.pgc"
103104

104105

105106
#line 1 "regression.h"
@@ -109,14 +110,14 @@ struct sqlca_t *ECPGget_sqlca(void);
109110

110111

111112

112-
#line25 "prep.pgc"
113+
#line26 "prep.pgc"
113114

114115

115116
/* exec sql whenever sqlerror sqlprint ; */
116-
#line27 "prep.pgc"
117+
#line28 "prep.pgc"
117118

118119
/* exec sql whenever not found sqlprint ; */
119-
#line28 "prep.pgc"
120+
#line29 "prep.pgc"
120121

121122

122123
#ifdefWIN32
@@ -127,69 +128,73 @@ static void* fn(void* arg)
127128
{
128129
inti;
129130

131+
#ifdefWIN32
132+
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
133+
#endif
134+
130135
/* exec sql begin declare section */
131136

132137

133138

134139

135-
#line39 "prep.pgc"
140+
#line44 "prep.pgc"
136141
intvalue ;
137142

138-
#line40 "prep.pgc"
143+
#line45 "prep.pgc"
139144
charname [100 ] ;
140145

141-
#line41 "prep.pgc"
146+
#line46 "prep.pgc"
142147
charquery [256 ]="INSERT INTO T VALUES ( ? )" ;
143148
/* exec sql end declare section */
144-
#line42 "prep.pgc"
149+
#line47 "prep.pgc"
145150

146151

147152
value= (long)arg;
148153
sprintf(name,"Connection: %d",value);
149154

150155
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,name,0);
151-
#line47 "prep.pgc"
156+
#line52 "prep.pgc"
152157

153158
if (sqlca.sqlcode<0)sqlprint();}
154-
#line47 "prep.pgc"
159+
#line52 "prep.pgc"
155160

156161
{ECPGsetcommit(__LINE__,"on",NULL);
157-
#line48 "prep.pgc"
162+
#line53 "prep.pgc"
158163

159164
if (sqlca.sqlcode<0)sqlprint();}
160-
#line48 "prep.pgc"
165+
#line53 "prep.pgc"
161166

162167
for (i=1;i <=REPEATS;++i)
163168
{
164169
{ECPGprepare(__LINE__,NULL,0,"i",query);
165-
#line51 "prep.pgc"
170+
#line56 "prep.pgc"
166171

167172
if (sqlca.sqlcode<0)sqlprint();}
168-
#line51 "prep.pgc"
173+
#line56 "prep.pgc"
169174

170175
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_execute,"i",
171176
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
172177
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
173-
#line52 "prep.pgc"
178+
#line57 "prep.pgc"
174179

175180
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
176-
#line52 "prep.pgc"
181+
#line57 "prep.pgc"
177182

178183
if (sqlca.sqlcode<0)sqlprint();}
179-
#line52 "prep.pgc"
184+
#line57 "prep.pgc"
180185

181186
}
182187
{ECPGdeallocate(__LINE__,0,NULL,"i");
183-
#line54 "prep.pgc"
188+
#line59 "prep.pgc"
184189

185190
if (sqlca.sqlcode<0)sqlprint();}
186-
#line54 "prep.pgc"
191+
#line59 "prep.pgc"
187192

188193
{ECPGdisconnect(__LINE__,name);
189-
#line55 "prep.pgc"
194+
#line60 "prep.pgc"
190195

191196
if (sqlca.sqlcode<0)sqlprint();}
192-
#line55 "prep.pgc"
197+
#line60 "prep.pgc"
193198

194199

195200
return0;
@@ -205,34 +210,34 @@ int main ()
205210
#endif
206211

207212
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,NULL,0);
208-
#line69 "prep.pgc"
213+
#line74 "prep.pgc"
209214

210215
if (sqlca.sqlcode<0)sqlprint();}
211-
#line69 "prep.pgc"
216+
#line74 "prep.pgc"
212217

213218
{ECPGsetcommit(__LINE__,"on",NULL);
214-
#line70 "prep.pgc"
219+
#line75 "prep.pgc"
215220

216221
if (sqlca.sqlcode<0)sqlprint();}
217-
#line70 "prep.pgc"
222+
#line75 "prep.pgc"
218223

219224
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop table if exists T",ECPGt_EOIT,ECPGt_EORT);
220-
#line71 "prep.pgc"
225+
#line76 "prep.pgc"
221226

222227
if (sqlca.sqlcode<0)sqlprint();}
223-
#line71 "prep.pgc"
228+
#line76 "prep.pgc"
224229

225230
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"create table T ( i int )",ECPGt_EOIT,ECPGt_EORT);
226-
#line72 "prep.pgc"
231+
#line77 "prep.pgc"
227232

228233
if (sqlca.sqlcode<0)sqlprint();}
229-
#line72 "prep.pgc"
234+
#line77 "prep.pgc"
230235

231236
{ECPGdisconnect(__LINE__,"CURRENT");
232-
#line73 "prep.pgc"
237+
#line78 "prep.pgc"
233238

234239
if (sqlca.sqlcode<0)sqlprint();}
235-
#line73 "prep.pgc"
240+
#line78 "prep.pgc"
236241

237242

238243
#ifdefWIN32

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp