Object groupID = validateMatView(metadata, proc);
Object matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID, metadata);
String matViewName = metadata.getFullName(groupID);
String matTableName = metadata.getFullName(matTableId);
LogManager.logDetail(LogConstants.CTX_MATVIEWS, "processing refreshmatview for", matViewName); //$NON-NLS-1$
MatTableInfo info = globalStore.getMatTableInfo(matTableName);
boolean invalidate = Boolean.TRUE.equals(((Constant)proc.getParameter(1).getExpression()).getValue());
if (invalidate) {
touchTable(context, matTableName, false);
}
MatState oldState = info.setState(MatState.NEEDS_LOADING, invalidate?Boolean.FALSE:null, null);
if (oldState == MatState.LOADING) {
return CollectionTupleSource.createUpdateCountTupleSource(-1);
}
GroupSymbol matTable = new GroupSymbol(matTableName);
matTable.setMetadataID(matTableId);
int rowCount = loadGlobalTable(context, matTable, matTableName, globalStore, info, null);
return CollectionTupleSource.createUpdateCountTupleSource(rowCount);
} else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) {
Object groupID = validateMatView(metadata, proc);
Object pk = metadata.getPrimaryKey(groupID);
String matViewName = metadata.getFullName(groupID);
if (pk == null) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_pk", matViewName)); //$NON-NLS-1$
}
List<?> ids = metadata.getElementIDsInKey(pk);
if (ids.size() > 1) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_composite", matViewName)); //$NON-NLS-1$
}
String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
MatTableInfo info = globalStore.getMatTableInfo(matTableName);
if (!info.isValid()) {
return CollectionTupleSource.createUpdateCountTupleSource(-1);
}
TempTable tempTable = globalStore.getOrCreateTempTable(matTableName, new Query(), bufferManager, false);
if (!tempTable.isUpdatable()) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_updatable", matViewName)); //$NON-NLS-1$