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

Commitddcb5bb

Browse files
author
Michael Meskes
committed
- Added patch by Magnus Hagander <magnus@hagander.net> to use native
win32 threads.- Fixed regression tests to run threading tests.
1 parentfba8113 commitddcb5bb

17 files changed

+170
-152
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,4 +2177,10 @@ Th Mar 15 08:27:53 CET 2007
21772177
- Synced parser and keyword lists.
21782178
- Copied two token parsing from backend parser to ecpg parser.
21792179
- Also added a test case for this.
2180+
2181+
Thu, 29 Mar 2007 11:18:39 +0200
2182+
2183+
- Added patch by Magnus Hagander <magnus@hagander.net> to use native
2184+
win32 threads.
2185+
- Fixed regression tests to run threading tests.
21802186
- Set ecpg version to 4.3.1.

‎src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.40 2007/03/17 19:25:22 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.41 2007/03/29 12:02:24 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
55

66
#ifdefENABLE_THREAD_SAFETY
7+
#ifndefWIN32
78
#include<pthread.h>
9+
#else
10+
#include"ecpg-pthread-win32.h"
11+
#endif
812
#endif
913
#include"ecpgtype.h"
1014
#include"ecpglib.h"
@@ -13,9 +17,14 @@
1317
#include"sqlca.h"
1418

