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

Formatting

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