提交 da10e463 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Check UniqueIndexNullsHandling in HashIndex

上级 99bb9cda
......@@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import org.h2.command.dml.AllColumnsForPlan;
import org.h2.engine.Mode.UniqueIndexNullsHandling;
import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.Row;
......@@ -58,7 +59,8 @@ public class HashIndex extends BaseIndex {
@Override
public void add(Session session, Row row) {
Value key = row.getValue(indexColumn);
if (key != ValueNull.INSTANCE) {
if (key != ValueNull.INSTANCE
|| database.getMode().uniqueIndexNullsHandling == UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES) {
Object old = rows.get(key);
if (old != null) {
// TODO index duplicate key for hash indexes: is this allowed?
......@@ -73,7 +75,8 @@ public class HashIndex extends BaseIndex {
@Override
public void remove(Session session, Row row) {
Value key = row.getValue(indexColumn);
if (key != ValueNull.INSTANCE) {
if (key != ValueNull.INSTANCE
|| database.getMode().uniqueIndexNullsHandling == UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES) {
rows.remove(key);
} else {
nullRows.remove(row.getKey());
......@@ -87,7 +90,8 @@ public class HashIndex extends BaseIndex {
throw DbException.throwInternalError(first + " " + last);
}
Value v = first.getValue(indexColumn);
if (v == ValueNull.INSTANCE) {
if (v == ValueNull.INSTANCE
&& database.getMode().uniqueIndexNullsHandling != UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES) {
return new NonUniqueHashCursor(session, tableData, nullRows);
}
/*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论