1519
#ifdefENABLE_THREAD_SAFETY
20+
#ifndefWIN32
1621
staticpthread_mutex_tconnections_mutex=PTHREAD_MUTEX_INITIALIZER;
1722
staticpthread_key_tactual_connection_key;
1823
staticpthread_once_tactual_connection_key_once=PTHREAD_ONCE_INIT;
24+
#else
25+
staticHANDLEconnections_mutex=INVALID_HANDLE_VALUE;
26+
staticDWORDactual_connection_key;
27+
#endif/* WIN32 */
1928
#endif
2029
staticstructconnection*actual_connection=NULL;
2130
staticstructconnection*all_connections=NULL;
@@ -30,7 +39,13 @@ ecpg_actual_connection_init(void)
3039
void
3140
ecpg_pthreads_init(void)
3241
{
42+
#ifndefWIN32
3343
pthread_once(&actual_connection_key_once,ecpg_actual_connection_init);
44+
#else
45+
staticlonghas_run=0;
46+
if (InterlockedCompareExchange(&has_run,1,0)==0)
47+
ecpg_actual_connection_init();
48+
#endif
3449
}
3550
#endif
3651

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.64 2007/02/11 15:18:17 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.65 2007/03/29 12:02:24 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -39,7 +39,6 @@ static char *
3939
quote_postgres(char*arg,boolquote,intlineno)
4040
{
4141
char*res;
42-
interror;
4342
size_tlength;
4443
size_tescaped_len;
4544
size_tbuffer_len;
@@ -58,13 +57,7 @@ quote_postgres(char *arg, bool quote, int lineno)
5857
if (!res)
5958
return (res);
6059

61-
error=0;
6260
escaped_len=PQescapeString(res+1,arg,buffer_len);
63-
if (error)
64-
{
65-
ECPGfree(res);
66-
returnNULL;
67-
}
6861
if (length==escaped_len)
6962
{
7063
res[0]=res[escaped_len+1]='\'';

‎src/interfaces/ecpg/ecpglib/extern.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.22 2007/01/25 16:45:25 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.23 2007/03/29 12:02:24 meskes Exp $ */
22

33
#ifndef_ECPG_LIB_EXTERN_H
44
#define_ECPG_LIB_EXTERN_H
55

66
#include"postgres_fe.h"
77
#include"libpq-fe.h"
88
#include"sqlca.h"
9+
#include"ecpg_config.h"
910

1011
enumCOMPAT_MODE
1112
{

‎src/interfaces/ecpg/ecpglib/misc.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.34 2007/01/12 10:00:13 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.35 2007/03/29 12:02:24 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
55

66
#include<limits.h>
77
#include<unistd.h>
88
#ifdefENABLE_THREAD_SAFETY
9+
#ifndefWIN32
910
#include<pthread.h>
11+
#else
12+
#include"ecpg-pthread-win32.h"
13+
#endif
1014
#endif
1115
#include"ecpgtype.h"
1216
#include"ecpglib.h"
@@ -58,9 +62,13 @@ static struct sqlca_t sqlca_init =
5862
};
5963

6064
#ifdefENABLE_THREAD_SAFETY
65+
#ifndefWIN32
6166
staticpthread_key_tsqlca_key;
6267
staticpthread_once_tsqlca_key_once=PTHREAD_ONCE_INIT;
6368
#else
69+
staticDWORDsqlca_key;
70+
#endif
71+
#else
6472
staticstructsqlca_tsqlca=
6573
{
6674
{
@@ -90,8 +98,13 @@ static struct sqlca_t sqlca =
9098
#endif
9199

92100
#ifdefENABLE_THREAD_SAFETY
101+
#ifndefWIN32
93102
staticpthread_mutex_tdebug_mutex=PTHREAD_MUTEX_INITIALIZER;
94103
staticpthread_mutex_tdebug_init_mutex=PTHREAD_MUTEX_INITIALIZER;
104+
#else
105+
staticHANDLEdebug_mutex=INVALID_HANDLE_VALUE;
106+
staticHANDLEdebug_init_mutex=INVALID_HANDLE_VALUE;
107+
#endif/* WIN32 */
95108
#endif
96109
staticintsimple_debug=0;
97110
staticFILE*debugstream=NULL;
@@ -138,8 +151,13 @@ ECPGget_sqlca(void)
138151
{
139152
#ifdefENABLE_THREAD_SAFETY
140153
structsqlca_t*sqlca;
141-
154+
#ifdefWIN32
155+
staticlonghas_run=0;
156+
if (InterlockedCompareExchange(&has_run,1,0)==0)
157+
ecpg_sqlca_key_init();
158+
#else
142159
pthread_once(&sqlca_key_once,ecpg_sqlca_key_init);
160+
#endif
143161

144162
sqlca=pthread_getspecific(sqlca_key);
145163
if (sqlca==NULL)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg-pthread-win32.h,v 1.1 2007/03/29 12:02:24 meskes Exp $ */
2+
/*
3+
* pthread mapping macros for win32 native thread implementation
4+
*/
5+
#ifndef_ECPG_PTHREAD_WIN32_H
6+
#define_ECPG_PTHREAD_WIN32_H
7+
#definepthread_mutex_lock(x) do { \
8+
if (*x == INVALID_HANDLE_VALUE) \
9+
*x = CreateMutex(NULL, FALSE, NULL); \
10+
WaitForSingleObject(*x, INFINITE); \
11+
} while (0);
12+
#definepthread_mutex_unlock(x) ReleaseMutex(*x)
13+
#definepthread_getspecific(x) TlsGetValue(x)
14+
#definepthread_setspecific(x,y) TlsSetValue(x,y)
15+
#definepthread_key_create(x,y) *x = TlsAlloc();
16+
#endif

‎src/interfaces/ecpg/include/ecpg_config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
(--enable-integer-datetimes) */
1212
#undef USE_INTEGER_DATETIMES
1313

14+
/* Define to 1 to build client libraries as thread-safe code.
15+
* (--enable-thread-safety) */
16+
#undef ENABLE_THREAD_SAFETY
17+

‎src/interfaces/ecpg/test/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.66 2007/02/09 15:55:59 petere Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.67 2007/03/29 12:02:24 meskes Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
@@ -11,6 +11,9 @@ TEMP_PORT = 5$(DEF_PGPORT)
1111
# default encoding
1212
MULTIBYTE = SQL_ASCII
1313

14+
# threading
15+
THREAD :=$(shell grep -q "define ENABLE_THREAD_SAFETY" ../include/ecpg_config.h && echo "--enable-threading")
16+
1417
# locale
1518
NOLOCALE =
1619
ifdefNO_LOCALE
@@ -75,11 +78,11 @@ endif
7578

7679

7780
check: all
78-
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql$(NOLOCALE)
81+
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql$(NOLOCALE)$(THREAD)
7982

8083
# the same options, but with --listen-on-tcp
8184
checktcp: all
82-
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql$(NOLOCALE) --listen-on-tcp
85+
sh ./pg_regress --dbname=regress1 --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --multibyte=$(MULTIBYTE) --load-language=plpgsql$(NOLOCALE) --listen-on-tcp$(THREAD)
8386

8487
installcheck: all
8588
sh ./pg_regress --dbname=regress1 --top-builddir=$(top_builddir) --load-language=plpgsql$(NOLOCALE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Success.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp