提交 9ed3dbeb authored 作者: Thomas Mueller's avatar Thomas Mueller

The wrong exception was thrown when trying to reference a table that doesn't…

The wrong exception was thrown when trying to reference a table that doesn't support references such as a tables in the information schema.
上级 f35d1435
......@@ -190,6 +190,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
case REFERENTIAL: {
Table refTable = refSchema.getTableOrView(session, refTableName);
session.getUser().checkRight(refTable, Right.ALL);
if (!refTable.canReference()) {
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, "Reference " + refTable.getSQL());
}
boolean isOwner = false;
IndexColumn.mapColumns(indexColumns, table);
if (index != null && canUseIndex(index, table, indexColumns)) {
......
......@@ -199,4 +199,8 @@ public class FunctionTable extends Table {
return function.isDeterministic();
}
public boolean canReference() {
return false;
}
}
......@@ -1736,12 +1736,12 @@ public class MetaTable extends Table {
}
public ArrayList<Index> getIndexes() {
ArrayList<Index> list = New.arrayList();
if (metaIndex == null) {
return null;
return list;
}
ArrayList<Index>list = New.arrayList();
list.add(new MetaIndex(this, IndexColumn.wrap(columns), true));
// TODO fixed scan index
// TODO re-use the index
list.add(metaIndex);
return list;
}
......@@ -1772,4 +1772,8 @@ public class MetaTable extends Table {
return true;
}
public boolean canReference() {
return false;
}
}
......@@ -168,4 +168,8 @@ public class RangeTable extends Table {
return true;
}
public boolean canReference() {
return false;
}
}
......@@ -255,6 +255,15 @@ public abstract class Table extends SchemaObjectBase {
*/
public abstract boolean canGetRowCount();
/**
* Check if this table can be referenced.
*
* @return true if it can
*/
public boolean canReference() {
return true;
}
/**
* Check if this table can be dropped.
*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论