use of org.teiid.query.sql.lang.AlterTrigger in project teiid by teiid.
the class TestAlterResolving method testAlterTriggerInsert.
@Test
public void testAlterTriggerInsert() {
AlterTrigger alterTrigger = (AlterTrigger) helpResolve("alter trigger on SmallA_2589 instead of insert as for each row begin atomic select new.intkey; end", RealMetadataFactory.exampleBQTCached());
assertNotNull(alterTrigger.getTarget().getMetadataID());
}
use of org.teiid.query.sql.lang.AlterTrigger in project teiid by teiid.
the class TestParseAlter method testAlterDisabledPhysical.
@Test
public void testAlterDisabledPhysical() throws Exception {
AlterTrigger alterTrigger = new AlterTrigger();
alterTrigger.setTarget(new GroupSymbol("x"));
alterTrigger.setEvent(TriggerEvent.UPDATE);
alterTrigger.setEnabled(false);
alterTrigger.setAfter(true);
alterTrigger.setName("y");
helpTest("alter trigger y on x after update disabled", "ALTER TRIGGER y ON x AFTER UPDATE DISABLED", alterTrigger);
}
use of org.teiid.query.sql.lang.AlterTrigger in project teiid by teiid.
the class TestParseAlter method testCreateTriggerPhysical.
@Test
public void testCreateTriggerPhysical() throws Exception {
AlterTrigger alterTrigger = new AlterTrigger();
alterTrigger.setCreate(true);
alterTrigger.setTarget(new GroupSymbol("x"));
alterTrigger.setEvent(TriggerEvent.INSERT);
alterTrigger.setAfter(true);
alterTrigger.setName("z");
alterTrigger.setDefinition((TriggerAction) QueryParser.getQueryParser().parseProcedure("for each row begin end", true));
helpTest("create trigger z on x after insert as for each row begin end", "CREATE TRIGGER z ON x AFTER INSERT AS\nFOR EACH ROW\nBEGIN ATOMIC\nEND", alterTrigger);
}
use of org.teiid.query.sql.lang.AlterTrigger in project teiid by teiid.
the class AlterResolver method resolveCommand.
@Override
public void resolveCommand(Command command, TempMetadataAdapter metadata, boolean resolveNullLiterals) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Alter<? extends Command> alter = (Alter<? extends Command>) command;
ResolverUtil.resolveGroup(alter.getTarget(), metadata);
int type = Command.TYPE_QUERY;
boolean viewTarget = true;
if (alter instanceof AlterTrigger) {
TriggerEvent event = ((AlterTrigger) alter).getEvent();
switch(event) {
case DELETE:
type = Command.TYPE_DELETE;
break;
case INSERT:
type = Command.TYPE_INSERT;
break;
case UPDATE:
type = Command.TYPE_UPDATE;
break;
}
if (((AlterTrigger) alter).isAfter()) {
viewTarget = false;
}
} else if (alter instanceof AlterProcedure) {
type = Command.TYPE_STORED_PROCEDURE;
viewTarget = false;
}
if (viewTarget && !QueryResolver.isView(alter.getTarget(), metadata)) {
throw new QueryResolverException(QueryPlugin.Event.TEIID30116, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30116, alter.getTarget()));
}
if (alter.getDefinition() != null) {
QueryResolver.resolveCommand(alter.getDefinition(), alter.getTarget(), type, metadata.getDesignTimeMetadata(), false);
}
}
use of org.teiid.query.sql.lang.AlterTrigger in project teiid by teiid.
the class TestParseAlter method testCreateTrigger.
@Test
public void testCreateTrigger() throws Exception {
AlterTrigger alterTrigger = new AlterTrigger();
alterTrigger.setCreate(true);
alterTrigger.setTarget(new GroupSymbol("x"));
alterTrigger.setEvent(TriggerEvent.UPDATE);
alterTrigger.setDefinition((TriggerAction) QueryParser.getQueryParser().parseProcedure("for each row begin end", true));
helpTest("create trigger on x instead of update as for each row begin end", "CREATE TRIGGER ON x INSTEAD OF UPDATE AS\nFOR EACH ROW\nBEGIN ATOMIC\nEND", alterTrigger);
}
Aggregations