Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c264653e
提交
c264653e
authored
1月 20, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New system property h2.identifiersToUpper.
上级
45234fea
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
85 行增加
和
37 行删除
+85
-37
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+76
-36
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+7
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
c264653e
...
@@ -18,7 +18,8 @@ Change Log
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Slightly improved performance if the table is already locked.
<ul><li>
New system property h2.identifiersToUpper. If set to false, identifiers in SQL statements are case sensitive.
</li><li>
Slightly improved performance if the table is already locked.
</li><li>
CompressLZF: faster decompression.
</li><li>
CompressLZF: faster decompression.
</li><li>
PgServer: the wrong size was sent for VARCHAR data. Thanks again to Sergi Vladykin for the patch.
</li><li>
PgServer: the wrong size was sent for VARCHAR data. Thanks again to Sergi Vladykin for the patch.
</li></ul>
</li></ul>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
c264653e
...
@@ -188,6 +188,7 @@ public class Parser {
...
@@ -188,6 +188,7 @@ public class Parser {
private
boolean
rightsChecked
;
private
boolean
rightsChecked
;
private
boolean
recompileAlways
;
private
boolean
recompileAlways
;
private
ObjectArray
<
Parameter
>
indexedParameterList
;
private
ObjectArray
<
Parameter
>
indexedParameterList
;
private
boolean
identifiersToUpper
=
SysProperties
.
IDENTIFIERS_TO_UPPER
;
public
Parser
(
Session
session
)
{
public
Parser
(
Session
session
)
{
database
=
session
.
getDatabase
();
database
=
session
.
getDatabase
();
...
@@ -303,6 +304,7 @@ public class Parser {
...
@@ -303,6 +304,7 @@ public class Parser {
case
'('
:
case
'('
:
c
=
parseSelect
();
c
=
parseSelect
();
break
;
break
;
case
'a'
:
case
'A'
:
case
'A'
:
if
(
readIf
(
"ALTER"
))
{
if
(
readIf
(
"ALTER"
))
{
c
=
parseAlter
();
c
=
parseAlter
();
...
@@ -310,6 +312,7 @@ public class Parser {
...
@@ -310,6 +312,7 @@ public class Parser {
c
=
parseAnalyze
();
c
=
parseAnalyze
();
}
}
break
;
break
;
case
'b'
:
case
'B'
:
case
'B'
:
if
(
readIf
(
"BACKUP"
))
{
if
(
readIf
(
"BACKUP"
))
{
c
=
parseBackup
();
c
=
parseBackup
();
...
@@ -317,6 +320,7 @@ public class Parser {
...
@@ -317,6 +320,7 @@ public class Parser {
c
=
parseBegin
();
c
=
parseBegin
();
}
}
break
;
break
;
case
'c'
:
case
'C'
:
case
'C'
:
if
(
readIf
(
"COMMIT"
))
{
if
(
readIf
(
"COMMIT"
))
{
c
=
parseCommit
();
c
=
parseCommit
();
...
@@ -330,6 +334,7 @@ public class Parser {
...
@@ -330,6 +334,7 @@ public class Parser {
c
=
parseComment
();
c
=
parseComment
();
}
}
break
;
break
;
case
'd'
:
case
'D'
:
case
'D'
:
if
(
readIf
(
"DELETE"
))
{
if
(
readIf
(
"DELETE"
))
{
c
=
parseDelete
();
c
=
parseDelete
();
...
@@ -342,6 +347,7 @@ public class Parser {
...
@@ -342,6 +347,7 @@ public class Parser {
c
=
parseDeallocate
();
c
=
parseDeallocate
();
}
}
break
;
break
;
case
'e'
:
case
'E'
:
case
'E'
:
if
(
readIf
(
"EXPLAIN"
))
{
if
(
readIf
(
"EXPLAIN"
))
{
c
=
parseExplain
();
c
=
parseExplain
();
...
@@ -349,36 +355,43 @@ public class Parser {
...
@@ -349,36 +355,43 @@ public class Parser {
c
=
parseExecute
();
c
=
parseExecute
();
}
}
break
;
break
;
case
'f'
:
case
'F'
:
case
'F'
:
if
(
isToken
(
"FROM"
))
{
if
(
isToken
(
"FROM"
))
{
c
=
parseSelect
();
c
=
parseSelect
();
}
}
break
;
break
;
case
'g'
:
case
'G'
:
case
'G'
:
if
(
readIf
(
"GRANT"
))
{
if
(
readIf
(
"GRANT"
))
{
c
=
parseGrantRevoke
(
GrantRevoke
.
GRANT
);
c
=
parseGrantRevoke
(
GrantRevoke
.
GRANT
);
}
}
break
;
break
;
case
'h'
:
case
'H'
:
case
'H'
:
if
(
readIf
(
"HELP"
))
{
if
(
readIf
(
"HELP"
))
{
c
=
parseHelp
();
c
=
parseHelp
();
}
}
break
;
break
;
case
'i'
:
case
'I'
:
case
'I'
:
if
(
readIf
(
"INSERT"
))
{
if
(
readIf
(
"INSERT"
))
{
c
=
parseInsert
();
c
=
parseInsert
();
}
}
break
;
break
;
case
'm'
:
case
'M'
:
case
'M'
:
if
(
readIf
(
"MERGE"
))
{
if
(
readIf
(
"MERGE"
))
{
c
=
parseMerge
();
c
=
parseMerge
();
}
}
break
;
break
;
case
'p'
:
case
'P'
:
case
'P'
:
if
(
readIf
(
"PREPARE"
))
{
if
(
readIf
(
"PREPARE"
))
{
c
=
parsePrepare
();
c
=
parsePrepare
();
}
}
break
;
break
;
case
'r'
:
case
'R'
:
case
'R'
:
if
(
readIf
(
"ROLLBACK"
))
{
if
(
readIf
(
"ROLLBACK"
))
{
c
=
parseRollback
();
c
=
parseRollback
();
...
@@ -390,6 +403,7 @@ public class Parser {
...
@@ -390,6 +403,7 @@ public class Parser {
c
=
parseReleaseSavepoint
();
c
=
parseReleaseSavepoint
();
}
}
break
;
break
;
case
's'
:
case
'S'
:
case
'S'
:
if
(
isToken
(
"SELECT"
))
{
if
(
isToken
(
"SELECT"
))
{
c
=
parseSelect
();
c
=
parseSelect
();
...
@@ -405,21 +419,25 @@ public class Parser {
...
@@ -405,21 +419,25 @@ public class Parser {
c
=
parseShow
();
c
=
parseShow
();
}
}
break
;
break
;
case
't'
:
case
'T'
:
case
'T'
:
if
(
readIf
(
"TRUNCATE"
))
{
if
(
readIf
(
"TRUNCATE"
))
{
c
=
parseTruncate
();
c
=
parseTruncate
();
}
}
break
;
break
;
case
'u'
:
case
'U'
:
case
'U'
:
if
(
readIf
(
"UPDATE"
))
{
if
(
readIf
(
"UPDATE"
))
{
c
=
parseUpdate
();
c
=
parseUpdate
();
}
}
break
;
break
;
case
'v'
:
case
'V'
:
case
'V'
:
if
(
readIf
(
"VALUES"
))
{
if
(
readIf
(
"VALUES"
))
{
c
=
parserCall
();
c
=
parserCall
();
}
}
break
;
break
;
case
'w'
:
case
'W'
:
case
'W'
:
if
(
readIf
(
"WITH"
))
{
if
(
readIf
(
"WITH"
))
{
c
=
parserWith
();
c
=
parserWith
();
...
@@ -588,7 +606,7 @@ public class Parser {
...
@@ -588,7 +606,7 @@ public class Parser {
}
}
Schema
schema
=
database
.
findSchema
(
schemaName
);
Schema
schema
=
database
.
findSchema
(
schemaName
);
if
(
schema
==
null
)
{
if
(
schema
==
null
)
{
if
(
"SESSION"
.
equals
(
schemaName
))
{
if
(
equalsToken
(
"SESSION"
,
schemaName
))
{
// for local temporary tables
// for local temporary tables
schema
=
database
.
getSchema
(
session
.
getCurrentSchemaName
());
schema
=
database
.
getSchema
(
session
.
getCurrentSchemaName
());
}
else
{
}
else
{
...
@@ -613,15 +631,15 @@ public class Parser {
...
@@ -613,15 +631,15 @@ public class Parser {
schema
=
tableAlias
;
schema
=
tableAlias
;
tableAlias
=
columnName
;
tableAlias
=
columnName
;
columnName
=
readColumnIdentifier
();
columnName
=
readColumnIdentifier
();
if
(!
catalogName
.
equals
(
database
.
getShortName
()))
{
if
(!
equalsToken
(
catalogName
,
database
.
getShortName
()))
{
throw
Message
.
getSQLException
(
ErrorCode
.
DATABASE_NOT_FOUND_1
,
catalogName
);
throw
Message
.
getSQLException
(
ErrorCode
.
DATABASE_NOT_FOUND_1
,
catalogName
);
}
}
}
}
if
(!
schema
.
equals
(
filter
.
getTable
().
getSchema
().
getName
()))
{
if
(!
equalsToken
(
schema
,
filter
.
getTable
().
getSchema
().
getName
()))
{
throw
Message
.
getSQLException
(
ErrorCode
.
SCHEMA_NOT_FOUND_1
,
schema
);
throw
Message
.
getSQLException
(
ErrorCode
.
SCHEMA_NOT_FOUND_1
,
schema
);
}
}
}
}
if
(!
tableAlias
.
equals
(
filter
.
getTableAlias
()))
{
if
(!
equalsToken
(
tableAlias
,
filter
.
getTableAlias
()))
{
throw
Message
.
getSQLException
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
tableAlias
);
throw
Message
.
getSQLException
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
tableAlias
);
}
}
}
}
...
@@ -679,7 +697,7 @@ public class Parser {
...
@@ -679,7 +697,7 @@ public class Parser {
if
(
readIf
(
"AS"
))
{
if
(
readIf
(
"AS"
))
{
alias
=
readAliasIdentifier
();
alias
=
readAliasIdentifier
();
}
else
if
(
currentTokenType
==
IDENTIFIER
)
{
}
else
if
(
currentTokenType
==
IDENTIFIER
)
{
if
(!
"SET"
.
equals
(
currentToken
))
{
if
(!
equalsToken
(
"SET"
,
currentToken
))
{
// SET is not a keyword (PostgreSQL supports it as a table name)
// SET is not a keyword (PostgreSQL supports it as a table name)
alias
=
readAliasIdentifier
();
alias
=
readAliasIdentifier
();
}
}
...
@@ -963,7 +981,7 @@ public class Parser {
...
@@ -963,7 +981,7 @@ public class Parser {
String
tableName
=
readIdentifierWithSchema
(
null
);
String
tableName
=
readIdentifierWithSchema
(
null
);
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
Schema
mainSchema
=
database
.
getSchema
(
Constants
.
SCHEMA_MAIN
);
Schema
mainSchema
=
database
.
getSchema
(
Constants
.
SCHEMA_MAIN
);
if
(
tableName
.
equals
(
RangeTable
.
NAME
))
{
if
(
equalsToken
(
tableName
,
RangeTable
.
NAME
))
{
Expression
min
=
readExpression
();
Expression
min
=
readExpression
();
read
(
","
);
read
(
","
);
Expression
max
=
readExpression
();
Expression
max
=
readExpression
();
...
@@ -976,7 +994,7 @@ public class Parser {
...
@@ -976,7 +994,7 @@ public class Parser {
}
}
table
=
new
FunctionTable
(
mainSchema
,
session
,
func
,
(
FunctionCall
)
func
);
table
=
new
FunctionTable
(
mainSchema
,
session
,
func
,
(
FunctionCall
)
func
);
}
}
}
else
if
(
"DUAL"
.
equals
(
tableName
))
{
}
else
if
(
equalsToken
(
"DUAL"
,
tableName
))
{
table
=
getDualTable
();
table
=
getDualTable
();
}
else
{
}
else
{
table
=
readTableOrView
(
tableName
);
table
=
readTableOrView
(
tableName
);
...
@@ -1260,7 +1278,7 @@ public class Parser {
...
@@ -1260,7 +1278,7 @@ public class Parser {
String
tableColumnName
=
tc
.
getName
();
String
tableColumnName
=
tc
.
getName
();
for
(
Column
c
:
joinCols
)
{
for
(
Column
c
:
joinCols
)
{
String
joinColumnName
=
c
.
getName
();
String
joinColumnName
=
c
.
getName
();
if
(
tableColumnName
.
equals
(
joinColumnName
))
{
if
(
equalsToken
(
tableColumnName
,
joinColumnName
))
{
join
.
addNaturalJoinColumn
(
c
);
join
.
addNaturalJoinColumn
(
c
);
Expression
tableExpr
=
new
ExpressionColumn
(
database
,
tableSchema
,
last
Expression
tableExpr
=
new
ExpressionColumn
(
database
,
tableSchema
,
last
.
getTableAlias
(),
tableColumnName
);
.
getTableAlias
(),
tableColumnName
);
...
@@ -2134,7 +2152,7 @@ public class Parser {
...
@@ -2134,7 +2152,7 @@ public class Parser {
name
=
readColumnIdentifier
();
name
=
readColumnIdentifier
();
if
(
readIf
(
"."
))
{
if
(
readIf
(
"."
))
{
String
databaseName
=
schema
;
String
databaseName
=
schema
;
if
(!
database
.
getShortName
().
equals
(
databaseName
))
{
if
(!
equalsToken
(
database
.
getShortName
(),
databaseName
))
{
throw
Message
.
getSQLException
(
ErrorCode
.
DATABASE_NOT_FOUND_1
,
databaseName
);
throw
Message
.
getSQLException
(
ErrorCode
.
DATABASE_NOT_FOUND_1
,
databaseName
);
}
}
schema
=
objectName
;
schema
=
objectName
;
...
@@ -2223,13 +2241,13 @@ public class Parser {
...
@@ -2223,13 +2241,13 @@ public class Parser {
}
}
}
else
{
}
else
{
read
();
read
();
if
(
"X"
.
equals
(
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
if
(
equalsToken
(
"X"
,
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
read
();
read
();
byte
[]
buffer
=
ByteUtils
.
convertStringToBytes
(
currentValue
.
getString
());
byte
[]
buffer
=
ByteUtils
.
convertStringToBytes
(
currentValue
.
getString
());
r
=
ValueExpression
.
get
(
ValueBytes
.
getNoCopy
(
buffer
));
r
=
ValueExpression
.
get
(
ValueBytes
.
getNoCopy
(
buffer
));
}
else
if
(
readIf
(
"."
))
{
}
else
if
(
readIf
(
"."
))
{
r
=
readTermObjectDot
(
name
);
r
=
readTermObjectDot
(
name
);
}
else
if
(
"CASE"
.
equals
(
name
))
{
}
else
if
(
equalsToken
(
"CASE"
,
name
))
{
// CASE must be processed before (,
// CASE must be processed before (,
// otherwise CASE(3) would be a function call, which it is
// otherwise CASE(3) would be a function call, which it is
// not
// not
...
@@ -2241,9 +2259,9 @@ public class Parser {
...
@@ -2241,9 +2259,9 @@ public class Parser {
}
}
}
else
if
(
readIf
(
"("
))
{
}
else
if
(
readIf
(
"("
))
{
r
=
readFunction
(
name
);
r
=
readFunction
(
name
);
}
else
if
(
"CURRENT_USER"
.
equals
(
name
))
{
}
else
if
(
equalsToken
(
"CURRENT_USER"
,
name
))
{
r
=
readFunctionWithoutParameters
(
"USER"
);
r
=
readFunctionWithoutParameters
(
"USER"
);
}
else
if
(
"CURRENT"
.
equals
(
name
))
{
}
else
if
(
equalsToken
(
"CURRENT"
,
name
))
{
if
(
readIf
(
"TIMESTAMP"
))
{
if
(
readIf
(
"TIMESTAMP"
))
{
r
=
readFunctionWithoutParameters
(
"CURRENT_TIMESTAMP"
);
r
=
readFunctionWithoutParameters
(
"CURRENT_TIMESTAMP"
);
}
else
if
(
readIf
(
"TIME"
))
{
}
else
if
(
readIf
(
"TIME"
))
{
...
@@ -2253,24 +2271,24 @@ public class Parser {
...
@@ -2253,24 +2271,24 @@ public class Parser {
}
else
{
}
else
{
r
=
new
ExpressionColumn
(
database
,
null
,
null
,
name
);
r
=
new
ExpressionColumn
(
database
,
null
,
null
,
name
);
}
}
}
else
if
(
"NEXT"
.
equals
(
name
)
&&
readIf
(
"VALUE"
))
{
}
else
if
(
equalsToken
(
"NEXT"
,
name
)
&&
readIf
(
"VALUE"
))
{
read
(
"FOR"
);
read
(
"FOR"
);
Sequence
sequence
=
readSequence
();
Sequence
sequence
=
readSequence
();
r
=
new
SequenceValue
(
sequence
);
r
=
new
SequenceValue
(
sequence
);
}
else
if
(
"DATE"
.
equals
(
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
}
else
if
(
equalsToken
(
"DATE"
,
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
String
date
=
currentValue
.
getString
();
String
date
=
currentValue
.
getString
();
read
();
read
();
r
=
ValueExpression
.
get
(
ValueDate
.
get
(
ValueDate
.
parseDate
(
date
)));
r
=
ValueExpression
.
get
(
ValueDate
.
get
(
ValueDate
.
parseDate
(
date
)));
}
else
if
(
"TIME"
.
equals
(
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
}
else
if
(
equalsToken
(
"TIME"
,
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
String
time
=
currentValue
.
getString
();
String
time
=
currentValue
.
getString
();
read
();
read
();
r
=
ValueExpression
.
get
(
ValueTime
.
get
(
ValueTime
.
parseTime
(
time
)));
r
=
ValueExpression
.
get
(
ValueTime
.
get
(
ValueTime
.
parseTime
(
time
)));
}
else
if
(
"TIMESTAMP"
.
equals
(
name
)
&&
currentTokenType
==
VALUE
}
else
if
(
equalsToken
(
"TIMESTAMP"
,
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
String
timestamp
=
currentValue
.
getString
();
String
timestamp
=
currentValue
.
getString
();
read
();
read
();
r
=
ValueExpression
.
get
(
ValueTimestamp
.
getNoCopy
(
ValueTimestamp
.
parseTimestamp
(
timestamp
)));
r
=
ValueExpression
.
get
(
ValueTimestamp
.
getNoCopy
(
ValueTimestamp
.
parseTimestamp
(
timestamp
)));
}
else
if
(
"E"
.
equals
(
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
}
else
if
(
equalsToken
(
"E"
,
name
)
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
String
text
=
currentValue
.
getString
();
String
text
=
currentValue
.
getString
();
read
();
read
();
r
=
ValueExpression
.
get
(
ValueString
.
get
(
text
));
r
=
ValueExpression
.
get
(
ValueString
.
get
(
text
));
...
@@ -2485,8 +2503,8 @@ public class Parser {
...
@@ -2485,8 +2503,8 @@ public class Parser {
s
=
currentToken
;
s
=
currentToken
;
read
();
read
();
}
}
if
(
"."
.
equals
(
currentToken
))
{
if
(
equalsToken
(
"."
,
currentToken
))
{
if
(
schemaName
.
equalsIgnoreCase
(
database
.
getShortName
()))
{
if
(
equalsToken
(
schemaName
,
database
.
getShortName
()))
{
read
(
"."
);
read
(
"."
);
schemaName
=
s
;
schemaName
=
s
;
if
(
currentTokenType
!=
IDENTIFIER
)
{
if
(
currentTokenType
!=
IDENTIFIER
)
{
...
@@ -2521,14 +2539,14 @@ public class Parser {
...
@@ -2521,14 +2539,14 @@ public class Parser {
}
}
private
void
read
(
String
expected
)
throws
SQLException
{
private
void
read
(
String
expected
)
throws
SQLException
{
if
(
!
expected
.
equals
(
currentToken
)
||
currentTokenQuoted
)
{
if
(
currentTokenQuoted
||
!
equalsToken
(
expected
,
currentToken
)
)
{
throw
Message
.
getSyntaxError
(
sqlCommand
,
parseIndex
,
expected
);
throw
Message
.
getSyntaxError
(
sqlCommand
,
parseIndex
,
expected
);
}
}
read
();
read
();
}
}
private
boolean
readIf
(
String
token
)
throws
SQLException
{
private
boolean
readIf
(
String
token
)
throws
SQLException
{
if
(
token
.
equals
(
currentToken
)
&&
!
currentTokenQuoted
)
{
if
(
!
currentTokenQuoted
&&
equalsToken
(
token
,
currentToken
)
)
{
read
();
read
();
return
true
;
return
true
;
}
}
...
@@ -2537,7 +2555,7 @@ public class Parser {
...
@@ -2537,7 +2555,7 @@ public class Parser {
}
}
private
boolean
isToken
(
String
token
)
{
private
boolean
isToken
(
String
token
)
{
boolean
result
=
token
.
equals
(
currentToken
)
&&
!
currentTokenQuoted
;
boolean
result
=
equalsToken
(
token
,
currentToken
)
&&
!
currentTokenQuoted
;
if
(
result
)
{
if
(
result
)
{
return
true
;
return
true
;
}
}
...
@@ -2545,6 +2563,16 @@ public class Parser {
...
@@ -2545,6 +2563,16 @@ public class Parser {
return
false
;
return
false
;
}
}
private
boolean
equalsToken
(
String
a
,
String
b
)
{
if
(
a
.
equals
(
b
))
{
return
true
;
}
if
(!
identifiersToUpper
&&
a
.
equalsIgnoreCase
(
b
))
{
return
true
;
}
return
false
;
}
private
void
addExpected
(
String
token
)
{
private
void
addExpected
(
String
token
)
{
if
(
expectedList
!=
null
)
{
if
(
expectedList
!=
null
)
{
expectedList
.
add
(
token
);
expectedList
.
add
(
token
);
...
@@ -2956,8 +2984,10 @@ public class Parser {
...
@@ -2956,8 +2984,10 @@ public class Parser {
break
;
break
;
default
:
default
:
if
(
c
>=
'a'
&&
c
<=
'z'
)
{
if
(
c
>=
'a'
&&
c
<=
'z'
)
{
if
(
identifiersToUpper
)
{
command
[
i
]
=
(
char
)
(
c
-
(
'a'
-
'A'
));
command
[
i
]
=
(
char
)
(
c
-
(
'a'
-
'A'
));
changed
=
true
;
changed
=
true
;
}
type
=
CHAR_NAME
;
type
=
CHAR_NAME
;
}
else
if
(
c
>=
'A'
&&
c
<=
'Z'
)
{
}
else
if
(
c
>=
'A'
&&
c
<=
'Z'
)
{
type
=
CHAR_NAME
;
type
=
CHAR_NAME
;
...
@@ -2966,6 +2996,7 @@ public class Parser {
...
@@ -2966,6 +2996,7 @@ public class Parser {
}
else
{
}
else
{
if
(
Character
.
isJavaIdentifierPart
(
c
))
{
if
(
Character
.
isJavaIdentifierPart
(
c
))
{
type
=
CHAR_NAME
;
type
=
CHAR_NAME
;
if
(
identifiersToUpper
)
{
char
u
=
Character
.
toUpperCase
(
c
);
char
u
=
Character
.
toUpperCase
(
c
);
if
(
u
!=
c
)
{
if
(
u
!=
c
)
{
command
[
i
]
=
u
;
command
[
i
]
=
u
;
...
@@ -2974,6 +3005,7 @@ public class Parser {
...
@@ -2974,6 +3005,7 @@ public class Parser {
}
}
}
}
}
}
}
types
[
i
]
=
type
;
types
[
i
]
=
type
;
lastType
=
type
;
lastType
=
type
;
}
}
...
@@ -3076,6 +3108,14 @@ public class Parser {
...
@@ -3076,6 +3108,14 @@ public class Parser {
return
getSaveTokenType
(
s
,
database
.
getMode
().
supportOffsetFetch
);
return
getSaveTokenType
(
s
,
database
.
getMode
().
supportOffsetFetch
);
}
}
private
boolean
isKeyword
(
String
s
)
{
if
(!
identifiersToUpper
)
{
// if not yet converted to uppercase, do it now
s
=
StringUtils
.
toUpperEnglish
(
s
);
}
return
isKeyword
(
s
,
false
);
}
/**
/**
* Checks if this string is a SQL keyword.
* Checks if this string is a SQL keyword.
*
*
...
@@ -3334,7 +3374,7 @@ public class Parser {
...
@@ -3334,7 +3374,7 @@ public class Parser {
throw
Message
.
getSQLException
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
currentToken
);
throw
Message
.
getSQLException
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
currentToken
);
}
}
}
}
if
(
database
.
getIgnoreCase
()
&&
dataType
.
type
==
Value
.
STRING
&&
!
"VARCHAR_CASESENSITIVE"
.
equals
(
original
))
{
if
(
database
.
getIgnoreCase
()
&&
dataType
.
type
==
Value
.
STRING
&&
!
equalsToken
(
"VARCHAR_CASESENSITIVE"
,
original
))
{
original
=
"VARCHAR_IGNORECASE"
;
original
=
"VARCHAR_IGNORECASE"
;
dataType
=
DataType
.
getTypeByName
(
original
);
dataType
=
DataType
.
getTypeByName
(
original
);
}
}
...
@@ -3645,7 +3685,7 @@ public class Parser {
...
@@ -3645,7 +3685,7 @@ public class Parser {
boolean
ifNotExists
=
readIfNoExists
();
boolean
ifNotExists
=
readIfNoExists
();
String
constantName
=
readIdentifierWithSchema
();
String
constantName
=
readIdentifierWithSchema
();
Schema
schema
=
getSchema
();
Schema
schema
=
getSchema
();
if
(
isKeyword
(
constantName
,
false
))
{
if
(
isKeyword
(
constantName
))
{
throw
Message
.
getSQLException
(
ErrorCode
.
CONSTANT_ALREADY_EXISTS_1
,
constantName
);
throw
Message
.
getSQLException
(
ErrorCode
.
CONSTANT_ALREADY_EXISTS_1
,
constantName
);
}
}
read
(
"VALUE"
);
read
(
"VALUE"
);
...
@@ -3662,7 +3702,7 @@ public class Parser {
...
@@ -3662,7 +3702,7 @@ public class Parser {
CreateAggregate
command
=
new
CreateAggregate
(
session
);
CreateAggregate
command
=
new
CreateAggregate
(
session
);
command
.
setForce
(
force
);
command
.
setForce
(
force
);
String
name
=
readUniqueIdentifier
();
String
name
=
readUniqueIdentifier
();
if
(
isKeyword
(
name
,
false
)
||
Function
.
getFunction
(
database
,
name
)
!=
null
||
Aggregate
.
getAggregateType
(
name
)
>=
0
)
{
if
(
isKeyword
(
name
)
||
Function
.
getFunction
(
database
,
name
)
!=
null
||
Aggregate
.
getAggregateType
(
name
)
>=
0
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
FUNCTION_ALIAS_ALREADY_EXISTS_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
FUNCTION_ALIAS_ALREADY_EXISTS_1
,
name
);
}
}
command
.
setName
(
name
);
command
.
setName
(
name
);
...
@@ -3772,7 +3812,7 @@ public class Parser {
...
@@ -3772,7 +3812,7 @@ public class Parser {
CreateFunctionAlias
command
=
new
CreateFunctionAlias
(
session
);
CreateFunctionAlias
command
=
new
CreateFunctionAlias
(
session
);
command
.
setForce
(
force
);
command
.
setForce
(
force
);
String
name
=
readUniqueIdentifier
();
String
name
=
readUniqueIdentifier
();
if
(
isKeyword
(
name
,
false
)
||
Function
.
getFunction
(
database
,
name
)
!=
null
||
Aggregate
.
getAggregateType
(
name
)
>=
0
)
{
if
(
isKeyword
(
name
)
||
Function
.
getFunction
(
database
,
name
)
!=
null
||
Aggregate
.
getAggregateType
(
name
)
>=
0
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
FUNCTION_ALIAS_ALREADY_EXISTS_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
FUNCTION_ALIAS_ALREADY_EXISTS_1
,
name
);
}
}
command
.
setAliasName
(
name
);
command
.
setAliasName
(
name
);
...
@@ -4140,7 +4180,7 @@ public class Parser {
...
@@ -4140,7 +4180,7 @@ public class Parser {
readIfEqualOrTo
();
readIfEqualOrTo
();
if
(!
readIf
(
"ISO"
))
{
if
(!
readIf
(
"ISO"
))
{
String
s
=
readString
();
String
s
=
readString
();
if
(!
s
.
equals
(
"ISO"
))
{
if
(!
equalsToken
(
s
,
"ISO"
))
{
throw
getSyntaxError
();
throw
getSyntaxError
();
}
}
}
}
...
@@ -4178,7 +4218,7 @@ public class Parser {
...
@@ -4178,7 +4218,7 @@ public class Parser {
Set
command
=
new
Set
(
session
,
SetTypes
.
COLLATION
);
Set
command
=
new
Set
(
session
,
SetTypes
.
COLLATION
);
String
name
=
readAliasIdentifier
();
String
name
=
readAliasIdentifier
();
command
.
setString
(
name
);
command
.
setString
(
name
);
if
(
name
.
equals
(
CompareMode
.
OFF
))
{
if
(
equalsToken
(
name
,
CompareMode
.
OFF
))
{
return
command
;
return
command
;
}
}
Collator
coll
=
CompareMode
.
getCollator
(
name
);
Collator
coll
=
CompareMode
.
getCollator
(
name
);
...
@@ -4628,7 +4668,7 @@ public class Parser {
...
@@ -4628,7 +4668,7 @@ public class Parser {
private
CreateTable
parseCreateTable
(
boolean
temp
,
boolean
globalTemp
,
boolean
persistIndexes
)
throws
SQLException
{
private
CreateTable
parseCreateTable
(
boolean
temp
,
boolean
globalTemp
,
boolean
persistIndexes
)
throws
SQLException
{
boolean
ifNotExists
=
readIfNoExists
();
boolean
ifNotExists
=
readIfNoExists
();
String
tableName
=
readIdentifierWithSchema
();
String
tableName
=
readIdentifierWithSchema
();
if
(
temp
&&
globalTemp
&&
"SESSION"
.
equals
(
schemaName
))
{
if
(
temp
&&
globalTemp
&&
equalsToken
(
"SESSION"
,
schemaName
))
{
// support weird syntax: declare global temporary table session.xy
// support weird syntax: declare global temporary table session.xy
// (...) not logged
// (...) not logged
schemaName
=
session
.
getCurrentSchemaName
();
schemaName
=
session
.
getCurrentSchemaName
();
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
c264653e
...
@@ -267,6 +267,13 @@ public class SysProperties {
...
@@ -267,6 +267,13 @@ public class SysProperties {
*/
*/
public
static
final
int
ESTIMATED_FUNCTION_TABLE_ROWS
=
getIntSetting
(
"h2.estimatedFunctionTableRows"
,
1000
);
public
static
final
int
ESTIMATED_FUNCTION_TABLE_ROWS
=
getIntSetting
(
"h2.estimatedFunctionTableRows"
,
1000
);
/**
* System property <code>h2.identifiersToUpper</code> (default: true).<br />
* Unquoted identifiers in SQL statements are case insensitive and converted
* to uppercase.
*/
public
static
final
boolean
IDENTIFIERS_TO_UPPER
=
getBooleanSetting
(
"h2.identifiersToUpper"
,
true
);
/**
/**
* System property <code>h2.largeResultBufferSize</code> (default: 4096).<br />
* System property <code>h2.largeResultBufferSize</code> (default: 4096).<br />
* Buffer size for large result sets. Set this value to 0 to disable the
* Buffer size for large result sets. Set this value to 0 to disable the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论