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

Commit96b1719

Browse files
committed
Make ECPG regression tests use native threading instead of pthreads, now that
ecpglib supports it.Change configure (patch from Bruce) and msvc build system to no longer require pthreads on win32, since all parts of postgresql can be thread-safe using the native platform functions.
1 parentddcb5bb commit96b1719

File tree

11 files changed

+201
-115
lines changed

11 files changed

+201
-115
lines changed

‎configure

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,6 +3683,7 @@ IFS=$ac_save_IFS
36833683
#
36843684
echo "$as_me:$LINENO: checking allow thread-safe client libraries" >&5
36853685
echo $ECHO_N "checking allow thread-safe client libraries... $ECHO_C" >&6
3686+
if test "$PORTNAME" != "win32"; then
36863687

36873688
pgac_args="$pgac_args enable_thread_safety"
36883689

@@ -3709,6 +3710,36 @@ else
37093710

37103711
fi;
37113712

3713+
else
3714+
# Win32 should always use threads
3715+
3716+
pgac_args="$pgac_args enable_thread_safety"
3717+
3718+
# Check whether --enable-thread-safety or --disable-thread-safety was given.
3719+
if test "${enable_thread_safety+set}" = set; then
3720+
enableval="$enable_thread_safety"
3721+
3722+
case $enableval in
3723+
yes)
3724+
:
3725+
;;
3726+
no)
3727+
:
3728+
;;
3729+
*)
3730+
{ { echo "$as_me:$LINENO: error: no argument expected for --enable-thread-safety option" >&5
3731+
echo "$as_me: error: no argument expected for --enable-thread-safety option" >&2;}
3732+
{ (exit 1); exit 1; }; }
3733+
;;
3734+
esac
3735+
3736+
else
3737+
enable_thread_safety=yes
3738+
3739+
fi;
3740+
3741+
fi
3742+
37123743

37133744
pgac_args="$pgac_args enable_thread_safety_force"
37143745

@@ -16701,8 +16732,8 @@ fi
1670116732
# For each platform, we need to know about any special compile and link
1670216733
# libraries, and whether the normal C function names are thread-safe.
1670316734
# See the comment at the top of src/port/thread.c for more information.
16704-
#
16705-
if test "$enable_thread_safety" = yes; then
16735+
# WIN32 doesn't need the pthread tests; it always uses threads
16736+
if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then
1670616737

1670716738

1670816739

@@ -17236,6 +17267,7 @@ _LIBS="$LIBS"
1723617267
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1723717268
LIBS="$LIBS $PTHREAD_LIBS"
1723817269

17270+
if test "$PORTNAME" != "win32"; then
1723917271
if test "${ac_cv_header_pthread_h+set}" = set; then
1724017272
echo "$as_me:$LINENO: checking for pthread.h" >&5
1724117273
echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6
@@ -17382,6 +17414,7 @@ echo "$as_me: error: pthread.h not found, required for --enable-thread-safety" >
1738217414
fi
1738317415

1738417416

17417+
fi
1738517418

1738617419

1738717420

‎configure.in

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.506 2007/03/26 21:30:56 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.507 2007/03/29 15:30:51 mha Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -416,7 +416,13 @@ IFS=$ac_save_IFS
416416
# Enable thread-safe client libraries
417417
#
418418
AC_MSG_CHECKING([allow thread-safe client libraries])
419+
if test "$PORTNAME" != "win32"; then
419420
PGAC_ARG_BOOL(enable, thread-safety, no, [ --enable-thread-safety make client libraries thread-safe])
421+
else
422+
# Win32 should always use threads
423+
PGAC_ARG_BOOL(enable, thread-safety, yes, [ --enable-thread-safety make client libraries thread-safe])
424+
fi
425+
420426
PGAC_ARG_BOOL(enable, thread-safety-force, no, [ --enable-thread-safety-force force thread-safety in spite of thread test failure])
421427
if test "$enable_thread_safety" = yes -o \
422428
"$enable_thread_safety_force" = yes; then
@@ -1108,8 +1114,8 @@ AC_FUNC_FSEEKO
11081114
# For each platform, we need to know about any special compile and link
11091115
# libraries, and whether the normal C function names are thread-safe.
11101116
# See the comment at the top of src/port/thread.c for more information.
1111-
#
1112-
if test "$enable_thread_safety" = yes; then
1117+
# WIN32 doesn't need the pthread tests; it always uses threads
1118+
if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then
11131119
ACX_PTHREAD# set thread flags
11141120

