Index: Connection.c =================================================================== --- Connection.c (revisi¢n: 1) +++ Connection.c (copia de trabajo) @@ -298,7 +298,6 @@ //----------------------------------------------------------------------------- // Connection_Connect() // Create a new connection object by connecting to the database. -// Anadido gestion de transacciones globales. Conexion al monitor transaccional //----------------------------------------------------------------------------- static int Connection_Connect( udt_Connection *self, // connection @@ -306,130 +305,107 @@ unsigned dsnLength, // length of TNS entry ub4 mode, // mode to connect as int threaded, // threaded? - int twophase, // allow two phase commit? - int global) // es transaccion global? + int twophase) // allow two phase commit? { ub4 credentialType = OCI_CRED_EXT; sword status; // allocate the server handle - if ( global == 0 ) { - status = OCIHandleAlloc(self->environment->handle, - (dvoid**) &self->serverHandle, OCI_HTYPE_SERVER, 0, 0); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): allocate server handle") < 0) - return -1; + status = OCIHandleAlloc(self->environment->handle, + (dvoid**) &self->serverHandle, OCI_HTYPE_SERVER, 0, 0); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): allocate server handle") < 0) + return -1; - // attach to the server - Py_BEGIN_ALLOW_THREADS - status = OCIServerAttach(self->serverHandle, - self->environment->errorHandle, (text*) dsn, dsnLength, - OCI_DEFAULT); - Py_END_ALLOW_THREADS - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): server attach") < 0) - return -1; + // attach to the server + Py_BEGIN_ALLOW_THREADS + status = OCIServerAttach(self->serverHandle, + self->environment->errorHandle, (text*) dsn, dsnLength, + OCI_DEFAULT); + Py_END_ALLOW_THREADS + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): server attach") < 0) + return -1; - // allocate the service context handle - status = OCIHandleAlloc(self->environment->handle, - (dvoid**) &self->handle, OCI_HTYPE_SVCCTX, 0, 0); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): allocate service context handle") < 0) - return -1; + // allocate the service context handle + status = OCIHandleAlloc(self->environment->handle, + (dvoid**) &self->handle, OCI_HTYPE_SVCCTX, 0, 0); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): allocate service context handle") < 0) + return -1; - // set attribute for server handle - status = OCIAttrSet(self->handle, OCI_HTYPE_SVCCTX, self->serverHandle, 0, - OCI_ATTR_SERVER, self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set server handle") < 0) - return -1; + // set attribute for server handle + status = OCIAttrSet(self->handle, OCI_HTYPE_SVCCTX, self->serverHandle, 0, + OCI_ATTR_SERVER, self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set server handle") < 0) + return -1; - // set the internal and external names; these are needed for global - // transactions but are limited in terms of the lengths of the strings - if (twophase) { - status = OCIAttrSet(self->serverHandle, OCI_HTYPE_SERVER, - (dvoid*) "cx_Oracle", 0, OCI_ATTR_INTERNAL_NAME, - self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set internal name") < 0) - return -1; - status = OCIAttrSet(self->serverHandle, OCI_HTYPE_SERVER, - (dvoid*) "cx_Oracle", 0, OCI_ATTR_EXTERNAL_NAME, - self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set external name") < 0) - return -1; - } + // set the internal and external names; these are needed for global + // transactions but are limited in terms of the lengths of the strings + if (twophase) { + status = OCIAttrSet(self->serverHandle, OCI_HTYPE_SERVER, + (dvoid*) "cx_Oracle", 0, OCI_ATTR_INTERNAL_NAME, + self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set internal name") < 0) + return -1; + status = OCIAttrSet(self->serverHandle, OCI_HTYPE_SERVER, + (dvoid*) "cx_Oracle", 0, OCI_ATTR_EXTERNAL_NAME, + self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set external name") < 0) + return -1; + } - // allocate the session handle - status = OCIHandleAlloc(self->environment->handle, - (dvoid**) &self->sessionHandle, OCI_HTYPE_SESSION, 0, 0); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): allocate session handle") < 0) - return -1; + // allocate the session handle + status = OCIHandleAlloc(self->environment->handle, + (dvoid**) &self->sessionHandle, OCI_HTYPE_SESSION, 0, 0); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): allocate session handle") < 0) + return -1; - // set user name in session handle - if (self->username && PyString_GET_SIZE(self->username) > 0) { - credentialType = OCI_CRED_RDBMS; - status = OCIAttrSet(self->sessionHandle, OCI_HTYPE_SESSION, - (text*) PyString_AS_STRING(self->username), - PyString_GET_SIZE(self->username), OCI_ATTR_USERNAME, - self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set user name") < 0) - return -1; - } + // set user name in session handle + if (self->username && PyString_GET_SIZE(self->username) > 0) { + credentialType = OCI_CRED_RDBMS; + status = OCIAttrSet(self->sessionHandle, OCI_HTYPE_SESSION, + (text*) PyString_AS_STRING(self->username), + PyString_GET_SIZE(self->username), OCI_ATTR_USERNAME, + self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set user name") < 0) + return -1; + } - // set password in session handle - if (self->password && PyString_GET_SIZE(self->password) > 0) { - credentialType = OCI_CRED_RDBMS; - status = OCIAttrSet(self->sessionHandle, OCI_HTYPE_SESSION, - (text*) PyString_AS_STRING(self->password), - PyString_GET_SIZE(self->password), OCI_ATTR_PASSWORD, - self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set password") < 0) - return -1; - } - - // set the session handle on the service context handle - status = OCIAttrSet(self->handle, OCI_HTYPE_SVCCTX, - self->sessionHandle, 0, OCI_ATTR_SESSION, - self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): set session handle") < 0) - return -1; - - // begin the session - Py_BEGIN_ALLOW_THREADS - status = OCISessionBegin(self->handle, self->environment->errorHandle, - self->sessionHandle, credentialType, mode); - Py_END_ALLOW_THREADS - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): begin session") < 0) { - self->sessionHandle = NULL; - return -1; - } + // set password in session handle + if (self->password && PyString_GET_SIZE(self->password) > 0) { + credentialType = OCI_CRED_RDBMS; + status = OCIAttrSet(self->sessionHandle, OCI_HTYPE_SESSION, + (text*) PyString_AS_STRING(self->password), + PyString_GET_SIZE(self->password), OCI_ATTR_PASSWORD, + self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set password") < 0) + return -1; } - else { - self->handle = xaoSvcCtx(NULL); - if (! self->handle) { - PyErr_SetString(PyExc_RuntimeError, - "Connection_Connect(): get DEFAULT service context handle"); - return NULL; - } - status = OCIAttrGet(self->handle, OCI_HTYPE_SVCCTX, &self->serverHandle, - 0, OCI_ATTR_SERVER, self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): get DEFAULT server handle") < 0) - return -1; + // set the session handle on the service context handle + status = OCIAttrSet(self->handle, OCI_HTYPE_SVCCTX, + self->sessionHandle, 0, OCI_ATTR_SESSION, + self->environment->errorHandle); + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): set session handle") < 0) + return -1; - status = OCIAttrGet(self->handle, OCI_HTYPE_SVCCTX, &self->sessionHandle, - 0, OCI_ATTR_SESSION, self->environment->errorHandle); - if (Environment_CheckForError(self->environment, status, - "Connection_Connect(): get DEFAULT session handle") < 0) - return -1; + // begin the session + Py_BEGIN_ALLOW_THREADS + status = OCISessionBegin(self->handle, self->environment->errorHandle, + self->sessionHandle, credentialType, mode); + Py_END_ALLOW_THREADS + if (Environment_CheckForError(self->environment, status, + "Connection_Connect(): begin session") < 0) { + self->sessionHandle = NULL; + return -1; } return 0; @@ -465,7 +441,6 @@ //----------------------------------------------------------------------------- // Connection_Init() // Initialize the connection members. -// Anadida variable global //----------------------------------------------------------------------------- static int Connection_Init( udt_Connection *self, // connection @@ -475,7 +450,7 @@ unsigned usernameLength, passwordLength, dsnLength; const char *username, *password, *dsn; PyObject *threadedObj, *twophaseObj; - int threaded, twophase, global; + int threaded, twophase; #ifdef ORACLE_9I udt_SessionPool *pool; #endif @@ -494,7 +469,7 @@ username = password = dsn = NULL; threadedObj = twophaseObj = NULL; usernameLength = passwordLength = dsnLength = 0; - global = threaded = twophase = 0; + threaded = twophase = 0; connectMode = OCI_DEFAULT; #ifdef ORACLE_9I pool = NULL; @@ -521,11 +496,7 @@ } // set up the environment - if ( username != NULL ) - if ( ! strcmp("DEFAULT", username) || ! strcmp("default", username) ) - global = 1; - - self->environment = Environment_New(threaded, global); + self->environment = Environment_New(threaded); if (!self->environment) return -1; @@ -586,7 +557,7 @@ return Connection_Acquire(self, pool); #endif return Connection_Connect(self, dsn, dsnLength, connectMode, threaded, - twophase, global); + twophase); } Index: cx_Oracle.c =================================================================== --- cx_Oracle.c (revisi¢n: 1) +++ cx_Oracle.c (copia de trabajo) @@ -64,11 +64,6 @@ static PyTypeObject *g_DateTimeType = NULL; static PyTypeObject *g_DecimalType = NULL; -//----------------------------------------------------------------------------- -// xaosw() -// Variable externa para protocolo XA en Oracle -//----------------------------------------------------------------------------- -extern struct xa_switch_t xaosw; //----------------------------------------------------------------------------- // SetException() @@ -239,29 +234,9 @@ #endif } -//----------------------------------------------------------------------------- -// xaosw_func() -// Devuelve la estructura xaosw -//----------------------------------------------------------------------------- -static PyObject* xaosw_func( - PyObject* self, - PyObject* args) -{ - PyObject *xao = NULL; - xao = PyCObject_FromVoidPtr((void *) &xaosw, NULL); - if ( xao == NULL ) { - PyErr_SetString(g_NotSupportedErrorException, - "Can't get xaosw structure"); - return NULL; - } - - return xao; -} - //----------------------------------------------------------------------------- // Declaration of methods supported by this module -// Anadido el metodo xaosw para recuperar la estructura xa de Oracle //----------------------------------------------------------------------------- static PyMethodDef g_ModuleMethods[] = { { "makedsn", MakeDSN, METH_VARARGS }, @@ -272,7 +247,6 @@ { "DateFromTicks", DateFromTicks, METH_VARARGS }, { "TimeFromTicks", TimeFromTicks, METH_VARARGS }, { "TimestampFromTicks", TimestampFromTicks, METH_VARARGS }, - { "xaosw", xaosw_func, METH_VARARGS }, { NULL } }; Index: Environment.c =================================================================== --- Environment.c (revisi¢n: 1) +++ Environment.c (copia de trabajo) @@ -56,11 +56,9 @@ //----------------------------------------------------------------------------- // Environment_New() // Create a new environment object. -// Anadido parametro de transaccion global //----------------------------------------------------------------------------- static udt_Environment *Environment_New( - int threaded, // use threaded mode? - int global) // en transaccion global? + int threaded) // use threaded mode? { udt_Environment *environment; sword status; @@ -81,27 +79,14 @@ mode |= OCI_THREADED; // create the environment handle - if ( global == 0 ) { - status = OCIEnvCreate(&environment->handle, mode, NULL, NULL, - NULL, NULL, 0, NULL); - if (!environment->handle) { - Py_DECREF(environment); - PyErr_SetString(PyExc_RuntimeError, - "Unable to acquire Oracle environment handle"); - return NULL; - } - } - else { - status = 0; - environment->handle = xaoEnv(NULL); - if (!environment->handle) { - Py_DECREF(environment); - PyErr_SetString(PyExc_RuntimeError, - "Unable to acquire DEFAULT environment handle"); + status = OCIEnvCreate(&environment->handle, mode, NULL, NULL, + NULL, NULL, 0, NULL); + if (!environment->handle) { + Py_DECREF(environment); + PyErr_SetString(PyExc_RuntimeError, + "Unable to acquire Oracle environment handle"); return NULL; - } } - if (Environment_CheckForError(environment, status, "Environment_New(): create env handle") < 0) { environment->handle = NULL; Index: SessionPool.c =================================================================== --- SessionPool.c (revisi¢n: 1) +++ SessionPool.c (copia de trabajo) @@ -158,8 +158,6 @@ //----------------------------------------------------------------------------- // SessionPool_Init() // Initialize the session pool object. -// La creacion del entorno siempre implica transaccion local, no pueden -// coexistir un gestor de sessiones y un gestor de transacciones //----------------------------------------------------------------------------- static int SessionPool_Init( udt_SessionPool *self, // session pool object @@ -212,7 +210,7 @@ self->sessionIncrement = sessionIncrement; // set up the environment - self->environment = Environment_New(threaded, 0); + self->environment = Environment_New(threaded); if (!self->environment) return -1;