提交 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:
</p><p>
<code>
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,
ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION,
UNIQUE, WHERE
FOR, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, KEY, LIKE, LIMIT, MINUS, NATURAL,
NOT, NULL, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY,
TRUE, UNION, UNIQUE, WHERE
</code>
</p><p>
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility,
......
......@@ -19,7 +19,10 @@ Change Log
<h1>Change Log</h1>
<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.
</li><li>Issue 354: when using the multi-threaded kernel option,
and multiple threads concurrently prepared SQL statements that use the same view
......
......@@ -3438,6 +3438,8 @@ public class Parser {
return getKeywordOrIdentifier(s, "IS", KEYWORD);
case 'J':
return getKeywordOrIdentifier(s, "JOIN", KEYWORD);
case 'K':
return getKeywordOrIdentifier(s, "KEY", KEYWORD);
case 'L':
if ("LIMIT".equals(s)) {
return KEYWORD;
......@@ -5010,8 +5012,17 @@ public class Parser {
command.setIndex(getSchema().findIndex(session, indexName));
}
return command;
} else if (allowIndexDefinition && (readIf("INDEX") || readIf("KEY"))) {
} else if (allowIndexDefinition && (isToken("INDEX") || isToken("KEY"))) {
// 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);
command.setComment(comment);
command.setTableName(tableName);
......
......@@ -34,6 +34,7 @@ public class TestCompatibility extends TestBase {
public void test() throws SQLException {
deleteDb("compatibility");
testKeyAsColumnInMySQLMode();
testCaseSensitiveIdentifiers();
conn = getConnection("compatibility");
......@@ -51,6 +52,14 @@ public class TestCompatibility extends TestBase {
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 {
Connection c = getConnection("compatibility;DATABASE_TO_UPPER=FALSE");
Statement stat = c.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论