Changeset: beacbd2e7ce4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=beacbd2e7ce4
Modified Files:
        debian/control
        sql/server/rel_select.c
        
sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
        sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err
        
sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
        
sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err
        
sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
        sql/test/BugTracker-2016/Tests/invalidcolumns.Bug-3968.stable.err
        
sql/test/BugTracker-2017/Tests/udf_crash_subquery_scalar_paramters.Bug-6399.stable.err
        
sql/test/BugTracker-2018/Tests/crash-after-call-non-existing-loader.stable.err
        sql/test/Tests/drop-function-if-exists.stable.err
Branch: linear-hashing
Log Message:

Merged with Nov2019


diffs (truncated from 366 to 300 lines):

diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -279,7 +279,7 @@ Description: MonetDB5 128 bit integer (h
 Package: monetdb-python2
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
- monetdb5-sql (= ${source:Version})
+ monetdb5-sql (= ${source:Version}), python-numpy
 Description: Integration of MonetDB and Python, allowing use of Python from 
within SQL
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -296,7 +296,7 @@ Description: Integration of MonetDB and 
 Package: monetdb-python3
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
- monetdb5-sql (= ${source:Version})
+ monetdb5-sql (= ${source:Version}), python3-numpy
 Description: Integration of MonetDB and Python, allowing use of Python from 
within SQL
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -313,7 +313,7 @@ Description: Integration of MonetDB and 
 Package: monetdb-r
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
- monetdb5-sql (= ${source:Version})
+ monetdb5-sql (= ${source:Version}), r-base-core
 Description: Integration of MonetDB and R, allowing use of R from within SQL
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
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
@@ -603,8 +603,8 @@ rel_named_table_function(sql_query *quer
        sql_rel *sq = NULL, *outer = NULL;
        sql_exp *e = NULL;
        sql_subfunc *sf = NULL;
-       symbol *sym = ast->data.lval->h->data.sym;
-       dnode *l = sym->data.lval->h;
+       symbol *sym = ast->data.lval->h->data.sym, *subquery = NULL;
+       dnode *l = sym->data.lval->h, *n;
        char *tname = NULL;
        char *fname = qname_fname(l->data.lval); 
        char *sname = qname_schema(l->data.lval);
@@ -615,40 +615,46 @@ rel_named_table_function(sql_query *quer
                return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no such 
schema '%s'", sname);
 
        tl = sa_list(sql->sa);
-       exps = new_exp_list(sql->sa);
+       exps = sa_list(sql->sa);
        if (l->next) { /* table call with subquery */
-               if (l->next->type == type_symbol && l->next->data.sym->token == 
SQL_SELECT) {
-                       if (l->next->next != NULL)
-                               return sql_error(sql, 02, SQLSTATE(42000) 
"SELECT: '%s' requires a single sub query", fname);
-                       if (!(sq = rel_subquery(query, NULL, l->next->data.sym, 
ek)))
-                               return NULL;
-               } else if (l->next->type == type_symbol || l->next->type == 
type_list) {
-                       dnode *n;
+               if (l->next->type == type_symbol || l->next->type == type_list) 
{
                        exp_kind iek = {type_value, card_column, TRUE};
-                       list *exps = sa_list (sql->sa);
+                       list *exps = sa_list(sql->sa);
+                       int count = 0;
 
                        if (l->next->type == type_symbol)
                                n = l->next;
-                       else 
+                       else
                                n = l->next->data.lval->h;
-                       for ( ; n; n = n->next) {
-                               sql_exp *e = rel_value_exp(query, &outer, 
n->data.sym, sql_sel, iek);
-
-                               if (!e)
-                                       return NULL;
-                               append(exps, e);
+
+                       for (dnode *m = n; m; m = m->next) {
+                               if (m->type == type_symbol && 
m->data.sym->token == SQL_SELECT)
+                                       subquery = m->data.sym;
+                               count++;
                        }
-                       sq = rel_project(sql->sa, NULL, exps);
-                       if (lateral && outer) {
-                               sq = rel_crossproduct(sql->sa, sq, outer, 
op_join);
-                               set_dependent(sq);
+                       if (subquery && count > 1)
+                               return sql_error(sql, 02, SQLSTATE(42000) 
"SELECT: The input for the table returning function '%s' must be either a 
single sub query, or a list of values", fname);
+
+                       if (subquery) {
+                               if (!(sq = rel_subquery(query, NULL, subquery, 
ek)))
+                                       return NULL;
+                       } else {
+                               for ( ; n; n = n->next) {
+                                       sql_exp *e = rel_value_exp(query, 
&outer, n->data.sym, sql_sel, iek);
+
+                                       if (!e)
+                                               return NULL;
+                                       append(exps, e);
+                               }
+                               sq = rel_project(sql->sa, NULL, exps);
+                               if (lateral && outer) {
+                                       sq = rel_crossproduct(sql->sa, sq, 
outer, op_join);
+                                       set_dependent(sq);
+                               }
                        }
                }
-               /* reset error */
-               sql->session->status = 0;
-               sql->errstr[0] = '\0';
                if (!sq || (!lateral && outer))
-                       return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no 
such operator '%s'", fname);
+                       return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no 
such table returning function '%s'", fname);
                for (en = sq->exps->h; en; en = en->next) {
                        sql_exp *e = en->data;
 
@@ -659,7 +665,7 @@ rel_named_table_function(sql_query *quer
 
        e = find_table_function(sql, s, fname, exps, tl);
        if (!e)
-               return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such 
operator '%s'", fname);
+               return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such 
table returning function '%s'", fname);
        rel = sq;
 
        if (ast->data.lval->h->next->data.sym)
@@ -669,10 +675,8 @@ rel_named_table_function(sql_query *quer
 
        /* column or table function */
        sf = e->f;
-       if (e->type != e_func || sf->func->type != F_UNION) {
-               (void) sql_error(sql, 02, SQLSTATE(42000) "SELECT: '%s' does 
not return a table", exp_func_name(e));
-               return NULL;
-       }
+       if (e->type != e_func || sf->func->type != F_UNION)
+               return sql_error(sql, 02, SQLSTATE(42000) "SELECT: '%s' does 
not return a table", exp_func_name(e));
 
        if (sq) {
                for (node *n = sq->exps->h, *m = sf->func->ops->h ; n && m ; n 
= n->next, m = m->next) {
@@ -5943,8 +5947,8 @@ rel_loader_function(sql_query *query, sy
        exp_kind ek = { type_value, card_relation, TRUE };
        sql_rel *sq = NULL;
        sql_exp *e = NULL;
-       symbol *sym = fcall;
-       dnode *l = sym->data.lval->h;
+       symbol *sym = fcall, *subquery = NULL;
+       dnode *l = sym->data.lval->h, *n;
        char *sname = qname_schema(l->data.lval);
        char *fname = qname_fname(l->data.lval);
        char *tname = NULL;
@@ -5956,37 +5960,42 @@ rel_loader_function(sql_query *query, sy
                return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no such 
schema '%s'", sname);
 
        tl = sa_list(sql->sa);
-       exps = new_exp_list(sql->sa);
+       exps = sa_list(sql->sa);
        if (l->next) { /* table call with subquery */
-               if (l->next->type == type_symbol && l->next->data.sym->token == 
SQL_SELECT) {
-                       if (l->next->next != NULL)
-                               return sql_error(sql, 02, SQLSTATE(42000) 
"SELECT: '%s' requires a single sub query", fname);
-                       if (!(sq = rel_subquery(query, NULL, l->next->data.sym, 
ek)))
-                               return NULL;
-               } else if (l->next->type == type_symbol || l->next->type == 
type_list) {
-                       dnode *n;
+               if (l->next->type == type_symbol || l->next->type == type_list) 
{
                        exp_kind iek = {type_value, card_column, TRUE};
-                       list *exps = sa_list (sql->sa);
+                       list *exps = sa_list(sql->sa);
+                       int count = 0;
 
                        if (l->next->type == type_symbol)
                                n = l->next;
-                       else 
+                       else
                                n = l->next->data.lval->h;
-                       for ( ; n; n = n->next) {
-                               sql_exp *e = rel_value_exp(query, NULL, 
n->data.sym, sql_sel, iek);
-
-                               if (!e)
-                                       return NULL;
-                               append(exps, e);
+
+                       for (dnode *m = n; m; m = m->next) {
+                               if (m->type == type_symbol && 
m->data.sym->token == SQL_SELECT)
+                                       subquery = m->data.sym;
+                               count++;
                        }
-                       sq = rel_project(sql->sa, NULL, exps);
-               }
-
-               /* reset error */
-               sql->session->status = 0;
-               sql->errstr[0] = '\0';
+                       if (subquery && count > 1)
+                               return sql_error(sql, 02, SQLSTATE(42000) 
"SELECT: The input for the loader function '%s' must be either a single sub 
query, or a list of values", fname);
+
+                       if (subquery) {
+                               if (!(sq = rel_subquery(query, NULL, subquery, 
ek)))
+                                       return NULL;
+                       } else {
+                               for ( ; n; n = n->next) {
+                                       sql_exp *e = rel_value_exp(query, NULL, 
n->data.sym, sql_sel, iek);
+
+                                       if (!e)
+                                               return NULL;
+                                       append(exps, e);
+                               }
+                               sq = rel_project(sql->sa, NULL, exps);
+                       }
+               }
                if (!sq)
-                       return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no 
such operator '%s'", fname);
+                       return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no 
such loader function '%s'", fname);
                for (en = sq->exps->h; en; en = en->next) {
                        sql_exp *e = en->data;
 
@@ -5997,7 +6006,7 @@ rel_loader_function(sql_query *query, sy
 
        e = find_table_function_type(sql, s, fname, exps, tl, F_LOADER, &sf);
        if (!e || !sf)
-               return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such 
operator '%s'", fname);
+               return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such 
loader function '%s'", fname);
 
        if (sq) {
                for (node *n = sq->exps->h, *m = sf->func->ops->h ; n && m ; n 
= n->next, m = m->next) {
diff --git 
a/sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
 
b/sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
--- 
a/sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
+++ 
b/sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
@@ -74,12 +74,12 @@ stderr of test 'TypeException_with_missi
 MAPI  = (monetdb) /var/tmp/mtest-27483/.s.monetdb.35395
 QUERY = select fDistanceArcMinEq(213.7849600 , -0.4932472, ra,"dec") as 
distance_arcmin
         from t2674, fGetNearbyObjAllEq(213.7849600 , -0.4932472 , 20.8897421 ) 
as N;
-ERROR = !SELECT: no such operator 'fgetnearbyobjalleq'
+ERROR = !SELECT: no such table returning function 'fgetnearbyobjalleq'
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = select fDistanceArcMinEq(213.7849600 , -0.4932472, ra,"dec") as 
distance_arcmin
         from t2674, fGetNearbyObjAllEq(213.7849600 , -0.4932472 , 20.8897421 ) 
as N;
-ERROR = !SELECT: no such operator 'fgetnearbyobjalleq'
+ERROR = !SELECT: no such table returning function 'fgetnearbyobjalleq'
 CODE  = 42000
 
 # 11:02:37 >  
diff --git a/sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err 
b/sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err
--- a/sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err
+++ b/sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err
@@ -35,7 +35,7 @@ ERROR = !CREATE FUNCTION: external name 
 CODE  = 3F000
 MAPI  = (monetdb) /var/tmp/mtest-23748/.s.monetdb.37404
 QUERY = select * from x((select id from _tables), (select schema_id from 
_tables));
-ERROR = !SELECT: 'x' requires a single sub query
+ERROR = !SELECT: The input for the table returning function 'x' must be either 
a single sub query, or a list of values
 CODE  = 42000
 
 # 09:35:12 >  
diff --git 
a/sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
 
b/sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
--- 
a/sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
+++ 
b/sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
@@ -33,7 +33,7 @@ ERROR = !CREATE FUNCTION: external name 
 CODE  = 3F000
 MAPI  = (monetdb) /var/tmp/mtest-23419/.s.monetdb.31192
 QUERY = select * from x((select id from _tables), (select schema_id from 
_tables));
-ERROR = !SELECT: 'x' requires a single sub query
+ERROR = !SELECT: The input for the table returning function 'x' must be either 
a single sub query, or a list of values
 CODE  = 42000
 
 # 13:48:49 >  
diff --git 
a/sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err
 
b/sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err
--- 
a/sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err
+++ 
b/sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err
@@ -36,7 +36,7 @@ ERROR = !RETURN: number of columns do no
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = select * from t();
-ERROR = !SELECT: no such operator 't'
+ERROR = !SELECT: no such table returning function 't'
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = drop function t;
diff --git 
a/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
 
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
--- 
a/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
+++ 
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
@@ -40,15 +40,15 @@ stderr of test 'psm_functions_and_access
 
 MAPI  = (psm) /var/tmp/mtest-32127/.s.monetdb.34402
 QUERY = explain select * from storagemodel();
-ERROR = !SELECT: no such operator 'storagemodel'
+ERROR = !SELECT: no such table returning function 'storagemodel'
 CODE  = 42000
 MAPI  = (psm) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = select * from storagemodel();
-ERROR = !SELECT: no such operator 'storagemodel'
+ERROR = !SELECT: no such table returning function 'storagemodel'
 CODE  = 42000
 MAPI  = (psm) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = select * from storagemodel();
-ERROR = !SELECT: no such operator 'storagemodel'
+ERROR = !SELECT: no such table returning function 'storagemodel'
 CODE  = 42000
 
 # 18:51:04 >  
diff --git a/sql/test/BugTracker-2016/Tests/invalidcolumns.Bug-3968.stable.err 
b/sql/test/BugTracker-2016/Tests/invalidcolumns.Bug-3968.stable.err
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to