提交 2f18ec4c authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting

上级 19dad98c
......@@ -111,10 +111,11 @@ public class CreateTrigger extends SchemaCommand {
trigger.setRowBased(rowBased);
trigger.setTypeMask(typeMask);
trigger.setOnRollback(onRollback);
if(this.triggerClassName != null)
if (this.triggerClassName != null) {
trigger.setTriggerClassName(triggerClassName, force);
else
} else {
trigger.setTriggerSource(triggerSource, force);
}
db.addSchemaObject(session, trigger);
table.addTrigger(trigger);
return 0;
......
......@@ -71,7 +71,7 @@ public class TriggerObject extends SchemaObjectBase {
try {
Session sysSession = database.getSystemSession();
Connection c2 = sysSession.createConnection(false);
final Object obj;
Object obj;
if (triggerClassName != null) {
obj = JdbcUtils.loadUserClass(triggerClassName).newInstance();
} else {
......@@ -89,14 +89,15 @@ public class TriggerObject extends SchemaObjectBase {
}
private Trigger loadFromSource() {
final SourceCompiler compiler = database.getCompiler();
SourceCompiler compiler = database.getCompiler();
synchronized (compiler) {
final String fullClassName = Constants.USER_PACKAGE + ".trigger." + getName();
String fullClassName = Constants.USER_PACKAGE + ".trigger." + getName();
compiler.setSource(fullClassName, triggerSource);
try {
final Method m = compiler.getMethod(fullClassName);
if (m.getParameterTypes().length > 0)
Method m = compiler.getMethod(fullClassName);
if (m.getParameterTypes().length > 0) {
throw new IllegalStateException("No parameters are allowed for a trigger");
}
return (Trigger) m.invoke(null);
} catch (DbException e) {
throw e;
......@@ -162,7 +163,7 @@ public class TriggerObject extends SchemaObjectBase {
Value identity = session.getLastScopeIdentity();
try {
triggerCallback.fire(c2, null, null);
} catch (Throwable e) {
} catch (Throwable e) {
throw DbException.get(ErrorCode.ERROR_EXECUTING_TRIGGER_3, e, getName(),
triggerClassName != null ? triggerClassName : "..source..", e.toString());
} finally {
......@@ -327,10 +328,11 @@ public class TriggerObject extends SchemaObjectBase {
} else {
buff.append(" QUEUE ").append(queueSize);
}
if (triggerClassName != null)
if (triggerClassName != null) {
buff.append(" CALL ").append(Parser.quoteIdentifier(triggerClassName));
else
} else {
buff.append(" AS ").append(StringUtils.quoteStringSQL(triggerSource));
}
return buff.toString();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论