[Zope-Checkins] CVS: Products/DCOracle2/src - dco2.c:1.113

Matthew T. Kromer matt@zope.com
Mon, 15 Jul 2002 10:12:53 -0400


Update of /cvs-repository/Products/DCOracle2/src
In directory cvs.zope.org:/tmp/cvs-serv480/src

Modified Files:
	dco2.c 
Log Message:
Checkin slightly busted XID support from this weekend.  Unfortunately, using
XIDs seems to lead to invalid svchp handles, so it doesnt seem very useful.

Getting the transaction XID will work without problems; what doesnt work right
is doing a rollback/commit, setting an XID, and starting a new transaction.



=== Products/DCOracle2/src/dco2.c 1.112 => 1.113 === (657/757 lines abridged)
 #include <fcntl.h>
 #include <time.h>
 #include <oci.h>
+/* Next header is XID structure from Oracle */
+#include <xa.h>
 #include <Python.h>
 #include <pythread.h>
 
@@ -199,6 +201,25 @@
 */
 
 /*
+** The Transaction object represents the transaction ID that is associated
+** with a service context.
+*/
+
+typedef struct {
+	PyObject_HEAD
+	OCITrans	*tranp;			/* Transaction ID 	*/
+	OCIError	*errhp;			/* Error handle		*/
+	int		flags;			/* Flags		*/
+	PyObject	*name;			/* Transaction Name	*/
+	XID		xid;			/* XID			*/
+} TransactionContext;
+
+staticforward PyTypeObject TransactionContextType;
+
+#define TC_XID (1<<0)
+#define TC_NAME (1<<1)
+
+/*
 ** The Server Context describes the various OCI handles that are used to
 ** represent a session
 **
@@ -213,10 +234,12 @@
 	OCIServer	*srvhp;			/* Server handle	*/
 	OCISession	*usrhp;			/* User handle		*/
 	OCISvcCtx	*svchp;			/* Service Context	*/
+	TransactionContext *tctx;		/* Transaction Context  */
 } ServerContext;
 
 staticforward PyTypeObject ServerContextType;
 
+
 /*
 ** Cursors can have lots of bindings...
 */
@@ -508,6 +531,12 @@
 static PyObject *ServerContext_rollback(ServerContext *self, PyObject *args);
 static PyObject *ServerContext_describe(ServerContext *self, PyObject *args);

[-=- -=- -=- 657 lines omitted -=- -=- -=-]

+	}
+
+	self->flags |= TC_XID;
+
+	TRACE(T_EXIT,("s", "TransactionContext_setXID"));
+
+	Py_INCREF(Py_None);
+	return Py_None;
+}
+
+/*
+** TransactionContext_flushCache
+**
+** flush the XID cache
+*/
+
+PyObject *TransactionContext_flushCache(TransactionContext *self, PyObject *args) {
+
+
+	TRACE(T_ENTRY,("sA", "TransactionContext_flushCache", args));
+
+	Py_XDECREF(self->name);
+	self->name = NULL;
+
+	memset(&self->xid, 0, sizeof(self->xid));
+
+	self->flags &= ~(TC_NAME|TC_XID);
+
+	TRACE(T_EXIT,("s", "TransactionContext_flushCache"));
+
+	Py_INCREF(Py_None);
+	return Py_None;
+}
+
+
+/*
 ** OracleDate_alloc
 **
 */
@@ -7188,6 +7778,10 @@
 	ServerContextType.ob_type = &PyType_Type;
 	PyDict_SetItemString(dict, "ServerContextType",
 		OBJECT(&ServerContextType));
+
+	TransactionContextType.ob_type = &PyType_Type;
+	PyDict_SetItemString(dict, "TransactionContextType",
+		OBJECT(&TransactionContextType));
 
 	LobLocatorType.ob_type = &PyType_Type;
 	PyDict_SetItemString(dict, "LobLocatorType",