Update of /cvsroot/monetdb/sql/src/common
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28466/src/common

Modified Files:
        sql_list.mx 
Log Message:
propagated changes of Friday Nov 20 2009 - Saturday Nov 28 2009
from the Nov2009 branch to the development trunk

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/11/20 - nielsnes: src/common/sql_list.mx,1.21.2.2
  new optimizer to fix (performance) bug. We should always start grouping with
  a sorted column (if its part of a group by list).
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: sql_list.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/common/sql_list.mx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- sql_list.mx 12 Nov 2009 08:39:29 -0000      1.22
+++ sql_list.mx 28 Nov 2009 19:56:35 -0000      1.23
@@ -80,7 +80,9 @@
 int
 list_length(list *l)
 {
-       return l->cnt;
+       if (l)
+               return l->cnt;
+       return 0;
 }
 
 list *
@@ -254,6 +256,27 @@
 }
 
 list *
+list_keysort(list *l, int *keys, fdup dup)
+{
+       list *res = list_create(l->destroy);
+       node *n = NULL;
+       int i, j, *pos, cnt = list_length(l);
+
+       pos = (int*)alloca(cnt*sizeof(int));
+       for (n = l->h, i = 0; n; n = n->next, i++) {
+               pos[i] = i;
+       }
+       /* sort descending */
+       GDKqsort_rev(keys, pos, NULL, cnt, sizeof(int), sizeof(int), TYPE_int);
+       for(j=0; j<cnt; j++) {
+               for(n = l->h, i = 0; n && i != pos[j]; n = n->next, i++) 
+                       ;
+               list_append(res, dup(n->data));
+       }
+       return res;
+}
+
+list *
 list_sort(list *l, fkeyvalue key, fdup dup)
 {
        list *res = list_create(l->destroy);


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to