Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4318/src/backends/monet5

Modified Files:
        sql_result.mx 
Log Message:
propagated changes of Tuesday Jul 14 2009 - Monday Jul 20 2009
from the May2009 branch to the development trunk

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/07/14 - mr-meltdown: src/backends/monet5/sql_result.mx,1.115.2.1
Fix some spacing, no content change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/07/19 - nielsnes: src/backends/monet5/sql_result.mx,1.115.2.2
applied (adapted) utf8 patch

it fixes utf8 strings lengths, ie we now return number of unicode characters
not number of bytes.
NULL now all have a length of 0 characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- sql_result.mx       28 Apr 2009 11:38:05 -0000      1.115
+++ sql_result.mx       20 Jul 2009 13:56:38 -0000      1.116
@@ -49,6 +49,7 @@
 
 #include "sql_config.h"
 #include "sql_result.h"
+#include <str.h>
 #include <tablet.h>
 #include <mtime.h>
 #include <bat/res_table.h>
@@ -222,18 +223,20 @@
        return (int) (s - *buf);
 }
 
-static size_t
+static int
 bat_max_strlength(BAT *b)
 {
        BUN p, q;
-       size_t max = 0;
-       size_t l = 0;
+       int l = 0;
+       int max = 0;
        BATiter bi = bat_iterator(b);
 
        BATloop(b, p, q) {
-               char *s = BUNtail(bi, p);
-               l = strlen(s);
+               str v = (str) BUNtail(bi, p);
+               strLength(&l, v);
 
+               if (l == int_nil) 
+                       l = 0;
                if (l > max)
                        max = l;
        }
@@ -251,16 +254,19 @@
        BATiter bi = bat_iterator(b);
 
        BATloop(b, p, q) {
+               lng m = 0;
                @1 l = *((@1 *)BUNtail(bi, p));
-               if (l == @1_nil) l = 4;
-               if (l > max) max = l;
-               if (l < min) min = l;
+
+               if (l != @1_nil)
+                       m = l;
+               if (m > max) max = m;
+               if (m < min) min = m;
        }
 
-       if ((-min * 10) > max) max = (-min * 10);
+       if ((-min * 10) > max) 
+               max = (-min * 10);
        while (max /= 10) ret++;
-       ret++;
-       
+               ret++;
        return ret;
 }
 @c
@@ -361,8 +367,15 @@
        if (type == TYPE_str) {
                sql_column *col = (sql_column*)c->extra;
 
-               if (col->type.digits > 0 && (unsigned)(e-s) > col->type.digits)
-                       return NULL;
+               if (col->type.digits > 0 && (unsigned)(e-s) > col->type.digits){
+                       str v = (str)s;
+                       strLength(&len, v);
+
+                       if (len == int_nil) 
+                               len = 4;
+                       if ((unsigned int) len > col->type.digits) 
+                               return NULL;
+               }
                return TABLETstrFrStr(c, s, e);
        }
         
@@ -668,6 +681,9 @@
                case TYPE_int:
                        ok = mvc_send_int(s, *(int*)p);
                        break;
+               case TYPE_lng:
+                       ok = mvc_send_lng(s, *(lng*)p);
+                       break;
                default: {
                        l = (*BATatoms[mtype].atomToStr) (buf, len, p);
                        ok = (stream_write(s, *buf, l, 1) == 1);
@@ -805,17 +821,20 @@
                if (eclass == EC_CHAR) {
                        ok = mvc_send_int(s, digits);
                } else {
-                       count = 0;
+                       int l = 0;
                        if (bid) {
                                BAT *b = BATdescriptor(bid);
 
-                               count = bat_max_strlength(b);
+                               l = bat_max_strlength(b);
                                BBPunfix(b->batCacheid);
-                       } else {
-                               if (p) count = strlen((char *) p);
-                               else count = 4;
+                       } else if (p) {
+                               str v = (str) p;
+
+                               strLength(&l, v);
+                               if (l == int_nil) 
+                                       l = 0;
                        }
-                       ok = mvc_send_lng(s, (lng) count);
+                       ok = mvc_send_int(s, l);
                }
        } else if (eclass == EC_NUM) {
                count = 0;
@@ -849,7 +868,7 @@
                                while (val /= 10) count++;
                                count++;
                        } else {
-                               count = 4;
+                               count = 0;
                        }
                }
                ok = mvc_send_lng(s, (lng) count);
@@ -907,6 +926,7 @@
        (void) qtype; /* pacify compiler in case asserts are disabled */
 #endif
        assert(qtype == Q_TABLE);
+
        if (stream_write(s, "&1 0 1 1 1\n", 11, 1) == 1 &&
            /* fallback to default tuplecount (1) and id (0) */
            /* TODO first header name then values */
@@ -1054,7 +1074,8 @@
        for (i = 0; i < t->nr_cols; i++) {
                res_col *c = t->cols + i;
 
-               if (stream_write(s, c->type.type->sqlname, 
strlen(c->type.type->sqlname), 1) != 1)
+               if (stream_write(s, c->type.type->sqlname,
+                                       strlen(c->type.type->sqlname), 1) != 1)
                        return export_error(order);
                if (i + 1 < t->nr_cols && stream_write(s, ",\t", 2, 1) != 1)
                        return export_error(order);


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to