try {
HsqlName name = (HsqlName) parameters[0];
Table table =
session.database.schemaManager.getTable(session,
name.name, name.schema.name);
DataFileCache cache = session.database.logger.getCache();
session.checkAdmin();
session.checkDDLWrite();
if (!session.database.logger.isFileDatabase()) {
return Result.updateZeroResult;
}
if (session.database.logger.getDataFileSpaces() == 0) {
throw Error.error(ErrorCode.ACCESS_IS_DENIED);
}
if (table.getSpaceID()
!= DataSpaceManager.tableIdDefault) {
return Result.updateZeroResult;
}
// memory database
if (cache == null) {
return Result.updateZeroResult;
}
DataSpaceManager dataSpace = cache.spaceManager;
int tableSpaceID = dataSpace.getNewTableSpaceID();
table.setSpaceID(tableSpaceID);
// if cache exists, a memory table can get a space id
// it can then be converted to cached
if (!table.isCached()) {
return Result.updateZeroResult;
}
TableSpaceManager tableSpace =
dataSpace.getTableSpace(tableSpaceID);
PersistentStore store = table.getRowStore(session);
store.setSpaceManager(tableSpace);
return Result.updateZeroResult;
} catch (HsqlException e) {
return Result.newErrorResult(e, sql);
}
}
case StatementTypes.SET_TABLE_SET_TABLESPACE : {
try {
HsqlName name = (HsqlName) parameters[0];
int spaceid = ((Integer) parameters[1]).intValue();
Table table =
session.database.schemaManager.getTable(session,
name.name, name.schema.name);
DataFileCache cache = session.database.logger.getCache();
if (!session.isProcessingScript()) {
return Result.updateZeroResult;
}