Update of /cvsroot/monetdb/pathfinder/compiler/sql
In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv3278/compiler/sql
Modified Files:
Tag: XQFT
lalg2sql.brg
Log Message:
propagated changes of Thursday Apr 22 2010 - Sunday Apr 25 2010
from the development trunk to the XQFT branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010/04/22 - tsheyar: compiler/sql/lalg2sql.brg,1.173
-- Support comparison of boolean values in SQL code generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: lalg2sql.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/lalg2sql.brg,v
retrieving revision 1.168.2.3
retrieving revision 1.168.2.4
diff -u -d -r1.168.2.3 -r1.168.2.4
--- lalg2sql.brg 19 Apr 2010 13:50:41 -0000 1.168.2.3
+++ lalg2sql.brg 25 Apr 2010 20:50:49 -0000 1.168.2.4
@@ -3770,7 +3770,11 @@
/* Rel: num_gt (Rel) */
case 27:
{
- PFsql_t * (*op) (const PFsql_t *, const PFsql_t *);
+ PFsql_t *(*op) (const PFsql_t *, const PFsql_t *);
+ PFalg_simple_type_t lty = type_of (p, p->sem.binary.col1),
+ rty = type_of (p, p->sem.binary.col2);
+ PFsql_t *lcol,
+ *rcol;
/* copy all existing column, from, and where lists */
copy_cols_from_where (p, L(p));
@@ -3780,16 +3784,27 @@
else
op = PFsql_gt;
+ lcol = col_env_lookup (COLMAP(p), p->sem.binary.col1, lty);
+ rcol = col_env_lookup (COLMAP(p), p->sem.binary.col2, rty);
+
+ /* for databases without boolean types we have to fake the
+ comparison of boolean values (by using integers) */
+ if (lty == aat_bln) {
+ lcol = (lcol->kind == sql_column_name ||
+ lcol->kind == sql_lit_int)
+ ? lcol
+ : case_ (when (lcol, TRUE_INT), else_ (FALSE_INT));
+ rcol = (rcol->kind == sql_column_name ||
+ rcol->kind == sql_lit_int)
+ ? rcol
+ : case_ (when (rcol, TRUE_INT), else_ (FALSE_INT));
+ }
+
/* add the new column to the environment */
col_env_add (COLMAP(p),
p->sem.binary.res,
type_of (p, p->sem.binary.res),
- op (col_env_lookup (COLMAP(p),
- p->sem.binary.col1,
- type_of (p, p->sem.binary.col1)),
- col_env_lookup (COLMAP(p),
- p->sem.binary.col2,
- type_of (p,
p->sem.binary.col2))));
+ op (lcol, rcol));
} break;
/* Rel: bool_and (Rel) */
------------------------------------------------------------------------------
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins