PostgreSQL Source Code git master
Loading...
Searching...
No Matches
thread-alloc.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdint.h>
#include <stdlib.h>
#include "ecpg_config.h"
#include <pthread.h>
#include <stdio.h>
Include dependency graph for thread-alloc.c:

Go to the source code of this file.

Data Structures

struct  sqlca_t
 

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_tECPGget_sqlca (void)
 
static voidfn (void *arg)
 
int main ()
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
  Y 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file thread-alloc.c.

◆ PGDLLIMPORT

#define PGDLLIMPORT

Definition at line 36 of file thread-alloc.c.

◆ POSTGRES_SQLCA_H

#define POSTGRES_SQLCA_H

Definition at line 30 of file thread-alloc.c.

◆ REPEATS

#define REPEATS   50

Definition at line 25 of file thread-alloc.c.

◆ sqlca

#define sqlca   (*ECPGget_sqlca())

Definition at line 87 of file thread-alloc.c.

◆ SQLERRMC_LEN

#define SQLERRMC_LEN   150

Definition at line 40 of file thread-alloc.c.

◆ THREADS

#define THREADS   16

Definition at line 24 of file thread-alloc.c.

Function Documentation

◆ ECPGget_sqlca()

struct sqlca_t * ECPGget_sqlca ( void  )

Definition at line 108 of file misc.c.

109{
110 struct sqlca_t *sqlca;
111
113
115 if (sqlca == NULL)
116 {
117 sqlca = malloc(sizeof(struct sqlca_t));
118 if (sqlca == NULL)
119 return NULL;
122 }
123 return sqlca;
124}
static pthread_key_t sqlca_key
Definition misc.c:58
void ecpg_init_sqlca(struct sqlca_t *sqlca)
Definition misc.c:67
static void ecpg_sqlca_key_init(void)
Definition misc.c:102
static pthread_once_t sqlca_key_once
Definition misc.c:59
static int fb(int x)
void pthread_setspecific(pthread_key_t key, void *val)
void * pthread_getspecific(pthread_key_t key)
#define malloc(a)
#define sqlca
Definition sqlca.h:59

◆ fn()

static void * fn ( void arg)
static

Definition at line 119 of file thread-alloc.c.

121{
122 int i;
123
124 /* exec sql begin declare section */
125
126
127
128
129#line 33 "alloc.pgc"
130 int value ;
131
132#line 34 "alloc.pgc"
133 char name [ 100 ] ;
134
135#line 35 "alloc.pgc"
136 char ** r = NULL ;
137/* exec sql end declare section */
138#line 36 "alloc.pgc"
139
140
141 value = (intptr_t) arg;
142 sprintf(name, "Connection: %d", value);
143
144 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
145#line 41 "alloc.pgc"
146
147if (sqlca.sqlcode < 0) sqlprint();}
148#line 41 "alloc.pgc"
149
150 { ECPGsetcommit(__LINE__, "on", NULL);
151#line 42 "alloc.pgc"
152
153if (sqlca.sqlcode < 0) sqlprint();}
154#line 42 "alloc.pgc"
155
156 for (i = 1; i <= REPEATS; ++i)
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
163if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
164#line 45 "alloc.pgc"
165
166if (sqlca.sqlcode < 0) sqlprint();}
167#line 45 "alloc.pgc"
168
169 free(r);
170 r = NULL;
171 }
173#line 49 "alloc.pgc"
174
175if (sqlca.sqlcode < 0) sqlprint();}
176#line 49 "alloc.pgc"
177
178
179 return 0;
180}
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
Definition connect.c:158
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition connect.c:693
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition connect.c:260
#define ECPG_NOT_FOUND
Definition ecpgerrno.h:10
@ ECPGst_normal
Definition ecpgtype.h:97
@ ECPGt_EOIT
Definition ecpgtype.h:62
@ ECPGt_NO_INDICATOR
Definition ecpgtype.h:64
@ ECPGt_EORT
Definition ecpgtype.h:63
@ ECPGt_char
Definition ecpgtype.h:43
void sqlprint(void)
Definition error.c:334
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,...)
Definition execute.c:2291
static struct @172 value
int i
Definition isn.c:77
void * arg
#define sprintf
Definition port.h:262
#define free(a)
#define REPEATS
#define sqlca
const char * name

References arg, ECPG_NOT_FOUND, ECPGconnect(), ECPGdisconnect(), ECPGdo(), ECPGsetcommit(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_NO_INDICATOR, fb(), free, i, name, REPEATS, sprintf, sqlca, sqlprint(), and value.

Referenced by _ArchiveEntry(), _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()

int main ( void  )

Definition at line 182 of file thread-alloc.c.

183{
184 intptr_t i;
185#ifdef WIN32
187#else
189#endif
190
191#ifdef WIN32
192 for (i = 0; i < THREADS; ++i)
193 {
194 unsigned id;
195 threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
196 }
197
199 for (i = 0; i < THREADS; ++i)
201#else
202 for (i = 0; i < THREADS; ++i)
203 pthread_create(&threads[i], NULL, fn, (void *) i);
204 for (i = 0; i < THREADS; ++i)
206#endif
207
208 return 0;
209}
static void * fn(void *arg)
#define THREADS

References fb(), fn(), i, and THREADS.