提交 baea6316 authored 作者: Noel Grandin's avatar Noel Grandin

Issue #585: MySQL mode DELETE statements compatibility

上级 9e9e37f9
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #585: MySQL mode DELETE statements compatibility
</li>
<li>Issue #569: ClassCastException when filtering on ENUM value in WHERE clause
</li>
<li>Issue #539: Allow override of builtin functions/aliases
......
......@@ -92,6 +92,7 @@ import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.DbObject;
import org.h2.engine.FunctionAlias;
import org.h2.engine.Mode;
import org.h2.engine.Procedure;
import org.h2.engine.Right;
import org.h2.engine.Session;
......@@ -818,7 +819,10 @@ public class Parser {
}
currentPrepared = command;
int start = lastParseIndex;
readIf("FROM");
if (!readIf("FROM") && database.getMode() == Mode.MYSQL) {
readIdentifierWithSchema();
read("FROM");
}
TableFilter filter = readSimpleTableFilter(0);
command.setTableFilter(filter);
if (readIf("WHERE")) {
......
......@@ -9,7 +9,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Set;
import java.util.regex.Pattern;
import org.h2.util.New;
import org.h2.util.StringUtils;
......@@ -25,6 +24,7 @@ public class Mode {
static final String REGULAR = "REGULAR";
private static final HashMap<String, Mode> MODES = New.hashMap();
public static final Mode MYSQL;
// Modes are also documented in the features section
......@@ -236,7 +236,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null;
add(mode);
mode = new Mode("MySQL");
MYSQL = mode = new Mode("MySQL");
mode.convertInsertNullToZero = true;
mode.indexDefinitionInCreateTable = true;
mode.lowerCaseIdentifiers = true;
......
......@@ -292,6 +292,7 @@ public class TestCompatibility extends TestBase {
private void testMySQL() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("set mode mysql");
stat.execute("create schema test_schema");
stat.execute("use test_schema");
assertResult("TEST_SCHEMA", stat, "select schema()");
......@@ -312,6 +313,10 @@ public class TestCompatibility extends TestBase {
"SELECT FROM_UNIXTIME(1196300000, '%Y %M')");
assertResult("2003-12-31", stat,
"SELECT DATE('2003-12-31 11:02:03')");
assertResult("2003-12-31", stat,
"SELECT DATE('2003-12-31 11:02:03')");
// check the weird MySQL variant of DELETE
stat.execute("DELETE TEST FROM TEST WHERE 1=2");
if (config.memory) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论