--On May 22, 2009 10:17:47 PM +0200 Markus Hoenicka <markus.hoeni...@mhoenicka.de> wrote:

Mike Alexander writes:
 > I've attached a patch to fix this.  This patch makes the code
bigger,   > but not much slower.  If this is a problem it could be
made conditional   > on the endianess of the target machine, but this
didn't seem worth the   > trouble to me.

Thanks Mike. I've applied the patch and tested it without any problems
on FreeBSD. Unfortunately I can't test things on a PowerPC box myself,
as "make check" in libdbi-drivers should have revealed this problem
long ago. I didn't make the code conditional as it doesn't seem to
cause much speed loss on low-endian machines, if at all.

Thanks. Unfortunately I noticed a couple of issues with this patch. One of the data types supported by the union is DBI_INTEGER_SIZE3 but the union doesn't have a 3 byte integer field. My change yesterday treated it as if it were a 2 byte field, but looking closer I see that the rest of the code treats it as if it were a 4 byte field. I've attached a new patch that fixes this. All that's needed is moving 2 "case DBI_INTEGER_SIZE3" statements one or two lines later.

The other thing I noticed is that the Oracle driver still has an endian problem. It lies about the type in the dbi_data_t struct that it returns. It stores a long long value for all DBI_INTEGER_SIZE* types. This won't work on a big endian machine (after my changes). See the code around line 640 in dbd_oracle.c to see what I'm talking about. Since I don't have Oracle or documentation for its API, this is not something I'm prepared to fix.

--
Mike Alexander           m...@umich.edu
Ann Arbor, MI            PGP key ID: BEA343A6
--- old/dbi_result.c	2009-05-21 19:07:09.000000000 -0400
+++ src/dbi_result.c	2009-05-23 00:25:42.000000000 -0400
@@ -891,6 +891,7 @@
 
   switch (RESULT->field_attribs[fieldidx] & DBI_INTEGER_SIZEMASK) {
   case DBI_INTEGER_SIZE1:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_char;
   case DBI_INTEGER_SIZE2:
     return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_short;
   case DBI_INTEGER_SIZE3:
@@ -947,7 +948,9 @@
 
   switch (RESULT->field_attribs[fieldidx] & DBI_INTEGER_SIZEMASK) {
   case DBI_INTEGER_SIZE1:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_char;
   case DBI_INTEGER_SIZE2:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_short;
   case DBI_INTEGER_SIZE3:
   case DBI_INTEGER_SIZE4:
     return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_long;
@@ -995,9 +998,12 @@
 
   switch (RESULT->field_attribs[fieldidx] & DBI_INTEGER_SIZEMASK) {
   case DBI_INTEGER_SIZE1:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_char;
   case DBI_INTEGER_SIZE2:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_short;
   case DBI_INTEGER_SIZE3:
   case DBI_INTEGER_SIZE4:
+    return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_long;
   case DBI_INTEGER_SIZE8:
     return RESULT->rows[RESULT->currowidx]->field_values[fieldidx].d_longlong;
   default:
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
libdbi-devel mailing list
libdbi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-devel

Reply via email to