Changeset: e0f4cec30293 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e0f4cec30293
Modified Files:
        sql/ChangeLog.Jun2020
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/51_sys_schema_extension.sql
        sql/server/rel_select.c
        sql/server/sql_parser.y
        sql/server/sql_scan.c
        sql/server/sql_tokens.h
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
Branch: Jun2020
Log Message:

Removed unionjoin statements. They were dropped by the SQL:2003 standard, plus 
MonetDB implementation was not compliant


diffs (232 lines):

diff --git a/sql/ChangeLog.Jun2020 b/sql/ChangeLog.Jun2020
--- a/sql/ChangeLog.Jun2020
+++ b/sql/ChangeLog.Jun2020
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Apr 15 2020 Pedro Ferreira <pedro.ferre...@monetdbsolutions.com>
+- Removed UNION JOIN statements. They were dropped by the SQL:2003
+  standard, plus MonetDB implementation was not fully compliant.
+
 * Wed Apr  1 2020 Sjoerd Mullender <sjo...@acm.org>
 - The OFFSET value in the COPY INTO query now counts uninterpreted
   newlines.  Before it counted "unquoted record separators" which meant
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2906,6 +2906,11 @@ sql_update_jun2020(Client c, mvc *sql, c
                        "update sys._tables set system = true where schema_id = 
(select id from sys.schemas where name = 'logging')"
                        " and name = 'compinfo';\n");
 
+       /* 51_sys_schema_extensions */
+       pos += snprintf(buf + pos, bufsize - pos,
+                       "ALTER TABLE sys.keywords SET READ WRITE;\n"
+                       "DELETE FROM sys.keywords where \"keyword\" = 
'UNIONJOIN';\n");
+
        pos += snprintf(buf + pos, bufsize - pos, "commit;\n");
        pos += snprintf(buf + pos, bufsize - pos, "set schema \"%s\";\n", 
prev_schema);
        assert(pos < bufsize);
diff --git a/sql/scripts/51_sys_schema_extension.sql 
b/sql/scripts/51_sys_schema_extension.sql
--- a/sql/scripts/51_sys_schema_extension.sql
+++ b/sql/scripts/51_sys_schema_extension.sql
@@ -268,7 +268,6 @@ INSERT INTO sys.keywords (keyword) VALUE
   ('UNCOMMITTED'),
   ('UNENCRYPTED'),
   ('UNION'),
-  ('UNIONJOIN'),
   ('UNIQUE'),
   ('UPDATE'),
   ('USER'),
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
@@ -160,7 +160,6 @@ rel_orderby(mvc *sql, sql_rel *l)
 static sql_rel * rel_setquery(sql_query *query, symbol *sq);
 static sql_rel * rel_joinquery(sql_query *query, sql_rel *rel, symbol *sq);
 static sql_rel * rel_crossquery(sql_query *query, sql_rel *rel, symbol *q);
-static sql_rel * rel_unionjoinquery(sql_query *query, sql_rel *rel, symbol 
*sq);
 
 static sql_rel *
 rel_table_optname(mvc *sql, sql_rel *sq, symbol *optname)
@@ -340,14 +339,6 @@ query_exp_optname(sql_query *query, sql_
                        return NULL;
                return rel_table_optname(sql, tq, q->data.lval->t->data.sym);
        }
-       case SQL_UNIONJOIN:
-       {
-               sql_rel *tq = rel_unionjoinquery(query, r, q);
-
-               if (!tq)
-                       return NULL;
-               return rel_table_optname(sql, tq, q->data.lval->t->data.sym);
-       }
        default:
                (void) sql_error(sql, 02, SQLSTATE(42000) "case %d %s", (int) 
q->token, token2string(q->token));
        }
