提交 5032d2b7 authored 作者: Thomas Mueller's avatar Thomas Mueller

The SCRIPT command and tool now also support the CHARSET option.

上级 b239f94c
......@@ -133,6 +133,7 @@ SCRIPT [ SIMPLE ] [ NODATA ] [ NOPASSWORDS ] [ NOSETTINGS ]
[ DROP ] [ BLOCKSIZE blockSizeInt ]
[ TO fileNameString [ COMPRESSION { DEFLATE | LZF | ZIP | GZIP } ]
[ CIPHER cipher PASSWORD string ] ]
[ CHARSET charsetString ]
","
Creates a SQL script from the database.
......
......@@ -4476,6 +4476,9 @@ public class Parser {
command.setPassword(readString().toCharArray());
}
}
if (readIf("CHARSET")) {
command.setCharset(readString());
}
}
return command;
}
......
......@@ -29,12 +29,31 @@ public class TestRunscript extends TestBase implements Trigger {
}
public void test() throws SQLException {
testEncoding();
testClobPrimaryKey();
test(false);
test(true);
deleteDb("runscript");
}
private void testEncoding() throws SQLException {
deleteDb("runscript");
Connection conn;
Statement stat;
conn = getConnection("runscript");
stat = conn.createStatement();
stat.execute("create table \"T\u00f6\"(id int)");
stat.execute("script to '"+getBaseDir()+"/backup.sql'");
stat.execute("drop all objects");
stat.execute("runscript from '"+getBaseDir()+"/backup.sql'");
stat.execute("select * from \"t\u00f6\"");
stat.execute("script to '"+getBaseDir()+"/backup.sql' charset 'UTF-8'");
stat.execute("drop all objects");
stat.execute("runscript from '"+getBaseDir()+"/backup.sql' charset 'UTF-8'");
stat.execute("select * from \"t\u00f6\"");
conn.close();
}
/**
* This method is called via reflection from the database.
*
......
......@@ -570,18 +570,21 @@ public class TestTools extends TestBase {
String fileName = getBaseDir() + "/b2.sql";
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "utils", "-quiet");
Connection conn = DriverManager.getConnection(url, user, password);
conn.createStatement().execute("CREATE TABLE \u00f6()");
conn.createStatement().execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
conn.createStatement().execute("INSERT INTO TEST VALUES(1, 'Hello')");
conn.close();
Script.main("-url", url, "-user", user, "-password", password, "-script", fileName, "-options",
"nodata", "compression", "lzf", "cipher", "xtea", "password", "'123'");
"nodata", "compression", "lzf", "cipher", "xtea", "password", "'123'", "charset", "'utf-8'");
Script.main("-url", url, "-user", user, "-password", password, "-script", fileName + ".txt");
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "utils", "-quiet");
RunScript.main("-url", url, "-user", user, "-password", password, "-script", fileName,
"-options", "compression", "lzf", "cipher", "xtea", "password", "'123'");
"-options", "compression", "lzf", "cipher", "xtea", "password", "'123'", "charset", "'utf-8'");
conn = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/utils", "sa", "abc");
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
assertFalse(rs.next());
rs = conn.createStatement().executeQuery("SELECT * FROM \u00f6");
assertFalse(rs.next());
conn.close();
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "utils", "-quiet");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论