提交 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'
SCRIPT [ SIMPLE ] [ NODATA ] [ NOPASSWORDS ] [ NOSETTINGS ]
[ DROP ] [ BLOCKSIZE blockSizeInt ]
[ TO fileNameString [ scriptCompression ]
[ CIPHER cipher PASSWORD string ] ]
[ CHARSET charsetString ]
[ CIPHER cipher PASSWORD string ]
[ CHARSET charsetString ] ]
[ TABLE tableName [, ...] ]
[ SCHEMA schemaName [, ...] ]
","
......
......@@ -4689,19 +4689,6 @@ public class Parser {
private ScriptCommand parseScript() {
ScriptCommand command = new ScriptCommand(session);
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")) {
simple = true;
}
......@@ -4741,6 +4728,19 @@ public class Parser {
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;
}
......
......@@ -94,7 +94,7 @@ public class TestRunscript extends TestBase implements Trigger {
}
rs.close();
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();
// user and one row per schema = 3
assertResultRowCount(3, rs);
......@@ -137,7 +137,7 @@ public class TestRunscript extends TestBase implements Trigger {
assertTrue("The table 'b.test2' should not be present in the script",
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();
// user, schemas 'a' & 'b' and 2 rows per table = 7
assertResultRowCount(7, rs);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论