11151121
# Some platforms use these, so just defineed them. They can't hurt if they
@@ -1137,7 +1143,9 @@ _LIBS="$LIBS"
11371143
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
11381144
LIBS="$LIBS $PTHREAD_LIBS"
11391145

1146+
if test "$PORTNAME" != "win32"; then
11401147
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safety])])
1148+
fi
11411149

11421150
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
11431151

‎doc/src/sgml/install-win32.sgml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.37 2007/03/24 22:16:49 mha Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.38 2007/03/29 15:30:52 mha Exp $ -->
22

33
<chapter id="install-win32">
44
<title>Installation on <productname>Windows</productname></title>
@@ -161,15 +161,6 @@
161161
</para></listitem>
162162
</varlistentry>
163163

164-
<varlistentry>
165-
<term><productname>pthreads</productname></term>
166-
<listitem><para>
167-
Required for building the <application>ECPG</application> libraries.
168-
Binaries can be downloaded from
169-
<ulink url="ftp://sources.redhat.com/pub/pthreads-win32"></>.
170-
</para></listitem>
171-
</varlistentry>
172-
173164
<varlistentry>
174165
<term><productname>Python</productname></term>
175166
<listitem><para>

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

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ main(void)
2323
return0;
2424
}
2525
#else
26+
#ifndefWIN32
2627
#include<pthread.h>
28+
#else
29+
#include<windows.h>
30+
#endif
2731

2832

2933
#line 1 "regression.h"
@@ -33,7 +37,7 @@ main(void)
3337

3438

3539

36-
#line18 "thread.pgc"
40+
#line22 "thread.pgc"
3741

3842

3943
void*test_thread(void*arg);
@@ -43,15 +47,19 @@ int iterations = 20;
4347

4448
intmain(intargc,char*argv[])
4549
{
50+
#ifndefWIN32
4651
pthread_t*threads;
52+
#else
53+
HANDLE*threads;
54+
#endif
4755
intn;
4856
/* exec sql begin declare section */
4957

5058

51-
#line30 "thread.pgc"
59+
#line38 "thread.pgc"
5260
intl_rows ;
5361
/* exec sql end declare section */
54-
#line31 "thread.pgc"
62+
#line39 "thread.pgc"
5563

5664

5765
/* Do not switch on debug output for regression tests. The threads get executed in
@@ -60,57 +68,65 @@ int main(int argc, char *argv[])
6068

6169
/* setup test_thread table */
6270
{ECPGconnect(__LINE__,0,"regress1" ,NULL,NULL ,NULL,0); }
63-
#line38 "thread.pgc"
71+
#line46 "thread.pgc"
6472

6573
{ECPGdo(__LINE__,0,1,NULL,"drop table test_thread ",ECPGt_EOIT,ECPGt_EORT);}
66-
#line39 "thread.pgc"
74+
#line47 "thread.pgc"
6775
/* DROP might fail */
6876
{ECPGtrans(__LINE__,NULL,"commit");}
69-
#line40 "thread.pgc"
77+
#line48 "thread.pgc"
7078

7179
{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);}
72-
#line45 "thread.pgc"
80+
#line53 "thread.pgc"
7381

7482
{ECPGtrans(__LINE__,NULL,"commit");}
75-
#line46 "thread.pgc"
83+
#line54 "thread.pgc"
7684

7785
{ECPGdisconnect(__LINE__,"CURRENT");}
78-
#line47 "thread.pgc"
86+
#line55 "thread.pgc"
7987

8088

8189
/* create, and start, threads */
82-
threads=calloc(nthreads,sizeof(pthread_t));
90+
threads=calloc(nthreads,sizeof(threads[0]));
8391
if(threads==NULL )
8492
{
8593
fprintf(stderr,"Cannot alloc memory\n");
8694
return(1 );
8795
}
8896
for(n=0;n<nthreads;n++ )
8997
{
98+
#ifndefWIN32
9099
pthread_create(&threads[n],NULL,test_thread, (void*) (n+1));
100+
#else
101+
threads[n]=CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)test_thread, (void*) (n+1),0,NULL);
102+
#endif
91103
}
92104

