Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d5478abd
Unverified
提交
d5478abd
authored
5月 25, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 25, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1162 from katzyn/misc
Reduce allocation of temporary strings
上级
be13b43d
f7dc512d
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
64 行增加
和
40 行删除
+64
-40
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-1
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+2
-1
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+1
-1
FullTextLucene.java
h2/src/main/org/h2/fulltext/FullTextLucene.java
+1
-1
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+0
-1
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+0
-1
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+0
-2
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+17
-17
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+2
-2
Data.java
h2/src/main/org/h2/store/Data.java
+0
-1
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+0
-1
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+2
-3
Shell.java
h2/src/main/org/h2/tools/Shell.java
+3
-3
Profiler.java
h2/src/main/org/h2/util/Profiler.java
+1
-1
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+34
-4
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
d5478abd
...
@@ -288,7 +288,7 @@ public class Parser {
...
@@ -288,7 +288,7 @@ public class Parser {
Command
c
=
new
CommandContainer
(
this
,
sql
,
p
);
Command
c
=
new
CommandContainer
(
this
,
sql
,
p
);
if
(
hasMore
)
{
if
(
hasMore
)
{
String
remaining
=
originalSQL
.
substring
(
parseIndex
);
String
remaining
=
originalSQL
.
substring
(
parseIndex
);
if
(
remaining
.
trim
().
length
()
!=
0
)
{
if
(
!
StringUtils
.
isWhitespaceOrEmpty
(
remaining
)
)
{
c
=
new
CommandList
(
this
,
sql
,
c
,
remaining
);
c
=
new
CommandList
(
this
,
sql
,
c
,
remaining
);
}
}
}
}
...
...
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
d5478abd
...
@@ -29,6 +29,7 @@ import org.h2.store.fs.FileUtils;
...
@@ -29,6 +29,7 @@ import org.h2.store.fs.FileUtils;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.CompressTool
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.StringUtils
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.CompareMode
;
import
org.h2.value.CompareMode
;
...
@@ -88,7 +89,7 @@ abstract class ScriptBase extends Prepared implements DataHandler {
...
@@ -88,7 +89,7 @@ abstract class ScriptBase extends Prepared implements DataHandler {
protected
String
getFileName
()
{
protected
String
getFileName
()
{
if
(
fileNameExpr
!=
null
&&
fileName
==
null
)
{
if
(
fileNameExpr
!=
null
&&
fileName
==
null
)
{
fileName
=
fileNameExpr
.
optimize
(
session
).
getValue
(
session
).
getString
();
fileName
=
fileNameExpr
.
optimize
(
session
).
getValue
(
session
).
getString
();
if
(
fileName
==
null
||
fileName
.
trim
().
length
()
==
0
)
{
if
(
fileName
==
null
||
StringUtils
.
isWhitespaceOrEmpty
(
fileName
)
)
{
fileName
=
"script.sql"
;
fileName
=
"script.sql"
;
}
}
fileName
=
SysProperties
.
getScriptDirectory
()
+
fileName
;
fileName
=
SysProperties
.
getScriptDirectory
()
+
fileName
;
...
...
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
d5478abd
...
@@ -596,7 +596,7 @@ public class FullText {
...
@@ -596,7 +596,7 @@ public class FullText {
// this is just to query the result set columns
// this is just to query the result set columns
return
result
;
return
result
;
}
}
if
(
text
==
null
||
text
.
trim
().
length
()
==
0
)
{
if
(
text
==
null
||
StringUtils
.
isWhitespaceOrEmpty
(
text
)
)
{
return
result
;
return
result
;
}
}
FullTextSettings
setting
=
FullTextSettings
.
getInstance
(
conn
);
FullTextSettings
setting
=
FullTextSettings
.
getInstance
(
conn
);
...
...
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
d5478abd
...
@@ -405,7 +405,7 @@ public class FullTextLucene extends FullText {
...
@@ -405,7 +405,7 @@ public class FullTextLucene extends FullText {
// this is just to query the result set columns
// this is just to query the result set columns
return
result
;
return
result
;
}
}
if
(
text
==
null
||
text
.
trim
().
length
()
==
0
)
{
if
(
text
==
null
||
StringUtils
.
isWhitespaceOrEmpty
(
text
)
)
{
return
result
;
return
result
;
}
}
try
{
try
{
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
d5478abd
...
@@ -9,7 +9,6 @@ import java.util.Collections;
...
@@ -9,7 +9,6 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.dml.AllColumnsForPlan
;
import
org.h2.command.dml.AllColumnsForPlan
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
...
...
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
d5478abd
...
@@ -10,7 +10,6 @@ import java.util.Collections;
...
@@ -10,7 +10,6 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.dml.AllColumnsForPlan
;
import
org.h2.command.dml.AllColumnsForPlan
;
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
d5478abd
...
@@ -16,9 +16,7 @@ import java.sql.SQLException;
...
@@ -16,9 +16,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
d5478abd
...
@@ -250,8 +250,8 @@ public class WebApp {
...
@@ -250,8 +250,8 @@ public class WebApp {
private
String
autoCompleteList
()
{
private
String
autoCompleteList
()
{
String
query
=
(
String
)
attributes
.
get
(
"query"
);
String
query
=
(
String
)
attributes
.
get
(
"query"
);
boolean
lowercase
=
false
;
boolean
lowercase
=
false
;
if
(
query
.
trim
().
length
()
>
0
&&
String
tQuery
=
query
.
trim
();
Character
.
isLowerCase
(
query
.
trim
()
.
charAt
(
0
)))
{
if
(!
tQuery
.
isEmpty
()
&&
Character
.
isLowerCase
(
tQuery
.
charAt
(
0
)))
{
lowercase
=
true
;
lowercase
=
true
;
}
}
try
{
try
{
...
@@ -281,7 +281,8 @@ public class WebApp {
...
@@ -281,7 +281,8 @@ public class WebApp {
while
(
sql
.
length
()
>
0
&&
sql
.
charAt
(
0
)
<=
' '
)
{
while
(
sql
.
length
()
>
0
&&
sql
.
charAt
(
0
)
<=
' '
)
{
sql
=
sql
.
substring
(
1
);
sql
=
sql
.
substring
(
1
);
}
}
if
(
sql
.
trim
().
length
()
>
0
&&
Character
.
isLowerCase
(
sql
.
trim
().
charAt
(
0
)))
{
String
tSql
=
sql
.
trim
();
if
(!
tSql
.
isEmpty
()
&&
Character
.
isLowerCase
(
tSql
.
charAt
(
0
)))
{
lowercase
=
true
;
lowercase
=
true
;
}
}
Bnf
bnf
=
session
.
getBnf
();
Bnf
bnf
=
session
.
getBnf
();
...
@@ -320,7 +321,7 @@ public class WebApp {
...
@@ -320,7 +321,7 @@ public class WebApp {
list
.
add
(
type
+
"#"
+
key
+
"#"
+
value
);
list
.
add
(
type
+
"#"
+
key
+
"#"
+
value
);
}
}
Collections
.
sort
(
list
);
Collections
.
sort
(
list
);
if
(
query
.
endsWith
(
"\n"
)
||
query
.
trim
()
.
endsWith
(
";"
))
{
if
(
query
.
endsWith
(
"\n"
)
||
tQuery
.
endsWith
(
";"
))
{
list
.
add
(
0
,
"1#(Newline)#\n"
);
list
.
add
(
0
,
"1#(Newline)#\n"
);
}
}
StatementBuilder
buff
=
new
StatementBuilder
();
StatementBuilder
buff
=
new
StatementBuilder
();
...
@@ -1302,41 +1303,40 @@ public class WebApp {
...
@@ -1302,41 +1303,40 @@ public class WebApp {
return
buff
.
toString
();
return
buff
.
toString
();
}
else
if
(
isBuiltIn
(
sql
,
"@edit"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@edit"
))
{
edit
=
true
;
edit
=
true
;
sql
=
sql
.
substring
(
"@edit"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@edit"
.
length
()
);
session
.
put
(
"resultSetSQL"
,
sql
);
session
.
put
(
"resultSetSQL"
,
sql
);
}
}
if
(
isBuiltIn
(
sql
,
"@list"
))
{
if
(
isBuiltIn
(
sql
,
"@list"
))
{
list
=
true
;
list
=
true
;
sql
=
sql
.
substring
(
"@list"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@list"
.
length
()
);
}
}
if
(
isBuiltIn
(
sql
,
"@meta"
))
{
if
(
isBuiltIn
(
sql
,
"@meta"
))
{
metadata
=
true
;
metadata
=
true
;
sql
=
sql
.
substring
(
"@meta"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@meta"
.
length
()
);
}
}
if
(
isBuiltIn
(
sql
,
"@generated"
))
{
if
(
isBuiltIn
(
sql
,
"@generated"
))
{
generatedKeys
=
Statement
.
RETURN_GENERATED_KEYS
;
generatedKeys
=
Statement
.
RETURN_GENERATED_KEYS
;
sql
=
sql
.
substring
(
"@generated"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@generated"
.
length
()
);
}
else
if
(
isBuiltIn
(
sql
,
"@history"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@history"
))
{
buff
.
append
(
getCommandHistoryString
());
buff
.
append
(
getCommandHistoryString
());
return
buff
.
toString
();
return
buff
.
toString
();
}
else
if
(
isBuiltIn
(
sql
,
"@loop"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@loop"
))
{
sql
=
sql
.
substring
(
"@loop"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@loop"
.
length
()
);
int
idx
=
sql
.
indexOf
(
' '
);
int
idx
=
sql
.
indexOf
(
' '
);
int
count
=
Integer
.
decode
(
sql
.
substring
(
0
,
idx
));
int
count
=
Integer
.
decode
(
sql
.
substring
(
0
,
idx
));
sql
=
sql
.
substring
(
idx
).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
idx
);
return
executeLoop
(
conn
,
count
,
sql
);
return
executeLoop
(
conn
,
count
,
sql
);
}
else
if
(
isBuiltIn
(
sql
,
"@maxrows"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@maxrows"
))
{
int
maxrows
=
(
int
)
Double
.
parseDouble
(
int
maxrows
=
(
int
)
Double
.
parseDouble
(
StringUtils
.
trimSubstring
(
sql
,
"@maxrows"
.
length
()));
sql
.
substring
(
"@maxrows"
.
length
()).
trim
());
session
.
put
(
"maxrows"
,
Integer
.
toString
(
maxrows
));
session
.
put
(
"maxrows"
,
Integer
.
toString
(
maxrows
));
return
"${text.result.maxrowsSet}"
;
return
"${text.result.maxrowsSet}"
;
}
else
if
(
isBuiltIn
(
sql
,
"@parameter_meta"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@parameter_meta"
))
{
sql
=
sql
.
substring
(
"@parameter_meta"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@parameter_meta"
.
length
()
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
sql
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
sql
);
buff
.
append
(
getParameterResultSet
(
prep
.
getParameterMetaData
()));
buff
.
append
(
getParameterResultSet
(
prep
.
getParameterMetaData
()));
return
buff
.
toString
();
return
buff
.
toString
();
}
else
if
(
isBuiltIn
(
sql
,
"@password_hash"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@password_hash"
))
{
sql
=
sql
.
substring
(
"@password_hash"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@password_hash"
.
length
()
);
String
[]
p
=
split
(
sql
);
String
[]
p
=
split
(
sql
);
return
StringUtils
.
convertBytesToHex
(
return
StringUtils
.
convertBytesToHex
(
SHA256
.
getKeyPasswordHash
(
p
[
0
],
p
[
1
].
toCharArray
()));
SHA256
.
getKeyPasswordHash
(
p
[
0
],
p
[
1
].
toCharArray
()));
...
@@ -1348,7 +1348,7 @@ public class WebApp {
...
@@ -1348,7 +1348,7 @@ public class WebApp {
profiler
.
startCollecting
();
profiler
.
startCollecting
();
return
"Ok"
;
return
"Ok"
;
}
else
if
(
isBuiltIn
(
sql
,
"@sleep"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@sleep"
))
{
String
s
=
sql
.
substring
(
"@sleep"
.
length
()).
trim
(
);
String
s
=
StringUtils
.
trimSubstring
(
sql
,
"@sleep"
.
length
()
);
int
sleep
=
1
;
int
sleep
=
1
;
if
(
s
.
length
()
>
0
)
{
if
(
s
.
length
()
>
0
)
{
sleep
=
Integer
.
parseInt
(
s
);
sleep
=
Integer
.
parseInt
(
s
);
...
@@ -1356,7 +1356,7 @@ public class WebApp {
...
@@ -1356,7 +1356,7 @@ public class WebApp {
Thread
.
sleep
(
sleep
*
1000
);
Thread
.
sleep
(
sleep
*
1000
);
return
"Ok"
;
return
"Ok"
;
}
else
if
(
isBuiltIn
(
sql
,
"@transaction_isolation"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@transaction_isolation"
))
{
String
s
=
sql
.
substring
(
"@transaction_isolation"
.
length
()).
trim
(
);
String
s
=
StringUtils
.
trimSubstring
(
sql
,
"@transaction_isolation"
.
length
()
);
if
(
s
.
length
()
>
0
)
{
if
(
s
.
length
()
>
0
)
{
int
level
=
Integer
.
parseInt
(
s
);
int
level
=
Integer
.
parseInt
(
s
);
conn
.
setTransactionIsolation
(
level
);
conn
.
setTransactionIsolation
(
level
);
...
@@ -1445,7 +1445,7 @@ public class WebApp {
...
@@ -1445,7 +1445,7 @@ public class WebApp {
Random
random
=
new
Random
(
1
);
Random
random
=
new
Random
(
1
);
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
if
(
isBuiltIn
(
sql
,
"@statement"
))
{
if
(
isBuiltIn
(
sql
,
"@statement"
))
{
sql
=
sql
.
substring
(
"@statement"
.
length
()).
trim
(
);
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@statement"
.
length
()
);
prepared
=
false
;
prepared
=
false
;
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
for
(
int
i
=
0
;
!
stop
&&
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
!
stop
&&
i
<
count
;
i
++)
{
...
...
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
d5478abd
...
@@ -310,7 +310,7 @@ class WebThread extends WebApp implements Runnable {
...
@@ -310,7 +310,7 @@ class WebThread extends WebApp implements Runnable {
}
}
}
}
}
}
}
else
if
(
line
.
trim
().
length
()
==
0
)
{
}
else
if
(
StringUtils
.
isWhitespaceOrEmpty
(
line
)
)
{
break
;
break
;
}
}
}
}
...
@@ -328,7 +328,7 @@ class WebThread extends WebApp implements Runnable {
...
@@ -328,7 +328,7 @@ class WebThread extends WebApp implements Runnable {
}
}
private
static
String
getHeaderLineValue
(
String
line
)
{
private
static
String
getHeaderLineValue
(
String
line
)
{
return
line
.
substring
(
line
.
indexOf
(
':'
)
+
1
).
trim
(
);
return
StringUtils
.
trimSubstring
(
line
,
line
.
indexOf
(
':'
)
+
1
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
d5478abd
...
@@ -20,7 +20,6 @@ import java.sql.Timestamp;
...
@@ -20,7 +20,6 @@ import java.sql.Timestamp;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.Bits
;
import
org.h2.util.Bits
;
...
...
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
d5478abd
...
@@ -17,7 +17,6 @@ import java.util.Arrays;
...
@@ -17,7 +17,6 @@ import java.util.Arrays;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.SysProperties
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.CompressTool
;
...
...
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
d5478abd
...
@@ -166,7 +166,7 @@ public class RunScript extends Tool {
...
@@ -166,7 +166,7 @@ public class RunScript extends Tool {
if
(
sql
==
null
)
{
if
(
sql
==
null
)
{
break
;
break
;
}
}
if
(
sql
.
trim
().
length
()
==
0
)
{
if
(
StringUtils
.
isWhitespaceOrEmpty
(
sql
)
)
{
continue
;
continue
;
}
}
boolean
resultSet
=
stat
.
execute
(
sql
);
boolean
resultSet
=
stat
.
execute
(
sql
);
...
@@ -210,8 +210,7 @@ public class RunScript extends Tool {
...
@@ -210,8 +210,7 @@ public class RunScript extends Tool {
}
}
if
(
trim
.
startsWith
(
"@"
)
&&
StringUtils
.
toUpperEnglish
(
trim
).
if
(
trim
.
startsWith
(
"@"
)
&&
StringUtils
.
toUpperEnglish
(
trim
).
startsWith
(
"@INCLUDE"
))
{
startsWith
(
"@INCLUDE"
))
{
sql
=
trim
;
sql
=
StringUtils
.
trimSubstring
(
sql
,
"@INCLUDE"
.
length
());
sql
=
sql
.
substring
(
"@INCLUDE"
.
length
()).
trim
();
if
(!
FileUtils
.
isAbsolute
(
sql
))
{
if
(!
FileUtils
.
isAbsolute
(
sql
))
{
sql
=
path
+
SysProperties
.
FILE_SEPARATOR
+
sql
;
sql
=
path
+
SysProperties
.
FILE_SEPARATOR
+
sql
;
}
}
...
...
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
d5478abd
...
@@ -248,7 +248,7 @@ public class Shell extends Tool implements Runnable {
...
@@ -248,7 +248,7 @@ public class Shell extends Tool implements Runnable {
println
(
"No history"
);
println
(
"No history"
);
}
}
}
else
if
(
lower
.
startsWith
(
"autocommit"
))
{
}
else
if
(
lower
.
startsWith
(
"autocommit"
))
{
lower
=
lower
.
substring
(
"autocommit"
.
length
()).
trim
(
);
lower
=
StringUtils
.
trimSubstring
(
lower
,
"autocommit"
.
length
()
);
if
(
"true"
.
equals
(
lower
))
{
if
(
"true"
.
equals
(
lower
))
{
conn
.
setAutoCommit
(
true
);
conn
.
setAutoCommit
(
true
);
}
else
if
(
"false"
.
equals
(
lower
))
{
}
else
if
(
"false"
.
equals
(
lower
))
{
...
@@ -258,7 +258,7 @@ public class Shell extends Tool implements Runnable {
...
@@ -258,7 +258,7 @@ public class Shell extends Tool implements Runnable {
}
}
println
(
"Autocommit is now "
+
conn
.
getAutoCommit
());
println
(
"Autocommit is now "
+
conn
.
getAutoCommit
());
}
else
if
(
lower
.
startsWith
(
"maxwidth"
))
{
}
else
if
(
lower
.
startsWith
(
"maxwidth"
))
{
lower
=
lower
.
substring
(
"maxwidth"
.
length
()).
trim
(
);
lower
=
StringUtils
.
trimSubstring
(
lower
,
"maxwidth"
.
length
()
);
try
{
try
{
maxColumnSize
=
Integer
.
parseInt
(
lower
);
maxColumnSize
=
Integer
.
parseInt
(
lower
);
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
...
@@ -445,7 +445,7 @@ public class Shell extends Tool implements Runnable {
...
@@ -445,7 +445,7 @@ public class Shell extends Tool implements Runnable {
}
}
private
void
execute
(
String
sql
)
{
private
void
execute
(
String
sql
)
{
if
(
sql
.
trim
().
length
()
==
0
)
{
if
(
StringUtils
.
isWhitespaceOrEmpty
(
sql
)
)
{
return
;
return
;
}
}
long
time
=
System
.
nanoTime
();
long
time
=
System
.
nanoTime
();
...
...
h2/src/main/org/h2/util/Profiler.java
浏览文件 @
d5478abd
...
@@ -249,7 +249,7 @@ public class Profiler implements Runnable {
...
@@ -249,7 +249,7 @@ public class Profiler implements Runnable {
if
(!
line
.
startsWith
(
"at "
))
{
if
(!
line
.
startsWith
(
"at "
))
{
break
;
break
;
}
}
line
=
line
.
substring
(
3
).
trim
(
);
line
=
StringUtils
.
trimSubstring
(
line
,
3
);
stack
.
add
(
line
);
stack
.
add
(
line
);
}
}
if
(!
stack
.
isEmpty
())
{
if
(!
stack
.
isEmpty
())
{
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
d5478abd
...
@@ -848,7 +848,20 @@ public class StringUtils {
...
@@ -848,7 +848,20 @@ public class StringUtils {
}
}
/**
/**
* Trim a character from a substring. Equivalence of {@code substring(begin, end).trim()}.
* Trim a character from a substring. Equivalent of
* {@code substring(beginIndex).trim()}.
*
* @param s the string
* @param beginIndex start index of substring (inclusive)
* @return trimmed substring
*/
public
static
String
trimSubstring
(
String
s
,
int
beginIndex
)
{
return
trimSubstring
(
s
,
beginIndex
,
s
.
length
());
}
/**
* Trim a character from a substring. Equivalent of
* {@code substring(beginIndex, endIndex).trim()}.
*
*
* @param s the string
* @param s the string
* @param beginIndex start index of substring (inclusive)
* @param beginIndex start index of substring (inclusive)
...
@@ -969,11 +982,28 @@ public class StringUtils {
...
@@ -969,11 +982,28 @@ public class StringUtils {
* @return true if it is
* @return true if it is
*/
*/
public
static
boolean
isNumber
(
String
s
)
{
public
static
boolean
isNumber
(
String
s
)
{
if
(
s
.
length
()
==
0
)
{
int
l
=
s
.
length
();
if
(
l
==
0
)
{
return
false
;
return
false
;
}
}
for
(
char
c
:
s
.
toCharArray
())
{
for
(
int
i
=
0
;
i
<
l
;
i
++)
{
if
(!
Character
.
isDigit
(
c
))
{
if
(!
Character
.
isDigit
(
s
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
/**
* Check if the specified string is empty or contains only whitespace.
*
* @param s
* the string
* @return whether the specified string is empty or contains only whitespace
*/
public
static
boolean
isWhitespaceOrEmpty
(
String
s
)
{
for
(
int
i
=
0
,
l
=
s
.
length
();
i
<
l
;
i
++)
{
if
(
s
.
charAt
(
i
)
>
' '
)
{
return
false
;
return
false
;
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论