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

Matthew T. Kromer matt at zope.com
Mon Aug 11 11:33:21 EDT 2003


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

Modified Files:
	dco2.c 
Log Message:
Fix for Christian Long, regarding datatypes on Binding Arrays being
mismatched by keeping IN OUT datatypes for binding array cells.  A cell's
datatype was set on write based on type detection.  This might disagree with
the definition of the BindingArray.  

A string object being written to a BindingArray will be coerced into a
the binding array's type by changing the data type of the cell and shortening
the length by 1 (assuming the bind wasnt SQLT_STR).

When the dynamic output bind recieves a datatype that doesn't match the
definition of the binding array, it will update that cell's type information
to match the binding array.


=== Products/DCOracle2/src/dco2.c 1.133 => 1.134 ===
--- Products/DCOracle2/src/dco2.c:1.133	Tue May  6 12:29:22 2003
+++ Products/DCOracle2/src/dco2.c	Mon Aug 11 10:33:15 2003
@@ -143,6 +143,11 @@
 #define USEOBJECT
 #endif
 
+/* Turn off zero length conversion to NULL by default */
+#ifndef ZEROLENISNULL
+#define ZEROLENISNULL 0
+#endif
+
 /* Get around unused warnings with GCC -Wall by using this on a def for
 ** intentionally unused items.   Currently "ID" and "Traceprint" are
 ** meant to be unused; Traceprint is for debugging.
@@ -3039,6 +3044,14 @@
 					"%d derived\n",
 					binding->dty, bao->ba->dtyp[iter]);
 				*/
+
+				/* Well, whatever WAS here isnt the type
+				** that Oracle sent back, so update
+				** the type now.  One hopes that it
+				** didn't get sent in incorrectly.
+				*/
+
+				bao->ba->dtyp[iter] = binding->dty;
 			}
 		}
 
@@ -4813,12 +4826,14 @@
 
 	len = *rlenp;
 
-	if (len == 0) {
+#if ZEROLENISNULL
+	if (len == 0) 
 		Py_INCREF(Py_None);
 		TRACE(T_EXIT,("sAs", "ResultSetItem_value", Py_None,
 			"0 Len"));
 		return Py_None;
 	}
+#endif
 
 	typeline = typeByType(self->rs->dty);
 
@@ -7089,7 +7104,6 @@
 	ba->alenp[i] = mybind.alen;
 	ba->rcodep[i] = mybind.rcode;
 	
-
 	if (ba->count < i+1)
 		ba->count = i+1;
 
@@ -7116,6 +7130,23 @@
 
 
 	Py_XDECREF(mybind.object);	/* release the object ref */
+
+
+	if (ba->dtyp[i] != bao->dty) {
+		TRACE(T_ERROR,("ssdd", "BindingArrayObject_ass_item",
+			"Type mismatch on assignment", ba->dtyp[i], bao->dty));
+
+		if (ba->dtyp[i] == SQLT_STR) {
+			/* If it was a string, just make it whatever it is
+			** supposed to be
+			*/
+			ba->dtyp[i] = bao->dty;
+			/* Correct for trailing null */
+			ba->valueszp[i] = ba->valueszp[i] - 1;
+			ba->alenp[i] = ba->alenp[i] - 1;
+		}
+
+	}
 
 	if (bindvalue != value) {
 		Py_DECREF(bindvalue);




More information about the Zope-Checkins mailing list