3 #define POSTGRES_ECPG_INTERNAL
14 #include "pg_config_paths.h"
23 #define LONG_LONG_MIN LLONG_MIN
25 #define LONG_LONG_MIN LONGLONG_MIN
34 'S',
'Q',
'L',
'C',
'A',
' ',
' ',
' '
45 'N',
'O',
'T',
' ',
'S',
'E',
'T',
' '
51 0, 0, 0, 0, 0, 0, 0, 0
54 '0',
'0',
'0',
'0',
'0'
88 connection_name ? connection_name :
ecpg_gettext(
"NULL"));
131 if (!
ecpg_init(con, connection_name, lineno))
160 ECPGtrans(
int lineno,
const char *connection_name,
const char *transaction)
165 if (!
ecpg_init(con, connection_name, lineno))
168 ecpg_log(
"ECPGtrans on line %d: action \"%s\"; connection \"%s\"\n", lineno, transaction, con ? con->
name :
"null");
182 strncmp(transaction,
"begin", 5) != 0 &&
183 strncmp(transaction,
"start", 5) != 0 &&
184 strncmp(transaction,
"commit prepared", 15) != 0 &&
185 strncmp(transaction,
"rollback prepared", 17) != 0)
235 const char *intl_format;
255 bufsize = strlen(intl_format) + 100;
299 *((
char *) ptr) =
'\0';
303 *((
short int *) ptr) = SHRT_MIN;
307 *((
int *) ptr) = INT_MIN;
312 *((
long *) ptr) = LONG_MIN;
319 memset((
char *) ptr, 0xff,
sizeof(
float));
322 memset((
char *) ptr, 0xff,
sizeof(
double));
332 memset((
char *) ptr, 0,
sizeof(
decimal));
336 memset((
char *) ptr, 0,
sizeof(
numeric));
340 memset((
char *) ptr, 0xff,
sizeof(
interval));
343 memset((
char *) ptr, 0xff,
sizeof(
timestamp));
351 _check(
const unsigned char *ptr,
int length)
353 for (length--; length >= 0; length--)
354 if (ptr[length] != 0xff)
368 if (*((
const char *) ptr) ==
'\0')
373 if (*((
const short int *) ptr) == SHRT_MIN)
378 if (*((
const int *) ptr) == INT_MIN)
384 if (*((
const long *) ptr) == LONG_MIN)
393 return _check(ptr,
sizeof(
float));
396 return _check(ptr,
sizeof(
double));
444 while ((istate = InterlockedExchange(&mp->
initstate, 2)) == 2)
447 InitializeCriticalSection(&mp->
csection);
450 EnterCriticalSection(&mp->
csection);
459 LeaveCriticalSection(&mp->
csection);
493 static volatile bool already_bound =
false;
500 int save_errno = GetLastError();
502 int save_errno = errno;
515 ldir = getenv(
"PGLOCALEDIR");
519 already_bound =
true;
525 SetLastError(save_errno);
553 for (ptr =
ivlist; ptr != NULL; ptr = ptr->
next)
555 if (ptr->
number == number)
577 strncpy(
sqlca->sqlstate,
"YE001",
sizeof(
sqlca->sqlstate));
578 snprintf(
sqlca->sqlerrm.sqlerrmc,
sizeof(
sqlca->sqlerrm.sqlerrmc),
"out of memory on line %d", lineno);
579 sqlca->sqlerrm.sqlerrml = strlen(
sqlca->sqlerrm.sqlerrmc);
598 return (ptr) ? ptr->
pointer : NULL;
#define PG_TEXTDOMAIN(domain)
struct connection * ecpg_get_connection(const char *connection_name)
static void PGresult * res
#define ECPG_OUT_OF_MEMORY
bool ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPAT_MODE compat)
#define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
#define ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST
void ecpg_raise(int line, int code, const char *sqlstate, const char *str)
@ ECPGt_unsigned_long_long
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
PGresult * PQexec(PGconn *conn, const char *query)
void ECPGset_var(int number, void *pointer, int lineno)
PGTransactionStatusType ECPGtransactionStatus(const char *connection_name)
static pthread_key_t sqlca_key
static void ecpg_sqlca_key_destructor(void *arg)
void ECPGdebug(int n, FILE *dbgs)
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
static struct sqlca_t sqlca_init
static pthread_mutex_t debug_init_mutex
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
static bool _check(const unsigned char *ptr, int length)
static pthread_mutex_t debug_mutex
bool ECPGis_noind_null(enum ECPGttype type, const void *ptr)
void ecpg_log(const char *format,...)
bool ecpg_init(const struct connection *con, const char *connection_name, const int lineno)
static FILE * debugstream
void * ECPGget_var(int number)
bool ECPGstatus(int lineno, const char *connection_name)
struct sqlca_t * ECPGget_sqlca(void)
void ecpg_init_sqlca(struct sqlca_t *sqlca)
static volatile int simple_debug
bool ecpg_internal_regression_mode
static void ecpg_sqlca_key_init(void)
static pthread_once_t sqlca_key_once
static void const char * fmt
static void const char fflush(stdout)
vfprintf(stderr, fmt, args)
void ECPGfree_auto_mem(void)
int pthread_mutex_unlock(pthread_mutex_t *mp)
void * pthread_getspecific(pthread_key_t key)
int pthread_mutex_lock(pthread_mutex_t *mp)
void pthread_setspecific(pthread_key_t key, void *val)
int pthread_mutex_init(pthread_mutex_t *mp, void *attr)
#define PTHREAD_MUTEX_INITIALIZER
char arr[FLEXIBLE_ARRAY_MEMBER]
CRITICAL_SECTION csection
static void * fn(void *arg)