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

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

上级 16f2bc37
...@@ -63,6 +63,7 @@ Change Log ...@@ -63,6 +63,7 @@ Change Log
</li><li>Issue 490: support MySQL "USING BTREE" index declaration </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 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 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> </li></ul>
<h2>Version 1.3.172 (2013-05-25)</h2> <h2>Version 1.3.172 (2013-05-25)</h2>
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
package org.h2.table; package org.h2.table;
import java.util.ArrayList;
import java.util.List;
import org.h2.command.ddl.CreateTableData; import org.h2.command.ddl.CreateTableData;
import org.h2.constant.DbSettings; import org.h2.constant.DbSettings;
import org.h2.mvstore.db.MVTableEngine; import org.h2.mvstore.db.MVTableEngine;
...@@ -24,6 +26,8 @@ public abstract class TableBase extends Table { ...@@ -24,6 +26,8 @@ public abstract class TableBase extends Table {
* The table engine used (null for regular tables). * The table engine used (null for regular tables).
*/ */
private final String tableEngine; private final String tableEngine;
/** Provided table parameters */
private List<String> tableEngineParams = new ArrayList<String>();
private final boolean globalTemporary; private final boolean globalTemporary;
...@@ -31,6 +35,9 @@ public abstract class TableBase extends Table { ...@@ -31,6 +35,9 @@ public abstract class TableBase extends Table {
super(data.schema, data.id, data.tableName, data.persistIndexes, data.persistData); super(data.schema, data.id, data.tableName, data.persistIndexes, data.persistData);
this.tableEngine = data.tableEngine; this.tableEngine = data.tableEngine;
this.globalTemporary = data.globalTemporary; this.globalTemporary = data.globalTemporary;
if(data.tableEngineParams != null) {
this.tableEngineParams = data.tableEngineParams;
}
setTemporary(data.temporary); setTemporary(data.temporary);
Column[] cols = new Column[data.columns.size()]; Column[] cols = new Column[data.columns.size()];
data.columns.toArray(cols); data.columns.toArray(cols);
...@@ -83,6 +90,14 @@ public abstract class TableBase extends Table { ...@@ -83,6 +90,14 @@ public abstract class TableBase extends Table {
buff.append('\"'); buff.append('\"');
} }
} }
if(!tableEngineParams.isEmpty()) {
buff.append("\nWITH ");
buff.resetCount();
for (String parameter : tableEngineParams) {
buff.appendExceptFirst(", ");
buff.append("\""+parameter+"\"");
}
}
if (!isPersistIndexes() && !isPersistData()) { if (!isPersistIndexes() && !isPersistData()) {
buff.append("\nNOT PERSISTENT"); buff.append("\nNOT PERSISTENT");
} }
......
...@@ -82,6 +82,13 @@ public class TestTableEngines extends TestBase { ...@@ -82,6 +82,13 @@ public class TestTableEngines extends TestBase {
assertEquals("param1", EndlessTableEngine.createTableData.tableEngineParams.get(0)); assertEquals("param1", EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2", EndlessTableEngine.createTableData.tableEngineParams.get(1)); assertEquals("param2", EndlessTableEngine.createTableData.tableEngineParams.get(1));
conn.close(); 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"); deleteDb("tableEngine");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论