mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
- Fixed Informix compat math functions to cope with the situations
where one argument takes the result. - Applied thread patches by Lee Kindness
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.13 2004/02/10 07:26:25 tgl Exp $
|
||||
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.14 2004/03/14 12:16:29 meskes Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
|
||||
|
||||
NAME= ecpg
|
||||
SO_MAJOR_VERSION= 4
|
||||
SO_MINOR_VERSION= 1
|
||||
SO_MINOR_VERSION= 2
|
||||
|
||||
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.19 2003/11/29 19:52:08 pgsql Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.20 2004/03/14 12:16:29 meskes Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@@ -14,9 +14,20 @@
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_key_t actual_connection_key;
|
||||
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
|
||||
#else
|
||||
static struct connection *actual_connection = NULL;
|
||||
#endif
|
||||
static struct connection *all_connections = NULL;
|
||||
static struct connection *actual_connection = NULL;
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static void
|
||||
ecpg_actual_connection_init(void)
|
||||
{
|
||||
pthread_key_create(&actual_connection_key, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct connection *
|
||||
ecpg_get_connection_nr(const char *connection_name)
|
||||
@@ -24,7 +35,13 @@ ecpg_get_connection_nr(const char *connection_name)
|
||||
struct connection *ret = NULL;
|
||||
|
||||
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
|
||||
{
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
ret = pthread_getspecific(actual_connection_key);
|
||||
#else
|
||||
ret = actual_connection;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
struct connection *con;
|
||||
@@ -86,8 +103,13 @@ ecpg_finish(struct connection * act)
|
||||
con->next = act->next;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
if( pthread_getspecific(actual_connection_key) == act )
|
||||
pthread_setspecific(actual_connection_key, all_connections);
|
||||
#else
|
||||
if (actual_connection == act)
|
||||
actual_connection = all_connections;
|
||||
#endif
|
||||
|
||||
ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
|
||||
|
||||
@@ -150,7 +172,11 @@ ECPGsetconn(int lineno, const char *connection_name)
|
||||
if (!ECPGinit(con, connection_name, lineno))
|
||||
return (false);
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_setspecific(actual_connection_key, con);
|
||||
#else
|
||||
actual_connection = con;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -370,7 +396,13 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
||||
else
|
||||
this->next = all_connections;
|
||||
|
||||
actual_connection = all_connections = this;
|
||||
all_connections = this;
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
|
||||
pthread_setspecific(actual_connection_key, all_connections);
|
||||
#else
|
||||
actual_connection = all_connections;
|
||||
#endif
|
||||
|
||||
ECPGlog("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
|
||||
realname ? realname : "<DEFAULT>",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.18 2003/11/29 19:52:08 pgsql Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.19 2004/03/14 12:16:30 meskes Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@@ -118,10 +118,15 @@ ECPGinit(const struct connection * con, const char *connection_name, const int l
|
||||
}
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static void
|
||||
ecpg_sqlca_key_init(void)
|
||||
static void *ecpg_sqlca_key_destructor(void *arg)
|
||||
{
|
||||
pthread_key_create(&sqlca_key, NULL);
|
||||
if( arg != NULL )
|
||||
free(arg); /* sqlca structure allocated in ECPGget_sqlca */
|
||||
}
|
||||
|
||||
static void ecpg_sqlca_key_init(void)
|
||||
{
|
||||
pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user