Changeset: 3ddce7b7e6db for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ddce7b7e6db Modified Files: pathfinder/compiler/Makefile.ag pathfinder/compiler/algebra-m5sql/Makefile.ag pathfinder/compiler/algebra-m5sql/lalg2msa.c pathfinder/compiler/algebra-m5sql/msa.c pathfinder/compiler/algebra-m5sql/msaprint.c pathfinder/compiler/algebra/alg_dag.c pathfinder/compiler/algebra/algebra.c pathfinder/compiler/algebra/logical.c pathfinder/compiler/compile.c pathfinder/compiler/include/Makefile.ag pathfinder/compiler/include/alg_dag.h pathfinder/compiler/include/compile.h pathfinder/compiler/include/lalg2msa.h pathfinder/compiler/include/logical.h pathfinder/compiler/include/msa.h pathfinder/compiler/include/msa_mnemonic.h pathfinder/compiler/include/msaprint.h pathfinder/compiler/main.c pathfinder/runtime/Makefile.ag Branch: default Log Message:
Merged Pathfinder to MonetDB5 SQL algebra compiler project into PF2M5 branch commit e53213ce89ad1d44d4f15f7e14b1d64be50ff063 Author: Thomas Ressel <[email protected]> Date: Mon May 10 17:49:19 2010 +0200 Added first draft of new (generic) DAG traversal This version still uses old DAG traversal. commit d6db6981ecd573e14e5144c129fb006bc051b3f3 Author: Thomas Ressel <[email protected]> Date: Thu May 6 09:53:11 2010 +0200 Changed sem.groupby.grp_crit_list to sem.groupby_grp_list. More minor changes. commit fe00096fa2879706e3beea81e51f69054331a134 Author: Thomas Ressel <[email protected]> Date: Wed May 5 22:40:05 2010 +0200 Added remaining aggregation functions (dist, all, prod, seqty1) Added semantical field of table operator to keep the original column names Introduced new type of expressions for rank, rowrank and rownum commit 1e6a18e1c03886efbbd68b114a0d123bd89b0bf6 Author: Thomas Ressel <[email protected]> Date: Mon May 3 21:56:31 2010 +0200 Changed distinct operator translation to now perform bind with distinct flag set to true. Introduced msa_mnemonic.h. Introduced "deep-copy" solution to problem of references to same cols in a select-project operator tuple (first version!). Refined translation of la_rownum, la_rank and la_rowrank. commit ef128a1bedc82136fed83eadf7a82d4a0f9817da Author: Thomas Ressel <[email protected]> Date: Wed Apr 28 12:43:09 2010 +0200 Translation now DAG-like to prevent duplicate printing of operators Translation of eqjoin without binding child operators (first version!) Implemented translation of la_aggr (changes in msa.h/msa.c: added semantical field for partitioning column) Implemented translation of la_distinct (changes in msa.h/msa.c: PFmsa_distinct just marks operator as distinct, constructors of operators propagate distinct flag up) Added propagation of sort order information in translation of la_rownum, la_rowrank and la_rank Changed msaprint to show presence of distinct flag in projection operator: PROJECT DISTINCT commit bf6c0ba157197decd7117c14da3c6e9981d4c472 Author: Thomas Ressel <[email protected]> Date: Mon Apr 26 14:16:36 2010 +0200 Implemented la_distinct operator: Passing up of distinct flag till a msa_project operator is built (binding) commit 296411bfac80ac83c98b111fb1e8056d418ba185 Author: Thomas Ressel <[email protected]> Date: Mon Apr 26 13:57:28 2010 +0200 Edited comments commit c667670cec2fa56e0f5340e2ec3360833d637d61 Author: Thomas Ressel <[email protected]> Date: Mon Apr 26 13:44:49 2010 +0200 Added lists for sort cols and partitioning cols in semantical field of la_func (and therefor necessary changes in DAG traversal, see file msaprint.c and alg_dag.c) Added operators la_rownum, rowrank, rank and rowid Refined translation of select operator Fixed buggy implementation of la_project translation commit 20100dd3f2e620d7256451705ba7be0d912d554a Author: Thomas Ressel <[email protected]> Date: Thu Apr 22 11:35:59 2010 +0200 Added PFmsa_expr_func_names for la_rank, la_rowrank Therefor changes in msaprint.c (printing of la_rank, la_rowrank functions) Minor changes in msa.c (constructor of function expression) Implemented binding and more operators in lalg2msa.c commit efab1baaf07842b568c7e3f88c0d3b6c2c1db5b3 Author: Thomas Ressel <[email protected]> Date: Fri Apr 16 07:13:42 2010 +0200 Insertet mnemonics Bug fixing in general translation scheme commit e7543a2814be3eaeab02782a9991e65566c9c509 Author: Thomas Ressel <[email protected]> Date: Mon Apr 12 15:44:24 2010 +0200 Bugfixing in constructor of PFmsa_expr_func commit c106fa5208da8afb1e2ba1b3db165a012ed2aca2 Author: Thomas Ressel <[email protected]> Date: Mon Apr 12 15:23:05 2010 +0200 Bugfixing regarding la_not operator translation commit 5761f53fac3a862d2b7d32a0752acab13115e69a Author: Thomas Ressel <[email protected]> Date: Mon Apr 12 09:23:36 2010 +0200 Added support of la_num_eq and la_num_gt operators in translation commit ffe3a714c00e2d9dbfd0fae32c3d87c58f5bf188 Author: Thomas Ressel <[email protected]> Date: Sun Apr 11 20:11:50 2010 +0200 Commented, discarded unnecessary prints commit 03c76a2b9a277149c3b22540157c77d12cc2ee1a Author: Thomas Ressel <[email protected]> Date: Sun Apr 11 20:11:02 2010 +0200 First implementation of translation from la to msa. commit 2bd8820e3a16789cdf420dc294a3417be07e36cd Author: Thomas Ressel <[email protected]> Date: Thu Apr 1 09:55:41 2010 +0200 Minor changes in lalg2msa.c commit 28c518d29198b3c4dee7c874605dbca280e440d6 Author: Thomas Ressel <[email protected]> Date: Sun Mar 28 18:57:04 2010 +0200 Added annotation for la to msa translation in logical.h commit 6e0503257ee957f70352634809c757f11564b403 Author: Thomas Ressel <[email protected]> Date: Mon Mar 22 08:19:13 2010 +0100 Added annotation field in PFmsa_op_t commit 045b00678c205dd9cea92ddec28df29c70a2239d Merge: 00fc7ff 9261a04 Author: Thomas Ressel <[email protected]> Date: Thu Mar 18 11:32:32 2010 +0100 Merge branch 'master' of dbgrp.informatik.uni-tuebingen.de:PF2M5 Conflicts: pathfinder/compiler/algebra-m5sql/msaprint.c commit 00fc7ffff5eb018a88693371136d2692ea4b1c7d Author: Thomas Ressel <[email protected]> Date: Wed Mar 17 21:11:33 2010 +0100 Completed printing of operator info commit 9261a045c955b54b566f27e4a1b50b8ab5d181d9 Author: Jan Rittinger <[email protected]> Date: Tue Mar 16 15:17:15 2010 +0100 -- cleanup during discussion commit 63757e5c7e483fb8894a0d12d3bb8747c0545e12 Author: Thomas Ressel <[email protected]> Date: Tue Mar 16 09:04:33 2010 +0100 added printing of groupby op commit f09d619a9670dc010a3cc379bb03823c83451e30 Author: Thomas Ressel <[email protected]> Date: Sun Mar 14 21:43:13 2010 +0100 1 commit 4b1cdcd3c4b10344d8d56084a2431ee4e0273584 Author: Thomas Ressel <[email protected]> Date: Sun Mar 14 20:55:57 2010 +0100 Minor changes commit a8988a86af52f347b4092b5fe97becfbda5ffa19 Author: Jan Rittinger <[email protected]> Date: Thu Mar 11 14:16:24 2010 +0100 -- Improved pretty-printing commit 9a6bac349ea08d9e68829cdde05e1905cb878878 Author: Thomas Ressel <[email protected]> Date: Thu Mar 11 10:31:25 2010 +0100 Minor changes commit 048ff2d1adf9faadf668122597e5153756c9a305 Author: Thomas Ressel <[email protected]> Date: Thu Mar 11 09:44:51 2010 +0100 Dot colors changed commit d2677ae247d7cef4cc248e0e77f9920771080863 Author: Thomas Ressel <[email protected]> Date: Thu Mar 11 09:00:57 2010 +0100 Major changes in dot output commit ad8ddbba6736042f052f3a2e36486de5312b72ac Author: Jan Rittinger <[email protected]> Date: Thu Mar 4 15:46:54 2010 +0100 Sketched some ideas commit 4bc28649adf4d82335a89c11d04ce2203126bae4 Author: Thomas Ressel <[email protected]> Date: Thu Mar 4 08:22:10 2010 +0100 Simplified PFmsa_distinct Removed unnecessary printf commit 62f76ab83622c0ad906d25f2e37436b49424cfdd Author: Thomas Ressel <[email protected]> Date: Wed Mar 3 19:31:07 2010 +0100 Added comments commit ff950d5671f6df43e789e18ea5056ea6fc663dbc Author: Thomas Ressel <[email protected]> Date: Wed Mar 3 19:03:31 2010 +0100 In msa.h: Moved distinct flag to PFmsa_op_t Added expressions that represent arithmetic functions such as add, sub, mult, div, mod In msa.c: Added function to "make" every operator distinct Union and except operators now check only for corresponding type (polymophy is possible in XQuery) Added auxiliary functions to extract schemata from expression lists or to copy schema of operators In lalg2msa.c: Build 3 example queries using data structures of msa.c commit bdf6c83c62358f860ddef5aec7ca5ed57340936e Author: Jan Rittinger <[email protected]> Date: Mon Feb 22 15:56:49 2010 +0100 -- Während der Diskussion erstellte Änderungen commit b3ad36dd7249946c29caddbdaab930e69f3bf1a7 Author: Thomas Ressel <[email protected]> Date: Sun Feb 21 21:26:40 2010 +0100 Changed arguments of expr_cols_in_schema function Adapted semantical information for serialize relation operator. commit 4c791d19fb6eed9dcc9a17cdaac3cb766f841d76 Author: Thomas Ressel <[email protected]> Date: Fri Feb 19 15:04:00 2010 +0100 minor changes (Pushed exprlist definitions to top of file) commit 97f5807e95448ec265f0832a36fff245ab79cde8 Author: Thomas Ressel <[email protected]> Date: Fri Feb 19 15:01:27 2010 +0100 Added further abbreviation for expression list in msa.c (e.g. elat(el, i) abbreviates PFmsa_exprlist_at(el, i)) commit 166dac85cf7bcd55edfce3dd3f2ed63939cff200 Author: Thomas Ressel <[email protected]> Date: Thu Feb 18 20:39:10 2010 +0100 Changed name of auxiliary function commit f74612d5a9a98027a84f4f7dcfd1ffdbe5050766 Author: Thomas Ressel <[email protected]> Date: Thu Feb 18 20:31:42 2010 +0100 Introduced one single constructor for comparison expressions such as equal, gt, gte Changed semantics, constructors of expressions and operators Still to do: constructor for expr_func constructor for op_serialize_rel mnemonics for PFmsa_exprllist_t testing auxiliary func to determine if an expr only references to cols in a certain schema commit ad0ba2a3f50cce13b3f7747234e15191d74532d1 Author: Thomas Ressel <[email protected]> Date: Mon Feb 15 20:35:54 2010 +0100 Begun implementing operator table and literal table, begun using PFoops for error mgmt commit d29e5b2e98e37da83761ed269bec25dc6e181af8 Author: Thomas Ressel <[email protected]> Date: Mon Feb 15 17:56:08 2010 +0100 Changed expressions and operators semantics and constructors commit 48550e84cbc096ec077b8cb34a028b5bd85fedf2 Author: Jan Rittinger <[email protected]> Date: Fri Feb 12 15:46:53 2010 +0100 -- some adjustments to the expression and operator types commit e4578e0a8cc9b44ceb00b26fce87e53986e33b76 Author: Thomas Ressel <[email protected]> Date: Fri Feb 12 13:13:38 2010 +0100 Added semantical field for serialize relation operator: field with names of columns that represent iter, pos and items commit fc8a5ee6dd5c9f68b82d9e1479608a35e428e2b9 Author: Thomas Ressel <[email protected]> Date: Fri Feb 12 10:55:57 2010 +0100 Added loop to initialize children of op and expr with NULL commit f2c701a9b01e181fca2b220c0e1128a171be4eb9 Author: Thomas Ressel <[email protected]> Date: Thu Feb 11 18:36:47 2010 +0100 Changed names of msa_func to msa_expr_func and msa_join to msa_op_join Changed semantical information of expressions Spaces instead of tabs commit ae1dcdd0df001cfdfac4b2176c94c2a48b4e479d Merge: 18a0576 2234e9b Author: Jan Rittinger <[email protected]> Date: Thu Feb 11 15:15:46 2010 +0100 Merge branch 'master' of dbgrp.informatik.uni-tuebingen.de:PF2M5 Conflicts: pathfinder/compiler/algebra-m5sql/msa.c pathfinder/compiler/include/msa.h commit 18a0576cca0cb197796be1b6ee727fef427859a9 Author: Jan Rittinger <[email protected]> Date: Thu Feb 11 15:08:46 2010 +0100 -- Added stub for printer commit 2234e9b8d787ae99edbd7864d2b61372392ccb71 Author: Thomas Ressel <[email protected]> Date: Thu Feb 11 14:32:22 2010 +0100 Expression constructors refined. commit 77ba12b629c11e735db32db137a88e7807885f37 Author: Thomas Ressel <[email protected]> Date: Thu Feb 11 11:19:56 2010 +0100 First draft commit 8ad2e9e91d8df670dda305d9d6c9a798c081a657 Author: Jan Rittinger <[email protected]> Date: Wed Jan 27 16:29:13 2010 +0100 -- Added stub for M5 SQL algebra diffs (truncated from 4066 to 300 lines): diff -r 93e4d15fe948 -r 3ddce7b7e6db pathfinder/compiler/Makefile.ag --- a/pathfinder/compiler/Makefile.ag Sun May 09 13:58:39 2010 +0200 +++ b/pathfinder/compiler/Makefile.ag Mon May 10 21:34:13 2010 +0200 @@ -21,7 +21,7 @@ # 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All # Rights Reserved. -SUBDIRS = utils schema debug mem parser semantics core algebra mil include sql xmlimport +SUBDIRS = utils schema debug mem parser semantics core algebra mil include sql algebra-m5sql xmlimport EXTRA_DIST_DIR = Tests @@ -72,6 +72,7 @@ mil/libmil \ libcompiler2 \ mem/libmem \ + algebra-m5sql/libmsa \ sql/libsql \ # xmlimport/libxmlimport \ diff -r 93e4d15fe948 -r 3ddce7b7e6db pathfinder/compiler/algebra-m5sql/Makefile.ag --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pathfinder/compiler/algebra-m5sql/Makefile.ag Mon May 10 21:34:13 2010 +0200 @@ -0,0 +1,48 @@ +# +# Copyright Notice: +# ----------------- +# +# The contents of this file are subject to the Pathfinder Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://monetdb.cwi.nl/Legal/PathfinderLicense-1.1.html +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# The Original Code is the Pathfinder system. +# +# The Original Code has initially been developed by the Database & +# Information Systems Group at the University of Konstanz, Germany and +# the Database Group at the Technische Universitaet Muenchen, Germany. +# It is now maintained by the Database Systems Group at the Eberhard +# Karls Universitaet Tuebingen, Germany. Portions created by the +# University of Konstanz, the Technische Universitaet Muenchen, and the +# Universitaet Tuebingen are Copyright (C) 2000-2005 University of +# Konstanz, (C) 2005-2008 Technische Universitaet Muenchen, and (C) +# 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All +# Rights Reserved. +# +# Fri Oct 27 10:05:33 CEST 2006, Manuel Mayr + +INCLUDES = ../include $(MONETDB_INCS) + +# locally disable "-Werror" +#X_CFLAGS = "-pedantic" + +# ignore warning "null dimension: sizeof()" +# with Sun Studio 12 compiler +lalg2msa_CFLAGS = $(SUN_NOERR_CFLAGS) + +lib_msa = { + NOINST + DIR = libdir + SOURCES = \ + lalg2msa.c \ + msa.c \ + msaprint.c +} + +#EXTRA_DIST = diff -r 93e4d15fe948 -r 3ddce7b7e6db pathfinder/compiler/algebra-m5sql/lalg2msa.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pathfinder/compiler/algebra-m5sql/lalg2msa.c Mon May 10 21:34:13 2010 +0200 @@ -0,0 +1,1052 @@ +/** + * @file + * + * Transforms the logical algebra tree into a tree that represents + * SQL statements. + * + * Copyright Notice: + * ----------------- + * + * The contents of this file are subject to the Pathfinder Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://monetdb.cwi.nl/Legal/PathfinderLicense-1.1.html + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the Pathfinder system. + * + * The Original Code has initially been developed by the Database & + * Information Systems Group at the University of Konstanz, Germany and + * the Database Group at the Technische Universitaet Muenchen, Germany. + * It is now maintained by the Database Systems Group at the Eberhard + * Karls Universitaet Tuebingen, Germany. Portions created by the + * University of Konstanz, the Technische Universitaet Muenchen, and the + * Universitaet Tuebingen are Copyright (C) 2000-2005 University of + * Konstanz, (C) 2005-2008 Technische Universitaet Muenchen, and (C) + * 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All + * Rights Reserved. + * + * $Id: $ + */ + +/* always include pf_config.h first! */ +#include "pf_config.h" +#include "pathfinder.h" + +/** assert() */ +#include <assert.h> +/** fprintf() */ +#include <stdio.h> +/** strcpy, strlen, ... */ +#include <string.h> + +#include "oops.h" /* PFoops() */ +#include "mem.h" +#include "array.h" +#include "string_utils.h" + +#include "lalg2msa.h" + +/* Easily access subtree-parts */ +#include "child_mnemonic.h" + +#include "msa.h" +#include "algebra.h" +#include "alg_dag.h" +#include "ordering.h" + +#include "msa_mnemonic.h" + +/* Auxiliary function that searches for a certain col + in a expression list and returns an expression + representing the found column. If no column was + found, NULL will be returned */ +static PFmsa_expr_t * +find_expr(PFmsa_exprlist_t *expr_list, PFalg_col_t col) +{ + unsigned int i; + + for (i = 0; i < elsize(expr_list); i++) { + PFmsa_expr_t *curr_expr = elat(expr_list, i); + if ((curr_expr->col) == col) + return curr_expr; + } + return NULL; +} + +/* Auxiliary function that constructs an expression list containing + column references of the columns in a schema */ +static PFmsa_exprlist_t * +exprlist_from_schema(PFalg_schema_t schema) +{ + unsigned int i; + PFmsa_exprlist_t *ret = el(schema.count); + + for (i = 0; i < schema.count; i++) { + PFmsa_expr_t *new_expr = PFmsa_expr_column(schema.items[i].name, schema.items[i].type); + eladd(ret) = new_expr; + } + + return ret; +} + +static PFmsa_expr_t * +deep_copy_expr(PFmsa_expr_t *n) +{ + PFmsa_expr_t *ret = PFmalloc (sizeof(PFmsa_expr_t)); + memcpy(ret, n, sizeof(PFmsa_expr_t)); + unsigned int i; + + for (i = 0; i < PFMSA_OP_MAXCHILD && n->child[i]; i++) { + ret->child[i] = deep_copy_expr(n->child[i]); + } + + return ret; +} + +/* Bind a msa operator to a la operator during translation. That is: + Put a selection and projection operator on top of the current + operator to 'materialize' changes in schema and predicates */ +static void +bind(PFla_op_t *n) +{ + PFmsa_op_t *sel = PFmsa_op_select (OP(n), SEL_LIST(n)); + PFmsa_op_t *prj = PFmsa_op_project (sel, false, PRJ_LIST(n)); + + OP(n) = prj; + PRJ_LIST(n) = exprlist_from_schema (n->schema); + SEL_LIST(n) = el(1); + + return; +} + +/* ----- Translate the logical algebra into M5 SQL algebra ----- */ + +/* Worker that performes translation from la to msa. Note that + not every operator is translated 1-to-1 but so called selection + and projection lists are carried along, which represent changes + in schema (e.g. attaching of a row) or selection predicates. + + The function is bottom-up: We descend to leaf nodes, compute + operators and lists and write them to an annotation field (msa_ann) + in the original la operator */ +static void +alg2msa_worker(PFla_op_t *n) +{ + unsigned int i; + /* declarations need for the translation: msa annotation and its contents */ + PFmsa_ann_t *msa_ann; + PFmsa_op_t *op; + PFmsa_exprlist_t *prj_list; + PFmsa_exprlist_t *sel_list; + + /* traverse child operators recursively */ + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) { + if (!n->child[i]->bit_dag) + alg2msa_worker(n->child[i]); + } + + switch (n->kind) { + + case la_serialize_seq: + { + PFalg_collist_t *collist; + + /* bind node containing la DAG */ + bind(R(n)); + + /* la_side_effects node will not be bound */ + + /* build list containing the item column */ + collist = PFalg_collist(1); + PFalg_collist_add(collist) = n->sem.ser_seq.item; + + op = PFmsa_op_serialize_rel(OP (R(n)), + OP (L(n)), + col_NULL, + n->sem.ser_seq.pos, + collist); + + /* not necessary to set project nor select list */ + } + break; + + case la_serialize_rel: + + /* FIXME: NOT TESTED YET! */ + + /* bind node with la DAG */ + bind(R(n)); + + /* la_side_effects node will not be bound */ + + op = PFmsa_op_serialize_rel(OP (R(n)), + OP (L(n)), + n->sem.ser_rel.iter, + n->sem.ser_rel.pos, + n->sem.ser_rel.items); + + /* not necessary to set project nor select list */ + + break; + + case la_side_effects: + + /* build operator and lists */ + op = PFmsa_op_nil_node(); + prj_list = NULL; + sel_list = NULL; + + break; + + case la_lit_tbl: + /* Build literal table operator with the information + of the original la operator. */ + + /* build operator and lists */ + op = PFmsa_op_literal_table(n->schema, n->sem.lit_tbl.count, + n->sem.lit_tbl.tuples); + prj_list = exprlist_from_schema(n->schema); + sel_list = el(1); + + break; + + case la_empty_tbl: + /* Build empty table operator with the schema + of the original la operator. */ + + /* build operator and lists */ + op = PFmsa_op_literal_table(n->schema, 0, + NULL); _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
