original) (raw)
PostgreSQL Source Code: src/interfaces/ecpg/test/expected/thread-alloc.c File Reference (#include <[ecpglib.h](ecpglib%5F8h%5Fsource.html)>
#include <[ecpgerrno.h](ecpgerrno%5F8h%5Fsource.html)>
#include <[sqlca.h](sqlca%5F8h%5Fsource.html)>
#include <stdint.h>
#include <stdlib.h>
#include "ecpg_config.h"
#include <pthread.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
---|---|
#define | ECPGdebug(X, Y) ECPGdebug((X)+100,(Y)) |
#define | THREADS 16 |
#define | REPEATS 50 |
#define | POSTGRES_SQLCA_H |
#define | PGDLLIMPORT |
#define | SQLERRMC_LEN 150 |
#define | sqlca (*ECPGget_sqlca()) |
Functions | |
---|---|
struct sqlca_t * | ECPGget_sqlca (void) |
static void * | fn (void *arg) |
int | main () |
◆ ECPGdebug
| #define ECPGdebug | ( | | X, | | ----------------- | ---------------------- | | -- | | | Y | | | | | ) | ECPGdebug((X)+100,(Y)) | | |
◆ PGDLLIMPORT
◆ POSTGRES_SQLCA_H
◆ REPEATS
◆ sqlca
◆ SQLERRMC_LEN
◆ THREADS
◆ ECPGget_sqlca()
struct sqlca_t * ECPGget_sqlca | ( | void | ) |
---|
Definition at line 108 of file misc.c.
109{
111
113
115 if (sqlca == NULL)
116 {
118 if (sqlca == NULL)
119 return NULL;
122 }
124}
static pthread_key_t sqlca_key
void ecpg_init_sqlca(struct sqlca_t *sqlca)
static void ecpg_sqlca_key_init(void)
static pthread_once_t sqlca_key_once
void pthread_setspecific(pthread_key_t key, void *val)
void * pthread_getspecific(pthread_key_t key)
◆ fn()
static void * fn ( void * arg) | static |
---|
Definition at line 119 of file thread-alloc.c.
121{
122 int i;
123
124
125
126
127
128
129#line 33 "alloc.pgc"
131
132#line 34 "alloc.pgc"
133 char name [ 100 ] ;
134
135#line 35 "alloc.pgc"
136 char ** r = NULL ;
137
138#line 36 "alloc.pgc"
139
140
143
144 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
145#line 41 "alloc.pgc"
146
148#line 41 "alloc.pgc"
149
151#line 42 "alloc.pgc"
152
154#line 42 "alloc.pgc"
155
157 {
158 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT,
159 ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
161#line 45 "alloc.pgc"
162
164#line 45 "alloc.pgc"
165
167#line 45 "alloc.pgc"
168
170 r = NULL;
171 }
173#line 49 "alloc.pgc"
174
176#line 49 "alloc.pgc"
177
178
179 return 0;
180}
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
bool ECPGdisconnect(int lineno, const char *connection_name)
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
References arg, ECPG_NOT_FOUND, ECPGconnect(), ECPGdisconnect(), ECPGdo(), ECPGsetcommit(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_NO_INDICATOR, free, i, name, REPEATS, sprintf, sqlca, sqlprint(), and value.
Referenced by _ArchiveEntry(), check_foreign_key(), close_walfile(), create_LifetimeEnd(), expand_tilde(), fmgr_symbol(), format_function_arguments(), format_function_signature(), main(), open_walfile(), ParseFuncOrColumn(), pgfnames_cleanup(), scan_directory(), scan_file(), SetOutput(), skipfile(), sql_check(), and transformFuncCall().
◆ main()
Definition at line 182 of file thread-alloc.c.
183{
184 intptr_t i;
185#ifdef WIN32
187#else
188 pthread_t threads[THREADS];
189#endif
190
191#ifdef WIN32
193 {
194 unsigned id;
195 threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
196 }
197
198 WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
200 CloseHandle(threads[i]);
201#else
203 pthread_create(&threads[i], NULL, fn, (void *) i);
205 pthread_join(threads[i], NULL);
206#endif
207
208 return 0;
209}
static void * fn(void *arg)