Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3ccdfaff
提交
3ccdfaff
authored
11月 06, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not use regular expressions in Regular and some other modes in ColumnNamer
上级
5c4719de
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
16 行删除
+33
-16
ColumnNamer.java
h2/src/main/org/h2/util/ColumnNamer.java
+14
-9
ColumnNamerConfiguration.java
h2/src/main/org/h2/util/ColumnNamerConfiguration.java
+19
-7
没有找到文件。
h2/src/main/org/h2/util/ColumnNamer.java
浏览文件 @
3ccdfaff
...
@@ -6,7 +6,7 @@ package org.h2.util;
...
@@ -6,7 +6,7 @@ package org.h2.util;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.regex.
Matcher
;
import
java.util.regex.
Pattern
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
...
@@ -124,26 +124,31 @@ public class ColumnNamer {
...
@@ -124,26 +124,31 @@ public class ColumnNamer {
}
}
private
boolean
isAllowableColumnName
(
String
proposedName
)
{
private
boolean
isAllowableColumnName
(
String
proposedName
)
{
// check null
// check null
if
(
proposedName
==
null
)
{
if
(
proposedName
==
null
)
{
return
false
;
return
false
;
}
}
// check size limits
// check size limits
if
(
proposedName
.
length
()
>
configuration
.
getMaxIdentiferLength
()
||
proposedName
.
length
()
==
0
)
{
int
length
=
proposedName
.
length
();
if
(
length
>
configuration
.
getMaxIdentiferLength
()
||
length
==
0
)
{
return
false
;
return
false
;
}
}
Matcher
match
=
configuration
.
getCompiledRegularExpressionMatchAllowed
().
matcher
(
proposedName
);
Pattern
allowed
=
configuration
.
getCompiledRegularExpressionMatchAllowed
(
);
return
match
.
matches
();
return
allowed
==
null
||
allowed
.
matcher
(
proposedName
)
.
matches
();
}
}
private
String
fixColumnName
(
String
proposedName
)
{
private
String
fixColumnName
(
String
proposedName
)
{
Matcher
match
=
configuration
.
getCompiledRegularExpressionMatchDisallowed
().
matcher
(
proposedName
);
Pattern
disallowed
=
configuration
.
getCompiledRegularExpressionMatchDisallowed
();
proposedName
=
match
.
replaceAll
(
""
);
if
(
disallowed
==
null
)
{
proposedName
=
StringUtils
.
replaceAll
(
proposedName
,
"\u0000"
,
""
);
}
else
{
proposedName
=
disallowed
.
matcher
(
proposedName
).
replaceAll
(
""
);
}
// check size limits - then truncate
// check size limits - then truncate
if
(
proposedName
.
length
()
>
configuration
.
getMaxIdentiferLength
())
{
int
length
=
proposedName
.
length
(),
maxLength
=
configuration
.
getMaxIdentiferLength
();
proposedName
=
proposedName
.
substring
(
0
,
configuration
.
getMaxIdentiferLength
());
if
(
length
>
maxLength
)
{
proposedName
=
proposedName
.
substring
(
0
,
maxLength
);
}
}
return
proposedName
;
return
proposedName
;
...
...
h2/src/main/org/h2/util/ColumnNamerConfiguration.java
浏览文件 @
3ccdfaff
...
@@ -40,8 +40,7 @@ public class ColumnNamerConfiguration {
...
@@ -40,8 +40,7 @@ public class ColumnNamerConfiguration {
this
.
defaultColumnNamePattern
=
defaultColumnNamePattern
;
this
.
defaultColumnNamePattern
=
defaultColumnNamePattern
;
this
.
generateUniqueColumnNames
=
generateUniqueColumnNames
;
this
.
generateUniqueColumnNames
=
generateUniqueColumnNames
;
compiledRegularExpressionMatchAllowed
=
Pattern
.
compile
(
regularExpressionMatchAllowed
);
recompilePatterns
();
compiledRegularExpressionMatchDisallowed
=
Pattern
.
compile
(
regularExpressionMatchDisallowed
);
}
}
public
int
getMaxIdentiferLength
()
{
public
int
getMaxIdentiferLength
()
{
...
@@ -80,6 +79,11 @@ public class ColumnNamerConfiguration {
...
@@ -80,6 +79,11 @@ public class ColumnNamerConfiguration {
this
.
defaultColumnNamePattern
=
defaultColumnNamePattern
;
this
.
defaultColumnNamePattern
=
defaultColumnNamePattern
;
}
}
/**
* Returns compiled pattern for allowed names.
*
* @return compiled pattern, or null for default
*/
public
Pattern
getCompiledRegularExpressionMatchAllowed
()
{
public
Pattern
getCompiledRegularExpressionMatchAllowed
()
{
return
compiledRegularExpressionMatchAllowed
;
return
compiledRegularExpressionMatchAllowed
;
}
}
...
@@ -88,6 +92,11 @@ public class ColumnNamerConfiguration {
...
@@ -88,6 +92,11 @@ public class ColumnNamerConfiguration {
this
.
compiledRegularExpressionMatchAllowed
=
compiledRegularExpressionMatchAllowed
;
this
.
compiledRegularExpressionMatchAllowed
=
compiledRegularExpressionMatchAllowed
;
}
}
/**
* Returns compiled pattern for disallowed names.
*
* @return compiled pattern, or null for default
*/
public
Pattern
getCompiledRegularExpressionMatchDisallowed
()
{
public
Pattern
getCompiledRegularExpressionMatchDisallowed
()
{
return
compiledRegularExpressionMatchDisallowed
;
return
compiledRegularExpressionMatchDisallowed
;
}
}
...
@@ -138,8 +147,11 @@ public class ColumnNamerConfiguration {
...
@@ -138,8 +147,11 @@ public class ColumnNamerConfiguration {
private
void
recompilePatterns
()
{
private
void
recompilePatterns
()
{
try
{
try
{
// recompile RE patterns
// recompile RE patterns
setCompiledRegularExpressionMatchAllowed
(
Pattern
.
compile
(
getRegularExpressionMatchAllowed
()));
setCompiledRegularExpressionMatchAllowed
(
setCompiledRegularExpressionMatchDisallowed
(
Pattern
.
compile
(
getRegularExpressionMatchDisallowed
()));
regularExpressionMatchAllowed
!=
null
?
Pattern
.
compile
(
regularExpressionMatchAllowed
)
:
null
);
setCompiledRegularExpressionMatchDisallowed
(
regularExpressionMatchDisallowed
!=
null
?
Pattern
.
compile
(
regularExpressionMatchDisallowed
)
:
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
configure
(
REGULAR
);
configure
(
REGULAR
);
throw
e
;
throw
e
;
...
@@ -147,7 +159,7 @@ public class ColumnNamerConfiguration {
...
@@ -147,7 +159,7 @@ public class ColumnNamerConfiguration {
}
}
public
static
ColumnNamerConfiguration
getDefault
()
{
public
static
ColumnNamerConfiguration
getDefault
()
{
return
new
ColumnNamerConfiguration
(
Integer
.
MAX_VALUE
,
"(?m)(?s).+"
,
"(?m)(?s)[\\x00]"
,
"_UNNAMED_$$"
,
false
);
return
new
ColumnNamerConfiguration
(
Integer
.
MAX_VALUE
,
null
,
null
,
"_UNNAMED_$$"
,
false
);
}
}
private
static
String
unquoteString
(
String
s
)
{
private
static
String
unquoteString
(
String
s
)
{
...
@@ -220,8 +232,8 @@ public class ColumnNamerConfiguration {
...
@@ -220,8 +232,8 @@ public class ColumnNamerConfiguration {
case
Ignite:
case
Ignite:
default
:
default
:
setMaxIdentiferLength
(
Integer
.
MAX_VALUE
);
setMaxIdentiferLength
(
Integer
.
MAX_VALUE
);
setRegularExpressionMatchAllowed
(
"(?m)(?s).+"
);
setRegularExpressionMatchAllowed
(
null
);
setRegularExpressionMatchDisallowed
(
"(?m)(?s)[\\x00]"
);
setRegularExpressionMatchDisallowed
(
null
);
setDefaultColumnNamePattern
(
"_UNNAMED_$$"
);
setDefaultColumnNamePattern
(
"_UNNAMED_$$"
);
setGenerateUniqueColumnNames
(
false
);
setGenerateUniqueColumnNames
(
false
);
break
;
break
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论