提交 333a5027 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #436 from alexpaschenko/h2-434

Issue #434 - parse engine params in CREATE TABLE w/o engine specified
......@@ -613,7 +613,8 @@ CREATE SEQUENCE SEQ_ID
CREATE [ CACHED | MEMORY ] [ TEMP | [ GLOBAL | LOCAL ] TEMPORARY ]
TABLE [ IF NOT EXISTS ] name
[ ( { columnDefinition | constraint } [,...] ) ]
[ ENGINE tableEngineName [ WITH tableEngineParamName [,...] ] ]
[ ENGINE tableEngineName ]
[ WITH tableEngineParamName [,...] ]
[ NOT PERSISTENT ] [ TRANSACTIONAL ]
[ AS select ]","
Creates a new table.
......@@ -635,6 +636,9 @@ The ENGINE option is only required when custom table implementations are used.
The table engine class must implement the interface ""org.h2.api.TableEngine"".
Any table engine parameters are passed down in the tableEngineParams field of the CreateTableData object.
Either ENGINE, or WITH (table engine params), or both may be specified. If ENGINE is not specified
in CREATE TABLE, then the engine specified by DEFAULT_TABLE_ENGINE option of database params is used.
Tables with the NOT PERSISTENT modifier are kept fully in memory, and all
rows are lost when the database is closed.
......
......@@ -6124,6 +6124,8 @@ public class Parser {
}
} else {
command.setTableEngine(readUniqueIdentifier());
}
}
if (readIf("WITH")) {
ArrayList<String> tableEngineParams = New.arrayList();
do {
......@@ -6131,8 +6133,6 @@ public class Parser {
} while (readIf(","));
command.setTableEngineParams(tableEngineParams);
}
}
}
// MySQL compatibility
if (readIf("AUTO_INCREMENT")) {
read("=");
......
......@@ -104,6 +104,13 @@ public class TestTableEngines extends TestBase {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE t1(id int, name varchar) ENGINE \"" +
EndlessTableEngine.class.getName() + "\" WITH \"param1\", \"param2\"");
assertEquals(2,
EndlessTableEngine.createTableData.tableEngineParams.size());
assertEquals("param1",
EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2",
EndlessTableEngine.createTableData.tableEngineParams.get(1));
stat.execute("CREATE TABLE t2(id int, name varchar) WITH \"param1\", \"param2\"");
assertEquals(2,
EndlessTableEngine.createTableData.tableEngineParams.size());
assertEquals("param1",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论