Changeset: 14ad72baecb8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=14ad72baecb8
Added Files:
        sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.sql
        sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.stable.err
        sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.stable.out
        sql/test/BugTracker-2019/Tests/prod-decimals.Bug-6774.sql
        sql/test/BugTracker-2019/Tests/prod-decimals.Bug-6774.stable.err
        sql/test/BugTracker-2019/Tests/prod-decimals.Bug-6774.stable.out
Modified Files:
        clients/mapiclient/mhelp.c
        sql/common/sql_types.c
        sql/server/rel_rel.h
        sql/server/rel_select.c
        sql/test/BugTracker-2019/Tests/All
        sql/test/analytics/Tests/analytics09.sql
        sql/test/analytics/Tests/analytics09.stable.err
        sql/test/analytics/Tests/analytics09.stable.out
        sql/test/subquery/Tests/correlated.sql
        sql/test/sys-schema/Tests/systemfunctions.stable.out
        sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:

Merge with Nov2019


diffs (truncated from 928 to 300 lines):

diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -513,7 +513,7 @@ SQLhelp sqlhelp1[] = {
         NULL},
        {"UPDATE",
         "",
-        "[ WITH cte_list ] UPDATE qname [ [AS] ident ] SET assignment_list [ 
WHERE search_condition ]",
+        "[ WITH cte_list ] UPDATE qname [ [AS] ident ] SET assignment_list [ 
FROM from_item ] [ WHERE search_condition ]",
         "cte_list,assignment_list,search_condition",
         NULL},
        {"VALUES",
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1622,8 +1622,9 @@ sqltypeinit( sql_allocator *sa)
        if (HAVE_HGE)
                sql_create_aggr(sa, "prod", "aggr", "prod", HGE, LargestINT);
 #endif
-       /*sql_create_aggr(sa, "prod", "aggr", "prod", LNG, LNG);*/
 
+#if 0
+       /* prod for decimals introduce errors in the output scales */
        t = decimals; /* BTE */
        sql_create_aggr(sa, "prod", "aggr", "prod", *(t), LargestDEC);
        t++; /* SHT */
@@ -1638,6 +1639,7 @@ sqltypeinit( sql_allocator *sa)
                sql_create_aggr(sa, "prod", "aggr", "prod", *(t), LargestDEC);
        }
 #endif
+#endif
 
        for (t = numerical; t < dates; t++) {
                sql_create_func(sa, "mod", "calc", "%", *t, *t, *t, SCALE_FIX);
@@ -1819,6 +1821,8 @@ sqltypeinit( sql_allocator *sa)
                sql_create_analytic(sa, "prod", "sql", "prod", HGE, LargestINT, 
SCALE_NONE);
 #endif
 
+#if 0
+       /* prod for decimals introduce errors in the output scales */
        t = decimals; // BTE
        sql_create_analytic(sa, "prod", "sql", "prod", *(t), LargestDEC, 
SCALE_NONE);
        t++; // SHT
@@ -1833,6 +1837,7 @@ sqltypeinit( sql_allocator *sa)
                sql_create_analytic(sa, "prod", "sql", "prod", *(t), 
LargestDEC, SCALE_NONE);
        }
 #endif
