Changeset: 14211c2d07ea for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=14211c2d07ea
Modified Files:
        clients/mapiclient/mnc.c
        monetdb5/modules/mal/mal_mapi.c
        sql/ChangeLog.Mar2018
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/21_dependency_views.sql
        sql/server/rel_select.c
        sql/test/BugTracker-2016/Tests/storagemodel.sql
        sql/test/BugTracker-2016/Tests/storagemodel.stable.out
        
sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out
        sql/test/Dependencies/Tests/Dependencies.stable.out
        sql/test/Dependencies/Tests/Dependencies.stable.out.int128
        sql/test/Dependencies/Tests/dependency_loop.stable.out
        sql/test/Dependencies/Tests/dependency_loop.stable.out.int128
        tools/merovingian/daemon/connections.c
Branch: default
Log Message:

merged with Mar2018


diffs (truncated from 753 to 300 lines):

diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c
--- a/clients/mapiclient/mnc.c
+++ b/clients/mapiclient/mnc.c
@@ -213,6 +213,7 @@ main(int argc, char **argv)
 #endif
 
                if (connect(s, serv, sizeof(server)) == SOCKET_ERROR) {
+                       closesocket(s);
                        fprintf(stderr,
                                 "initiating connection on socket failed: %s\n",
                                 strerror(errno));
@@ -253,13 +254,20 @@ main(int argc, char **argv)
 
                server.sin_port = htons((unsigned short) ((port) & 0xFFFF));
                if (bind(sock, (SOCKPTR) &server, length) == SOCKET_ERROR) {
+                       closesocket(sock);
                        fprintf(stderr, "bind to port %d failed: %s\n",
                                        port, strerror(errno));
                        exit(1);
                }
 
-               listen(sock, 1);
+               if(listen(sock, 1) == -1) {
+                       closesocket(sock);
+                       fprintf(stderr, "failed to set socket to listen: %s\n",
+                                       strerror(errno));
+                       exit(1);
+               }
                if ((s = accept4(sock, (SOCKPTR)0, (socklen_t *)0, 
SOCK_CLOEXEC)) == INVALID_SOCKET) {
+                       closesocket(sock);
                        fprintf(stderr, "failed to accept connection: %s\n",
                                        strerror(errno));
                        exit(1);
@@ -288,8 +296,11 @@ main(int argc, char **argv)
                                /* on Windows: unsigned int,
                                 * elsewhere: size_t, but then
                                 * unsigned int shouldn't harm */
-                               if (!write(1, buf, (unsigned int) len))
+                               if (!write(1, buf, (unsigned int) len)) {
+                                       mnstr_destroy(in);
+                                       mnstr_destroy(out);
                                        exit(2);
+                               }
                                seenflush = 0;
                        } else {
                                /* flush or error */
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -158,6 +158,7 @@ doChallenge(void *data)
        generateChallenge(challenge, 8, 12);
        algos = mcrypt_getHashAlgorithms();
        if(!algos) {
+               mnstr_printf(fdout, "!allocation failure in the server\n");
                GDKsyserror("SERVERlisten:"MAL_MALLOC_FAIL);
                close_stream(fdin);
                close_stream(fdout);
@@ -278,6 +279,7 @@ doChallenge(void *data)
        bs = bstream_create(fdin, 128 * BLOCK);
 
        if (bs == NULL){
+               mnstr_printf(fdout, "!allocation failure in the server\n");
                close_stream(fdin);
                close_stream(fdout);
                GDKfree(buf);
@@ -436,7 +438,7 @@ SERVERlistenThread(SOCKET *Sock)
                                {       int *c_d;
                                        /* filedescriptor, put it in place of 
msgsock */
                                        cmsg = CMSG_FIRSTHDR(&msgh);
-                                       shutdown(msgsock, SHUT_WR);
+                                       (void) shutdown(msgsock, SHUT_WR);
                                        closesocket(msgsock);
                                        if (!cmsg || cmsg->cmsg_type != 
SCM_RIGHTS) {
                                                fprintf(stderr, 
"!mal_mapi.listen: "
@@ -714,7 +716,20 @@ SERVERlisten(int *Port, str *Usockfile, 
 #endif
                                );
                }
-               listen(sock, maxusers);
+               if(listen(sock, maxusers) == SOCKET_ERROR) {
+                       closesocket(sock);
+                       GDKfree(psock);
+                       if (usockfile)
+                               GDKfree(usockfile);
+                       throw(IO, "mal_mapi.listen",
+                                 OPERATION_FAILED ": failed to set socket to 
listen %s",
+#ifdef _MSC_VER
+                                 wsaerror(WSAGetLastError())
+#else
+                                 strerror(errno)
+#endif
+                               );
+               }
        }
 #ifdef HAVE_SYS_UN_H
        if (usockfile) {
@@ -757,11 +772,16 @@ SERVERlisten(int *Port, str *Usockfile, 
                userver.sun_path[sizeof(userver.sun_path) - 1] = 0;
 
                length = (SOCKLEN) sizeof(userver);
-               remove(usockfile);
+               if(remove(usockfile) == -1 && errno != ENOENT) {
+                       char *e = createException(IO, "mal_mapi.listen", 
OPERATION_FAILED ": remove UNIX socket file");
+                       closesocket(usock);
+                       GDKfree(psock);
+                       return e;
+               }
                if (bind(usock, (SOCKPTR) &userver, length) == SOCKET_ERROR) {
                        char *e;
                        closesocket(usock);
-                       remove(usockfile);
+                       (void) remove(usockfile);
                        GDKfree(psock);
                        e = createException(IO, "mal_mapi.listen",
                                                                OPERATION_FAILED
@@ -776,7 +796,24 @@ SERVERlisten(int *Port, str *Usockfile, 
                        GDKfree(usockfile);
                        return e;
                }
-               listen(usock, maxusers);
+               if(listen(usock, maxusers) == SOCKET_ERROR) {
+                       char *e;
+                       closesocket(usock);
+                       (void) remove(usockfile);
+                       GDKfree(psock);
+                       e = createException(IO, "mal_mapi.listen",
+                                                               OPERATION_FAILED
+                                                               ": setting UNIX 
socket file %s to listen failed: %s",
+                                                               usockfile,
+#ifdef _MSC_VER
+                                                               
wsaerror(WSAGetLastError())
+#else
+                                                               strerror(errno)
+#endif
+                               );
+                       GDKfree(usockfile);
+                       return e;
+               }
        }
 #endif
 
@@ -914,7 +951,7 @@ SERVERclient(void *res, const Stream *In
        if (MT_create_thread(&tid, doChallenge, data, MT_THR_DETACHED)) {
                mnstr_destroy(data->in);
                mnstr_destroy(data->out);
-               free(data);
+               GDKfree(data);
                throw(MAL, "mapi.SERVERclient", "cannot fork new client 
thread");
        }
        return MAL_SUCCEED;
@@ -1203,7 +1240,7 @@ SERVERlookup(int *ret, str *dbalias)
 str
 SERVERtrace(void *ret, int *key, int *flag){
        (void )ret;
-       mapi_trace(SERVERsessions[*key].mid,*flag);
+       (void) mapi_trace(SERVERsessions[*key].mid,*flag);
        return MAL_SUCCEED;
 }
 
diff --git a/sql/ChangeLog.Mar2018 b/sql/ChangeLog.Mar2018
--- a/sql/ChangeLog.Mar2018
+++ b/sql/ChangeLog.Mar2018
@@ -6,11 +6,11 @@
   ids which can be used in sys.dependencies table.
 - Added new system view: sys.dependencies_vw which shows all data of
   sys.dependencies including names on objects, object types and dependency 
types.
-- Added new system views for finding out dependencies between database objects.
-  These new dependency views improve, extend and replace the
+- Added 25 new system views for finding out dependencies between database 
objects.
+  These new dependency views improve, extend and replace the 17
   sys.dependencies_X_on_Y() functions as previously defined in
-  21_dependency_functions.sql.
-  The sys.dependencies_X_on_Y() functions are now marked as deprecated.
+  21_dependency_functions.sql. Those sys.dependencies_X_on_Y() functions
+  are now marked as deprecated.
 - Added new system view: sys.roles which contains all defined roles.
 - Added new system view: sys.var_values which shows the values for
   system variables.
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1107,7 +1107,7 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
        }
        if (sname)
                throw(SQL, "sql.idxbind", SQLSTATE(HY005) "Cannot access column 
descriptor %s for %s.%s", iname, sname, tname);
-       throw(SQL, "sql.idxbind", SQLSTATE(HY005) "Connot access column 
descriptor %s for %s", iname, tname);
+       throw(SQL, "sql.idxbind", SQLSTATE(HY005) "Cannot access column 
descriptor %s for %s", iname, tname);
 }
 
 str mvc_append_column(sql_trans *t, sql_column *c, BAT *ins) {
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
@@ -1178,41 +1178,42 @@ sql_update_mar2018(Client c, mvc *sql)
 "\n"
 "GRANT SELECT ON sys.dependency_keys_on_foreignkeys TO PUBLIC;\n"
 "\n"
-"CREATE VIEW sys.dependency_tables_on_procdures AS\n"
-"SELECT t.schema_id AS table_schema_id, t.id AS table_id, t.name AS 
table_name, p.name, p.type AS proc_type, dep.depend_type AS depend_type\n"
+"CREATE VIEW sys.dependency_tables_on_procedures AS\n"
+"SELECT t.schema_id AS table_schema_id, t.id AS table_id, t.name AS 
table_name, p.id AS procedure_id, p.name AS procedure_name, p.type AS 
procedure_type, dep.depend_type AS depend_type\n"
 "  FROM sys.functions AS p, sys.tables AS t, sys.dependencies AS dep\n"
 " WHERE t.id = dep.id AND p.id = dep.depend_id\n"
 "   AND dep.depend_type = 13 AND p.type = 2 AND t.type NOT IN (1, 11)\n"
 " ORDER BY t.name, t.schema_id, p.name, p.id;\n"
 "\n"
-"GRANT SELECT ON sys.dependency_tables_on_procdures TO PUBLIC;\n"
+"GRANT SELECT ON sys.dependency_tables_on_procedures TO PUBLIC;\n"
 "\n"
-"CREATE VIEW sys.dependency_views_on_procdures AS\n"
-"SELECT v.name AS view_name, p.name AS proc_name, p.type AS proc_type, 
dep.depend_type AS depend_type\n"
+"CREATE VIEW sys.dependency_views_on_procedures AS\n"
+"SELECT v.schema_id AS view_schema_id, v.id AS view_id, v.name AS view_name, 
p.id AS procedure_id, p.name AS procedure_name, p.type AS procedure_type, 
dep.depend_type AS depend_type\n"
 "  FROM sys.functions AS p, sys.tables AS v, sys.dependencies AS dep\n"
 " WHERE v.id = dep.id AND p.id = dep.depend_id\n"
 "   AND dep.depend_type = 13 AND p.type = 2 AND v.type IN (1, 11)\n"
 " ORDER BY v.name, v.schema_id, p.name, p.id;\n"
 "\n"
-"GRANT SELECT ON sys.dependency_views_on_procdures TO PUBLIC;\n"
+"GRANT SELECT ON sys.dependency_views_on_procedures TO PUBLIC;\n"
 "\n"
-"CREATE VIEW sys.dependency_columns_on_procdures AS\n"
-"SELECT c.name AS column_name, p.name AS proc_name, p.type AS proc_type, 
dep.depend_type AS depend_type\n"
+"CREATE VIEW sys.dependency_columns_on_procedures AS\n"
+"SELECT c.table_id, c.id AS column_id, c.name AS column_name, p.id AS 
procedure_id, p.name AS procedure_name, p.type AS procedure_type, 
dep.depend_type AS depend_type\n"
 "  FROM sys.functions AS p, sys.columns AS c, sys.dependencies AS dep\n"
 " WHERE c.id = dep.id AND p.id = dep.depend_id\n"
 "   AND dep.depend_type = 13 AND p.type = 2\n"
 " ORDER BY c.name, c.table_id, p.name, p.id;\n"
 "\n"
-"GRANT SELECT ON sys.dependency_columns_on_procdures TO PUBLIC;\n"
+"GRANT SELECT ON sys.dependency_columns_on_procedures TO PUBLIC;\n"
 "\n"
-"CREATE VIEW sys.dependency_functions_on_procdures AS\n"
-"SELECT p.name AS proc_name, p.type AS proc_type, f2.name AS func_name, 
f2.type AS func_type, dep.depend_type AS depend_type\n"
-"  FROM sys.functions AS p, sys.functions AS f2, sys.dependencies AS dep\n"
-" WHERE f2.id = dep.id AND p.id = dep.depend_id\n"
+"CREATE VIEW sys.dependency_functions_on_procedures AS\n"
+"SELECT f.schema_id AS function_schema_id, f.id AS function_id, f.name AS 
function_name, f.type AS function_type,\n"
+"       p.schema_id AS procedure_schema_id, p.id AS procedure_id, p.name AS 
procedure_name, p.type AS procedure_type, dep.depend_type AS depend_type\n"
+"  FROM sys.functions AS p, sys.functions AS f, sys.dependencies AS dep\n"
+" WHERE f.id = dep.id AND p.id = dep.depend_id\n"
 "   AND dep.depend_type = 13 AND p.type = 2\n"
-" ORDER BY p.name, p.id, f2.name, f2.id;\n"
+" ORDER BY p.name, p.id, f.name, f.id;\n"
 "\n"
-"GRANT SELECT ON sys.dependency_functions_on_procdures TO PUBLIC;\n"
+"GRANT SELECT ON sys.dependency_functions_on_procedures TO PUBLIC;\n"
 "\n"
 "CREATE VIEW sys.dependency_columns_on_types AS\n"
 "SELECT t.schema_id AS table_schema_id, t.id AS table_id, t.name AS 
table_name, dt.id AS type_id, dt.sqlname AS type_name, c.id AS column_id, 
c.name AS column_name, dep.depend_type AS depend_type\n"
@@ -1249,7 +1250,7 @@ sql_update_mar2018(Client c, mvc *sql)
 " 'dependency_tables_on_triggers', 'dependency_columns_on_triggers', 
'dependency_functions_on_triggers',\n"
 " 'dependency_tables_on_indexes', 'dependency_columns_on_indexes',\n"
 " 'dependency_tables_on_foreignkeys', 'dependency_keys_on_foreignkeys',\n"
-" 'dependency_tables_on_procdures', 'dependency_views_on_procdures', 
'dependency_columns_on_procdures', 'dependency_functions_on_procdures',\n"
+" 'dependency_tables_on_procedures', 'dependency_views_on_procedures', 
'dependency_columns_on_procedures', 'dependency_functions_on_procedures',\n"
 " 'dependency_columns_on_types', 'dependency_functions_on_types', 
'dependency_args_on_types')\n"
 " AND schema_id IN (SELECT id FROM sys.schemas WHERE name = 'sys');\n"
        );
diff --git a/sql/scripts/21_dependency_views.sql 
b/sql/scripts/21_dependency_views.sql
--- a/sql/scripts/21_dependency_views.sql
+++ b/sql/scripts/21_dependency_views.sql
@@ -302,44 +302,45 @@ GRANT SELECT ON sys.dependency_keys_on_f
 -- **** dependency_type 13 = PROCEDURE ***
 -- SELECT * FROM sys.dependencies_vw WHERE depend_type = 13 ORDER BY obj_type, 
id;
 -- Table t has a dependency on procedure p.
-CREATE VIEW sys.dependency_tables_on_procdures AS
-SELECT t.schema_id AS table_schema_id, t.id AS table_id, t.name AS table_name, 
p.name, p.type AS proc_type, dep.depend_type AS depend_type
+CREATE VIEW sys.dependency_tables_on_procedures AS
+SELECT t.schema_id AS table_schema_id, t.id AS table_id, t.name AS table_name, 
p.id AS procedure_id, p.name AS procedure_name, p.type AS procedure_type, 
dep.depend_type AS depend_type
   FROM sys.functions AS p, sys.tables AS t, sys.dependencies AS dep
  WHERE t.id = dep.id AND p.id = dep.depend_id
    AND dep.depend_type = 13 AND p.type = 2 AND t.type NOT IN (1, 11)
  ORDER BY t.name, t.schema_id, p.name, p.id;
 
-GRANT SELECT ON sys.dependency_tables_on_procdures TO PUBLIC;
+GRANT SELECT ON sys.dependency_tables_on_procedures TO PUBLIC;
 
 -- View v has a dependency on procedure p.
-CREATE VIEW sys.dependency_views_on_procdures AS
-SELECT v.name AS view_name, p.name AS proc_name, p.type AS proc_type, 
dep.depend_type AS depend_type
+CREATE VIEW sys.dependency_views_on_procedures AS
+SELECT v.schema_id AS view_schema_id, v.id AS view_id, v.name AS view_name, 
p.id AS procedure_id, p.name AS procedure_name, p.type AS procedure_type, 
dep.depend_type AS depend_type
   FROM sys.functions AS p, sys.tables AS v, sys.dependencies AS dep
  WHERE v.id = dep.id AND p.id = dep.depend_id
    AND dep.depend_type = 13 AND p.type = 2 AND v.type IN (1, 11)
  ORDER BY v.name, v.schema_id, p.name, p.id;
 
-GRANT SELECT ON sys.dependency_views_on_procdures TO PUBLIC;
+GRANT SELECT ON sys.dependency_views_on_procedures TO PUBLIC;
 
 -- Column c has a dependency on procedure p.
-CREATE VIEW sys.dependency_columns_on_procdures AS
-SELECT c.name AS column_name, p.name AS proc_name, p.type AS proc_type, 
dep.depend_type AS depend_type
+CREATE VIEW sys.dependency_columns_on_procedures AS
+SELECT c.table_id, c.id AS column_id, c.name AS column_name, p.id AS 
procedure_id, p.name AS procedure_name, p.type AS procedure_type, 
dep.depend_type AS depend_type
   FROM sys.functions AS p, sys.columns AS c, sys.dependencies AS dep
  WHERE c.id = dep.id AND p.id = dep.depend_id
    AND dep.depend_type = 13 AND p.type = 2
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to