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

The SCRIPT statements now supports filtering by schema and table.

上级 5c36fb7d
...@@ -145,8 +145,8 @@ RUNSCRIPT FROM 'backup.sql' ...@@ -145,8 +145,8 @@ RUNSCRIPT FROM 'backup.sql'
SCRIPT [ SIMPLE ] [ NODATA ] [ NOPASSWORDS ] [ NOSETTINGS ] SCRIPT [ SIMPLE ] [ NODATA ] [ NOPASSWORDS ] [ NOSETTINGS ]
[ DROP ] [ BLOCKSIZE blockSizeInt ] [ DROP ] [ BLOCKSIZE blockSizeInt ]
[ TO fileNameString [ scriptCompression ] [ TO fileNameString [ scriptCompression ]
[ CIPHER cipher PASSWORD string ] ] [ CIPHER cipher PASSWORD string ]
[ CHARSET charsetString ] [ CHARSET charsetString ] ]
[ TABLE tableName [, ...] ] [ TABLE tableName [, ...] ]
[ SCHEMA schemaName [, ...] ] [ SCHEMA schemaName [, ...] ]
"," ","
......
...@@ -4689,19 +4689,6 @@ public class Parser { ...@@ -4689,19 +4689,6 @@ public class Parser {
private ScriptCommand parseScript() { private ScriptCommand parseScript() {
ScriptCommand command = new ScriptCommand(session); ScriptCommand command = new ScriptCommand(session);
boolean data = true, passwords = true, settings = true, dropTables = false, simple = false; boolean data = true, passwords = true, settings = true, dropTables = false, simple = false;
if (readIf("SCHEMA")) {
HashSet<String> schemaNames = New.hashSet();
do {
schemaNames.add(readUniqueIdentifier());
} while (readIf(","));
command.setSchemaNames(schemaNames);
} else if (readIf("TABLE")) {
ArrayList<Table> tables = New.arrayList();
do {
tables.add(readTableOrView());
} while (readIf(","));
command.setTables(tables);
}
if (readIf("SIMPLE")) { if (readIf("SIMPLE")) {
simple = true; simple = true;
} }
...@@ -4741,6 +4728,19 @@ public class Parser { ...@@ -4741,6 +4728,19 @@ public class Parser {
command.setCharset(readString()); command.setCharset(readString());
} }
} }
if (readIf("SCHEMA")) {
HashSet<String> schemaNames = New.hashSet();
do {
schemaNames.add(readUniqueIdentifier());
} while (readIf(","));
command.setSchemaNames(schemaNames);
} else if (readIf("TABLE")) {
ArrayList<Table> tables = New.arrayList();
do {
tables.add(readTableOrView());
} while (readIf(","));
command.setTables(tables);
}
return command; return command;
} }
......
...@@ -94,7 +94,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -94,7 +94,7 @@ public class TestRunscript extends TestBase implements Trigger {
} }
rs.close(); rs.close();
stat.execute("create schema include_schema2"); stat.execute("create schema include_schema2");
stat.execute("script schema include_schema1, include_schema2"); stat.execute("script nosettings schema include_schema1, include_schema2");
rs = stat.getResultSet(); rs = stat.getResultSet();
// user and one row per schema = 3 // user and one row per schema = 3
assertResultRowCount(3, rs); assertResultRowCount(3, rs);
...@@ -137,7 +137,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -137,7 +137,7 @@ public class TestRunscript extends TestBase implements Trigger {
assertTrue("The table 'b.test2' should not be present in the script", assertTrue("The table 'b.test2' should not be present in the script",
rs.getString(1).indexOf("b.test2".toUpperCase()) == -1); rs.getString(1).indexOf("b.test2".toUpperCase()) == -1);
} }
stat.execute("script table a.test1, test2"); stat.execute("script nosettings table a.test1, test2");
rs = stat.getResultSet(); rs = stat.getResultSet();
// user, schemas 'a' & 'b' and 2 rows per table = 7 // user, schemas 'a' & 'b' and 2 rows per table = 7
assertResultRowCount(7, rs); assertResultRowCount(7, rs);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论