use of org.teiid.query.metadata.DatabaseStore in project teiid by teiid.
the class DdlPlan method alterProcedureDefinition.
public static void alterProcedureDefinition(final VDBMetaData vdb, final Procedure p, final String sql, boolean updateStore) {
TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
DatabaseStore store = vdb.getAttachment(DatabaseStore.class);
try {
Command command = QueryParser.getQueryParser().parseProcedure(p.getQueryPlan(), false);
QueryResolver.resolveCommand(command, new GroupSymbol(p.getFullName()), Command.TYPE_STORED_PROCEDURE, metadata, false);
MetadataValidator.determineDependencies(p, command);
} catch (TeiidException e) {
// should have been caught in validation, but this logic
// is also not mature so since there is no lock on the vdb
// it is possible that the plan is no longer valid at this point due
// to a concurrent execution
}
p.setQueryPlan(sql);
p.setLastModified(System.currentTimeMillis());
// $NON-NLS-1$
metadata.addToMetadataCache(p, "transformation/" + StoredProcedure.class.getSimpleName().toUpperCase(), null);
}
use of org.teiid.query.metadata.DatabaseStore in project teiid by teiid.
the class DdlPlan method alterView.
public static void alterView(final VDBMetaData vdb, final Table t, final String sql, boolean updateStore) {
TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
DatabaseStore store = vdb.getAttachment(DatabaseStore.class);
try {
Command command = QueryParser.getQueryParser().parseCommand(t.getSelectTransformation());
QueryResolver.resolveCommand(command, metadata);
MetadataValidator.determineDependencies(t, command);
} catch (TeiidException e) {
// should have been caught in validation, but this logic
// is also not mature so since there is no lock on the vdb
// it is possible that the plan is no longer valid at this point due
// to a concurrent execution
}
t.setSelectTransformation(sql);
t.setLastModified(System.currentTimeMillis());
// $NON-NLS-1$
metadata.addToMetadataCache(t, "transformation/" + SQLConstants.Reserved.SELECT, null);
}
use of org.teiid.query.metadata.DatabaseStore in project teiid by teiid.
the class TestDDLParser method helpParse.
public static Database helpParse(String ddl, DatabaseStore.Mode mode) {
final Map<String, Datatype> dataTypes = getDataTypes();
DatabaseStore store = new DatabaseStore() {
@Override
public Map<String, Datatype> getRuntimeTypes() {
return dataTypes;
}
@Override
protected TransformationMetadata getTransformationMetadata() {
Database database = getCurrentDatabase();
CompositeMetadataStore store = new CompositeMetadataStore(database.getMetadataStore());
// grants are already stored on the VDBMetaData
store.getGrants().clear();
return new TransformationMetadata(DatabaseUtil.convert(database), store, null, null, null);
}
};
store.startEditing(true);
store.setMode(mode);
QueryParser.getQueryParser().parseDDL(store, new StringReader(ddl));
store.stopEditing();
if (store.getDatabases().isEmpty()) {
return null;
}
return store.getDatabases().get(0);
}
Aggregations