Changeset: dc198a96657a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dc198a96657a Modified Files: Branch: default Log Message:
Merge git master into default diffs (truncated from 2388 to 300 lines): diff -r 5afb63be5387 -r dc198a96657a pathfinder/compiler/Makefile.ag --- a/pathfinder/compiler/Makefile.ag Wed Jun 16 09:02:46 2010 +0200 +++ b/pathfinder/compiler/Makefile.ag Wed Jun 16 11:49:23 2010 +0200 @@ -41,6 +41,7 @@ env.c \ oops.c \ pfstrings.c \ + plan_bundle.c \ qname.c \ scope.c \ timer.c \ @@ -53,6 +54,7 @@ env.c \ oops.c \ pfstrings.c \ + plan_bundle.c \ qname.c \ timer.c } @@ -76,7 +78,7 @@ sql/libsql \ # xmlimport/libxmlimport \ - utils/libstringutils \ + utils/libstringutils \ # $(LIBGC_LDADD) $(LIBGC_LIBS) \ $(LIBXML2_LDADD) $(LIBXML2_LIBS) \ @@ -102,8 +104,9 @@ algebra/liblogical \ debug/liblogdebug \ libcompiler3 \ - utils/libstringutils \ + utils/libstringutils \ semantics/libns \ + semantics/liboptions \ mem/libmem \ $(LIBGC_LDADD) $(LIBGC_LIBS) \ $(LIBXML2_LDADD) $(LIBXML2_LIBS) \ @@ -129,8 +132,9 @@ sql/libsql \ debug/libprettyp \ libcompiler3 \ - utils/libstringutils \ + utils/libstringutils \ semantics/libns \ + semantics/liboptions \ mem/libmem \ $(LIBGC_LDADD) $(LIBGC_LIBS) \ $(LIBXML2_LDADD) $(LIBXML2_LIBS) \ @@ -140,4 +144,34 @@ main_sql.c } +# PF/Ferry library that reads in a Logical Algbra plan in XML format, +# optimizes it, and provides various output formats (DOT, XML, SQL). +# +# (Note that the linker requires all used symbols to be listed +# before their definition, which makes e.g., libmem a good candidate +# for the last item of the list.) +lib_pf_ferry = { + LIBS = \ + ./algebra/liblogopt \ + ./algebra/map/libmap \ + ./algebra/opt/libopt \ + ./algebra/prop/libprop \ + ./xmlimport/libxmlimport \ + ./algebra/liblogical \ + ./sql/libsql \ + ./debug/libprettyp \ + ./debug/liblogdebug \ + ./libcompiler3 \ + ./utils/libstringutils \ + ./semantics/libns \ + ./semantics/liboptions \ + ./mem/libmem_embedded \ + $(LIBGC_LDADD) $(LIBGC_LIBS) \ + $(LIBXML2_LDADD) $(LIBXML2_LIBS) \ + $(SOCKET_LIBS) $(DL_LIBS) + + SOURCES = \ + pf_ferry.c +} + EXTRA_DIST = win32_getopt.c diff -r 5afb63be5387 -r dc198a96657a pathfinder/compiler/compile.c --- a/pathfinder/compiler/compile.c Wed Jun 16 09:02:46 2010 +0200 +++ b/pathfinder/compiler/compile.c Wed Jun 16 11:49:23 2010 +0200 @@ -61,7 +61,6 @@ #include "options.h" /* extract option declarations from parse tree */ #include "xquery_fo.h" /* built-in XQuery F&O */ #include "func_chk.h" /* function resolution */ -#include "prettyp.h" #include "abssynprint.h" #include "coreprint.h" #include "logdebug.h" @@ -301,17 +300,17 @@ int PFcompile (char *url, FILE *pfout, PFstate_t *status) { - PFpnode_t *proot = NULL; - PFcnode_t *croot = NULL; + PFpnode_t *proot = NULL; + PFcnode_t *croot = NULL; /* We either have a plan bundle in @a lapb or a logical query plan in @a laroot. */ - PFla_pb_t *lapb = NULL; - PFla_op_t *laroot = NULL; - PFpa_op_t *paroot = NULL; - PFmil_t *mroot = NULL; - PFarray_t *mil_program = NULL; - char *xquery = NULL; - int module_base; + PFla_pb_t *lapb = NULL; + PFla_op_t *laroot = NULL; + PFpa_op_t *paroot = NULL; + PFmil_t *mroot = NULL; + PFchar_array_t *mil_program = NULL; + char *xquery = NULL; + int module_base; /* elapsed time for compiler phase */ long tm, tm_first = 0; @@ -680,46 +679,26 @@ /* Split Point: SQL Code Generation */ /************************************/ if (status->output_format == PFoutput_format_sql) { - unsigned int i = 0, c; - /* plan bundle emits SQL code wrapped in XML tags */ - if (lapb) - fprintf (pfout, "<query_plan_bundle>\n"); - /* If we have a plan bundle we have to generate - a SQL query for each query plan. */ - do { - /* plan bundle emits SQL code wrapped in XML tags - with additional column and linking information */ - if (lapb) { - laroot = PFla_pb_op_at (lapb, i); - assert (laroot->kind == la_serialize_rel); + PFchar_array_t *sql_str = PFchar_array (4096); - fprintf (pfout, "<query_plan id=\"%i\"", - PFla_pb_id_at (lapb, i)); - if (PFla_pb_idref_at (lapb, i) != -1) - fprintf (pfout, " idref=\"%i\" colref=\"%i\"", - PFla_pb_idref_at (lapb, i), - PFla_pb_colref_at (lapb, i)); - fprintf (pfout, ">\n"); - fprintf (pfout, - "<schema>\n" - " <column name=\"%s\" function=\"iter\"/>\n", - PFcol_str (laroot->sem.ser_rel.iter)); - for (c = 0; c < clsize (laroot->sem.ser_rel.items); c++) - fprintf (pfout, - " <column name=\"%s\" new=\"false\"" - " function=\"item\"" - " position=\"%u\"/>\n", - PFcol_str (clat (laroot->sem.ser_rel.items, c)), - c); - fprintf (pfout, "</schema>\n" - "<query>" + /** + * Iterate over the plan_bundle list lapb and bind every item to laroot_. + * + * BEWARE: macro has to be used in combination with macro PFla_pb_end. + */ + PFla_pb_foreach (sql_str, laroot_, lapb, laroot) + + + + /* plan bundle emits SQL code wrapped in XML tags */ + if (lapb) + PFarray_printf (sql_str, + " <query>" "<![CDATA[\n"); - i++; - } /* generate the SQL code */ tm = PFtimer_start (); - PFsql_t *sqlroot = PFlalg2sql(laroot); + PFsql_t *sqlroot = PFlalg2sql(laroot_); tm = PFtimer_stop (tm); if (status->timing) PFlog ("Compilation to SQL:\t\t\t %s", PFtimer_str (tm)); @@ -739,23 +718,28 @@ /* serialize the internal SQL query tree */ tm = PFtimer_start (); - PFsql_print (pfout, sqlroot); + PFsql_print (sql_str, sqlroot); tm = PFtimer_stop (tm); if (status->timing) PFlog ("SQL Code generation:\t\t\t %s", PFtimer_str (tm)); /* plan bundle emits SQL code wrapped in XML tags */ if (lapb) - fprintf (pfout, "]]>" - "</query>\n" - "</query_plan>\n"); + PFarray_printf (sql_str, + "]]>" + "</query>\n"); - /* iterate over the plans in the plan bundle */ - } while (lapb && i < PFla_pb_size (lapb)); - /* plan bundle emits SQL code wrapped in XML tags */ - if (lapb) - fprintf (pfout, "</query_plan_bundle>\n"); + + /** + * Iterate over the plan_bundle list lapb and bind every item to laroot_. + * + * BEWARE: macro has to be used in combination with macro PFla_pb_foreach. + */ + PFla_pb_foreach_end (sql_str, lapb) + + /* print the resulting string to the output stream */ + fputs (sql_str->base, pfout); goto bailout; } @@ -919,26 +903,28 @@ /* print algebra tree if requested */ if (status->print_la_tree) { + PFchar_array_t *out_str = PFchar_array (4096); if (laroot) { if (status->print_pretty) { PFinfo (OOPS_WARNING, "Cannot prettyprint logical algebra tree. Sorry."); } if (status->print_dot) - PFla_dot (pfout, laroot, status->format); + PFla_dot (out_str, laroot, status->format); if (status->print_xml) - PFla_xml (pfout, laroot, status->format); + PFla_xml (out_str, laroot, status->format); } else if (lapb) { if (status->print_dot) - PFla_dot_bundle (pfout, lapb, status->format); + PFla_dot_bundle (out_str, lapb, status->format); if (status->print_xml) - PFla_xml_bundle (pfout, lapb, status->format); + PFla_xml_bundle (out_str, lapb, status->format); } else PFinfo (OOPS_NOTICE, "logical algebra tree not available " "at this point of compilation"); + fputs (out_str->base, pfout); } /* print MIL algebra tree if requested */ @@ -990,10 +976,10 @@ long timing; int module_base; /* for ALGEBRA (PFoutput_format_mil) & SQL (PFoutput_format_sql) */ - PFla_op_t *laroot = NULL; - PFpa_op_t *paroot = NULL; - PFmil_t *mroot = NULL; - PFarray_t *serialized_mil_code = NULL; + PFla_op_t *laroot = NULL; + PFpa_op_t *paroot = NULL; + PFmil_t *mroot = NULL; + PFchar_array_t *serialized_mil_code = NULL; PFguide_list_t *guide_list = NULL; /* guide list */ /* for MILPRINT_SUMMER (PFoutput_format_milprint_summer) */ char *intern_prologue = NULL, diff -r 5afb63be5387 -r dc198a96657a pathfinder/compiler/debug/abssynprint.c --- a/pathfinder/compiler/debug/abssynprint.c Wed Jun 16 09:02:46 2010 +0200 +++ b/pathfinder/compiler/debug/abssynprint.c Wed Jun 16 11:49:23 2010 +0200 @@ -563,11 +563,14 @@ void PFabssyn_pretty (FILE *f, PFpnode_t *t, bool qnames_resolved) { + PFchar_array_t *a = PFchar_array (500); + PFprettyprintf ("%c", START_BLOCK); abssyn_pretty (t, qnames_resolved); PFprettyprintf ("%c", END_BLOCK); - (void) PFprettyp (f); + PFprettyp (a); + fputs (a->base, f); fputc ('\n', f); } diff -r 5afb63be5387 -r dc198a96657a pathfinder/compiler/debug/coreprint.c --- a/pathfinder/compiler/debug/coreprint.c Wed Jun 16 09:02:46 2010 +0200 +++ b/pathfinder/compiler/debug/coreprint.c Wed Jun 16 11:49:23 2010 +0200 @@ -51,7 +51,6 @@ /* PFesc_string */ #include "pfstrings.h" -#include "prettyp.h" #include <assert.h> _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list