提交 7c19e7bc authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 ad13cf0d
......@@ -122,7 +122,7 @@
<fileset dir="src/main"/>
</copy>
<java classname="org.h2.test.coverage.Coverage" classpath="bin" dir="bin" fork="true">
<arg line="-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -r org/h2"/>
<arg line="-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -e org/h2/store/fs -r org/h2"/>
</java>
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/**"/>
</target>
......
......@@ -31,8 +31,11 @@ It can also be compiled to a native executable using GCJ.
<br /><a name="environment"></a>
<h2>Environment</h2>
<p>
A Java Runtime Environment (JRE) version 1.4 or higher is required to run this database.
</p>
<p>
To build the database executables, the following software stack was used.
In most cases, newer version or compatible software works too.
Newer version or compatible software works too.
</p>
<ul>
<li>Windows XP
......
......@@ -139,8 +139,4 @@ public abstract class Command implements CommandInterface {
public void cancel() {
this.cancel = true;
}
public String getSQL() {
return null;
}
}
......@@ -8,7 +8,6 @@ import java.io.IOException;
import java.sql.SQLException;
import org.h2.constant.SysProperties;
import org.h2.engine.SessionInterface;
import org.h2.engine.SessionRemote;
import org.h2.expression.ParameterInterface;
import org.h2.expression.ParameterRemote;
......@@ -192,10 +191,6 @@ public class CommandRemote implements CommandInterface {
}
}
public SessionInterface getSession() {
return session;
}
public void close() {
if (session == null || session.isClosed()) {
return;
......
......@@ -60,10 +60,6 @@ public class CreateSequence extends SchemaCommand {
this.increment = increment;
}
public boolean getBelongsToTable() {
return belongsToTable;
}
public void setBelongsToTable(boolean belongsToTable) {
this.belongsToTable = belongsToTable;
}
......
......@@ -163,7 +163,7 @@ public abstract class Query extends Prepared {
}
} else {
String s = e.getSQL();
for (int j = 0; j < expressionSQL.size(); j++) {
for (int j = 0; expressionSQL != null && j < expressionSQL.size(); j++) {
String s2 = (String) expressionSQL.get(j);
if (s2.equals(s)) {
idx = j;
......
......@@ -667,18 +667,6 @@ public class Select extends Query {
return expressions;
}
public Expression getCondition() {
return condition;
}
public boolean isDistinct() {
return distinct;
}
public ObjectArray getGroupBy() {
return group;
}
public void setForUpdate(boolean b) {
this.isForUpdate = b;
}
......
......@@ -324,14 +324,6 @@ public class SelectUnion extends Query {
return left.isReadOnly() && right.isReadOnly();
}
public Query getLeftQuery() {
return left;
}
public Query getRightQuery() {
return right;
}
public void updateAggregate(Session session) throws SQLException {
left.updateAggregate(session);
right.updateAggregate(session);
......
......@@ -31,10 +31,6 @@ public class ScanCursor implements Cursor {
row = null;
}
Session getSession() {
return session;
}
public Row get() {
return row;
}
......
......@@ -34,8 +34,6 @@ import org.h2.message.Message;
/**
* A data source for H2 database connections
*
* @author Tom
*/
public class JdbcDataSource extends TraceObject implements
//#ifdef JDK14
......
......@@ -170,10 +170,6 @@ public class LogSystem {
}
}
boolean needMoreUndo() {
return sessions.size() > 0;
}
void addUndoLogRecord(LogFile log, int logRecordId, int sessionId) {
LogRecord record = new LogRecord(log, logRecordId, sessionId);
undo.add(record);
......
......@@ -77,9 +77,6 @@ public class UpdatableRow {
return isUpdatable;
}
void initKey() throws SQLException {
}
private int getColumnIndex(String columnName) throws SQLException {
for (int i = 0; i < columnCount; i++) {
String col = result.getColumnName(i);
......
......@@ -223,10 +223,6 @@ public class TcpServer implements Service {
running.remove(t);
}
boolean getLog() {
return log;
}
String getBaseDir() {
return baseDir;
}
......
......@@ -176,7 +176,7 @@ public class FtpControl extends Thread {
if (!readonly) {
try {
fs.mkdirs(fileName);
reply(257, "\"" + param + "\" directory"); // TODO quote (" > "")
reply(257, StringUtils.quoteIdentifier(param) + " directory");
ok = true;
} catch (SQLException e) {
server.logError(e);
......@@ -209,14 +209,13 @@ public class FtpControl extends Thread {
break;
case 'P':
if ("PWD".equals(command)) {
reply(257, "\"" + currentDir + "\" directory"); // TODO quote (" > "")
reply(257, StringUtils.quoteIdentifier(currentDir) + " directory");
} else if ("PASV".equals(command)) {
ServerSocket dataSocket = server.createDataSocket();
data = new FtpData(server, control.getInetAddress(), dataSocket);
data.start();
int port = dataSocket.getLocalPort();
reply(227, "Passive Mode (" + serverIpAddress + "," + (port >> 8) + "," + (port & 255) + ")");
// reply(501, ne.getMessage());
}
break;
case 'R':
......@@ -261,8 +260,7 @@ public class FtpControl extends Thread {
}
restart = 0;
} else {
processList(param, true); // Firefox compatibility (still
// not good)
processList(param, true); // Firefox compatibility (still not good)
// reply(426, "Not a file");
}
} else if ("RMD".equals(command)) {
......@@ -355,8 +353,7 @@ public class FtpControl extends Thread {
String list = server.getDirectoryListing(directory, directories);
reply(150, "Starting transfer");
server.log(list);
// need to use the current locale (UTF-8 would be wrong for the Windows
// Explorer)
// need to use the current locale (UTF-8 would be wrong for the Windows Explorer)
data.send(list.getBytes());
reply(226, "Done");
}
......
......@@ -62,10 +62,6 @@ public abstract class DataPage {
}
}
protected DataPage(DataHandler handler, int capacity) {
this(handler, new byte[capacity]);
}
protected DataPage(DataHandler handler, byte[] data) {
this.handler = handler;
this.data = data;
......
......@@ -79,6 +79,7 @@ import org.h2.test.unit.TestExit;
import org.h2.test.unit.TestFile;
import org.h2.test.unit.TestFileLock;
import org.h2.test.unit.TestFileSystem;
import org.h2.test.unit.TestFtp;
import org.h2.test.unit.TestIntArray;
import org.h2.test.unit.TestIntIntHashMap;
import org.h2.test.unit.TestMultiThreadedKernel;
......@@ -134,6 +135,7 @@ java org.h2.test.TestAll timer
public boolean jdk14 = true;
private Server server;
public boolean cache2Q;
public static void main(String[] args) throws Exception {
long time = System.currentTimeMillis();
......@@ -142,6 +144,10 @@ java org.h2.test.TestAll timer
/*
unit tests for ftp
start writing javadocs for jdbcx package
replicating file system
background thread writing file system (all writes)
......@@ -276,6 +282,12 @@ write tests using the PostgreSQL JDBC driver
// repeatable test with a very big database (making backups of the database files)
/*
Features of H2
- Case insensitive string data type
- GROUP_CONCAT aggregate, User defined aggregates
*/
if (args.length > 0) {
if ("crash".equals(args[0])) {
new TestCrashAPI().runTest(test);
......@@ -381,6 +393,7 @@ write tests using the PostgreSQL JDBC driver
logMode = 1;
cipher = null;
mvcc = false;
cache2Q = false;
testAll();
diskUndo = false;
......@@ -395,6 +408,7 @@ write tests using the PostgreSQL JDBC driver
logMode = 1;
cipher = null;
mvcc = false;
cache2Q = false;
testAll();
big = false;
......@@ -411,6 +425,7 @@ write tests using the PostgreSQL JDBC driver
throttle = 0;
cipher = null;
mvcc = false;
cache2Q = false;
testAll();
diskUndo = true;
......@@ -425,6 +440,7 @@ write tests using the PostgreSQL JDBC driver
throttle = 1;
cipher = "XTEA";
mvcc = false;
cache2Q = false;
testAll();
diskUndo = false;
......@@ -442,6 +458,7 @@ write tests using the PostgreSQL JDBC driver
throttle = 0;
cipher = null;
mvcc = false;
cache2Q = false;
testAll();
big = true;
......@@ -458,6 +475,7 @@ write tests using the PostgreSQL JDBC driver
throttle = 0;
cipher = null;
mvcc = false;
cache2Q = true;
testAll();
big = true;
......@@ -474,6 +492,7 @@ write tests using the PostgreSQL JDBC driver
throttle = 0;
cipher = "AES";
mvcc = false;
cache2Q = false;
testAll();
smallLog = big = networked = memory = ssl = textStorage = diskResult = deleteIndex = traceSystemOut = false;
......@@ -481,6 +500,7 @@ write tests using the PostgreSQL JDBC driver
logMode = 1;
cipher = null;
mvcc = true;
cache2Q = false;
testAll();
}
......@@ -499,6 +519,7 @@ write tests using the PostgreSQL JDBC driver
new TestExit().runTest(this);
new TestFile().runTest(this);
new TestFileLock().runTest(this);
new TestFtp().runTest(this);
new TestFileSystem().runTest(this);
new TestIntArray().runTest(this);
new TestIntIntHashMap().runTest(this);
......
......@@ -138,6 +138,9 @@ public abstract class TestBase {
if (config.mvcc) {
url += ";MVCC=TRUE";
}
if (config.cache2Q) {
url += ";CACHE_TYPE=TQ";
}
if (config.diskResult && admin) {
url += ";MAX_MEMORY_ROWS=100;CACHE_SIZE=0";
}
......
......@@ -17,7 +17,7 @@ import java.io.Writer;
* The class used at runtime to measure the code usage and performance.
*/
public class Profile extends Thread {
public static final boolean LIST_UNVISITED = true;
public static final boolean LIST_UNVISITED = false;
public static final boolean FAST = false;
public static final boolean TRACE = false;
public static final Profile MAIN = new Profile();
......
package org.h2.tools.ftp;
package org.h2.test.unit;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.sql.SQLException;
import java.util.ArrayList;
import org.h2.engine.Constants;
import org.h2.util.IOUtils;
import org.h2.util.NetUtils;
import org.h2.util.StringUtils;
public class FtpClient {
private Socket socket;
......@@ -20,6 +23,9 @@ public class FtpClient {
private PrintWriter writer;
private int code;
private String message;
private Socket socketData;
private InputStream inData;
private OutputStream outData;
public static FtpClient open(String url) throws SQLException, IOException {
FtpClient client = new FtpClient();
......@@ -46,6 +52,7 @@ public class FtpClient {
code = 0;
} else {
code = Integer.parseInt(message.substring(0, idx));
message = message.substring(idx + 1);
}
}
......@@ -61,60 +68,164 @@ public class FtpClient {
writer.flush();
}
public void sendUser(String userName) throws IOException {
public void login(String userName, String password) throws IOException {
send("USER " + userName);
readCode(331);
}
public void sendQuit() throws IOException {
send("QUIT");
readCode(221);
}
public void sendPassword(String password) throws IOException {
send("PASS " + password);
readCode(230);
send("SYST");
readCode(215);
send("SITE");
readCode(500);
send("STRU F");
readCode(200);
send("TYPE I");
readCode(200);
}
public void sendChangeWorkingDirectory(String dir) throws IOException {
public void close() throws IOException {
if (socket != null) {
send("QUIT");
readCode(221);
socket.close();
}
}
public void changeWorkingDirectory(String dir) throws IOException {
send("CWD " + dir);
readCode(250);
}
public void sendChangeDirectoryUp() throws IOException {
public void changeDirectoryUp() throws IOException {
send("CDUP");
readCode(250);
}
public void sendDelete(String fileName) throws IOException {
public void delete(String fileName) throws IOException {
send("DELE " + fileName);
readCode(250);
}
public void sendMakeDirectory(String dir) throws IOException {
public void makeDirectory(String dir) throws IOException {
send("MKD " + dir);
readCode(257);
}
public void sendMode(String dir) throws IOException {
public void mode(String mode) throws IOException {
send("MODE " + mode);
readCode(200);
}
public void sendModifiedTime(String dir) throws IOException {
public void modificationTime(String fileName) throws IOException {
send("MDTM " + fileName);
readCode(213);
}
public void sendNameList(String dir) throws IOException {
public void noOperation() throws IOException {
send("NOOP");
readCode(200);
}
public void sendRenameFrom(String dir) throws IOException {
public String printWorkingDirectory() throws IOException {
send("PWD");
readCode(257);
return unquote();
}
private String unquote() {
int first = message.indexOf('"') + 1;
int last = message.lastIndexOf('"');
StringBuffer buff = new StringBuffer();
for (int i = first; i < last; i++) {
char ch = message.charAt(i);
buff.append(ch);
if (ch == '\"') {
i++;
}
}
return buff.toString();
}
private void passive() throws IOException, SQLException {
send("PASV");
readCode(227);
int first = message.indexOf('(') + 1;
int last = message.indexOf(')');
String[] address = StringUtils.arraySplit(message.substring(first, last), ',', true);
StringBuffer buff = new StringBuffer();
for (int i = 0; i < 4; i++) {
if (i > 0) {
buff.append('.');
}
buff.append(address[i]);
}
String ip = buff.toString();
InetAddress addr = InetAddress.getByName(ip);
int port = (Integer.parseInt(address[4]) << 8) | Integer.parseInt(address[5]);
socketData = NetUtils.createSocket(addr, port, false);
inData = socketData.getInputStream();
outData = socketData.getOutputStream();
}
public void rename(String fromFileName, String toFileName) throws IOException {
send("RNFR " + fromFileName);
readCode(350);
send("RNTO " + toFileName);
readCode(250);
}
public void retrieve(String fileName, OutputStream out, long restartAt) throws IOException, SQLException {
passive();
if (restartAt > 0) {
send("REST " + restartAt);
readCode(350);
}
send("RETR " + fileName);
IOUtils.copyAndClose(inData, out);
readCode(226);
}
public String[] sendList(String dir) throws IOException {
send("LIST " + dir);
public void removeDirectory(String dir) throws IOException {
send("RMD " + dir);
readCode(250);
ArrayList list = new ArrayList();
String[] result = new String[list.size()];
list.toArray(result);
return result;
}
public long size(String fileName) throws IOException {
send("SIZE " + fileName);
readCode(250);
long size = Long.parseLong(message);
return size;
}
public void store(String fileName, InputStream in) throws IOException, SQLException {
passive();
send("STOR " + fileName);
readCode(150);
IOUtils.copyAndClose(in, outData);
readCode(226);
}
public String nameList(String dir) throws IOException, SQLException {
passive();
send("NLST " + dir);
readCode(150);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copyAndClose(inData, out);
readCode(226);
byte[] data = out.toByteArray();
return new String(data);
}
public String list(String dir) throws IOException, SQLException {
passive();
send("LIST " + dir);
readCode(150);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copyAndClose(inData, out);
readCode(226);
byte[] data = out.toByteArray();
return new String(data);
}
}
......@@ -18,19 +18,22 @@ import org.h2.test.TestBase;
public class TestFileSystem extends TestBase {
public void test() throws Exception {
testFileSystem(FileSystem.getInstance(FileSystemMemory.MEMORY_PREFIX));
testFileSystem(FileSystem.getInstance(baseDir + "/fs"));
testFileSystem(FileSystem.getInstance(FileSystemMemory.MEMORY_PREFIX_LZF));
testFileSystem(FileSystemMemory.MEMORY_PREFIX);
testFileSystem(baseDir + "/fs");
testFileSystem(FileSystemMemory.MEMORY_PREFIX_LZF);
int test;
// testFileSystem("jdbc:h2:mem:fs;TRACE_LEVEL_FILE=0/");
}
private void testFileSystem(FileSystem fs) throws Exception {
testTempFile(fs);
testRandomAccess(fs);
private void testFileSystem(String fsBase) throws Exception {
testTempFile(fsBase);
testRandomAccess(fsBase);
}
private void testRandomAccess(FileSystem fs) throws Exception {
String s = fs.createTempFile("temp", "tmp", false, false);
File file = new File(baseDir + "temp");
private void testRandomAccess(String fsBase) throws Exception {
FileSystem fs = FileSystem.getInstance(fsBase);
String s = fs.createTempFile(fsBase + "/temp", ".tmp", false, false);
File file = new File(baseDir + "/temp");
file.delete();
RandomAccessFile ra = new RandomAccessFile(file, "rw");
fs.delete(s);
......@@ -100,8 +103,9 @@ public class TestFileSystem extends TestBase {
ra.close();
}
private void testTempFile(FileSystem fs) throws Exception {
String s = fs.createTempFile("temp", "tmp", false, false);
private void testTempFile(String fsBase) throws Exception {
FileSystem fs = FileSystem.getInstance(fsBase);
String s = fs.createTempFile(fsBase + "/temp", ".tmp", false, false);
OutputStream out = fs.openFileOutputStream(s, false);
byte[] buffer = new byte[10000];
out.write(buffer);
......
package org.h2.test.unit;
import java.sql.SQLException;
import org.h2.test.TestBase;
import org.h2.tools.Server;
......@@ -11,9 +9,18 @@ public class TestFtp extends TestBase {
test(baseDir);
}
private void test(String dir) throws SQLException {
private void test(String dir) throws Exception {
Server server = Server.createFtpServer(new String[]{"-ftpDir", dir}).start();
FtpClient client = FtpClient.open("localhost:8021");
client.login("sa", "sa");
client.makeDirectory("test");
client.changeWorkingDirectory("test");
client.makeDirectory("hello");
client.changeWorkingDirectory("hello");
client.changeDirectoryUp();
client.nameList("hello");
client.removeDirectory("hello");
client.close();
server.stop();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论