Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
3ff0018c
Commit
3ff0018c
authored
17 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
In hopes of un-breaking the buildfarm, add missing file from
ITAGAKI Takahiro's patch.
parent
ab051bd2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/ecpg/test/thread/alloc.pgc
+89
-0
89 additions, 0 deletions
src/interfaces/ecpg/test/thread/alloc.pgc
with
89 additions
and
0 deletions
src/interfaces/ecpg/test/thread/alloc.pgc
0 → 100644
+
89
−
0
View file @
3ff0018c
#include <stdlib.h>
#include "ecpg_config.h"
#ifndef ENABLE_THREAD_SAFETY
int
main(void)
{
printf("No threading enabled.\n");
return 0;
}
#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
#else
#include <pthread.h>
#endif
#include <stdio.h>
#define THREADS 16
#define REPEATS 50
exec sql include sqlca;
exec sql include ../regression;
exec sql whenever sqlerror sqlprint;
exec sql whenever not found sqlprint;
#ifdef WIN32
static unsigned STDCALL fn(void* arg)
#else
static void* fn(void* arg)
#endif
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
int value;
char name[100];
char **r = NULL;
EXEC SQL END DECLARE SECTION;
value = (int)arg;
sprintf(name, "Connection: %d", value);
EXEC SQL CONNECT TO REGRESSDB1 AS :name;
EXEC SQL SET AUTOCOMMIT TO ON;
for (i = 1; i <= REPEATS; ++i)
{
EXEC SQL SELECT relname INTO :r FROM pg_class WHERE relname = 'pg_class';
free(r);
r = NULL;
}
EXEC SQL DISCONNECT :name;
return 0;
}
int main (int argc, char** argv)
{
int i;
#ifdef WIN32
HANDLE threads[THREADS];
#else
pthread_t threads[THREADS];
#endif
#ifdef WIN32
for (i = 0; i < THREADS; ++i)
{
unsigned id;
threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
}
WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
for (i = 0; i < THREADS; ++i)
CloseHandle(threads[i]);
#else
for (i = 0; i < THREADS; ++i)
pthread_create(&threads[i], NULL, fn, (void*)i);
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
return 0;
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment