Changeset: 87e2c956ff7e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/87e2c956ff7e
Modified Files:
clients/mapiclient/dump.c
Branch: Jan2022
Log Message:
Let the server do more of the work.
diffs (104 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2560,29 +2560,32 @@ dump_database(Mapi mid, stream *toConsol
"SELECT s.name, t.name, "
"a.name, "
"sum(p.privileges), "
- "g.name, p.grantable "
+ "g.name, go.opt "
"FROM sys.schemas s, sys.tables t, "
"sys.auths a, sys.privileges p, "
- "sys.auths g "
+ "sys.auths g, "
+ "(VALUES (0, ''), (1, ' WITH GRANT OPTION')) AS go (id,
opt) "
"WHERE p.obj_id = t.id "
"AND p.auth_id = a.id "
"AND t.schema_id = s.id "
"AND t.system = FALSE "
"AND p.grantor = g.id "
- "GROUP BY s.name, t.name, a.name, g.name, p.grantable "
- "ORDER BY s.name, t.name, a.name, g.name, p.grantable";
+ "AND p.grantable = go.id "
+ "GROUP BY s.name, t.name, a.name, g.name, go.opt "
+ "ORDER BY s.name, t.name, a.name, g.name, go.opt";
const char *column_grants =
"SELECT s.name, t.name, "
"c.name, a.name, "
"pc.privilege_code_name, "
- "g.name, p.grantable "
+ "g.name, go.opt "
"FROM sys.schemas s, "
"sys.tables t, "
"sys.columns c, "
"sys.auths a, "
"sys.privileges p, "
"sys.auths g, "
- "sys.privilege_codes pc "
+ "sys.privilege_codes pc, "
+ "(VALUES (0, ''), (1, ' WITH GRANT OPTION')) AS go (id,
opt) "
"WHERE p.obj_id = c.id "
"AND c.table_id = t.id "
"AND p.auth_id = a.id "
@@ -2590,16 +2593,18 @@ dump_database(Mapi mid, stream *toConsol
"AND t.system = FALSE "
"AND p.grantor = g.id "
"AND p.privileges = pc.privilege_code_id "
+ "AND p.grantable = go.id "
"ORDER BY s.name, t.name, c.name, a.name, g.name, p.grantable";
const char *function_grants =
"SELECT s.name, f.name, a.name, "
"pc.privilege_code_name, "
- "g.name, p.grantable, "
+ "g.name, go.opt, "
"ft.function_type_keyword "
"FROM sys.schemas s, sys.functions f, "
"sys.auths a, sys.privileges p, sys.auths g, "
"sys.function_types ft, "
- "sys.privilege_codes pc "
+ "sys.privilege_codes pc, "
+ "(VALUES (0, ''), (1, ' WITH GRANT OPTION')) AS go (id,
opt) "
"WHERE s.id = f.schema_id "
"AND f.id = p.obj_id "
"AND p.auth_id = a.id "
@@ -2607,6 +2612,7 @@ dump_database(Mapi mid, stream *toConsol
"AND p.privileges = pc.privilege_code_id "
"AND f.type = ft.function_type_id "
"AND NOT f.system "
+ "AND p.grantable = go.id "
"ORDER BY s.name, f.name, a.name, g.name, p.grantable";
const char *schemas =
"SELECT s.name, a.name, rem.remark "
@@ -3235,9 +3241,7 @@ dump_database(Mapi mid, stream *toConsol
mnstr_printf(toConsole, " ON TABLE ");
dquoted_print(toConsole, schema, ".");
dquoted_print(toConsole, tname, " TO ");
- dquoted_print(toConsole, aname, NULL);
- if (strcmp(grantable, "1") == 0)
- mnstr_printf(toConsole, " WITH GRANT OPTION");
+ dquoted_print(toConsole, aname, grantable);
mnstr_printf(toConsole, ";\n");
}
if (mapi_error(mid))
@@ -3261,9 +3265,7 @@ dump_database(Mapi mid, stream *toConsol
dquoted_print(toConsole, cname, ") ON ");
dquoted_print(toConsole, schema, ".");
dquoted_print(toConsole, tname, " TO ");
- dquoted_print(toConsole, aname, NULL);
- if (strcmp(grantable, "1") == 0)
- mnstr_printf(toConsole, " WITH GRANT OPTION");
+ dquoted_print(toConsole, aname, grantable);
mnstr_printf(toConsole, ";\n");
}
if (mapi_error(mid))
@@ -3287,9 +3289,7 @@ dump_database(Mapi mid, stream *toConsol
mnstr_printf(toConsole, "GRANT %s ON %s ", priv, ftype);
dquoted_print(toConsole, schema, ".");
dquoted_print(toConsole, fname, " TO ");
- dquoted_print(toConsole, aname, NULL);
- if (strcmp(grantable, "1") == 0)
- mnstr_printf(toConsole, " WITH GRANT OPTION");
+ dquoted_print(toConsole, aname, grantable);
mnstr_printf(toConsole, ";\n");
}
if (mapi_error(mid))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]