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

Commit3ff0018

Browse files
committed
In hopes of un-breaking the buildfarm, add missing file from
ITAGAKI Takahiro's patch.
1 parentab051bd commit3ff0018

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <stdlib.h>
2+
#include "ecpg_config.h"
3+
4+
#ifndef ENABLE_THREAD_SAFETY
5+
int
6+
main(void)
7+
{
8+
printf("No threading enabled.\n");
9+
return 0;
10+
}
11+
#else
12+
#ifdef WIN32
13+
#define WIN32_LEAN_AND_MEAN
14+
#include <windows.h>
15+
#include <process.h>
16+
#else
17+
#include <pthread.h>
18+
#endif
19+
#include <stdio.h>
20+
21+
#define THREADS16
22+
#define REPEATS50
23+
24+
exec sql include sqlca;
25+
exec sql include ../regression;
26+
27+
exec sql whenever sqlerror sqlprint;
28+
exec sql whenever not found sqlprint;
29+
30+
#ifdef WIN32
31+
static unsigned STDCALL fn(void* arg)
32+
#else
33+
static void* fn(void* arg)
34+
#endif
35+
{
36+
int i;
37+
38+
EXEC SQL BEGIN DECLARE SECTION;
39+
int value;
40+
char name[100];
41+
char **r = NULL;
42+
EXEC SQL END DECLARE SECTION;
43+
44+
value = (int)arg;
45+
sprintf(name, "Connection: %d", value);
46+
47+
EXEC SQL CONNECT TO REGRESSDB1 AS :name;
48+
EXEC SQL SET AUTOCOMMIT TO ON;
49+
for (i = 1; i <= REPEATS; ++i)
50+
{
51+
EXEC SQL SELECT relname INTO :r FROM pg_class WHERE relname = 'pg_class';
52+
free(r);
53+
r = NULL;
54+
}
55+
EXEC SQL DISCONNECT :name;
56+
57+
return 0;
58+
}
59+
60+
int main (int argc, char** argv)
61+
{
62+
int i;
63+
#ifdef WIN32
64+
HANDLE threads[THREADS];
65+
#else
66+
pthread_t threads[THREADS];
67+
#endif
68+
69+
#ifdef WIN32
70+
for (i = 0; i < THREADS; ++i)
71+
{
72+
unsigned id;
73+
threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
74+
}
75+
76+
WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
77+
for (i = 0; i < THREADS; ++i)
78+
CloseHandle(threads[i]);
79+
#else
80+
for (i = 0; i < THREADS; ++i)
81+
pthread_create(&threads[i], NULL, fn, (void*)i);
82+
for (i = 0; i < THREADS; ++i)
83+
pthread_join(threads[i], NULL);
84+
#endif
85+
86+
return 0;
87+
}
88+
#endif
89+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp