提交 94e77f22 authored 作者: perhuss's avatar perhuss

Issue #694: Support for Oracle style parenthesised column modification:

ALTER TABLE foo MODIFY (bar VARCHAR2(255) NOT NULL)
上级 043fd8e9
......@@ -6143,6 +6143,7 @@ public class Parser {
} else if (readIf("MODIFY")) {
// MySQL compatibility
readIf("COLUMN"); // optional
boolean hasOpeningBracket = readIf("("); // Oracle specifies (but will not require) an opening parenthesis
String columnName = readColumnIdentifier();
AlterTableAlterColumn command = null;
NullConstraintType nullConstraint = parseNotNullConstraint();
......@@ -6167,6 +6168,9 @@ public class Parser {
throw DbException.get(ErrorCode.UNKNOWN_MODE_1,
"Internal Error - unhandled case: " + nullConstraint.name());
}
if(hasOpeningBracket) {
read(")");
}
return command;
} else if (readIf("ALTER")) {
readIf("COLUMN");
......
......@@ -52,6 +52,7 @@ public class TestAlter extends TestBase {
testAlterTableAddMultipleColumnsAfter();
testAlterTableModifyColumn();
testAlterTableModifyColumnSetNull();
testAlterTableModifyColumnNotNullOracle();
conn.close();
deleteDb(getTestName());
}
......@@ -317,4 +318,16 @@ public class TestAlter extends TestBase {
stat.execute("insert into T values(null)"); // <- Fixed in v1.4.196 - NULL is allowed
stat.execute("drop table T");
}
private void testAlterTableModifyColumnNotNullOracle() throws SQLException {
stat.execute("create table foo (bar varchar(255))");
stat.execute("alter table foo modify (bar varchar(255) not null)");
try {
stat.execute("insert into foo values(null)");
fail("Null should not be allowed after modification.");
}
catch(SQLException e) {
// This is what we expect, fails to insert null.
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论