Update of /cvsroot/monetdb/sql/src/backends/monet4
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19709/src/backends/monet4

Modified Files:
        sql_server.mx 
Log Message:
propagated changes of Saturday Nov 17 2007 - Tuesday Nov 20 2007
from the SQL_2-20 branch to the development trunk


Index: sql_server.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet4/sql_server.mx,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -d -r1.179 -r1.180
--- sql_server.mx       17 Nov 2007 16:32:55 -0000      1.179
+++ sql_server.mx       20 Nov 2007 13:26:58 -0000      1.180
@@ -265,6 +265,8 @@
 
        .COMMAND not_unique( BAT[oid,oid] b) : bit = not_unique; "check if the 
tail sorted bat b doesn't have unique tail values" 
 
+       .COMMAND storage( int t ) : int = atom_storage; "return the atoms (t) 
storage type"
+
 .END sql_server;
 
 @-
@@ -1463,6 +1465,12 @@
        return GDK_SUCCEED;
 }
 
+int atom_storage(int *t, int *i )
+{
+       *t = ATOMstorage(*i);
+       return GDK_SUCCEED;
+}
+
 @-
 An SQL session needs a minimal set of modules, shown below.
 The MIL procs should also be moved to the kernel, despite the
@@ -1534,9 +1542,9 @@
        return x.join(b1);
 }
 
-proc log2(int i) : int {
+proc log2(lng i) : int {
   var n := 0;
-  while(i > 1)  {
+  while(i > lng(1))  {
      i >>= 1;
      n :+= 1;
   }
@@ -1560,16 +1568,22 @@
 
 proc SQLgroup(BAT[oid,any] a) : grp {
        # handle the grouping for unique checks with the special _CTgroup 
-       if (and(or((a.ttype()=int),(a.ttype()=lng)),(a.count()>(256*1024)))) {
-               var N := (max(a) - min(a));
-               if (or((N.type()=lng),isnil(N)))
-                       N := a.count();
-               if (or((N > a.count()),(N<0)))
-                       N := a.count();
-               if (or((N = 0),(log2(N)=0))) {
+       if 
(and(or((storage(a.ttype())=int),(storage(a.ttype())=lng)),(a.count()>(256*1024))))
 {
+               var N := lng(0);
+               if (and(storage(a.ttype())=lng,a.ttype()!=lng))
+                       N := (lng(max(a)) - lng(min(a)));
+               if (and(storage(a.ttype())=int,a.ttype()!=int))
+                       N := lng(int(max(a)) - int(min(a)));
+               if (N=lng(0))
+                       N := lng(max(a) - min(a));
+               if (isnil(N))
+                       N := lng(a.count());
+               if (or((N > lng(a.count())),(N<lng(0))))
+                       N := lng(a.count());
+               if (or((N = lng(0)),(log2(lng(N))=0))) {
                        return 1;
                }
-               return _CTgroup(a, log2(N), 1); 
+               return _CTgroup(a, log2(lng(N)), 1); 
        }
        return CTgroup(a);
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to