@@ -5915,6 +5906,7 @@ rel_joinquery(sql_query *query, sql_rel 
 static sql_rel *
 rel_crossquery(sql_query *query, sql_rel *rel, symbol *q)
 {
+       mvc *sql = query->sql;
        dnode *n = q->data.lval->h;
        symbol *tab1 = n->data.sym;
        symbol *tab2 = n->next->data.sym;
@@ -5926,59 +5918,7 @@ rel_crossquery(sql_query *query, sql_rel
        if (!t1 || !t2)
                return NULL;
 
-       rel = rel_crossproduct(query->sql->sa, t1, t2, op_join);
-       return rel;
-}
-       
-static sql_rel *
-rel_unionjoinquery(sql_query *query, sql_rel *rel, symbol *q)
-{
-       mvc *sql = query->sql;
-       dnode *n = q->data.lval->h;
-       sql_rel *lv = table_ref(query, rel, n->data.sym, 0);
-       sql_rel *rv = NULL;
-       int all = n->next->data.i_val;
-       list *lexps, *rexps;
-       node *m;
-       int found = 0;
-
-       if (lv)
-               rv = table_ref(query, rel, n->next->next->data.sym, 0);
-       assert(n->next->type == type_int);
-       if (!lv || !rv)
-               return NULL;
-
-       lexps = rel_projections(sql, lv, NULL, 1, 1);
-       /* find the matching columns (all should match?)
-        * union these
-        * if !all do a distinct operation at the end
-        */
-       /* join all result columns ie join(lh,rh) on column_name */
-       rexps = new_exp_list(sql->sa);
-       for (m = lexps->h; m; m = m->next) {
-               sql_exp *le = m->data;
-               sql_exp *rc = rel_bind_column(sql, rv, exp_name(le), sql_where 
| sql_join, 0);
-
-               if (!rc && all)
-                       break;
-               if (rc) {
-                       found = 1;
-                       append(rexps, rc);
-               }
-       }
-       if (!found) {
-               rel_destroy(rel);
-               return NULL;
-       }
-       lv = rel_project(sql->sa, lv, lexps);
-       rv = rel_project(sql->sa, rv, rexps);
-       rel = rel_setop(sql->sa, lv, rv, op_union);
-       rel->exps = rel_projections(sql, rel, NULL, 0, 1);
-       rel->nrcols = list_length(rel->exps);
-       set_processed(rel);
-       if (!all)
-               rel = rel_distinct(rel);
-       return rel;
+       return rel_crossproduct(sql->sa, t1, t2, op_join);
 }
 
 sql_rel *
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
@@ -656,7 +656,7 @@ int yydebug=1;
 %token FILTER
 
 /* operators */
-%left UNION EXCEPT INTERSECT CORRESPONDING UNIONJOIN
+%left UNION EXCEPT INTERSECT CORRESPONDING
 %left JOIN CROSS LEFT FULL RIGHT INNER NATURAL
 %left WITH DATA
 %left <operation> '(' ')'
@@ -3136,14 +3136,6 @@ joined_table:
          append_symbol(l, $1);
          append_symbol(l, $4);
          $$ = _symbol_create_list( SQL_CROSS, l); }
- |  table_ref UNIONJOIN table_ref join_spec
-       { dlist *l = L();
-         append_symbol(l, $1);
-         append_int(l, 0);
-         append_int(l, 4);
-         append_symbol(l, $3);
-         append_symbol(l, $4);
-         $$ = _symbol_create_list( SQL_UNIONJOIN, l); }
  |  table_ref join_type JOIN table_ref join_spec
        { dlist *l = L();
          append_symbol(l, $1);
@@ -6579,7 +6571,6 @@ char *token2string(tokens token)
        SQL(TRUNCATE);
        SQL(TYPE);
        SQL(UNION);
-       SQL(UNIONJOIN);
        SQL(UNIQUE);
        SQL(UNOP);
        SQL(UPDATE);
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -1387,14 +1387,6 @@ sqllex(YYSTYPE * yylval, void *parm)
                } else {
                        lc->yynext = next;
                }
-       } else if (token == UNION) {
-               int next = sqllex(yylval, parm);
-
-               if (next == JOIN) {
-                       token = UNIONJOIN;
-               } else {
-                       lc->yynext = next;
-               }
        } else if (token == SCOLON) {
                /* ignore semi-colon(s) following a semi-colon */
                if (lc->yylast == SCOLON) {
diff --git a/sql/server/sql_tokens.h b/sql/server/sql_tokens.h
--- a/sql/server/sql_tokens.h
+++ b/sql/server/sql_tokens.h
@@ -149,7 +149,6 @@ typedef enum tokens {
        SQL_TRUNCATE,
        SQL_TYPE,
        SQL_UNION,
-       SQL_UNIONJOIN,
        SQL_UNIQUE,
        SQL_UNOP,
        SQL_UPDATE,
diff --git a/sql/test/emptydb/Tests/check.stable.out 
b/sql/test/emptydb/Tests/check.stable.out
--- a/sql/test/emptydb/Tests/check.stable.out
+++ b/sql/test/emptydb/Tests/check.stable.out
@@ -5645,7 +5645,6 @@ drop function pcre_replace(string, strin
 [ "UNCOMMITTED"        ]
 [ "UNENCRYPTED"        ]
 [ "UNION"      ]
-[ "UNIONJOIN"  ]
 [ "UNIQUE"     ]
 [ "UPDATE"     ]
 [ "USER"       ]
diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit 
b/sql/test/emptydb/Tests/check.stable.out.32bit
--- a/sql/test/emptydb/Tests/check.stable.out.32bit
+++ b/sql/test/emptydb/Tests/check.stable.out.32bit
@@ -5642,7 +5642,6 @@ drop function pcre_replace(string, strin
 [ "UNCOMMITTED"        ]
 [ "UNENCRYPTED"        ]
 [ "UNION"      ]
-[ "UNIONJOIN"  ]
 [ "UNIQUE"     ]
 [ "UPDATE"     ]
 [ "USER"       ]
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -5904,7 +5904,6 @@ drop function pcre_replace(string, strin
 [ "UNCOMMITTED"        ]
 [ "UNENCRYPTED"        ]
 [ "UNION"      ]
-[ "UNIONJOIN"  ]
 [ "UNIQUE"     ]
 [ "UPDATE"     ]
 [ "USER"       ]
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to