提交 aa3e00d3 authored 作者: noelgrandin's avatar noelgrandin

Issue 501: "CREATE TABLE .. WITH" not serialized, patch from nico.devel

上级 16f2bc37
......@@ -63,6 +63,7 @@ Change Log
</li><li>Issue 490: support MySQL "USING BTREE" index declaration
</li><li>Issue 485: Database get corrupted when column is renamed for which check constraint was defined inside create table statement.
</li><li>Issue 499: support MySQL "UNIQUE KEY (ID) USING BTREE" constraint syntax
</li><li>Issue 501: "CREATE TABLE .. WITH" not serialized, patch from nico.devel
</li></ul>
<h2>Version 1.3.172 (2013-05-25)</h2>
......
......@@ -6,6 +6,8 @@
*/
package org.h2.table;
import java.util.ArrayList;
import java.util.List;
import org.h2.command.ddl.CreateTableData;
import org.h2.constant.DbSettings;
import org.h2.mvstore.db.MVTableEngine;
......@@ -24,13 +26,18 @@ public abstract class TableBase extends Table {
* The table engine used (null for regular tables).
*/
private final String tableEngine;
/** Provided table parameters */
private List<String> tableEngineParams = new ArrayList<String>();
private final boolean globalTemporary;
public TableBase(CreateTableData data) {
super(data.schema, data.id, data.tableName, data.persistIndexes, data.persistData);
this.tableEngine = data.tableEngine;
this.globalTemporary = data.globalTemporary;
if(data.tableEngineParams != null) {
this.tableEngineParams = data.tableEngineParams;
}
setTemporary(data.temporary);
Column[] cols = new Column[data.columns.size()];
data.columns.toArray(cols);
......@@ -83,6 +90,14 @@ public abstract class TableBase extends Table {
buff.append('\"');
}
}
if(!tableEngineParams.isEmpty()) {
buff.append("\nWITH ");
buff.resetCount();
for (String parameter : tableEngineParams) {
buff.appendExceptFirst(", ");
buff.append("\""+parameter+"\"");
}
}
if (!isPersistIndexes() && !isPersistData()) {
buff.append("\nNOT PERSISTENT");
}
......
......@@ -82,6 +82,13 @@ public class TestTableEngines extends TestBase {
assertEquals("param1", EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2", EndlessTableEngine.createTableData.tableEngineParams.get(1));
conn.close();
// Test serialisation of table parameters
EndlessTableEngine.createTableData.tableEngineParams.clear();
conn = getConnection("tableEngine");
assertEquals(2, EndlessTableEngine.createTableData.tableEngineParams.size());
assertEquals("param1", EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2", EndlessTableEngine.createTableData.tableEngineParams.get(1));
conn.close();
deleteDb("tableEngine");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论