Changeset: 98d29ff2e4d2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=98d29ff2e4d2
Modified Files:
        sql/server/rel_select.c
        sql/test/miscellaneous/Tests/groupby_error.sql
        sql/test/miscellaneous/Tests/groupby_error.stable.err
        sql/test/miscellaneous/Tests/groupby_error.stable.out
Branch: default
Log Message:

Removed rel_order_by_simple_column_exp function. It was a case of 
rel_order_by_column_exp, making it redundant.

All tests passed.


diffs (125 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
@@ -4128,37 +4128,7 @@ rel_partition_groupings(sql_query *query
 }
 
 /* find selection expressions matching the order by column expression */
-
-/* first limit to simple columns only */
-static sql_exp *
-rel_order_by_simple_column_exp(mvc *sql, sql_rel *r, symbol *column_r, int f)
-{
-       sql_exp *e = NULL;
-       dlist *l = column_r->data.lval;
-
-       if (!r || !is_project(r->op) || column_r->type == type_int)
-               return NULL;
-       assert(column_r->token == SQL_COLUMN && column_r->type == type_list);
-
-       r = r->l;
-       if (!r)
-               return e;
-       if (dlist_length(l) == 1) {
-               char *name = l->h->data.sval;
-               e = rel_bind_column(sql, r, name, f, 0);
-       }
-       if (dlist_length(l) == 2) {
-               char *tname = l->h->data.sval;
-               char *name = l->h->next->data.sval;
-
-               e = rel_bind_column2(sql, r, tname, name, f);
-       }
-       if (e) 
-               return e;
-       return sql_error(sql, 02, SQLSTATE(42000) "ORDER BY: absolute column 
names not supported");
-}
-
-/* second complex columns only */
+/* complex columns only */
 static sql_exp *
 rel_order_by_column_exp(sql_query *query, sql_rel **R, symbol *column_r, int f)
 {
@@ -4278,11 +4248,10 @@ rel_order_by(sql_query *query, sql_rel *
                                                return sql_error(sql, 02, 
SQLSTATE(42000) "order not of type SQL_COLUMN");
                                        }
                                } else if (e && exp_card(e) > rel->card) {
-                                       if (exp_name(e)) {
+                                       if (exp_name(e))
                                                return sql_error(sql, 
ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in 
query results without an aggregate function", exp_name(e));
-                                       } else {
+                                       else
                                                return sql_error(sql, 
ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query 
results without an aggregate function");
-                                       }
                                }
                                if (e && rel && is_project(rel->op)) {
                                        sql_exp *found = 
exps_find_exp(rel->exps, e);
@@ -4296,17 +4265,6 @@ rel_order_by(sql_query *query, sql_rel *
                                }
                        }
 
-                       if (!e && sql->session->status != -ERR_AMBIGUOUS && 
(col->token == SQL_COLUMN || col->token == SQL_IDENT)) {
-                               /* reset error */
-                               sql->session->status = 0;
-                               sql->errstr[0] = '\0';
-
-                               e = rel_order_by_simple_column_exp(sql, rel, 
col, sql_sel | sql_orderby | (f & sql_group_totals));
-                               if (e && e->card > rel->card) 
-                                       e = NULL;
-                               if (e)
-                                       e = rel_project_add_exp(sql, rel, e);
-                       }
                        if (rel && !e && sql->session->status != 
-ERR_AMBIGUOUS) {
                                /* reset error */
                                sql->session->status = 0;
diff --git a/sql/test/miscellaneous/Tests/groupby_error.sql 
b/sql/test/miscellaneous/Tests/groupby_error.sql
--- a/sql/test/miscellaneous/Tests/groupby_error.sql
+++ b/sql/test/miscellaneous/Tests/groupby_error.sql
@@ -25,6 +25,13 @@ SELECT 11 FROM tab1 AS cor0 LEFT JOIN ta
        -- 11
        -- 11
 
+SELECT col0 FROM tab0 ORDER BY tab0.col0;
+       -- 15
+       -- 87
+       -- 97
+
+SELECT col0 FROM tab0 ORDER BY sys.tab0.col0; --error, TODO
+
 prepare select col0 from tab0 where (?) in (select col0 from tab0);
 prepare select col0 from tab0 where (?,?) in (select col0,col1 from tab0);
 prepare select col0 from tab0 where (col1,col1) in (select col0,? from tab0);
diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.err 
b/sql/test/miscellaneous/Tests/groupby_error.stable.err
--- a/sql/test/miscellaneous/Tests/groupby_error.stable.err
+++ b/sql/test/miscellaneous/Tests/groupby_error.stable.err
@@ -31,7 +31,11 @@ MAPI  = (monetdb) /var/tmp/mtest-13678/.
 QUERY = SELECT parent."sys_id" FROM "kagami_dump"."test_task" parent INNER 
JOIN "kagami_dump"."test_task" child ON child."parent" = parent."sys_id" GROUP 
BY parent."sys_id" HAVING count(child."sys_id") >= 1 ORDER BY parent."number"; 
--error, parent."number" requires an aggregate function
 ERROR = !SELECT: no such column 'parent.number'
 CODE  = 42S22
-MAPI  = (monetdb) /var/tmp/mtest-19682/.s.monetdb.38130
+MAPI  = (monetdb) /var/tmp/mtest-561836/.s.monetdb.32526
+QUERY = SELECT col0 FROM tab0 ORDER BY sys.tab0.col0; --error, TODO
+ERROR = !TODO: column names of level >= 3
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-561836/.s.monetdb.32526
 QUERY = prepare select col0 from tab0 where (?) in (?); --error
 ERROR = !Cannot have a parameter (?) on both sides of an expression
 CODE  = 42000
diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.out 
b/sql/test/miscellaneous/Tests/groupby_error.stable.out
--- a/sql/test/miscellaneous/Tests/groupby_error.stable.out
+++ b/sql/test/miscellaneous/Tests/groupby_error.stable.out
@@ -117,6 +117,14 @@ stdout of test 'groupby_error` in direct
 [ 11   ]
 [ 11   ]
 [ 11   ]
+#SELECT col0 FROM tab0 ORDER BY tab0.col0;
+% sys.tab0 # table_name
+% col0 # name
+% int # type
+% 2 # length
+[ 15   ]
+[ 87   ]
+[ 97   ]
 #prepare select col0 from tab0 where (?) in (select col0 from tab0);
 #prepare select col0 from tab0 where (?) in (select col0 from tab0);
 % .prepare,    .prepare,       .prepare,       .prepare,       .prepare,       
.prepare # table_name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to