提交 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 ...@@ -613,7 +613,8 @@ CREATE SEQUENCE SEQ_ID
CREATE [ CACHED | MEMORY ] [ TEMP | [ GLOBAL | LOCAL ] TEMPORARY ] CREATE [ CACHED | MEMORY ] [ TEMP | [ GLOBAL | LOCAL ] TEMPORARY ]
TABLE [ IF NOT EXISTS ] name TABLE [ IF NOT EXISTS ] name
[ ( { columnDefinition | constraint } [,...] ) ] [ ( { columnDefinition | constraint } [,...] ) ]
[ ENGINE tableEngineName [ WITH tableEngineParamName [,...] ] ] [ ENGINE tableEngineName ]
[ WITH tableEngineParamName [,...] ]
[ NOT PERSISTENT ] [ TRANSACTIONAL ] [ NOT PERSISTENT ] [ TRANSACTIONAL ]
[ AS select ]"," [ AS select ]","
Creates a new table. Creates a new table.
...@@ -635,6 +636,9 @@ The ENGINE option is only required when custom table implementations are used. ...@@ -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"". 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. 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 Tables with the NOT PERSISTENT modifier are kept fully in memory, and all
rows are lost when the database is closed. rows are lost when the database is closed.
......
...@@ -6124,15 +6124,15 @@ public class Parser { ...@@ -6124,15 +6124,15 @@ public class Parser {
} }
} else { } else {
command.setTableEngine(readUniqueIdentifier()); command.setTableEngine(readUniqueIdentifier());
if (readIf("WITH")) {
ArrayList<String> tableEngineParams = New.arrayList();
do {
tableEngineParams.add(readUniqueIdentifier());
} while (readIf(","));
command.setTableEngineParams(tableEngineParams);
}
} }
} }
if (readIf("WITH")) {
ArrayList<String> tableEngineParams = New.arrayList();
do {
tableEngineParams.add(readUniqueIdentifier());
} while (readIf(","));
command.setTableEngineParams(tableEngineParams);
}
// MySQL compatibility // MySQL compatibility
if (readIf("AUTO_INCREMENT")) { if (readIf("AUTO_INCREMENT")) {
read("="); read("=");
......
...@@ -110,6 +110,13 @@ public class TestTableEngines extends TestBase { ...@@ -110,6 +110,13 @@ public class TestTableEngines extends TestBase {
EndlessTableEngine.createTableData.tableEngineParams.get(0)); EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2", assertEquals("param2",
EndlessTableEngine.createTableData.tableEngineParams.get(1)); 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",
EndlessTableEngine.createTableData.tableEngineParams.get(0));
assertEquals("param2",
EndlessTableEngine.createTableData.tableEngineParams.get(1));
conn.close(); conn.close();
if (!config.memory) { if (!config.memory) {
// Test serialization of table parameters // Test serialization of table parameters
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论