Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
859576ee
提交
859576ee
authored
1月 18, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add enum UniqueIndexNullsHandling and fix a typo
上级
cd69a288
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
29 行删除
+35
-29
Mode.java
h2/src/main/org/h2/engine/Mode.java
+30
-13
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+5
-16
没有找到文件。
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
859576ee
...
@@ -22,6 +22,29 @@ public class Mode {
...
@@ -22,6 +22,29 @@ public class Mode {
REGULAR
,
DB2
,
Derby
,
MSSQLServer
,
HSQLDB
,
MySQL
,
Oracle
,
PostgreSQL
,
Ignite
,
REGULAR
,
DB2
,
Derby
,
MSSQLServer
,
HSQLDB
,
MySQL
,
Oracle
,
PostgreSQL
,
Ignite
,
}
}
/**
* Determines how rows with {@code NULL} values in indexed columns are handled
* in unique indexes.
*/
public
enum
UniqueIndexNullsHandling
{
/**
* Multiple identical indexed columns with at least one {@code NULL} value are
* allowed in unique index.
*/
ALLOW_DUPLICATES_WITH_ANY_NULL
,
/**
* Multiple identical indexed columns with all {@code NULL} values are allowed
* in unique index.
*/
ALLOW_DUPLICATES_WITH_ALL_NULLS
,
/**
* Multiple identical indexed columns are not allowed in unique index.
*/
FORBID_ANY_DUPLICATES
;
}
private
static
final
HashMap
<
String
,
Mode
>
MODES
=
New
.
hashMap
();
private
static
final
HashMap
<
String
,
Mode
>
MODES
=
New
.
hashMap
();
// Modes are also documented in the features section
// Modes are also documented in the features section
...
@@ -87,16 +110,10 @@ public class Mode {
...
@@ -87,16 +110,10 @@ public class Mode {
public
boolean
systemColumns
;
public
boolean
systemColumns
;
/**
/**
* <ul>
* Determines how rows with {@code NULL} values in indexed columns are handled
* <li>If {@code 0}, multiple identical indexed columns with at least one
* in unique indexes.
* {@code NULL} value are allowed in unique index.</li>
* <li>If {@code 1}, multiple identical indexed columns with all {@code NULL}
* values are allowed in unique index.</li>
* <li>If {@code 2}, multiple identical indexed columns are not allowed in
* unique index.</li>
* </ul>
*/
*/
public
byte
uniquieIndexNullsHandling
;
public
UniqueIndexNullsHandling
uniqueIndexNullsHandling
=
UniqueIndexNullsHandling
.
ALLOW_DUPLICATES_WITH_ANY_NULL
;
/**
/**
* Empty strings are treated like NULL values. Useful for Oracle emulation.
* Empty strings are treated like NULL values. Useful for Oracle emulation.
...
@@ -207,7 +224,7 @@ public class Mode {
...
@@ -207,7 +224,7 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
Derby
.
name
());
mode
=
new
Mode
(
ModeEnum
.
Derby
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
aliasColumnName
=
true
;
mode
.
uniqu
ieIndexNullsHandling
=
2
;
mode
.
uniqu
eIndexNullsHandling
=
UniqueIndexNullsHandling
.
FORBID_ANY_DUPLICATES
;
mode
.
supportOffsetFetch
=
true
;
mode
.
supportOffsetFetch
=
true
;
mode
.
sysDummy1
=
true
;
mode
.
sysDummy1
=
true
;
mode
.
isolationLevelInSelectOrInsertStatement
=
true
;
mode
.
isolationLevelInSelectOrInsertStatement
=
true
;
...
@@ -219,7 +236,7 @@ public class Mode {
...
@@ -219,7 +236,7 @@ public class Mode {
mode
.
aliasColumnName
=
true
;
mode
.
aliasColumnName
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
nullConcatIsNull
=
true
;
mode
.
nullConcatIsNull
=
true
;
mode
.
uniqu
ieIndexNullsHandling
=
2
;
mode
.
uniqu
eIndexNullsHandling
=
UniqueIndexNullsHandling
.
FORBID_ANY_DUPLICATES
;
mode
.
allowPlusForStringConcat
=
true
;
mode
.
allowPlusForStringConcat
=
true
;
// HSQLDB does not support client info properties. See
// HSQLDB does not support client info properties. See
// http://hsqldb.org/doc/apidocs/
// http://hsqldb.org/doc/apidocs/
...
@@ -231,7 +248,7 @@ public class Mode {
...
@@ -231,7 +248,7 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
MSSQLServer
.
name
());
mode
=
new
Mode
(
ModeEnum
.
MSSQLServer
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
aliasColumnName
=
true
;
mode
.
squareBracketQuotedNames
=
true
;
mode
.
squareBracketQuotedNames
=
true
;
mode
.
uniqu
ieIndexNullsHandling
=
2
;
mode
.
uniqu
eIndexNullsHandling
=
UniqueIndexNullsHandling
.
FORBID_ANY_DUPLICATES
;
mode
.
allowPlusForStringConcat
=
true
;
mode
.
allowPlusForStringConcat
=
true
;
mode
.
swapConvertFunctionParameters
=
true
;
mode
.
swapConvertFunctionParameters
=
true
;
mode
.
supportPoundSymbolForColumnNames
=
true
;
mode
.
supportPoundSymbolForColumnNames
=
true
;
...
@@ -259,7 +276,7 @@ public class Mode {
...
@@ -259,7 +276,7 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
Oracle
.
name
());
mode
=
new
Mode
(
ModeEnum
.
Oracle
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
aliasColumnName
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
uniqu
ieIndexNullsHandling
=
1
;
mode
.
uniqu
eIndexNullsHandling
=
UniqueIndexNullsHandling
.
ALLOW_DUPLICATES_WITH_ALL_NULLS
;
mode
.
treatEmptyStringsAsNull
=
true
;
mode
.
treatEmptyStringsAsNull
=
true
;
mode
.
regexpReplaceBackslashReferences
=
true
;
mode
.
regexpReplaceBackslashReferences
=
true
;
mode
.
supportPoundSymbolForColumnNames
=
true
;
mode
.
supportPoundSymbolForColumnNames
=
true
;
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
859576ee
...
@@ -310,35 +310,24 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -310,35 +310,24 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* {@code false otherwise}
* {@code false otherwise}
*/
*/
protected
boolean
mayHaveDuplicates
(
SearchRow
searchRow
)
{
protected
boolean
mayHaveDuplicates
(
SearchRow
searchRow
)
{
int
mode
=
database
.
getMode
().
uniquieIndexNullsHandling
;
switch
(
database
.
getMode
().
uniqueIndexNullsHandling
)
{
/*
case
ALLOW_DUPLICATES_WITH_ANY_NULL:
* Multiple identical indexed columns with at least one NULL value are allowed
* in unique index.
*/
if
(
mode
==
0
)
{
for
(
int
index
:
columnIds
)
{
for
(
int
index
:
columnIds
)
{
if
(
searchRow
.
getValue
(
index
)
==
ValueNull
.
INSTANCE
)
{
if
(
searchRow
.
getValue
(
index
)
==
ValueNull
.
INSTANCE
)
{
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
case
ALLOW_DUPLICATES_WITH_ALL_NULLS:
/*
* Multiple identical indexed columns with all {@code NULL} values are allowed
* in unique index.
*/
if
(
mode
==
1
)
{
for
(
int
index
:
columnIds
)
{
for
(
int
index
:
columnIds
)
{
if
(
searchRow
.
getValue
(
index
)
!=
ValueNull
.
INSTANCE
)
{
if
(
searchRow
.
getValue
(
index
)
!=
ValueNull
.
INSTANCE
)
{
return
false
;
return
false
;
}
}
}
}
return
true
;
return
true
;
default
:
return
false
;
}
}
/*
* Multiple identical indexed columns are not allowed in unique index.
*/
return
false
;
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论