Unverified 提交 61eee27c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1260 from katzyn/ddl

Fix MySQL compatibility ALTER TABLE DROP INDEX with schema
...@@ -6093,7 +6093,7 @@ public class Parser { ...@@ -6093,7 +6093,7 @@ public class Parser {
return commandIfTableExists(schema, tableName, ifTableExists, command); return commandIfTableExists(schema, tableName, ifTableExists, command);
} else if (readIf("INDEX")) { } else if (readIf("INDEX")) {
// MySQL compatibility // MySQL compatibility
String indexOrConstraintName = readIdentifierWithSchema(); String indexOrConstraintName = readIdentifierWithSchema(schema.getName());
final SchemaCommand command; final SchemaCommand command;
if (schema.findIndex(session, indexOrConstraintName) != null) { if (schema.findIndex(session, indexOrConstraintName) != null) {
DropIndex dropIndexCommand = new DropIndex(session, getSchema()); DropIndex dropIndexCommand = new DropIndex(session, getSchema());
......
...@@ -124,7 +124,7 @@ public class TestScript extends TestDb { ...@@ -124,7 +124,7 @@ public class TestScript extends TestDb {
} }
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn", for (String s : new String[] { "alterTableAdd", "alterTableDropColumn",
"createAlias", "createSynonym", "createView", "createTable", "createTrigger", "createAlias", "createSynonym", "createView", "createTable", "createTrigger",
"dropSchema", "truncateTable" }) { "dropIndex", "dropSchema", "truncateTable" }) {
testScript("ddl/" + s + ".sql"); testScript("ddl/" + s + ".sql");
} }
for (String s : new String[] { "error_reporting", "insertIgnore", for (String s : new String[] { "error_reporting", "insertIgnore",
......
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE SCHEMA TEST;
> ok
CREATE TABLE TEST.TBL (
NAME VARCHAR
);
> ok
CREATE UNIQUE INDEX NAME_INDEX ON TEST.TBL(NAME);
> ok
-- MySQL compatibility syntax
ALTER TABLE TEST.TBL DROP INDEX NAME_INDEX;
> ok
CREATE UNIQUE INDEX NAME_INDEX ON TEST.TBL(NAME);
> ok
-- MySQL compatibility syntax
ALTER TABLE TEST.TBL DROP INDEX TEST.NAME_INDEX;
> ok
ALTER TABLE TEST.TBL ADD CONSTRAINT NAME_INDEX UNIQUE (NAME);
> ok
-- MySQL compatibility syntax
ALTER TABLE TEST.TBL DROP INDEX NAME_INDEX;
> ok
ALTER TABLE TEST.TBL ADD CONSTRAINT NAME_INDEX UNIQUE (NAME);
> ok
-- MySQL compatibility syntax
ALTER TABLE TEST.TBL DROP INDEX TEST.NAME_INDEX;
> ok
DROP SCHEMA TEST CASCADE;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论