Changeset: 1359aeb2906c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1359aeb2906c
Modified Files:
        clients/ChangeLog
        clients/mapiclient/dump.c
        clients/mapiclient/mclient.c
        clients/mapiclient/msqldump.h
Branch: default
Log Message:

Cleanup: remove test for presence of sys.systemfunctions.
The table was introduced back in 2010.  We can assume by now it's
there.


diffs (208 lines):

diff --git a/clients/ChangeLog b/clients/ChangeLog
--- a/clients/ChangeLog
+++ b/clients/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Mon Dec 12 2016 Sjoerd Mullender <[email protected]>
+- The mclient and msqldump programs lost compatibility with ancient
+  mserver5 versions (pre 2011) which didn't have the sys.systemfunctions
+  table.
+
 * Wed Nov 16 2016 Sjoerd Mullender <[email protected]>
 - Removed the "array" and "quick" functions from the mapi library.
   To be precise, the removed functions are: mapi_execute_array,
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -92,44 +92,6 @@ get_schema(Mapi mid)
        return NULL;
 }
 
-/* return TRUE if the sys.systemfunctions table exists */
-int
-has_systemfunctions(Mapi mid)
-{
-       MapiHdl hdl;
-       int ret;
-
-       if ((hdl = mapi_query(mid,
-                             "SELECT t.id "
-                             "FROM sys._tables t, "
-                                  "sys.schemas s "
-                             "WHERE t.name = 'systemfunctions' AND "
-                                   "t.schema_id = s.id AND "
-                                   "s.name = 'sys'")) == NULL ||
-           mapi_error(mid))
-               goto bailout;
-       ret = mapi_get_row_count(hdl) == 1;
-       while ((mapi_fetch_row(hdl)) != 0) {
-               if (mapi_error(mid))
-                       goto bailout;
-       }
-       if (mapi_error(mid))
-               goto bailout;
-       mapi_close_handle(hdl);
-       return ret;
-
-  bailout:
-       if (hdl) {
-               if (mapi_result_error(hdl))
-                       mapi_explain_result(hdl, stderr);
-               else
-                       mapi_explain_query(hdl, stderr);
-               mapi_close_handle(hdl);
-       } else
-               mapi_explain(mid, stderr);
-       return 0;
-}
-
 /* return TRUE if the sys.schemas table has a column named system */
 int
 has_schemas_system(Mapi mid)
@@ -1337,7 +1299,7 @@ dump_functions(Mapi mid, stream *toConso
        q = malloc(l);
        snprintf(q, l, functions,
                 dumpSystem ? "" : "AND f.id ",
-                dumpSystem ? "" : has_systemfunctions(mid) ? "NOT IN (SELECT 
function_id FROM sys.systemfunctions) " : "> 2000 ",
+                dumpSystem ? "" : "NOT IN (SELECT function_id FROM 
sys.systemfunctions) ",
                 sname ? "AND s.name = '" : "",
                 sname ? sname : "",
                 sname ? "' " : "",
@@ -1466,7 +1428,7 @@ dump_database(Mapi mid, stream *toConsol
                      "f.id = p.obj_id AND "
                      "p.auth_id = a.id AND "
                      "p.grantor = g.id "
-                     "%s"      /* and f.id not in systemfunctions */
+                     "AND f.id NOT IN (SELECT function_id FROM 
sys.systemfunctions) "
                "ORDER BY s.name, f.name, a.name, g.name, p.grantable";
        const char *schemas =
                "SELECT s.name, a.name "
@@ -1545,7 +1507,7 @@ dump_database(Mapi mid, stream *toConsol
                             "sys.functions f "
                        "WHERE f.language < 3 AND "
                              "s.id = f.schema_id "
-                       "%s"            /* and f.id not in systemfunctions */
+                       "AND f.id NOT IN (SELECT function_id FROM 
sys.systemfunctions) "
                        "UNION "
                        "SELECT s.name AS sname, "
                               "tr.id AS id, "