+#endif
 
        for (t = floats; t < dates; t++) {
                sql_create_analytic(sa, "sum", "sql", "sum", *t, *t, 
SCALE_NONE);
diff --git a/sql/server/rel_rel.h b/sql/server/rel_rel.h
--- a/sql/server/rel_rel.h
+++ b/sql/server/rel_rel.h
@@ -18,9 +18,9 @@
 #define sql_having   8
 #define sql_orderby 16
 #define sql_groupby 32 //ORed
-#define sql_partitionby 64 //ORed
-#define sql_aggr 128 //ORed
-#define sql_farg 256 //ORed
+#define sql_aggr    64 //ORed
+#define sql_farg   128 //ORed
+#define sql_window 256 //ORed
 
 #define is_sql_from(X)    ((X & sql_from) == sql_from)
 #define is_sql_where(X)   ((X & sql_where) == sql_where)
@@ -28,9 +28,9 @@
 #define is_sql_having(X)  ((X & sql_having) == sql_having)
 #define is_sql_orderby(X) ((X & sql_orderby) == sql_orderby)
 #define is_sql_groupby(X) ((X & sql_groupby) == sql_groupby)
-#define is_sql_partitionby(X) ((X & sql_partitionby) == sql_partitionby)
 #define is_sql_aggr(X)    ((X & sql_aggr) == sql_aggr)
 #define is_sql_farg(X)    ((X & sql_farg) == sql_farg)
+#define is_sql_window(X)  ((X & sql_window) == sql_window)
 
 #define rel_groupby_gbe(m,r,e) rel_groupby(m, r, append(new_exp_list(m->sa), 
e))
 #define new_rel_list(sa) sa_list(sa)
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
@@ -4060,11 +4060,10 @@ rel_aggr_intern(sql_query *query, sql_re
                if (uaname)
                        GDKfree(uaname);
                return e;
-       } else if (is_sql_groupby(f) || (is_sql_partitionby(f) && groupby->op 
!= op_groupby)) {
-               const char *clause = is_sql_groupby(f) ? "GROUP BY":"PARTITION 
BY";
+       } else if (is_sql_groupby(f)) {
                char *uaname = GDKmalloc(strlen(aname) + 1);
-               sql_exp *e = sql_error(sql, 02, SQLSTATE(42000) "%s: aggregate 
function '%s' not allowed in %s clause",
-                                                          uaname ? 
toUpperCopy(uaname, aname) : aname, aname, clause);
+               sql_exp *e = sql_error(sql, 02, SQLSTATE(42000) "%s: aggregate 
function '%s' not allowed in GROUP BY clause",
+                                                          uaname ? 
toUpperCopy(uaname, aname) : aname, aname);
                if (uaname)
                        GDKfree(uaname);
                return e;
@@ -5341,7 +5340,7 @@ rel_rankop(sql_query *query, sql_rel **r
 
        stack_clear_frame_visited_flag(sql); //clear visited flags before 
iterating
 
-       if(l->h->next->type == type_list) {
+       if (l->h->next->type == type_list) {
                window_specification = l->h->next->data.lval;
        } else if (l->h->next->type == type_string) {
                const char* window_alias = l->h->next->data.sval;
@@ -5357,7 +5356,7 @@ rel_rankop(sql_query *query, sql_rel **r
        order_by_clause = window_specification->h->next->next->data.sym;
        frame_clause = window_specification->h->next->next->next->data.sym;
 
-       if(window_ident && !get_window_clauses(sql, window_ident, 
&partition_by_clause, &order_by_clause, &frame_clause))
+       if (window_ident && !get_window_clauses(sql, window_ident, 
&partition_by_clause, &order_by_clause, &frame_clause))
                return NULL;
 
        frame_type = order_by_clause ? FRAME_RANGE : FRAME_ROWS;
@@ -5371,14 +5370,21 @@ rel_rankop(sql_query *query, sql_rel **r
        supports_frames = (window_function->token != SQL_RANK) || is_nth_value 
||
                                          (strcmp(s->base.name, "sys") == 0 && 
((strcmp(aname, "first_value") == 0) || strcmp(aname, "last_value") == 0));
 
-       if (is_sql_where(f) || is_sql_groupby(f) || is_sql_having(f) || 
is_sql_orderby(f) || is_sql_partitionby(f)) {
+       if (is_sql_where(f) || is_sql_groupby(f) || is_sql_having(f)) {
                char *uaname = GDKmalloc(strlen(aname) + 1);
-               const char *clause = 
is_sql_where(f)?"WHERE":is_sql_groupby(f)?"GROUP 
BY":is_sql_having(f)?"HAVING":is_sql_orderby(f)?"ORDER BY":"PARTITION BY";
+               const char *clause = 
is_sql_where(f)?"WHERE":is_sql_groupby(f)?"GROUP BY":"HAVING";
                (void) sql_error(sql, 02, SQLSTATE(42000) "%s: window function 
'%s' not allowed in %s clause",
                                                 uaname ? toUpperCopy(uaname, 
aname) : aname, aname, clause);
                if (uaname)
                        GDKfree(uaname);
                return NULL;
+       } else if (is_sql_window(f)) {
+               char *uaname = GDKmalloc(strlen(aname) + 1);
+               (void) sql_error(sql, 02, SQLSTATE(42000) "%s: window functions 
cannot be nested",
+                                                uaname ? toUpperCopy(uaname, 
aname) : aname);
+               if (uaname)
+                       GDKfree(uaname);
+               return NULL;
        }
 
        /* 
@@ -5393,7 +5399,7 @@ rel_rankop(sql_query *query, sql_rel **r
                reset_processed(r);
                project_added = 1;
        }
-       if (!is_sql_sel(f) || !r || r->op != op_project || is_processed(r))
+       if (!is_sql_sel(f) || !r || !is_project(r->op))
                return sql_error(sql, 02, SQLSTATE(42000) "OVER: only possible 
within the selection");
 
        /* outer project (*rel) r  r->l will be rewritten!
@@ -5403,7 +5409,7 @@ rel_rankop(sql_query *query, sql_rel **r
         * op used to reset p
         */
        p = r->l;
-       if(!p || (!is_joinop(p->op) && !p->exps->h)) { //no from clause, use a 
constant as the expression to project
+       if (!p || (!is_joinop(p->op) && !p->exps->h)) { //no from clause, use a 
constant as the expression to project
                sql_exp *exp = exp_atom_lng(sql->sa, 0);
                exp_label(sql->sa, exp, ++sql->label);
                if (!p) {
@@ -5420,7 +5426,7 @@ rel_rankop(sql_query *query, sql_rel **r
        pp = p;
 
        g = p;
-       while(g && !group) {
+       while (g && !group) {
                if (g && g->op == op_groupby) {
                        group = 1;
                } else if (g->l && !is_processed(g) && !is_base(g->op)) {
@@ -5431,14 +5437,14 @@ rel_rankop(sql_query *query, sql_rel **r
        }
        /* Partition By */
        if (partition_by_clause) {
-               gbe = rel_group_by(query, &pp, partition_by_clause, NULL /* 
cannot use (selection) column references, as this result is a selection column 
*/, nf);
+               gbe = rel_group_by(query, &pp, partition_by_clause, NULL /* 
cannot use (selection) column references, as this result is a selection column 
*/, nf | sql_window);
                if (!gbe && !group) { /* try with implicit groupby */
                        /* reset error */
                        sql->session->status = 0;
                        sql->errstr[0] = '\0';
                        p = pp = rel_project(sql->sa, p, sa_list(sql->sa));
                        reset_processed(p);
-                       gbe = rel_group_by(query, &p, partition_by_clause, NULL 
/* cannot use (selection) column references, as this result is a selection 
column */, f);
+                       gbe = rel_group_by(query, &p, partition_by_clause, NULL 
/* cannot use (selection) column references, as this result is a selection 
column */, f | sql_window);
                }
                if (!gbe)
                        return NULL;
@@ -5451,7 +5457,7 @@ rel_rankop(sql_query *query, sql_rel **r
                        reset_processed(p);
                }
 
-               for(n = gbe->h ; n ; n = n->next) {
+               for (n = gbe->h ; n ; n = n->next) {
                        sql_exp *en = n->data;
 
                        n->data = en = opt_groupby_add_exp(sql, p, group?g:pp, 
en);
@@ -5461,14 +5467,14 @@ rel_rankop(sql_query *query, sql_rel **r
        }
        /* Order By */
        if (order_by_clause) {
-               obe = rel_order_by(query, &pp, order_by_clause, nf);
+               obe = rel_order_by(query, &pp, order_by_clause, nf | 
sql_window);
                if (!obe && !group && !gbe) { /* try with implicit groupby */
                        /* reset error */
                        sql->session->status = 0;
                        sql->errstr[0] = '\0';
                        p = pp = rel_project(sql->sa, p, sa_list(sql->sa));
                        reset_processed(p);
-                       obe = rel_order_by(query, &p, order_by_clause, f);
+                       obe = rel_order_by(query, &p, order_by_clause, f | 
sql_window);
                }
                if (!obe)
                        return NULL;
@@ -5481,7 +5487,7 @@ rel_rankop(sql_query *query, sql_rel **r
                        reset_processed(p);
                }
 
-               for(n = obe->h ; n ; n = n->next) {
+               for (n = obe->h ; n ; n = n->next) {
                        sql_exp *oexp = n->data, *nexp;
 
                        if (is_sql_sel(f) && pp->op == op_project && 
!is_processed(pp) && !rel_find_exp(pp, oexp)) {
@@ -5529,7 +5535,7 @@ rel_rankop(sql_query *query, sql_rel **r
                         is_lead = (strcmp(s->base.name, "sys") == 0 && 
strcmp(aname, "lead") == 0);
                int nfargs = 0;
 
-               if(!dnn || is_ntile) { //pass an input column for analytic 
functions that don't require it
+               if (!dnn || is_ntile) { //pass an input column for analytic 
functions that don't require it
                        sql_rel *lr = p;
 
                        if (!lr || !is_project(lr->op)) {
@@ -5544,11 +5550,11 @@ rel_rankop(sql_query *query, sql_rel **r
                        append(fargs, in);
                        nfargs++;
                }
-               if(dnn) {
+               if (dnn) {
                        for(dnode *nn = dnn->h ; nn ; nn = nn->next) {
                                is_last = 0;
                                exp_kind ek = {type_value, card_column, FALSE};
-                               in = rel_value_exp2(query, &p, nn->data.sym, f, 
ek, &is_last);
+                               in = rel_value_exp2(query, &p, nn->data.sym, f 
| sql_window, ek, &is_last);
                                if(!in)
                                        return NULL;
                                if(is_ntile && nfargs == 1) { //ntile first 
argument null handling case
@@ -5600,14 +5606,14 @@ rel_rankop(sql_query *query, sql_rel **r
                                 * all aggregations implemented in a window 
have 1 and only 1 argument only, so for now no further
                                 * symbol compilation is required
                                 */
-                               in = rel_value_exp2(query, &p, 
n->next->data.sym, f, ek, &is_last);
+                               in = rel_value_exp2(query, &p, 
n->next->data.sym, f | sql_window, ek, &is_last);
                                if (!in && !group && !obe && !gbe) { /* try 
with implicit groupby */
                                        /* reset error */
                                        sql->session->status = 0;
                                        sql->errstr[0] = '\0';
                                        p = rel_project(sql->sa, lop, 
sa_list(sql->sa));
                                        reset_processed(p);
-                                       in = rel_value_exp2(query, &p, 
n->next->data.sym, f, ek, &is_last);
+                                       in = rel_value_exp2(query, &p, 
n->next->data.sym, f | sql_window, ek, &is_last);
                                }
                                if(!in)
                                        return NULL;
@@ -5684,7 +5690,7 @@ rel_rankop(sql_query *query, sql_rel **r
        }
 
        /* Frame */
-       if(frame_clause) {
+       if (frame_clause) {
                dnode *d = frame_clause->data.lval->h;
                symbol *wstart = d->data.sym, *wend = d->next->data.sym, 
*rstart = wstart->data.lval->h->data.sym,
                           *rend = wend->data.lval->h->data.sym;
@@ -5720,9 +5726,9 @@ rel_rankop(sql_query *query, sql_rel **r
                        frame_type = FRAME_ALL; //special case, iterate the 
entire partition
                }
 
-               if((fstart = calculate_window_bound(query, p, wstart->token, 
rstart, ie, frame_type, f)) == NULL)
+               if((fstart = calculate_window_bound(query, p, wstart->token, 
rstart, ie, frame_type, f | sql_window)) == NULL)
                        return NULL;
-               if((fend = calculate_window_bound(query, p, wend->token, rend, 
ie, frame_type, f)) == NULL)
+               if((fend = calculate_window_bound(query, p, wend->token, rend, 
ie, frame_type, f | sql_window)) == NULL)
                        return NULL;
                if(generate_window_bound_call(sql, &start, &eend, s, gbe ? pe : 
NULL, ie, fstart, fend, frame_type, excl,
                                                                          
wstart->token, wend->token) == NULL)
@@ -5758,7 +5764,7 @@ rel_rankop(sql_query *query, sql_rel **r
        if (!pe || !oe)
                return NULL;
 
-       if(!supports_frames) {
+       if (!supports_frames) {
                append(fargs, pe);
                append(fargs, oe);
        }
diff --git a/sql/test/BugTracker-2019/Tests/All 
b/sql/test/BugTracker-2019/Tests/All
--- a/sql/test/BugTracker-2019/Tests/All
+++ b/sql/test/BugTracker-2019/Tests/All
@@ -38,3 +38,5 @@ HAVE_LIBPY3?python-loader-string.Bug-675
 select-char.Bug-6761
 grant-select-column.Bug-6765
 next-get-value-bulk.Bug-6766
+KNOWNFAIL?filter_json_null.Bug-6773
+prod-decimals.Bug-6774
diff --git a/sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.sql 
b/sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2019/Tests/filter_json_null.Bug-6773.sql
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to