}
case StatementTypes.GRANT :
case StatementTypes.REVOKE : {
try {
boolean grant = type == StatementTypes.GRANT;
OrderedHashSet granteeList = (OrderedHashSet) arguments[0];
HsqlName name = (HsqlName) arguments[1];
this.setSchemaName(session, null, name);
name = session.database.schemaManager.getSchemaObjectName(
name.schema, name.name, name.type, true);
SchemaObject schemaObject =
session.database.schemaManager.getSchemaObject(name);
Right right = (Right) arguments[2];
Grantee grantor = (Grantee) arguments[3];
boolean cascade = ((Boolean) arguments[4]).booleanValue();
boolean isGrantOption =
((Boolean) arguments[5]).booleanValue();
if (grantor == null) {
grantor = isSchemaDefinition ? schemaName.owner
: session.getGrantee();
}
GranteeManager gm = session.database.granteeManager;
switch (schemaObject.getType()) {
case SchemaObject.CHARSET :
System.out.println("grant charset!");
break;
case SchemaObject.VIEW :
case SchemaObject.TABLE : {
Table t = (Table) schemaObject;
right.setColumns(t);
if (t.getTableType() == TableBase.TEMP_TABLE
&& !right.isFull()) {
return Result.newErrorResult(
Error.error(ErrorCode.X_42595), sql);
}
}
}
if (grant) {
gm.grant(granteeList, schemaObject, right, grantor,
isGrantOption);
} else {
gm.revoke(granteeList, schemaObject, right, grantor,
isGrantOption, cascade);
}
break;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.GRANT_ROLE :
case StatementTypes.REVOKE_ROLE : {
try {
boolean grant = type == StatementTypes.GRANT_ROLE;
OrderedHashSet granteeList = (OrderedHashSet) arguments[0];
OrderedHashSet roleList = (OrderedHashSet) arguments[1];
Grantee grantor = (Grantee) arguments[2];
boolean cascade = (Boolean) arguments[3];
GranteeManager gm = session.database.granteeManager;
gm.checkGranteeList(granteeList);
for (int i = 0; i < granteeList.size(); i++) {
String grantee = (String) granteeList.get(i);
gm.checkRoleList(grantee, roleList, grantor, grant);
}
if (grant) {
for (int i = 0; i < granteeList.size(); i++) {
String grantee = (String) granteeList.get(i);
for (int j = 0; j < roleList.size(); j++) {
String roleName = (String) roleList.get(j);
gm.grant(grantee, roleName, grantor);
}
}
} else {
for (int i = 0; i < granteeList.size(); i++) {
String grantee = (String) granteeList.get(i);
for (int j = 0; j < roleList.size(); j++) {
gm.revoke(grantee, (String) roleList.get(j),
grantor);
}
}
}