@@ -1803,9 +1765,7 @@ dump_database(Mapi mid, stream *toConsol
        hdl = NULL;
 
        /* dump views, functions, and triggers */
-       snprintf(query, sizeof(query), views_functions_triggers,
-                has_systemfunctions(mid) ? "AND f.id NOT IN (SELECT 
function_id FROM sys.systemfunctions) " : "");
-       if ((hdl = mapi_query(mid, query)) == NULL ||
+       if ((hdl = mapi_query(mid, views_functions_triggers)) == NULL ||
            mapi_error(mid))
                goto bailout;
 
@@ -1980,9 +1940,7 @@ dump_database(Mapi mid, stream *toConsol
                goto bailout;
        mapi_close_handle(hdl);
 
-       snprintf(query, sizeof(query), function_grants,
-                has_systemfunctions(mid) ? "AND f.id NOT IN (SELECT 
function_id FROM sys.systemfunctions) " : "");
-       if ((hdl = mapi_query(mid, query)) == NULL ||
+       if ((hdl = mapi_query(mid, function_grants)) == NULL ||
            mapi_error(mid))
                goto bailout;
 
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2195,7 +2195,6 @@ doFile(Mapi mid, stream *fp, int useinse
        MapiHdl hdl;
        MapiMsg rc = MOK;
        int lineno = 1;
-       enum hmyesno hassysfuncs = UNKNOWN;
        enum hmyesno hasschemsys = UNKNOWN;
        char *prompt = NULL;
        int prepno = 0;
@@ -2458,8 +2457,6 @@ doFile(Mapi mid, stream *fp, int useinse
                                                char nameq[128];
                                                char funcq[512];
 
-                                               if (hassysfuncs == UNKNOWN)
-                                                       hassysfuncs = 
has_systemfunctions(mid) ? YES : NO;
                                                if (hasschemsys == UNKNOWN)
                                                        hasschemsys = 
has_schemas_system(mid) ? YES : NO;
 
@@ -2477,46 +2474,26 @@ doFile(Mapi mid, stream *fp, int useinse
                                                                        "o.name 
LIKE '%s'",
                                                                        line);
                                                }
-                                               if (hassysfuncs == YES) {
-                                                       snprintf(funcq, 
sizeof(funcq),
-                                                                "SELECT 
o.name, "
-                                                                       "(CASE 
WHEN sf.function_id IS NOT NULL "
-                                                                             
"THEN 'SYSTEM ' "
-                                                                             
"ELSE '' "
-                                                                         "END 
|| 'FUNCTION') AS type, "
-                                                                        "CASE 
WHEN sf.function_id IS NULL "
-                                                                             
"THEN false "
-                                                                             
"ELSE true "
-                                                                        "END 
AS system, "
-                                                                        
"s.name AS sname, "
-                                                                        "%d AS 
ntype "
-                                                                "FROM 
sys.functions o "
-                                                                      "LEFT 
JOIN sys.systemfunctions sf "
-                                                                            
"ON o.id = sf.function_id, "
-                                                                      
"sys.schemas s "
-                                                                "WHERE 
o.schema_id = s.id AND "
-                                                                      "%s ",
-                                                                MD_FUNC,
-                                                                nameq);
-                                               } else {
-                                                       snprintf(funcq, 
sizeof(funcq),
-                                                                "SELECT 
o.name, "
-                                                                       "(CASE 
WHEN o.id <= 2000 "
-                                                                             
"THEN 'SYSTEM ' "
-                                                                             
"ELSE '' "
-                                                                        "END 
|| 'FUNCTION') AS type, "
-                                                                       "CASE 
WHEN o.id > 2000 "
-                                                                            
"THEN false "
-                                                                            
"ELSE true END AS system, "
-                                                                       "s.name 
AS sname, "
-                                                                       "%d AS 
ntype "
-                                                                "FROM 
sys.functions o, "
-                                                                     
"sys.schemas s "
-                                                                "WHERE 
o.schema_id = s.id AND "
-                                                                      "%s ",
-                                                                MD_FUNC,
-                                                                nameq);
-                                               }
+                                               snprintf(funcq, sizeof(funcq),
+                                                        "SELECT o.name, "
+                                                               "(CASE WHEN 
sf.function_id IS NOT NULL "
+                                                                     "THEN 
'SYSTEM ' "
+                                                                     "ELSE '' "
+                                                                 "END || 
'FUNCTION') AS type, "
+                                                                "CASE WHEN 
sf.function_id IS NULL "
+                                                                     "THEN 
false "
+                                                                     "ELSE 
true "
+                                                                "END AS 
system, "
+                                                                "s.name AS 
sname, "
+                                                                "%d AS ntype "
+                                                        "FROM sys.functions o "
+                                                              "LEFT JOIN 
sys.systemfunctions sf "
+                                                                    "ON o.id = 
sf.function_id, "
+                                                              "sys.schemas s "
+                                                        "WHERE o.schema_id = 
s.id AND "
+                                                              "%s ",
+                                                        MD_FUNC,
+                                                        nameq);
                                                snprintf(q, sizeof(q),
                                                         "SELECT name, "
                                                                "CAST(type AS 
VARCHAR(30)) AS type, "
diff --git a/clients/mapiclient/msqldump.h b/clients/mapiclient/msqldump.h
--- a/clients/mapiclient/msqldump.h
+++ b/clients/mapiclient/msqldump.h
@@ -13,5 +13,4 @@ extern int dump_table(Mapi mid, char *sc
 extern int dump_functions(Mapi mid, stream *toConsole, const char *sname, 
const char *fname);
 extern int dump_database(Mapi mid, stream *toConsole, int describe, const char 
useInserts);
 extern void dump_version(Mapi mid, stream *toConsole, const char *prefix);
-extern int has_systemfunctions(Mapi mid);
 extern int has_schemas_system(Mapi mid);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to