提交 51cba201 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 351: MySQL mode: can not create a table with the column "KEY", and can not…

Issue 351: MySQL mode: can not create a table with the column "KEY", and can not open databases where such a table already exists. (KEY is now a keyword.)
上级 469c5639
...@@ -454,9 +454,9 @@ unless they are quoted (surrounded with double quotes). The list is currently: ...@@ -454,9 +454,9 @@ unless they are quoted (surrounded with double quotes). The list is currently:
</p><p> </p><p>
<code> <code>
CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT, EXISTS, FALSE, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT, EXISTS, FALSE,
FOR, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, LIKE, LIMIT, MINUS, NATURAL, NOT, NULL, FOR, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, KEY, LIKE, LIMIT, MINUS, NATURAL,
ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION, NOT, NULL, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY,
UNIQUE, WHERE TRUE, UNION, UNIQUE, WHERE
</code> </code>
</p><p> </p><p>
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility, Certain words of this list are keywords because they are functions that can be used without '()' for compatibility,
......
...@@ -19,7 +19,10 @@ Change Log ...@@ -19,7 +19,10 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>TCP server: when using the trace option ("-trace"), the trace output contained <ul><li>Issue 351: MySQL mode: can not create a table with the column "KEY",
and can not open databases where such a table already exists.
(KEY is now a keyword.)
</li><li>TCP server: when using the trace option ("-trace"), the trace output contained
unnecessary stack traces when stopping the server. unnecessary stack traces when stopping the server.
</li><li>Issue 354: when using the multi-threaded kernel option, </li><li>Issue 354: when using the multi-threaded kernel option,
and multiple threads concurrently prepared SQL statements that use the same view and multiple threads concurrently prepared SQL statements that use the same view
......
...@@ -3438,6 +3438,8 @@ public class Parser { ...@@ -3438,6 +3438,8 @@ public class Parser {
return getKeywordOrIdentifier(s, "IS", KEYWORD); return getKeywordOrIdentifier(s, "IS", KEYWORD);
case 'J': case 'J':
return getKeywordOrIdentifier(s, "JOIN", KEYWORD); return getKeywordOrIdentifier(s, "JOIN", KEYWORD);
case 'K':
return getKeywordOrIdentifier(s, "KEY", KEYWORD);
case 'L': case 'L':
if ("LIMIT".equals(s)) { if ("LIMIT".equals(s)) {
return KEYWORD; return KEYWORD;
...@@ -5010,8 +5012,17 @@ public class Parser { ...@@ -5010,8 +5012,17 @@ public class Parser {
command.setIndex(getSchema().findIndex(session, indexName)); command.setIndex(getSchema().findIndex(session, indexName));
} }
return command; return command;
} else if (allowIndexDefinition && (readIf("INDEX") || readIf("KEY"))) { } else if (allowIndexDefinition && (isToken("INDEX") || isToken("KEY"))) {
// MySQL // MySQL
// need to read ahead, as it could be a column name
int start = lastParseIndex;
read();
if (DataType.getTypeByName(currentToken) != null) {
// known data type
parseIndex = start;
read();
return null;
}
CreateIndex command = new CreateIndex(session, schema); CreateIndex command = new CreateIndex(session, schema);
command.setComment(comment); command.setComment(comment);
command.setTableName(tableName); command.setTableName(tableName);
......
...@@ -34,6 +34,7 @@ public class TestCompatibility extends TestBase { ...@@ -34,6 +34,7 @@ public class TestCompatibility extends TestBase {
public void test() throws SQLException { public void test() throws SQLException {
deleteDb("compatibility"); deleteDb("compatibility");
testKeyAsColumnInMySQLMode();
testCaseSensitiveIdentifiers(); testCaseSensitiveIdentifiers();
conn = getConnection("compatibility"); conn = getConnection("compatibility");
...@@ -51,6 +52,14 @@ public class TestCompatibility extends TestBase { ...@@ -51,6 +52,14 @@ public class TestCompatibility extends TestBase {
deleteDb("compatibility"); deleteDb("compatibility");
} }
private void testKeyAsColumnInMySQLMode() throws SQLException {
Connection c = getConnection("compatibility;MODE=MYSQL");
Statement stat = c.createStatement();
stat.execute("create table test(id int primary key, key varchar)");
stat.execute("drop table test");
c.close();
}
private void testCaseSensitiveIdentifiers() throws SQLException { private void testCaseSensitiveIdentifiers() throws SQLException {
Connection c = getConnection("compatibility;DATABASE_TO_UPPER=FALSE"); Connection c = getConnection("compatibility;DATABASE_TO_UPPER=FALSE");
Statement stat = c.createStatement(); Statement stat = c.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论