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);
}
}
}
break;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.CREATE_ASSERTION : {
return Result.updateZeroResult;
}
case StatementTypes.CREATE_CHARACTER_SET : {
Charset charset = (Charset) arguments[0];
try {
setOrCheckObjectName(session, null, charset.getName(),
true);
session.database.schemaManager.addSchemaObject(charset);
break;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.CREATE_COLLATION : {
return Result.updateZeroResult;
}
case StatementTypes.CREATE_ROLE : {
try {
session.checkAdmin();
session.checkDDLWrite();
HsqlName name = (HsqlName) arguments[0];
session.database.getGranteeManager().addRole(name);
break;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.CREATE_USER : {
HsqlName name = (HsqlName) arguments[0];
String password = (String) arguments[1];
Grantee grantor = (Grantee) arguments[2];
boolean admin = ((Boolean) arguments[3]).booleanValue();
try {
session.checkAdmin();
session.checkDDLWrite();
session.database.getUserManager().createUser(name,
password);
if (admin) {
session.database.getGranteeManager().grant(name.name,
SqlInvariants.DBA_ADMIN_ROLE_NAME, grantor);
}
break;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.CREATE_SCHEMA : {
HsqlName name = (HsqlName) arguments[0];
Grantee owner = (Grantee) arguments[1];
try {
session.checkDDLWrite();
if (session.database.schemaManager.schemaExists(