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

The SCRIPT statements now supports filtering by schema and table.

上级 6edfc680
......@@ -172,9 +172,7 @@ The password must be in single quotes; it is case sensitive and can contain spac
This command locks objects while it is running.
TABLE will dump the DDL only for the selected table.
SCHEMA will dump the DDL only for objects in the selected schema.
When using the TABLE or SCHEMA option, only the selected table(s) / schema(s) are included.
","
SCRIPT NODATA
"
......
......@@ -42,7 +42,7 @@ Change Log
</li><li>TRUNC was added as an alias for TRUNCATE.
</li><li>Small optimisation for accessing result values by column name.
</li><li>Fix for bug in Statement#getMoreResults(int)
</li><li>Jacob Qvortrup <jfq@arosii.dk> added SCRIPT TABLE and SCRIPT SCHEMA extensions(int)
</li><li>The SCRIPT statements now supports filtering by schema and table. Thanks a lot to Jacob Qvortrup for providing the patch!
</li></ul>
<h2>Version 1.3.166 (2012-04-08)</h2>
......
......@@ -10,7 +10,6 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import org.h2.api.Trigger;
import org.h2.command.ddl.AlterIndexRename;
......@@ -4691,16 +4690,15 @@ public class Parser {
ScriptCommand command = new ScriptCommand(session);
boolean data = true, passwords = true, settings = true, dropTables = false, simple = false;
if (readIf("SCHEMA")) {
java.util.Set<String> schemaNames = new HashSet<String>();
HashSet<String> schemaNames = New.hashSet();
do {
schemaNames.add(readUniqueIdentifier());
} while (readIf(","));
command.setSchemaNames(schemaNames);
} else if (readIf("TABLE")) {
Collection<Table> tables = new ArrayList<Table>();
ArrayList<Table> tables = New.arrayList();
do {
Table table = readTableOrView();
tables.add(table);
tables.add(readTableOrView());
} while (readIf(","));
command.setTables(tables);
}
......
......@@ -616,25 +616,11 @@ public class ScriptCommand extends ScriptBase {
}
private boolean excludeSchema(Schema schema) {
if (this.schemaNames != null && !this.schemaNames.contains(schema.getName())) {
return true;
}
if (this.tables != null) {
boolean containsTable = false;
for (Table table : schema.getAllTablesAndViews()) {
if (tables.contains(table)) {
table.checkSupportAlter(); // This may not be the correct way to ensure that only real tables can be used as arguments.
containsTable = true;
}
}
if (!containsTable)
return true;
}
return false;
return schemaNames != null && !schemaNames.contains(schema.getName());
}
private boolean excludeTable(Table table) {
return this.tables != null && !this.tables.contains(table);
return tables != null && !tables.contains(table);
}
private void add(String s, boolean insert) throws IOException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论