提交 f0245c64 authored 作者: Thomas Mueller's avatar Thomas Mueller

The methods of the CloseListener are added to the Trigger interface. The…

The methods of the CloseListener are added to the Trigger interface. The interface CloseListener is removed.
上级 b985f204
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Converting a UUID to bytes was incorrect. Because of that, updatable result sets on
<ul><li>The methods of the CloseListener are added to the Trigger interface.
The interface CloseListener is removed.
</li><li>Converting a UUID to bytes was incorrect. Because of that, updatable result sets on
tables with UUID primary key did not work.
</li><li>The database URL property DATABASE_EVENT_LISTENER_OBJECT is no longer supported
(there are problems passing objects when the PostgreSQL driver is installed as well).
......
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.api;
import java.sql.SQLException;
/**
* A trigger that implements this interface will be notified when the database
* is closed.
*/
public interface CloseListener {
/**
* This method is called when the database is closed.
* If the method throws an exception, it will be logged, but
* closing the database will continue.
*
* @throws SQLException
*/
void close() throws SQLException;
/**
* This method is called when the trigger is dropped.
*
* @throws SQLException
*/
void remove() throws SQLException;
}
......@@ -36,7 +36,8 @@ public interface Trigger {
/**
* This method is called by the database engine once when initializing the
* trigger.
* trigger. It is called when the trigger is created, as well as when the
* database is opened.
*
* @param conn a connection to the database
* @param schemaName the name of the schema
......@@ -67,4 +68,20 @@ public interface Trigger {
*/
void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException;
/**
* This method is called when the database is closed.
* If the method throws an exception, it will be logged, but
* closing the database will continue.
*
* @throws SQLException
*/
void close() throws SQLException;
/**
* This method is called when the trigger is dropped.
*
* @throws SQLException
*/
void remove() throws SQLException;
}
......@@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.h2.api.CloseListener;
import org.h2.api.Trigger;
import org.h2.command.Parser;
import org.h2.engine.Session;
......@@ -773,7 +772,7 @@ public class FullText {
/**
* Trigger updates the index when a inserting, updating, or deleting a row.
*/
public static class FullTextTrigger implements Trigger, CloseListener {
public static class FullTextTrigger implements Trigger {
protected FullTextSettings setting;
protected IndexInfo index;
......
......@@ -30,7 +30,6 @@ import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
import org.h2.api.CloseListener;
import org.h2.api.Trigger;
import org.h2.command.Parser;
import org.h2.engine.Session;
......@@ -410,7 +409,7 @@ public class FullTextLucene extends FullText {
*/
public static class FullTextTrigger
//## Java 1.4 begin ##
implements Trigger, CloseListener
implements Trigger
//## Java 1.4 end ##
{
......
......@@ -8,8 +8,6 @@ package org.h2.schema;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.api.CloseListener;
import org.h2.api.Trigger;
import org.h2.command.Parser;
import org.h2.constant.ErrorCode;
......@@ -324,9 +322,7 @@ public class TriggerObject extends SchemaObjectBase {
table.removeTrigger(this);
database.removeMeta(session, getId());
if (triggerCallback != null) {
if (triggerCallback instanceof CloseListener) {
((CloseListener) triggerCallback).remove();
}
triggerCallback.remove();
}
table = null;
triggerClassName = null;
......@@ -370,9 +366,7 @@ public class TriggerObject extends SchemaObjectBase {
*/
public void close() throws SQLException {
if (triggerCallback != null) {
if (triggerCallback instanceof CloseListener) {
((CloseListener) triggerCallback).close();
}
triggerCallback.close();
}
}
......
......@@ -58,6 +58,14 @@ public class TriggerPassData implements Trigger {
System.out.println(triggerData + ": " + row[0]);
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
/**
* Call this method to change a specific trigger.
*
......
......@@ -95,6 +95,15 @@ public class TriggerSample {
prep.setBigDecimal(1, diff);
prep.execute();
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
}
......@@ -287,7 +287,9 @@ java org.h2.test.TestAll timer
System.setProperty("h2.check2", "true");
/*
Row.getMemorySize
FileStore.sync, Database.sync() (CHECKPOINT SYNC)
document in performance section:
PreparedStatement prep = conn.prepareStatement(
"select * from table(x int = ?) t inner join test on t.x = test.id");
......@@ -296,7 +298,6 @@ ResultSet rs = prep.executeQuery();
review package and class level javadocs
TestAll deleteIndex
use RuntimeException internally
document FETCH FIRST
......
......@@ -139,4 +139,12 @@ public class TestRunscript extends TestBase implements Trigger {
// nothing to do
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
......@@ -85,6 +85,14 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
prepInsert.execute();
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
private void testTriggerBeforeSelect() throws SQLException {
......@@ -137,6 +145,14 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
prepMeta.execute();
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
/**
......@@ -152,6 +168,15 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
int type) {
// nothing to do
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
private void testTriggerAlterTable() throws SQLException {
......@@ -290,6 +315,14 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
}
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
private void checkCommit(Connection conn) {
try {
conn.commit();
......
......@@ -346,6 +346,14 @@ public class TestPreparedStatement extends TestBase {
// ignore
}
public void close() {
// ignore
}
public void remove() {
// ignore
}
}
private void testScopedGeneratedKey(Connection conn) throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论