// calculated column values
String tableCatalog;
String tableSchema;
String tableName;
Grantee granteeObject;
String privilege;
// intermediate holders
Iterator tables;
Table table;
Object[] row;
// column number mappings
final int grantor = 0;
final int grantee = 1;
final int table_catalog = 2;
final int table_schema = 3;
final int table_name = 4;
final int privilege_type = 5;
final int is_grantable = 6;
final int with_hierarchy = 7;
OrderedHashSet grantees =
session.getGrantee().getGranteeAndAllRolesWithPublic();
tables = allTables();
while (tables.hasNext()) {
table = (Table) tables.next();
tableName = table.getName().name;
tableCatalog = table.getCatalogName().name;
tableSchema = table.getSchemaName().name;
for (int i = 0; i < grantees.size(); i++) {
granteeObject = (Grantee) grantees.get(i);
OrderedHashSet rights =
granteeObject.getAllDirectPrivileges(table);
OrderedHashSet grants =
granteeObject.getAllGrantedPrivileges(table);
if (!grants.isEmpty()) {
grants.addAll(rights);
rights = grants;