93105
/* wait for thread completion */
106+
#ifndefWIN32
94107
for(n=0;n<nthreads;n++ )
95108
{
96109
pthread_join(threads[n],NULL);
97110
}
111+
#else
112+
WaitForMultipleObjects(nthreads,threads, TRUE,INFINITE);
113+
#endif
98114
free(threads);
99115

100116
/* and check results */
101117
{ECPGconnect(__LINE__,0,"regress1" ,NULL,NULL ,NULL,0); }
102-
#line69 "thread.pgc"
118+
#line85 "thread.pgc"
103119

104120
{ECPGdo(__LINE__,0,1,NULL,"select count (*) from test_thread ",ECPGt_EOIT,
105121
ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
106122
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);}
107-
#line70 "thread.pgc"
123+
#line86 "thread.pgc"
108124

109125
{ECPGtrans(__LINE__,NULL,"commit");}
110-
#line71 "thread.pgc"
126+
#line87 "thread.pgc"
111127

112128
{ECPGdisconnect(__LINE__,"CURRENT");}
113-
#line72 "thread.pgc"
129+
#line88 "thread.pgc"
114130

115131
if(l_rows== (nthreads*iterations) )
116132
printf("Success.\n");
@@ -127,36 +143,36 @@ void *test_thread(void *arg)
127143

128144

129145

130-
#line85 "thread.pgc"
146+
#line101 "thread.pgc"
131147
intl_i ;
132148

133-
#line86 "thread.pgc"
149+
#line102 "thread.pgc"
134150
charl_connection [128 ] ;
135151
/* exec sql end declare section */
136-
#line87 "thread.pgc"
152+
#line103 "thread.pgc"
137153

138154

139155
/* build up connection name, and connect to database */
140156
snprintf(l_connection,sizeof(l_connection),"thread_%03ld",threadnum);
141157
/* exec sql whenever sqlerror sqlprint ; */
142-
#line91 "thread.pgc"
158+
#line107 "thread.pgc"
143159

144160
{ECPGconnect(__LINE__,0,"regress1" ,NULL,NULL ,l_connection,0);
145-
#line92 "thread.pgc"
161+
#line108 "thread.pgc"
146162

147163
if (sqlca.sqlcode<0)sqlprint();}
148-
#line92 "thread.pgc"
164+
#line108 "thread.pgc"
149165

150166
if(sqlca.sqlcode!=0 )
151167
{
152168
printf("%s: ERROR: cannot connect to database!\n",l_connection);
153169
return(NULL );
154170
}
155171
{ECPGtrans(__LINE__,l_connection,"begin transaction ");
156-
#line98 "thread.pgc"
172+
#line114 "thread.pgc"
157173

158174
if (sqlca.sqlcode<0)sqlprint();}
159-
#line98 "thread.pgc"
175+
#line114 "thread.pgc"
160176

161177

162178
/* insert into test_thread table */
@@ -167,27 +183,27 @@ if (sqlca.sqlcode < 0) sqlprint();}
167183
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
168184
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
169185
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
170-
#line103 "thread.pgc"
186+
#line119 "thread.pgc"
171187

172188
if (sqlca.sqlcode<0)sqlprint();}
173-
#line103 "thread.pgc"
189+
#line119 "thread.pgc"
174190

175191
if(sqlca.sqlcode!=0 )
176192
printf("%s: ERROR: insert failed!\n",l_connection);
177193
}
178194

179195
/* all done */
180196
{ECPGtrans(__LINE__,l_connection,"commit");
181-
#line109 "thread.pgc"
197+
#line125 "thread.pgc"
182198

183199
if (sqlca.sqlcode<0)sqlprint();}
184-
#line109 "thread.pgc"
200+
#line125 "thread.pgc"
185201

186202
{ECPGdisconnect(__LINE__,l_connection);
187-
#line110 "thread.pgc"
203+
#line126 "thread.pgc"
188204

189205
if (sqlca.sqlcode<0)sqlprint();}
190-
#line110 "thread.pgc"
206+
#line126 "thread.pgc"
191207

192208
return(NULL );
193209
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp