Changeset: 6e6920aab279 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6e6920aab279 Modified Files: sql/server/rel_select.c sql/server/sql_parser.y Branch: distinct_from Log Message:
implement [NOT] DISTINCT FROM diffs (71 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -2367,6 +2367,8 @@ rel_logical_value_exp(sql_query *query, int quantifier = 0, need_not = 0; sql_exp *rs = NULL, *ls; comp_type cmp_type = compare_str2type(compare_op); + bool is_not_distinct_from = false; + bool is_distinct_from = false; /* * = ANY -> IN, <> ALL -> NOT( = ANY) -> NOT IN @@ -2374,7 +2376,17 @@ rel_logical_value_exp(sql_query *query, */ if (n->next->next->next) quantifier = n->next->next->next->data.i_val + 1; - assert(quantifier == 0 || quantifier == 1 || quantifier == 2); + assert(quantifier == 0 || quantifier == 1 || quantifier == 2 || quantifier == 3 || quantifier == 4); + + /* [NOT] DISTINCT FROM */ + if (quantifier == 3) { + is_not_distinct_from = true; + quantifier = 0; + } + else if (quantifier == 4) { + is_distinct_from = true; + quantifier = 0; + } if ((quantifier == 1 && cmp_type == cmp_equal) || (quantifier == 2 && cmp_type == cmp_notequal)) { @@ -2405,6 +2417,15 @@ rel_logical_value_exp(sql_query *query, rs = rel_value_exp(query, rel, ro, f|sql_farg, ek); if (!rs) return NULL; + + if (is_distinct_from || is_not_distinct_from) { + if (rel_convert_types(sql, rel ? *rel : NULL, rel ? *rel : NULL, &ls, &rs, 1, type_equal_no_any) < 0) + return NULL; + sql_exp* e = exp_compare(sql->sa, ls, rs, is_not_distinct_from?cmp_equal:cmp_notequal); + set_semantics(e); + return e; + } + if (rs->type == e_atom) quantifier = 0; diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y --- a/sql/server/sql_parser.y +++ b/sql/server/sql_parser.y @@ -3900,6 +3900,20 @@ comparison_predicate: append_symbol(l, $5); append_int(l, $3); $$ = _symbol_create_list(SQL_COMPARE, l ); } + | pred_exp NOT DISTINCT FROM pred_exp + { dlist *l = L(); + append_symbol(l, $1); + append_string(l, sa_strdup(SA, "=")); + append_symbol(l, $5); + append_int(l, 2); + $$ = _symbol_create_list(SQL_COMPARE, l ); } + | pred_exp DISTINCT FROM pred_exp + { dlist *l = L(); + append_symbol(l, $1); + append_string(l, sa_strdup(SA, "=")); + append_symbol(l, $4); + append_int(l, 3); + $$ = _symbol_create_list(SQL_COMPARE, l ); } ; between_predicate: _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org