Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18720/algebra/opt

Modified Files:
        opt_complex.c 
Log Message:
-- Bugfix: In opt_complex.c we cannot rely on the correct schema
           stored in an operator (as the children might have changed).


Index: opt_complex.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_complex.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- opt_complex.c       11 Jan 2008 12:49:09 -0000      1.36
+++ opt_complex.c       11 Jan 2008 16:47:20 -0000      1.37
@@ -1044,25 +1044,24 @@
                 PFprop_key (p->prop,
                             PFord_order_col_at (p->sem.sort.sortby, 0))) {
                 /* create projection list */
-                PFalg_proj_t *proj_list = PFmalloc (p->schema.count *
-                                                    sizeof (*(proj_list)));
+                PFalg_proj_t *proj_list = PFmalloc ((L(p)->schema.count + 1)
+                                                    * sizeof (*(proj_list)));
 
-                /* copy the schema and replace the rownum result column
-                   by its input */
-                for (unsigned int i = 0; i < p->schema.count; i++)
-                    if (p->schema.items[i].name !=
-                        p->sem.sort.res)
-                        proj_list[i] = PFalg_proj (
-                                           p->schema.items[i].name,
-                                           p->schema.items[i].name);
-                    else
-                        proj_list[i] = PFalg_proj (
-                                           p->sem.sort.res,
-                                           PFord_order_col_at (
-                                               p->sem.sort.sortby,
-                                               0));
+                /* copy the child schema (as we cannot be sure that
+                   the schema of the rownum operator is still valid) ...*/
+                for (unsigned int i = 0; i < L(p)->schema.count; i++)
+                    proj_list[i] = PFalg_proj (
+                                       L(p)->schema.items[i].name,
+                                       L(p)->schema.items[i].name);
 
-                *p = *PFla_project_ (L(p), p->schema.count, proj_list);
+                /* ... and extend it with the sort
+                   criterion as new rownum column */
+                proj_list[L(p)->schema.count] = PFalg_proj (
+                                                    p->sem.sort.res,
+                                                    PFord_order_col_at (
+                                                        p->sem.sort.sortby, 
0));
+
+                *p = *PFla_project_ (L(p), L(p)->schema.count + 1, proj_list);
             }
             break;
             


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to