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

Temporary files are now deleted when the database is closed.

上级 da6b9d09
......@@ -18,7 +18,11 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>-
<ul><li>Self referencing constraints didn't restrict deleting rows that reference
itself if there is another row that references it.
</li><li>ResultSetMetaData.getColumnName now returns the alias name except for columns.
</li><li>Temporary files are now deleted when the database is closed, even
if they were not garbage collected so far.
</li></ul>
<h2>Version 1.1.101 (2008-10-17)</h2>
......
......@@ -17,14 +17,14 @@ Initial Developer: H2 Group
<table class="nav" onmousemove="return mouseMove(event)"><tr class="nav"><td class="nav" valign="top">
<div id="searchMenu" style="width: 180px; overflow: hidden;">
<div class="menu">
<img border="0" src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" />
<img src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" />
</div>
<form name="searchForm" action="submit" onsubmit="return goFirst();">
<form action="submit" onsubmit="return goFirst();">
<table width="100%" class="search">
<tr class="search">
<td class="search" colspan="2">
<a href="frame.html"><img border="0" src="images/language_en.gif" alt="English" /></a>
<a href="frame_ja.html"><img border="0" src="images/language_ja.gif" alt="Japanese" /></a>
<a href="frame.html"><img src="images/language_en.gif" alt="English" /></a>
<a href="frame_ja.html"><img src="images/language_ja.gif" alt="Japanese" /></a>
</td>
</tr>
<tr class="search">
......@@ -39,12 +39,13 @@ Initial Developer: H2 Group
</td>
</tr>
<tr class="search" style="display:none;" >
<td width="1%" class="search" style="vertical-align: middle;"><input id="highlight" type="checkbox" checked="checked" onclick="highlightCurrent(this.checked, search.value)" /></td>
<td width="99%" class="search" style="padding: 0px; vertical-align: middle;"> Highlight keyword(s) </td>
<td class="search" style="width: 1%; vertical-align: middle;"><input id="highlight" type="checkbox" checked="checked" onclick="highlightCurrent(this.checked, search.value)" /></td>
<td class="search" style="width: 99%; padding: 0px; vertical-align: middle;"> Highlight keyword(s) </td>
</tr>
<tr class="search">
<td class="search" colspan="2">
<table id="result" style="border: 0px;">
<tr style="display:none"><td></td></tr>
</table>
</td>
</tr>
......
......@@ -22,27 +22,26 @@ H2 Database Engine
Welcome to H2, the Java SQL database. The main feature of H2 are:
</p>
<ul>
<li>Very fast, free for everybody, source code is included
</li><li>Embedded, server and cluster modes
</li><li>JDBC and ODBC API; browser based Console application
</li><li>Written in Java; can be compiled with GCJ and IKVM.NET
</li><li>Small footprint: around 1 MB
<li>Very fast, open source, JDBC and ODBC API
</li><li>Embedded, server and cluster modes; in-memory databases
</li><li>Browser based Console application
</li><li>Small footprint: around 1 MB jar file size
</li></ul>
<table style="border: 0px; width: 395px;">
<tr><td style="background-color: #eee;">
<table style="border: 0px; margin: 0px 5px; background-color: #eee;">
<table style="border: 0px; width: 425px;">
<tr><td style="border: 0px; background-color: #eee;">
<table style="border: 0px; margin: 0px 7px 12px 7px;">
<tr><td style="border: 0px; background-color: #eee;" colspan="2">
<h3>Download Beta</h3>
Version ${version} (${versionDate}):
</td></tr>
<tr><td style="border: 0px; background-color: #eee;">
<a href="http://www.h2database.com/h2-setup-${versionDate}.exe"><img border="1" src="images/download.png" alt="download" /></a>
<a href="http://www.h2database.com/h2-setup-${versionDate}.exe"><img style="border: 1px #00f solid;" src="images/download.png" alt="download" /></a>
</td><td style="vertical-align: middle; border: 0px; background-color: #eee;">
<a href="http://www.h2database.com/h2-setup-${versionDate}.exe">Windows Installer (3.1 MB)</a>
</td></tr>
<tr><td style="border: 0px; background-color: #eee;">
<a href="http://www.h2database.com/h2-${versionDate}.zip"><img border="1" src="images/download.png" alt="download" /></a>
<a href="http://www.h2database.com/h2-${versionDate}.zip"><img style="border: 1px #00f solid;" src="images/download.png" alt="download" /></a>
</td><td style="vertical-align: middle; border: 0px; background-color: #eee;">
<a href="http://www.h2database.com/h2-${versionDate}.zip">All platforms (zip, 4.7 MB)</a>
</td></tr>
......@@ -50,9 +49,10 @@ Welcome to H2, the Java SQL database. The main feature of H2 are:
<a href="download.html">All Downloads (including Stable)</a>
</td></tr>
</table>
</td><td style="border: 0px;">&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: #eee;">
<table style="border: 0px; margin: 5px;">
</td>
<td style="border: 0px;">&nbsp;&nbsp;&nbsp;</td>
<td style="border: 0px; background-color: #eee;">
<table style="border: 0px; margin: 0px 7px 12px 7px;">
<tr><td style="border: 0px; background-color: #eee;">
<h3>Support</h3>
<p>
......@@ -77,22 +77,14 @@ Welcome to H2, the Java SQL database. The main feature of H2 are:
</table>
</td></tr>
<tr><td colspan="3" style="border: 0px">&nbsp;</td></tr>
<tr><td colspan="3" style="border: 0px">
<table style="border: 0px; margin: 5px; width: 100%;">
<tr><td style="border: 0px;" >
<h3>Performance</h3>
<img border="0" src="images/performance.png" alt="Performance comparison" /><br />
Operations/second (higher is better) - <a href="performance.html">More information about this test</a>
</td></tr>
</table>
<tr><td colspan="3" style="border: 0px; padding: 5px 0px 15px 0px;">
<h3> Performance </h3>
<img src="images/performance.png" alt="Performance comparison" /><br />
Operations/second (higher is better) - <a href="performance.html">More information about this test</a>
</td></tr>
<tr><td colspan="3" style="border: 0px">&nbsp;</td></tr>
<tr><td colspan="3" style="background-color: #eee;">
<table style="border: 0px; margin: 5px; background-color: #eee;">
<tr><td colspan="3" style="border: 0px; background-color: #eee;">
<table style="border: 0px; margin: 0px 7px 0px 7px;">
<tr><td style="border: 0px; background-color: #eee;">
<h3>News</h3>
<p>
......@@ -112,8 +104,8 @@ Welcome to H2, the Java SQL database. The main feature of H2 are:
<tr><td colspan="3" style="border: 0px">&nbsp;</td></tr>
<tr><td colspan="3" style="background-color: #eee;">
<table style="border: 0px; margin: 5px;">
<tr><td colspan="3" style="border: 0px; background-color: #eee;">
<table style="border: 0px; margin: 0px 7px 5px 7px;">
<tr><td style="border: 0px; background-color: #eee;">
<h3>Contribute</h3>
<p>
......@@ -124,10 +116,12 @@ Welcome to H2, the Java SQL database. The main feature of H2 are:
donate money. You will be listed as a supporter:
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" name="submit" alt="PayPal"/>
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
<img alt="" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----"/>
</p>
</form>
</td></tr>
</table>
......
......@@ -17,15 +17,15 @@ Initial Developer: H2 Group
<body style="margin: 10px 0px 0px 4px;" onload="frameMe('menu');">
<div class="menu">
<img border="0" src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" />
<img src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" />
</div>
<form name="searchForm" action="submit" onsubmit="return goFirst();">
<form action="submit" onsubmit="return goFirst();">
<table width="100%" class="search">
<tr class="search">
<td class="search" colspan="2">
<a href="frame.html"><img border="0" src="images/language_en.gif" alt="English" /></a>
<a href="frame_ja.html"><img border="0" src="images/language_ja.gif" alt="Japanese" /></a>
<a href="frame.html"><img src="images/language_en.gif" alt="English" /></a>
<a href="frame_ja.html"><img src="images/language_ja.gif" alt="Japanese" /></a>
</td>
</tr>
<tr class="search">
......@@ -40,12 +40,13 @@ Initial Developer: H2 Group
</td>
</tr>
<tr class="search" style="display:none;" >
<td width="1%" class="search" style="vertical-align: middle;"><input id="highlight" type="checkbox" checked="checked" onclick="highlightCurrent(this.checked, search.value)" /></td>
<td width="99%" class="search" style="padding: 0px; vertical-align: middle;">Highlight keyword(s)</td>
<td class="search" style="width: 1%; vertical-align: middle;"><input id="highlight" type="checkbox" checked="checked" onclick="highlightCurrent(this.checked, search.value)" /></td>
<td class="search" style="width: 99%; padding: 0px; vertical-align: middle;">Highlight keyword(s)</td>
</tr>
<tr class="search">
<td class="search" colspan="2">
<table id="result" style="border: 0px;">
<tr style="display:none"><td></td></tr>
</table>
</td>
</tr>
......
......@@ -30,6 +30,10 @@ code {
padding: 0px 2px;
}
img {
border: 0px;
}
body {
margin: 0px;
}
......@@ -182,12 +186,10 @@ table.content {
tr.content {
border:0px;
border-left:1px solid #aca899;
}
td.content {
border:0px;
border-left:1px solid #aca899;
}
.contentDiv {
......
......@@ -25,6 +25,10 @@ pre {
padding: 4px;
}
img {
border: 0px;
}
body {
margin: 0px;
}
......
......@@ -30,6 +30,7 @@ import org.h2.tools.CompressTool;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
/**
......@@ -226,6 +227,10 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
public String createTempFile() throws SQLException {
return session.getDatabase().createTempFile();
}
public TempFileDeleter getTempFileDeleter() {
return session.getDatabase().getTempFileDeleter();
}
public String getLobCompressionAlgorithm(int type) {
return session.getDatabase().getLobCompressionAlgorithm(type);
......
......@@ -14,7 +14,6 @@ import org.h2.engine.Session;
import org.h2.log.LogSystem;
import org.h2.message.Message;
import org.h2.result.LocalResult;
import org.h2.util.TempFileDeleter;
/**
* Represents a transactional statement.
......@@ -124,7 +123,7 @@ public class TransactionCommand extends Prepared {
case CHECKPOINT:
session.getUser().checkAdmin();
session.getDatabase().getLog().checkpoint();
TempFileDeleter.deleteUnused();
session.getDatabase().getTempFileDeleter().deleteUnused();
break;
case SAVEPOINT:
session.addSavepoint(savepointName);
......
......@@ -64,6 +64,7 @@ import org.h2.util.NetUtils;
import org.h2.util.ObjectArray;
import org.h2.util.SmallLRUCache;
import org.h2.util.StringUtils;
import org.h2.util.TempFileDeleter;
import org.h2.value.CompareMode;
import org.h2.value.Value;
import org.h2.value.ValueInt;
......@@ -162,6 +163,7 @@ public class Database implements DataHandler {
private Object reserveMemory;
private Server server;
private HashMap linkConnections;
private TempFileDeleter tempFileDeleter = TempFileDeleter.getInstance();
public Database(String name, ConnectionInfo ci, String cipher) throws SQLException {
this.compareMode = new CompareMode(null, null, 0);
......@@ -1099,6 +1101,7 @@ public class Database implements DataHandler {
traceSystem.getTrace(Trace.DATABASE).error("close", e);
}
}
tempFileDeleter.deleteAll();
try {
closeOpenFilesAndUnlock();
} catch (SQLException e) {
......@@ -2106,4 +2109,8 @@ public class Database implements DataHandler {
}
}
public TempFileDeleter getTempFileDeleter() {
return tempFileDeleter;
}
}
......@@ -32,6 +32,7 @@ import org.h2.util.ObjectArray;
import org.h2.util.RandomUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.StringUtils;
import org.h2.util.TempFileDeleter;
import org.h2.value.Transfer;
import org.h2.value.Value;
import org.h2.value.ValueString;
......@@ -682,4 +683,8 @@ public class SessionRemote implements SessionInterface, DataHandler {
}
}
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -51,7 +51,14 @@ import java.sql.SQLClientInfoException;
//## Java 1.6 end ##
/**
* <p>
* Represents a connection (session) to a database.
* </p>
* <p>
* Thread safety: The connection is thread-safe, because access
* is synchronized. However, for compatibility with other databases, a
* connection should only be used in one thread at any time.
* </p>
*/
public class JdbcConnection extends TraceObject implements Connection {
// TODO test: check if enough synchronization on jdbc objects
......
......@@ -9,6 +9,7 @@ package org.h2.store;
import java.sql.SQLException;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
/**
......@@ -121,6 +122,13 @@ public interface DataHandler {
* @return the file name
*/
String createTempFile() throws SQLException;
/**
* Get the temp file deleter mechanism.
*
* @return the temp file deleter
*/
TempFileDeleter getTempFileDeleter();
/**
* Get the synchronization object for lob operations.
......
......@@ -57,6 +57,7 @@ public class FileStore {
private boolean checkedWriting = true;
private boolean synchronousMode;
private String mode;
private TempFileDeleter tempFileDeleter;
/**
* Create a new file using the given settings.
......@@ -72,6 +73,9 @@ public class FileStore {
this.name = name;
this.magic = magic;
this.mode = mode;
if (handler != null) {
tempFileDeleter = handler.getTempFileDeleter();
}
try {
fs.createDirs(name);
if (fs.exists(name) && !fs.canWrite(name)) {
......@@ -241,8 +245,8 @@ public class FileStore {
public void closeAndDeleteSilently() {
if (file != null) {
closeSilently();
TempFileDeleter.updateAutoDelete(autoDeleteReference);
TempFileDeleter.deleteFile(autoDeleteReference, name);
tempFileDeleter.updateAutoDelete(autoDeleteReference);
tempFileDeleter.deleteFile(autoDeleteReference, name);
name = null;
}
}
......@@ -459,9 +463,9 @@ public class FileStore {
*/
public void autoDelete() {
if (autoDeleteReference == null) {
autoDeleteReference = TempFileDeleter.addFile(name, this);
autoDeleteReference = tempFileDeleter.addFile(name, this);
} else {
TempFileDeleter.updateAutoDelete(autoDeleteReference);
tempFileDeleter.updateAutoDelete(autoDeleteReference);
}
}
......@@ -469,7 +473,7 @@ public class FileStore {
* No longer automatically delete the file once it is no longer in use.
*/
public void stopAutoDelete() {
TempFileDeleter.stopAutoDelete(autoDeleteReference, name);
tempFileDeleter.stopAutoDelete(autoDeleteReference, name);
autoDeleteReference = null;
}
......
......@@ -48,6 +48,7 @@ import org.h2.util.ObjectArray;
import org.h2.util.ObjectUtils;
import org.h2.util.RandomUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.util.Tool;
import org.h2.value.Value;
import org.h2.value.ValueLob;
......@@ -1035,5 +1036,12 @@ public class Recover extends Tool implements DataHandler {
public SmallLRUCache getLobFileListCache() {
return null;
}
/**
* INTERNAL
*/
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -10,6 +10,7 @@ import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.util.HashMap;
import java.util.Iterator;
import org.h2.constant.SysProperties;
import org.h2.message.Message;
......@@ -19,13 +20,17 @@ import org.h2.message.Message;
*/
public class TempFileDeleter {
private static final ReferenceQueue QUEUE = new ReferenceQueue();
private static final HashMap REF_MAP = new HashMap();
private final ReferenceQueue queue = new ReferenceQueue();
private final HashMap refMap = new HashMap();
private TempFileDeleter() {
// utility class
}
public static TempFileDeleter getInstance() {
return new TempFileDeleter();
}
/**
* Contains information about a file.
*/
......@@ -50,13 +55,13 @@ public class TempFileDeleter {
* @param file the object to monitor
* @return the reference that can be used to stop deleting the file
*/
public static synchronized Reference addFile(String fileName, Object file) {
public synchronized Reference addFile(String fileName, Object file) {
FileUtils.trace("TempFileDeleter.addFile", fileName, file);
PhantomReference ref = new PhantomReference(file, QUEUE);
PhantomReference ref = new PhantomReference(file, queue);
TempFile f = new TempFile();
f.fileName = fileName;
f.lastModified = FileUtils.getLastModified(fileName);
REF_MAP.put(ref, f);
refMap.put(ref, f);
deleteUnused();
return ref;
}
......@@ -68,8 +73,8 @@ public class TempFileDeleter {
*
* @param ref the reference
*/
public static synchronized void updateAutoDelete(Reference ref) {
TempFile f2 = (TempFile) REF_MAP.get(ref);
public synchronized void updateAutoDelete(Reference ref) {
TempFile f2 = (TempFile) refMap.get(ref);
if (f2 != null) {
String fileName = f2.fileName;
long mod = FileUtils.getLastModified(fileName);
......@@ -83,9 +88,9 @@ public class TempFileDeleter {
* @param ref the reference as returned by addFile
* @param fileName the file name
*/
public static synchronized void deleteFile(Reference ref, String fileName) {
public synchronized void deleteFile(Reference ref, String fileName) {
if (ref != null) {
TempFile f2 = (TempFile) REF_MAP.remove(ref);
TempFile f2 = (TempFile) refMap.remove(ref);
if (f2 != null) {
if (SysProperties.CHECK && fileName != null && !f2.fileName.equals(fileName)) {
throw Message.getInternalError("f2:" + f2.fileName + " f:" + fileName);
......@@ -108,17 +113,25 @@ public class TempFileDeleter {
}
}
}
/**
* Delete all registered temp files.
*/
public void deleteAll() {
Iterator it = refMap.values().iterator();
while (it.hasNext()) {
TempFile tempFile = (TempFile) it.next();
deleteFile(null, tempFile.fileName);
}
deleteUnused();
}
/**
* Delete all unused files now.
*/
public static void deleteUnused() {
// Mystery: I don't know how QUEUE could get null, but two independent
// people reported NullPointerException here - if somebody understands
// how it could happen please report it!
// Environment: web application under Tomcat, exception occurs during undeploy
while (QUEUE != null) {
Reference ref = QUEUE.poll();
public void deleteUnused() {
while (queue != null) {
Reference ref = queue.poll();
if (ref == null) {
break;
}
......@@ -133,10 +146,10 @@ public class TempFileDeleter {
* @param ref the reference as returned by addFile
* @param fileName the file name
*/
public static void stopAutoDelete(Reference ref, String fileName) {
public void stopAutoDelete(Reference ref, String fileName) {
FileUtils.trace("TempFileDeleter.stopAutoDelete", fileName, ref);
if (ref != null) {
TempFile f2 = (TempFile) REF_MAP.remove(ref);
TempFile f2 = (TempFile) refMap.remove(ref);
if (SysProperties.CHECK && (f2 == null || !f2.fileName.equals(fileName))) {
throw Message.getInternalError("f2:" + f2 + " " + (f2 == null ? "" : f2.fileName) + " f:" + fileName);
}
......
......@@ -280,24 +280,23 @@ java org.h2.test.TestAll timer
/*
test ant build
use only one icon, not both
test documentation (japanese, pdf download, frames, sourceError)
test web site (including search, main, web main)
test with firefox 3, internet explorer, opera, safari, google chrome
don't write stack trace of common exceptions in log file: 23*
SET LOG 2:
Database.logIndexChanges stays; should be updated? need test case
DROP ALL OBJECTS in a loop: memory problem with storageMap
test with 1.0
fix html (use xhtml?)
'if not exists" / 'if exists" clauses to the
"alter table create/drop constraint"
test case:
create table test(id int not null);
alter table test add constraint if not exists pk primary key(id);
alter table test add constraint if not exists pk primary key(id);
alter table test drop constraint if exists pk;
alter table test drop constraint if exists pk;
drop table test;
http://validator.w3.org/
document url parameter open_new
osgi: create a sample application, test, document
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
......@@ -34,12 +35,22 @@ import org.h2.util.StringUtils;
* Tests LOB and CLOB data types.
*/
public class TestLob extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
testLobServerMemory();
if (config.memory) {
return;
}
testLobDeleteTemp();
testLobDelete();
testLobVariable();
testLobDrop();
......@@ -62,6 +73,17 @@ public class TestLob extends TestBase {
testJavaObject();
}
private void testLobDeleteTemp() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
Statement stat = conn.createStatement();
stat.execute("create table test(data clob) as select space(100000) from dual");
assertEquals(1, new File(baseDir + "/lob.lobs.db").listFiles().length);
stat.execute("delete from test");
conn.close();
assertEquals(0, new File(baseDir + "/lob.lobs.db").listFiles().length);
}
private void testLobServerMemory() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
......
......@@ -47,6 +47,15 @@ public class TestScript extends TestBase {
private String fileName = "org/h2/test/test-" +
Constants.VERSION_MAJOR + "." + Constants.VERSION_MINOR + ".txt";
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
/**
* Get all SQL statements of this file.
*
......
......@@ -229,6 +229,8 @@ public class TestMetaData extends TestBase {
rs.next();
int type = rs.getMetaData().getColumnType(1);
assertEquals(Types.VARCHAR, type);
rs = conn.createStatement().executeQuery("SELECT COUNT(*) C FROM DUAL");
assertEquals("C", rs.getMetaData().getColumnName(1));
}
private void testColumnPrecision() throws SQLException {
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(id identity, parent bigint, foreign key(parent) references(id));
> ok
insert into test values(0, 0), (1, NULL), (2, 1), (3, 3), (4, 3);
> update count: 5
delete from test where id = 3;
> exception
delete from test where id = 0;
> update count: 1
delete from test where id = 1;
> exception
drop table test;
> ok
select iso_week('2006-12-31') w, iso_year('2007-12-31') y, iso_day_of_week('2007-12-31') w;
> W Y W
> -- ---- -
......@@ -368,7 +386,7 @@ insert into t2 select x from system_range(1, 1000);
explain select count(*) from t1 where t1.id in ( select t2.id from t2 );
> PLAN
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT COUNT(*) FROM (SELECT DISTINCT T2.ID AS TEMP_VIEW_2_X FROM PUBLIC.T2 /* PUBLIC.T2_TABLE_SCAN */) TEMP_VIEW_3 /* SELECT DISTINCT T2.ID AS TEMP_VIEW_2_X FROM PUBLIC.T2 /++ PUBLIC.T2_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.T1 /* PUBLIC.PRIMARY_KEY_A: ID = TEMP_VIEW_3.TEMP_VIEW_2_X */ ON 1=1 WHERE T1.ID = TEMP_VIEW_3.TEMP_VIEW_2_X
> SELECT COUNT(*) FROM (SELECT DISTINCT T2.ID AS TEMP_VIEW_3_X FROM PUBLIC.T2 /* PUBLIC.T2_TABLE_SCAN */) TEMP_VIEW_4 /* SELECT DISTINCT T2.ID AS TEMP_VIEW_3_X FROM PUBLIC.T2 /++ PUBLIC.T2_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.T1 /* PUBLIC.PRIMARY_KEY_A: ID = TEMP_VIEW_4.TEMP_VIEW_3_X */ ON 1=1 WHERE T1.ID = TEMP_VIEW_4.TEMP_VIEW_3_X
> rows: 1
select count(*) from t1 where t1.id in ( select t2.id from t2 );
......@@ -815,7 +833,7 @@ insert into test values(1), (2), (3);
explain select * from test where id in(1, 2, null);
> PLAN
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT TEST.ID FROM TABLE_DISTINCT(TEMP_VIEW_20_X INTEGER=(1, 2, NULL)) TEMP_VIEW_21 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_21.TEMP_VIEW_20_X */ ON 1=1 WHERE (ID IN(1, 2, NULL)) AND (ID = TEMP_VIEW_21.TEMP_VIEW_20_X)
> SELECT TEST.ID FROM TABLE_DISTINCT(TEMP_VIEW_21_X INTEGER=(1, 2, NULL)) TEMP_VIEW_22 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_22.TEMP_VIEW_21_X */ ON 1=1 WHERE (ID IN(1, 2, NULL)) AND (ID = TEMP_VIEW_22.TEMP_VIEW_21_X)
> rows: 1
drop table test;
......@@ -2536,7 +2554,7 @@ select * from test t1 where id in(id);
explain select * from test t1 where id in(select id from test);
> PLAN
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM (SELECT DISTINCT ID AS TEMP_VIEW_70_X FROM PUBLIC.TEST /* PUBLIC.TEST_TABLE_SCAN */) TEMP_VIEW_71 /* SELECT DISTINCT ID AS TEMP_VIEW_70_X FROM PUBLIC.TEST /++ PUBLIC.TEST_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID = TEMP_VIEW_71.TEMP_VIEW_70_X */ ON 1=1 WHERE ID = TEMP_VIEW_71.TEMP_VIEW_70_X
> SELECT T1.ID, T1.NAME FROM (SELECT DISTINCT ID AS TEMP_VIEW_71_X FROM PUBLIC.TEST /* PUBLIC.TEST_TABLE_SCAN */) TEMP_VIEW_72 /* SELECT DISTINCT ID AS TEMP_VIEW_71_X FROM PUBLIC.TEST /++ PUBLIC.TEST_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID = TEMP_VIEW_72.TEMP_VIEW_71_X */ ON 1=1 WHERE ID = TEMP_VIEW_72.TEMP_VIEW_71_X
> rows: 1
select * from test t1 where id in(select id from test);
......@@ -2549,7 +2567,7 @@ select * from test t1 where id in(select id from test);
explain select * from test t1 where id in(1, select max(id) from test);
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM TABLE_DISTINCT(TEMP_VIEW_78_X INTEGER=(1, 2)) TEMP_VIEW_79 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_79.TEMP_VIEW_78_X */ ON 1=1 WHERE (ID IN(1, 2)) AND (ID = TEMP_VIEW_79.TEMP_VIEW_78_X)
> SELECT T1.ID, T1.NAME FROM TABLE_DISTINCT(TEMP_VIEW_79_X INTEGER=(1, 2)) TEMP_VIEW_80 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_80.TEMP_VIEW_79_X */ ON 1=1 WHERE (ID IN(1, 2)) AND (ID = TEMP_VIEW_80.TEMP_VIEW_79_X)
> rows: 1
select * from test t1 where id in(1, select max(id) from test);
......@@ -5452,13 +5470,13 @@ EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE EXISTS(SELECT * FROM TEST T2 WHERE
EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE ID IN(1, 2);
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM TABLE_DISTINCT(TEMP_VIEW_115_X INTEGER=(1, 2)) TEMP_VIEW_116 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_116.TEMP_VIEW_115_X */ ON 1=1 WHERE (ID IN(1, 2)) AND (ID = TEMP_VIEW_116.TEMP_VIEW_115_X)
> SELECT T1.ID, T1.NAME FROM TABLE_DISTINCT(TEMP_VIEW_116_X INTEGER=(1, 2)) TEMP_VIEW_117 /* PUBLIC."" */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID >= 1 AND ID <= 2 AND ID = TEMP_VIEW_117.TEMP_VIEW_116_X */ ON 1=1 WHERE (ID IN(1, 2)) AND (ID = TEMP_VIEW_117.TEMP_VIEW_116_X)
> rows: 1
EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE ID IN(SELECT ID FROM TEST);
> PLAN
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM (SELECT DISTINCT ID AS TEMP_VIEW_119_X FROM PUBLIC.TEST /* PUBLIC.TEST_TABLE_SCAN */) TEMP_VIEW_120 /* SELECT DISTINCT ID AS TEMP_VIEW_119_X FROM PUBLIC.TEST /++ PUBLIC.TEST_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID = TEMP_VIEW_120.TEMP_VIEW_119_X */ ON 1=1 WHERE ID = TEMP_VIEW_120.TEMP_VIEW_119_X
> SELECT T1.ID, T1.NAME FROM (SELECT DISTINCT ID AS TEMP_VIEW_120_X FROM PUBLIC.TEST /* PUBLIC.TEST_TABLE_SCAN */) TEMP_VIEW_121 /* SELECT DISTINCT ID AS TEMP_VIEW_120_X FROM PUBLIC.TEST /++ PUBLIC.TEST_TABLE_SCAN ++/ */ INNER JOIN PUBLIC.TEST T1 /* PUBLIC.PRIMARY_KEY_2: ID = TEMP_VIEW_121.TEMP_VIEW_120_X */ ON 1=1 WHERE ID = TEMP_VIEW_121.TEMP_VIEW_120_X
> rows: 1
EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE ID NOT IN(SELECT ID FROM TEST);
......
......@@ -14,6 +14,7 @@ import org.h2.store.DataPage;
import org.h2.store.FileStore;
import org.h2.test.TestBase;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
import org.h2.value.ValueDouble;
import org.h2.value.ValueFloat;
......@@ -152,4 +153,8 @@ public class TestDataPage extends TestBase implements DataHandler {
return null;
}
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -14,6 +14,7 @@ import org.h2.store.FileStore;
import org.h2.test.TestBase;
import org.h2.util.FileUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
/**
......@@ -187,4 +188,8 @@ public class TestFile extends TestBase implements DataHandler {
return null;
}
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -41,6 +41,15 @@ import org.h2.util.FileUtils;
public class TestTools extends TestBase {
private Server server;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
if (config.networked) {
......
......@@ -17,6 +17,7 @@ import org.h2.store.FileStore;
import org.h2.test.TestBase;
import org.h2.util.ObjectArray;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.util.ValueHashMap;
import org.h2.value.CompareMode;
import org.h2.value.Value;
......@@ -151,5 +152,9 @@ public class TestValueHashMap extends TestBase implements DataHandler {
public SmallLRUCache getLobFileListCache() {
return null;
}
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -24,6 +24,7 @@ import org.h2.test.TestBase;
import org.h2.util.FileUtils;
import org.h2.util.MemoryUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean;
......@@ -243,4 +244,8 @@ public class TestValueMemory extends TestBase implements DataHandler {
return lobFileListCache;
}
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
}
......@@ -714,9 +714,11 @@ public class BuildBase {
}
private void mkdirs(File f) {
if (!f.mkdirs()) {
throw new Error("Can not create directory " + f.getAbsolutePath());
}
if (!f.exists()) {
if (!f.mkdirs()) {
throw new Error("Can not create directory " + f.getAbsolutePath());
}
}
}
/**
......
......@@ -567,4 +567,4 @@ somehow marcio groove roy gis matt targeted brazil dig opt deregister
classname recaptcha unload unloaded unloads activator statistic hence rathsack
reflects doy bloom minimal gmx conserve panic serious robert thursday
wednesday saturday friday tuesday sharing opposite fassi dario clauses
factorial blogspot displaying thedevcloud dayof
\ No newline at end of file
factorial blogspot displaying thedevcloud dayof safety chrome
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论