Changeset: 17879d9a552c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=17879d9a552c
Modified Files:
pathfinder/compiler/include/sql.h
pathfinder/compiler/include/sql_mnemonic.h
pathfinder/compiler/sql/lalg2sql.brg
pathfinder/compiler/sql/sql.c
pathfinder/compiler/sql/sqlprint.c
Branch: default
Log Message:
Extended SQL code generation to cope with functions on dates.
Cleaned up 1:1 functions in the SQL code generation.
Cleaned up white spaces in the SQL code generation.
diffs (truncated from 2000 to 300 lines):
diff -r c6774f5ec11b -r 17879d9a552c pathfinder/compiler/include/sql.h
--- a/pathfinder/compiler/include/sql.h Sun Aug 01 21:59:04 2010 +0200
+++ b/pathfinder/compiler/include/sql.h Mon Aug 02 21:06:43 2010 +0200
@@ -103,7 +103,7 @@
*/
enum PFsql_kind_t {
sql_root /* The root of the SQL operator tree:
- it combines the schema information
+ it combines the schema information
with the query operators */
, sql_ser_info /* an item of a sequence of schema information
@@ -125,7 +125,7 @@
, sql_column_name /* SQL column name (a column reference) */
, sql_star /* a SQL wildcard '*' */
- , sql_with /* WITH operator
+ , sql_with /* WITH operator
(second child of the sql_root operator) */
, sql_cmmn_tbl_expr /* common table expression */
, sql_comment /* comment */
@@ -178,7 +178,7 @@
, sql_like /* like comparison */
, sql_similar_to /* similar to comparison */
, sql_in /* in comparison */
- , sql_stmt_list /* an item of a list of statments
+ , sql_stmt_list /* an item of a list of statments
(second argument of a sql_in operator) */
, sql_list_list /* list of lists */
, sql_not /* negation */
@@ -212,6 +212,10 @@
, sql_cast /* CAST expression */
, sql_type /* a SQL type */
+ , sql_year /* sql year function */
+ , sql_month /* sql month function */
+ , sql_day /* sql day function */
+
, sql_coalesce /* COALESCE () function */
, sql_case /* case operator */
@@ -243,11 +247,11 @@
struct {
char *str; /**< Comment. */
} comment;
-
+
struct {
char *str; /**< Schema name */
} schema;
-
+
struct {
PFsql_tident_t name; /**< Table name. */
} tbl;
@@ -260,21 +264,21 @@
PFsql_aident_t alias; /**< Alias name. */
char* name; /**< name of a column of an ext. relation. */
} ref_column_name;
-
+
struct {
bool distinct; /**< Boolean indicating if elimination
of equal tuples is required. */
} select;
-
+
struct {
PFsql_aident_t alias; /**< Alias name. */
PFsql_col_t *name; /**< Column name. */
} column;
-
+
struct {
PFsql_aident_t name; /**< Alias name. */
} alias;
-
+
/* semantic content for literal values */
struct {
union {
@@ -285,12 +289,12 @@
double dec; /**< Decimal value. */
} val;
} atom;
-
+
struct {
bool dir_asc; /**< Boolean indicating if the sort criterion
has to be ordered ascending or descending. */
} sortkey;
-
+
struct {
PFalg_simple_type_t t; /**< semantic information for type */
} type;
@@ -318,7 +322,7 @@
*/
struct PFsql_alg_ann_t {
unsigned bound:1; /**< indicates if the operator has been
bound */
-
+
PFarray_t *colmap; /**< Mapping table that maps (logical)
column/type pairs to their
SQL expression or in case of
@@ -327,11 +331,11 @@
PFarray_t *frommap; /**< table--alias mappings */
PFarray_t *wheremap; /**< contains references to the boolean
in colmap */
-
+
/* annotations needed to translate twig constructors (and path steps) */
PFsql_t *fragment; /**< a fragment reference */
PFsql_t *content_size; /**< a reference to a content-size binding
*/
-
+
unsigned int twig_pre; /**< local pre value for constructions
with the twig-constructor */
int twig_size; /**< local size value for constructions
@@ -346,8 +350,8 @@
constraints */
bool bind; /**< a boolean indicating if a numbering
operator needs to be bound */
-};
-
+};
+
/* .......... General .......... */
#define PFsql_generic_list(fun,...) \
@@ -422,7 +426,7 @@
/**
* Some specific schema information used by the serializer.
- * We communicate the special columns, the serializer needs.
+ * We communicate the special columns, the serializer needs.
*/
PFsql_t * PFsql_serialization_name_mapping (const PFsql_t *column,
const PFsql_t *name);
@@ -456,14 +460,14 @@
PFsql_t * PFsql_table_name (PFsql_tident_t name);
/**
- * Construct a SQL tree node representing a reference to a
- * column of an external relation.
+ * Construct a SQL tree node representing a reference to a
+ * column of an external relation.
*/
PFsql_t * PFsql_ref_column_name (PFsql_aident_t alias, char* name);
/**
- * Construct a SQL tree node representing a reference to an
- * external relation.
+ * Construct a SQL tree node representing a reference to an
+ * external relation.
*/
PFsql_t * PFsql_ref_table_name (char* name);
@@ -799,7 +803,7 @@
PFsql_t * PFsql_gteq (const PFsql_t *a, const PFsql_t *b);
/*
- * Create a SQL tree node representing a
+ * Create a SQL tree node representing a
* `between' predicate.
*/
PFsql_t * PFsql_between(const PFsql_t *clmn, const PFsql_t *a, const PFsql_t
*b);
@@ -822,7 +826,7 @@
* Create a SQL tree node representing the in operator
*/
PFsql_t * PFsql_in (const PFsql_t *column, const PFsql_t *list);
-PFsql_t * PFsql_stmt_list_ (unsigned int count, const PFsql_t **list);
+PFsql_t * PFsql_stmt_list_ (unsigned int count, const PFsql_t **list);
/**
* Create a SQL tree node representing a boolean
@@ -947,6 +951,7 @@
* @param t The type.
*/
PFsql_t * PFsql_type (PFalg_simple_type_t t);
+
/**
* Construct a SQL tree representing a SQL
* `CAST' operator.
@@ -955,6 +960,24 @@
* @param t Type.
*/
PFsql_t * PFsql_cast (const PFsql_t *expr, const PFsql_t *t);
+
+/**
+ * Create a tree node representing the SQL
+ * 'year' statement.
+ */
+PFsql_t * PFsql_year (const PFsql_t *a);
+
+/**
+ * Create a tree node representing the SQL
+ * 'month' statement.
+ */
+PFsql_t * PFsql_month (const PFsql_t *a);
+/**
+ * Create a tree node representing the SQL
+ * 'day' statement.
+ */
+PFsql_t * PFsql_day (const PFsql_t *a);
+
/**
* Create a tree node representing the SQL
* `COALESCE' function.
diff -r c6774f5ec11b -r 17879d9a552c pathfinder/compiler/include/sql_mnemonic.h
--- a/pathfinder/compiler/include/sql_mnemonic.h Sun Aug 01 21:59:04
2010 +0200
+++ b/pathfinder/compiler/include/sql_mnemonic.h Mon Aug 02 21:06:43
2010 +0200
@@ -89,7 +89,7 @@
#define lit_str(s) PFsql_lit_str(s)
#define lit_dec(d) PFsql_lit_dec(d)
#define null() PFsql_null()
-
+
/* .......... Arithmetic Operators .......... */
#define add(a,b) PFsql_add(a,b)
#define sub(a,b) PFsql_sub(a,b)
@@ -110,7 +110,7 @@
/* .......... Table Functions ............ */
#define values(a) PFsql_values(a)
#define list_list(...) PFsql_list_list(__VA_ARGS__)
-
+
/* .......... Boolean Operators .......... */
#define is(a, b) PFsql_is(a, b)
#define is_not(a, b) PFsql_is_not(a, b)
@@ -125,7 +125,7 @@
#define not_(a) PFsql_not(a)
#define and_(a,b) PFsql_and(a,b)
#define or_(a,b) PFsql_or(a,b)
-
+
/* .......... Aggregate Functions .......... */
#define count(c) PFsql_count(c)
#define max_(c) PFsql_max(c)
@@ -138,7 +138,7 @@
#define str_length(a) PFsql_str_length(a)
#define str_upper(a) PFsql_str_upper(a)
#define str_lower(a) PFsql_str_lower(a)
-
+
/* .......... OLAP Functionality .......... */
#define over(a,b) PFsql_over(a,b)
#define row_number() PFsql_row_number()
@@ -149,10 +149,13 @@
#define sortkey_list(...) PFsql_sortkey_list(__VA_ARGS__)
#define sortkey_item(i,d) PFsql_sortkey_item(i,d)
#define partition(cl) PFsql_partition(cl)
-
+
/* .......... Remaining Operators .......... */
#define type(t) PFsql_type(t)
#define cast(e,t) PFsql_cast(e,t)
+#define year(a) PFsql_year(a)
+#define month(a) PFsql_month(a)
+#define day(a) PFsql_day(a)
#define coalesce(e1,e2) PFsql_coalesce(e1,e2)
#define case_(...) PFsql_case(__VA_ARGS__)
#define when(be,e) PFsql_when(be,e)
diff -r c6774f5ec11b -r 17879d9a552c pathfinder/compiler/sql/lalg2sql.brg
--- a/pathfinder/compiler/sql/lalg2sql.brg Sun Aug 01 21:59:04 2010 +0200
+++ b/pathfinder/compiler/sql/lalg2sql.brg Mon Aug 02 21:06:43 2010 +0200
@@ -176,7 +176,7 @@
%term fun_call = 90 /**< function application */
%term fun_param = 91 /**< function application parameter */
%term fun_frag_param = 92 /**< function application parameter */
-
+
%term proxy = 96 /**< proxy operator that represents a group
of operators */
%term proxy_base = 97 /**< completes the content of the proxy
@@ -303,13 +303,13 @@
Rel: rec_base = 105 (10);
Rec: nil = 106 (10);
Arg: rec_arg (Rel, Rel) = 107 (10);
-Arg: rec_arg (Rel, distinct (Rel)) = 108 (10);
+Arg: rec_arg (Rel, distinct (Rel)) = 108 (10);
Rel: rec_fix (
side_effects (
nil,
rec_param (
- rec_arg (Rel, Rel),
+ rec_arg (Rel, Rel),
rec_param(Arg, nil))),
Rel) = 109 (10);
Rel: rec_fix (
@@ -716,7 +716,7 @@
return (a->spec == b->spec);
else
return (a->col == b->col) &&
- (a->ty == b->ty);
+ (a->ty == b->ty);
}
/**
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list