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

Issue #585: MySQL mode DELETE statements compatibility

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