提交 c7f8a6bf authored 作者: Thomas Mueller's avatar Thomas Mueller

DatabaseMetaData.getPrimaryKeys: the wrong constraint name was reported if there…

DatabaseMetaData.getPrimaryKeys: the wrong constraint name was reported if there was another constraint on the same table and columns.
上级 1b19a060
......@@ -733,7 +733,13 @@ public class MetaTable extends Table {
for (int k = 0; constraints != null && k < constraints.size(); k++) {
Constraint constraint = constraints.get(k);
if (constraint.getUniqueIndex() == index) {
constraintName = constraint.getName();
if (index.getIndexType().isPrimaryKey()) {
if (constraint.getConstraintType().equals(Constraint.PRIMARY_KEY)) {
constraintName = constraint.getName();
}
} else {
constraintName = constraint.getName();
}
}
}
IndexColumn[] cols = index.getIndexColumns();
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(id int, constraint pk primary key(id), constraint x unique(id));
> ok
select constraint_name from information_schema.indexes where table_name = 'TEST';
> CONSTRAINT_NAME
> ---------------
> PK
> rows: 1
drop table test;
> ok
create table test(id int, name varchar);
> ok
alter table test alter column id identity;
> ok
drop table test;
> ok
create table test(id int primary key, name varchar);
> ok
alter table test alter column id int auto_increment;
> ok
drop table test;
> ok
create table test(id identity) as select x from system_range(1, 4);
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论