Update of /cvsroot/monetdb/pathfinder/compiler/sql
In directory
sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv17272/compiler/sql
Modified Files:
Tag: XQFT
lalg2sql.brg
Log Message:
propagated changes of Monday Apr 19 2010
from the development trunk to the XQFT branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010/04/19 - ts-tum: compiler/sql/lalg2sql.brg,1.172
-- SQL code generation change: instead of 'sysibm.sysdummy1', we now generate
a pseudo-literal table for the translation of serialize_rel (nil, empty_tbl).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: lalg2sql.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/lalg2sql.brg,v
retrieving revision 1.168.2.2
retrieving revision 1.168.2.3
diff -u -d -r1.168.2.2 -r1.168.2.3
--- lalg2sql.brg 18 Mar 2010 11:29:31 -0000 1.168.2.2
+++ lalg2sql.brg 19 Apr 2010 13:50:41 -0000 1.168.2.3
@@ -2586,11 +2586,17 @@
Let's generate a pseudo-query whose result is an empty table:
SELECT -1 AS iter_nat, -1 AS pos_nat, ... AS item_...
- FROM sysibm.sysdummy1 AS a0000
+ FROM (VALUES (-1)) AS a0000(item1_int)
WHERE 1 = 0;
*/
PFsql_t *selectlist = NULL;
+ PFsql_t **list = NULL;
+ PFsql_t **l_list = NULL;
+ PFsql_aident_t newalias = new_alias ();
+
+ /* generate the selectlist based on the empty table's schema */
+ /* => SELECT -1 AS iter_nat, -1 AS pos_nat, ... AS item_... */
PFalg_schema_t schema = p->schema;
int count = schema.count;
for(int i = 0; i < count; i++)
@@ -2621,21 +2627,37 @@
}
- /* call a helper function that does the 'real' job */
+ /* generate the fromlist based on a pseudo literal table */
+ /* => FROM (VALUES (-1)) AS a0000(item1_int) */
+ list = PFmalloc (sizeof (PFsql_t *));
+ l_list = PFmalloc (sizeof (PFsql_t *));
+
+ list[0] = lit_int (-1);
+ l_list[0] = PFsql_stmt_list_ (1, (const PFsql_t **) list);
+
+ col_env_add (COLMAP (p),
+ col_item1,
+ aat_int,
+ ext_column_name (newalias,
+ new_col (col_item1, aat_int)));
+
+ from_list_add (FROMLIST(p),
+ values (PFsql_list_list_(1,
+ (const PFsql_t **) l_list)),
+ alias_def (newalias, column_list (
+ NULL, column_name (
+ new_col (col_item1, aat_int)))));
+
+
+ /* generate the final query */
PFsql_t* final_query = PFsql_select (
false,
selectlist,
- from_list(
- alias_bind (
- schema_table_name (
- "sysibm",
- table_name (PF_SQL_TABLE_SYSDUMMY1)),
- alias (new_alias ()))),
+ transform_frommap (p),
where_list (
eq (lit_int (1), lit_int (0))),
NULL,
NULL);
-
sql_stmts = root (nil (), final_query);
}
@@ -2887,6 +2909,7 @@
}
/* do not copy singleton relation */
+ /* todo: trigger the rewrite on cardinality instead of "sysibm" */
{
PFsql_t *tbl = from_list_at (FROMLIST(R(p)), 0).table;
if (!(PFarray_last (FROMLIST(R(p))) == 1 &&
@@ -4821,6 +4844,7 @@
item_expr = col_env_lookup (COLMAP(p), col, aat_str);
/* throw away singleton relation */
+ /* todo: trigger the rewrite on cardinality instead of "sysibm" */
if (PFarray_last (FROMLIST(p)) == 1) {
PFsql_t *tbl = from_list_at (FROMLIST(p), 0).table;
if (tbl->kind == sql_schema_tbl_name &&
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins