提交 421cc9fc authored 作者: Thomas Mueller's avatar Thomas Mueller

Creating a comment on a column didn't work if the schema name was equal the database name.

上级 f86ebb5c
......@@ -1086,18 +1086,34 @@ public class Parser {
throw getSyntaxError();
}
SetComment command = new SetComment(session);
String objectName = readIdentifierWithSchema();
String objectName;
if (column) {
String columnName = objectName;
objectName = schemaName;
// can't use readIdentifierWithSchema() because
// it wouldn't read schema.table.column correctly
// if the db name is equal to the schema name
ArrayList<String> list = New.arrayList();
do {
list.add(readUniqueIdentifier());
} while (readIf("."));
schemaName = session.getCurrentSchemaName();
if (readIf(".")) {
schemaName = objectName;
objectName = columnName;
columnName = readUniqueIdentifier();
if (list.size() == 4) {
if (!equalsToken(database.getShortName(), list.get(0))) {
throw DbException.getSyntaxError(sqlCommand, parseIndex, "database name");
}
list.remove(0);
}
if (list.size() == 3) {
schemaName = list.get(0);
list.remove(0);
}
if (list.size() != 2) {
throw DbException.getSyntaxError(sqlCommand, parseIndex, "table.column");
}
objectName = list.get(0);
command.setColumn(true);
command.setColumnName(columnName);
command.setColumnName(list.get(1));
} else {
objectName = readIdentifierWithSchema();
}
command.setSchemaName(schemaName);
command.setObjectName(objectName);
......
......@@ -37,6 +37,7 @@ public class TestCases extends TestBase {
public void test() throws Exception {
testOuterJoin();
testCommentOnColumnWithSchemaEqualDatabase();
testColumnWithConstraintAndComment();
testTruncateConstraintsDisabled();
testPreparedSubquery2();
......@@ -109,6 +110,17 @@ public class TestCases extends TestBase {
conn.close();
}
private void testCommentOnColumnWithSchemaEqualDatabase() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("create schema cases");
stat.execute("create table cases.cases(cases int)");
stat.execute("comment on column cases.cases.cases is 'schema.table.column'");
stat.execute("comment on column cases.cases.cases.cases is 'db.schema.table.column'");
conn.close();
}
private void testColumnWithConstraintAndComment() throws SQLException {
if (config.memory) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论