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

Commit407e660

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 parent839ee18 commit407e660

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
inti;
130130

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

137133

138134

139135

140-
#line44 "alloc.pgc"
136+
#line40 "alloc.pgc"
141137
intvalue ;
142138

143-
#line45 "alloc.pgc"
139+
#line41 "alloc.pgc"
144140
charname [100 ] ;
145141

146-
#line46 "alloc.pgc"
142+
#line42 "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+
#ifdefWIN32
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-
#line52 "alloc.pgc"
158+
#line54 "alloc.pgc"
157159

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

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

164166
if (sqlca.sqlcode<0)sqlprint();}
165-
#line53 "alloc.pgc"
167+
#line55 "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-
#line56 "alloc.pgc"
174+
#line58 "alloc.pgc"
173175

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

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

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

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

189191

190192
return0;

‎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
inti;
110110

111111
#ifdefWIN32
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-
#line34 "descriptor.pgc"
120+
#line36 "descriptor.pgc"
119121

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

123125
ECPGdeallocate_desc(__LINE__,"mydesc");
124-
#line35 "descriptor.pgc"
126+
#line37 "descriptor.pgc"
125127

126128
if (sqlca.sqlcode<0)sqlprint();
127-
#line35 "descriptor.pgc"
129+
#line37 "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
inti;
130130

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

137133

138134

139135

140-
#line44 "prep.pgc"
136+
#line40 "prep.pgc"
141137
intvalue ;
142138

143-
#line45 "prep.pgc"
139+
#line41 "prep.pgc"
144140
charname [100 ] ;
145141

146-
#line46 "prep.pgc"
142+
#line42 "prep.pgc"
147143
charquery [256 ]="INSERT INTO T VALUES ( ? )" ;
148144
/* exec sql end declare section */
149-
#line47 "prep.pgc"
145+
#line43 "prep.pgc"
150146

151147

148+
#ifdefWIN32
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-
#line52 "prep.pgc"
158+
#line54 "prep.pgc"
157159

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

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

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

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

172174
if (sqlca.sqlcode<0)sqlprint();}
173-
#line56 "prep.pgc"
175+
#line58 "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-
#line57 "prep.pgc"
180+
#line59 "prep.pgc"
179181

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

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

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

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

193195
{ECPGdisconnect(__LINE__,name);
194-
#line60 "prep.pgc"
196+
#line62 "prep.pgc"
195197

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

199201

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

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

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

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

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

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

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

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

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

236238
{ECPGdisconnect(__LINE__,"CURRENT");
237-
#line78 "prep.pgc"
239+
#line80 "prep.pgc"
238240

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

242244

243245
#ifdefWIN32

‎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
longthreadnum= (long)arg;
142142

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

149145

150146

151-
#line107 "thread.pgc"
147+
#line103 "thread.pgc"
152148
intl_i ;
153149

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

156+
#ifdefWIN32
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
#ifndefWIN32_ONLY_COMPILER
@@ -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-
#line117 "thread.pgc"
169+
#line119 "thread.pgc"
168170

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

172174
if (sqlca.sqlcode<0)sqlprint();}
173-
#line118 "thread.pgc"
175+
#line120 "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-
#line124 "thread.pgc"
183+
#line126 "thread.pgc"
182184

183185
if (sqlca.sqlcode<0)sqlprint();}
184-
#line124 "thread.pgc"
186+
#line126 "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-
#line129 "thread.pgc"
197+
#line131 "thread.pgc"
196198

197199
if (sqlca.sqlcode<0)sqlprint();}
198-
#line129 "thread.pgc"
200+
#line131 "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-
#line135 "thread.pgc"
208+
#line137 "thread.pgc"
207209

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

211213
{ECPGdisconnect(__LINE__,l_connection);
212-
#line136 "thread.pgc"
214+
#line138 "thread.pgc"
213215

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

217219
return(NULL );
218220
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp