Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
714b445d
提交
714b445d
authored
2月 09, 2018
作者:
thomasmueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove old changelog entries
上级
c628a91c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
212 行增加
和
377 行删除
+212
-377
changelog.html
h2/src/docsrc/html/changelog.html
+0
-377
ParserUtil.java
h2/src/main/org/h2/util/ParserUtil.java
+212
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
714b445d
...
...
@@ -566,381 +566,4 @@ table with an LOB column.
</li>
</ul>
<h2>
Version 1.4.189 Beta (2015-09-13)
</h2>
<ul>
<li>
Add support for dropping multiple columns in ALTER TABLE DROP COLUMN...
</li>
<li>
Fix bug in XA management when doing rollback after prepare. Patch by Stephane Lacoin.
</li>
<li>
MVStore CLOB and BLOB: An exception with the message "Block not found" could be thrown
when using the MVStore storage, when copying LOB objects
(for example due to "alter table" on a table with a LOB object),
and then re-opening the database.
</li>
<li>
Fix for issue #171: Broken QueryStatisticsData duration data when trace level smaller than TraceSystem.INFO
</li>
<li>
Pull request #170: Added SET QUERY_STATISTICS_MAX_ENTRIES
</li>
<li>
Pull request #165: Fix compatibility postgresql function string_agg
</li>
<li>
Pull request #163: improved performance when not using the default timezone.
</li>
<li>
Local temporary tables with many rows did not work correctly due to automatic analyze.
</li>
<li>
Server mode: concurrently using the same connection could throw an exception
"Connection is broken: unexpected status".
</li>
<li>
Performance improvement for metadata queries that join against the COLUMNS metadata table.
</li>
<li>
An ArrayIndexOutOfBoundsException was thrown in some cases
when opening an old version 1.3 database, or an 1.4 database with
both "mv_store=false" and the system property "h2.storeLocalTime" set to false.
It mainly showed up with an index on a time, date, or timestamp column.
The system property "h2.storeLocalTime" is no longer supported
(MVStore databases always store local time, and PageStore now databases never do).
</li>
</ul>
<h2>
Version 1.4.188 Beta (2015-08-01)
</h2>
<ul>
<li>
Server mode: CLOB processing for texts larger than about 1 MB sometimes did not work.
</li>
<li>
Server mode: BLOB processing for binaries larger than 2 GB did not work.
</li>
<li>
Multi-threaded processing: concurrent deleting the same row could throw the exception
"Row not found when trying to delete".
</li>
<li>
MVStore transactions: a thread could see a change of a different thread
within a different map. Pull request #153.
</li>
<li>
H2 Console: improved IBM DB2 compatibility.
</li>
<li>
A thread deadlock detector (disabled by default) can help
detect and analyze Java level deadlocks.
To enable, set the system property "h2.threadDeadlockDetector" to true.
</li>
<li>
Performance improvement for metadata queries that join against the COLUMNS metadata table.
</li>
<li>
MVStore: power failure could corrupt the store, if writes were re-ordered.
</li>
<li>
For compatibility with other databases, support for (double and float)
-0.0 has been removed. 0.0 is used instead.
</li>
<li>
Fix for #134, Column name with a # character. Patch by bradmesserle.
</li>
<li>
In version 1.4.186, "order by" was broken in some cases
due to the change "Make the planner use indexes for sorting when doing a GROUP BY".
The change was reverted.
</li>
<li>
Pull request #146: Improved CompareMode.
</li>
<li>
Fix for #144, JdbcResultSet.setFetchDirection() throws "Feature not supported".
</li>
<li>
Fix for issue #143, deadlock between two sessions hitting the same sequence on a column.
</li>
<li>
Pull request #137: SourceCompiler should not throw a syntax error on javac warning.
</li>
<li>
MVStore: out of memory while storing could corrupt the store
(theoretically, a rollback would be possible, but this case is not yet implemented).
</li>
<li>
The compressed in-memory file systems (memLZF:) could not be used in the MVStore.
</li>
<li>
The in-memory file systems (memFS: and memLZF:) did not support files larger than 2 GB
due to an integer overflow.
</li>
<li>
Pull request #138: Added the simple Oracle function: ORA_HASH (+ tests) #138
</li>
<li>
Timestamps in the trace log follow the format (yyyy-MM-dd HH:mm:ss) instead
of the old format (MM-dd HH:mm:ss). Patch by Richard Bull.
</li>
<li>
Pull request #125: Improved Oracle compatibility with "truncate" with timestamps and dates.
</li>
<li>
Pull request #127: Linked tables now support geometry columns.
</li>
<li>
ABS(CAST(0.0 AS DOUBLE)) returned -0.0 instead of 0.0.
</li>
<li>
BNF auto-completion failed with unquoted identifiers.
</li>
<li>
Oracle compatibility: empty strings were not converted to NULL when using prepared statements.
</li><li>
PostgreSQL compatibility: new syntax "create index ... using ...".
</li><li>
There was a bug in DataType.convertToValue when reading a ResultSet from a ResultSet.
</li><li>
Pull request #116: Improved concurrency in the trace system.
</li><li>
Issue 609: the spatial index did not support NULL.
</li><li>
Granting a schema is now supported.
</li><li>
Linked tables did not work when a function-based index is present (Oracle).
</li><li>
Creating a user with a null password, salt, or hash threw a NullPointerException.
</li><li>
Foreign key: don't add a single column index if column
is leading key of existing index.
</li><li>
Pull request #4: Creating and removing temporary tables was getting
slower and slower over time, because an internal object id was allocated but
never de-allocated.
</li><li>
Issue 609: the spatial index did not support NULL with update and delete operations.
</li><li>
Pull request #2: Add external metadata type support (table type "external")
</li><li>
MS SQL Server: the CONVERT method did not work in views
and derived tables.
</li><li>
Java 8 compatibility for "regexp_replace".
</li><li>
When in cluster mode, and one of the nodes goes down,
we need to log the problem with priority "error", not "debug"
</li></ul>
<h2>
Version 1.4.187 Beta (2015-04-10)
</h2>
<ul><li>
MVStore: concurrent changes to the same row could result in
the exception "The transaction log might be corrupt for key ...".
This could only be reproduced with 3 or more threads.
</li><li>
Results with CLOB or BLOB data are no longer reused.
</li><li>
References to BLOB and CLOB objects now have a timeout.
The configuration setting is LOB_TIMEOUT (default 5 minutes).
This should avoid growing the database file if there are many queries that return BLOB or CLOB objects,
and the database is not closed for a longer time.
</li><li>
MVStore: when committing a session that removed LOB values,
changes were flushed unnecessarily.
</li><li>
Issue 610: possible integer overflow in WriteBuffer.grow().
</li><li>
Issue 609: the spatial index did not support NULL (ClassCastException).
</li><li>
MVStore: in some cases, CLOB/BLOB data blocks were removed
incorrectly when opening a database.
</li><li>
MVStore: updates that affected many rows were were slow
in some cases if there was a secondary index.
</li><li>
Using "runscript" with autocommit disabled could result
in a lock timeout on the internal table "SYS".
</li><li>
Issue 603: there was a memory leak when using H2 in a web application.
Apache Tomcat logged an error message: "The web application ...
created a ThreadLocal with key of type [org.h2.util.DateTimeUtils$1]".
</li><li>
When using the MVStore,
running a SQL script generate by the Recover tool from a PageStore file
failed with a strange error message (NullPointerException),
now a clear error message is shown.
</li><li>
Issue 605: with version 1.4.186, opening a database could result in
an endless loop in LobStorageMap.init.
</li><li>
Queries that use the same table alias multiple times now work.
Before, the select expression list was expanded incorrectly.
Example: "select * from a as x, b as x".
</li><li>
The MySQL compatibility feature "insert ... on duplicate key update"
did not work with a non-default schema.
</li><li>
Issue 599: the condition "in(x, y)" could not be used in the select list
when using "group by".
</li><li>
The LIRS cache could grow larger than the allocated memory.
</li><li>
A new file system implementation that re-opens the file if it was closed due
to the application calling Thread.interrupt(). File name prefix "retry:".
Please note it is strongly recommended to avoid calling Thread.interrupt;
this is a problem for various libraries, including Apache Lucene.
</li><li>
MVStore: use RandomAccessFile file system if the file name starts with "file:".
</li><li>
Allow DATEADD to take a long value for count when manipulating milliseconds.
</li><li>
When using MV_STORE=TRUE and the SET CACHE_SIZE setting, the cache size was incorrectly set,
so that it was effectively 1024 times smaller than it should be.
</li><li>
Concurrent CREATE TABLE... IF NOT EXISTS in the presence of MULTI_THREAD=TRUE could
throw an exception.
</li><li>
Fix bug in MVStore when creating lots of temporary tables, where we could run out of
transaction IDs.
</li><li>
Add support for PostgreSQL STRING_AGG function. Patch by Fred Aquiles.
</li><li>
Fix bug in "jdbc:h2:nioMemFS" isRoot() function.
Also, the page size was increased to 64 KB.
</li></ul>
<h2>
Version 1.4.186 Beta (2015-03-02)
</h2>
<ul><li>
The Servlet API 3.0.1 is now used, instead of 2.4.
</li><li>
MVStore: old chunks no longer removed in append-only mode.
</li><li>
MVStore: the cache for page references could grow far too big, resulting in out of memory in some cases.
</li><li>
MVStore: orphaned lob objects were not correctly removed in some cases,
making the database grow unnecessarily.
</li><li>
MVStore: the maximum cache size was artificially limited to 2 GB
(due to an integer overflow).
</li><li>
MVStore / TransactionStore: concurrent updates could result in a
"Too many open transactions" exception.
</li><li>
StringUtils.toUpperEnglish now has a small cache.
This should speed up reading from a ResultSet when using the column name.
</li><li>
MVStore: up to 65535 open transactions are now supported.
Previously, the limit was at most 65535 transactions between the oldest open and the
newest open transaction (which was quite a strange limit).
</li><li>
The default limit for in-place LOB objects was changed from 128 to 256 bytes.
This is because each read creates a reference to a LOB, and maintaining the references
is a big overhead. With the higher limit, less references are needed.
</li><li>
Tables without columns didn't work.
(The use case for such tables is testing.)
</li><li>
The LIRS cache now resizes the table automatically in all cases
and no longer needs the averageMemory configuration.
</li><li>
Creating a linked table from an MVStore database to a non-MVStore database
created a second (non-MVStore) database file.
</li><li>
In version 1.4.184, a bug was introduced that broke queries
that have both joins and wildcards, for example:
select * from dual join(select x from dual) on 1=1
</li><li>
Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of out-of-range time values.
</li><li>
Allow declaring triggers as source code (like functions). Patch by Sylvain Cuaz.
</li><li>
Make the planner use indexes for sorting when doing a GROUP BY where
all of the GROUP BY columns are not mentioned in the select. Patch by Frederico (zepfred).
</li><li>
PostgreSQL compatibility: generate_series (as an alias for system_range). Patch by litailang.
</li><li>
Fix missing "column" type in right-hand parameter in ConditionIn. Patch by Arnaud Thimel.
</li></ul>
<h2>
Version 1.4.185 Beta (2015-01-16)
</h2>
<ul><li>
In version 1.4.184, "group by" ignored the table name,
and could pick a select column by mistake.
Example: select 0 as x from system_range(1, 2) d group by d.x;
</li><li>
New connection setting "REUSE_SPACE" (default: true). If disabled,
all changes are appended to the database file, and existing content is never overwritten.
This allows to rollback to a previous state of the database by truncating
the database file.
</li><li>
Issue 587: MVStore: concurrent compaction and store operations could result in an IllegalStateException.
</li><li>
Issue 594: Profiler.copyInThread does not work properly.
</li><li>
Script tool: Now, SCRIPT ... TO is always used (for higher speed and lower disk space usage).
</li><li>
Script tool: Fix parsing of BLOCKSIZE parameter, original patch by Ken Jorissen.
</li><li>
Fix bug in PageStore#commit method - when the ignoreBigLog flag was set,
the logic that cleared the flag could never be reached, resulting in performance degradation.
Reported by Alexander Nesterov.
</li><li>
Issue 552: Implement BIT_AND and BIT_OR aggregate functions.
</li></ul>
<h2>
Version 1.4.184 Beta (2014-12-19)
</h2>
<ul><li>
In version 1.3.183, indexes were not used if the table contains
columns with a default value generated by a sequence.
This includes tables with identity and auto-increment columns.
This bug was introduced by supporting "rownum" in views and derived tables.
</li><li>
MVStore: imported BLOB and CLOB data sometimes disappeared.
This was caused by a bug in the ObjectDataType comparison.
</li><li>
Reading from a StreamStore now throws an
IOException if the underlying data doesn't exist.
</li><li>
MVStore: if there is an exception while saving, the store is now in all cases immediately closed.
</li><li>
MVStore: the dump tool could go into an endless loop for some files.
</li><li>
MVStore: recovery for a database with many CLOB or BLOB entries is now much faster.
</li><li>
Group by with a quoted select column name alias didn't work. Example:
select 1 "a" from dual group by "a"
</li><li>
Auto-server mode: the host name is now stored in the .lock.db file.
</li></ul>
<h2>
Version 1.4.183 Beta (2014-12-13)
</h2>
<ul><li>
MVStore: the default auto-commit buffer size is now about twice as big.
This should reduce the database file size after inserting a lot of data.
</li><li>
The built-in functions "power" and "radians" now always return a double.
</li><li>
Using "row_number" or "rownum" in views or derived tables had unexpected results
if the outer query contained constraints for the given view. Example:
select b.nr, b.id from (select row_number() over() as nr, a.id as id
from (select id from test order by name) as a) as b where b.id = 1
</li><li>
MVStore: the Recover tool can now deal with more types of corruption in the file.
</li><li>
MVStore: the TransactionStore now first needs to be initialized before it can be used.
</li><li>
Views and derived tables with equality and range conditions on the same columns
did not work properly. example: select x from (select x from (select 1 as x)
where x
>
0 and x
<
2) where x = 1
</li><li>
The database URL setting PAGE_SIZE setting is now also used for the MVStore.
</li><li>
MVStore: the default page split size for persistent stores is now 4096
(it was 16 KB so far). This should reduce the database file size for most situations
(in some cases, less than half the size of the previous version).
</li><li>
With query literals disabled, auto-analyze of a table with CLOB or BLOB did not work.
</li><li>
MVStore: use a mark and sweep GC algorithm instead of reference counting,
to ensure used chunks are never overwrite, even if the reference counting
algorithm does not work properly.
</li><li>
In the multi-threaded mode, updating the column selectivity ("analyze")
in the background sometimes did not work.
</li><li>
In the multi-threaded mode, database metadata operations
did sometimes not work if the schema was changed at the same time
(for example, if tables were dropped).
</li><li>
Some CLOB and BLOB values could no longer be read when
the original row was removed (even when using the MVCC mode).
</li><li>
The MVStoreTool could throw an IllegalArgumentException.
</li><li>
Improved performance for some
date / time / timestamp conversion operations.
Thanks to Sergey Evdokimov for reporting the problem.
</li><li>
H2 Console: the built-in web server did not work properly
if an unknown file was requested.
</li><li>
MVStore: the jar file is renamed to "h2-mvstore-*.jar" and is
deployed to Maven separately.
</li><li>
MVStore: support for concurrent reads and writes is now enabled by default.
</li><li>
Server mode: the transfer buffer size has been changed from 16 KB to 64 KB,
after it was found that this improves performance on Linux quite a lot.
</li><li>
H2 Console and server mode: SSL is now disabled and TLS is used
to protect against the Poodle SSLv3 vulnerability.
The system property to disable secure anonymous connections is now
"h2.enableAnonymousTLS".
The default certificate is still self-signed, so you need to manually install
another one if you want to avoid man in the middle attacks.
</li><li>
MVStore: the R-tree did not correctly measure the memory usage.
</li><li>
MVStore: compacting a store with an R-tree did not always work.
</li><li>
Issue 581: When running in LOCK_MODE=0,
JdbcDatabaseMetaData#supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED)
should return false
</li><li>
Fix bug which could generate deadlocks when multiple connections accessed the same table.
</li><li>
Some places in the code were not respecting the value set in the "SET MAX_MEMORY_ROWS x" command
</li><li>
Fix bug which could generate a NegativeArraySizeException when performing large (>40M) row union operations
</li><li>
Fix "USE schema" command for MySQL compatibility, patch by mfulton
</li><li>
Parse and ignore the ROW_FORMAT=DYNAMIC MySQL syntax, patch by mfulton
</li></ul>
<h2>
Version 1.4.182 Beta (2014-10-17)
</h2>
<ul><li>
MVStore: improved error messages and logging;
improved behavior if there is an error when serializing objects.
</li><li>
OSGi: the MVStore packages are now exported.
</li><li>
With the MVStore option, when using multiple threads
that concurrently create indexes or tables,
it was relatively easy to get a lock timeout on the "SYS" table.
</li><li>
When using the multi-threaded option, the exception
"Unexpected code path" could be thrown, specially if the option
"analyze_auto" was set to a low value.
</li><li>
In the server mode, when reading from a CLOB or BLOB, if the connection
was closed, a NullPointerException could be thrown instead of an exception saying
the connection is closed.
</li><li>
DatabaseMetaData.getProcedures and getProcedureColumns
could throw an exception if a user defined class is not available.
</li><li>
Issue 584: the error message for a wrong sequence definition was wrong.
</li><li>
CSV tool: the rowSeparator option is no longer supported,
as the same can be achieved with the lineSeparator.
</li><li>
Descending indexes on MVStore tables did not work properly.
</li><li>
Issue 579: Conditions on the "_rowid_" pseudo-column didn't use an index
when using the MVStore.
</li><li>
Fixed documentation that "offset" and "fetch" are also keywords since version 1.4.x.
</li><li>
The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
</li><li>
Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in
other JDBC classes.
</li><li>
Issue 572: MySQL compatibility for "order by" in update statements.
</li><li>
The change in JDBC escape processing in version 1.4.181 affects both the parser
(which is running on the server) and the JDBC API (which is running on the client).
If you (or a tool you use) use the syntax "{t 'time}", or "{ts 'timestamp'}", or "{d 'data'}",
then both the client and the server need to be upgraded to version 1.4.181 or later.
</li></ul>
<h2>
Version 1.4.181 Beta (2014-08-06)
</h2>
<ul><li>
Improved MySQL compatibility by supporting "use schema".
Thanks a lot to Karl Pietrzak for the patch!
</li><li>
Writing to the trace file is now faster, specially with the debug level.
</li><li>
The database option "defrag_always=true" did not work with the MVStore.
</li><li>
The JDBC escape syntax {ts 'value'} did not interpret the value as a timestamp.
The same for {d 'value'} (for date) and {t 'value'} (for time).
Thanks to Lukas Eder for reporting the issue.
The following problem was detected after version 1.4.181 was released:
The change in JDBC escape processing affects both the parser (which is running on the server)
and the JDBC API (which is running on the client).
If you (or a tool you use) use the syntax {t 'time'}, or {ts 'timestamp'}, or {d 'date'},
then both the client and the server need to be upgraded to version 1.4.181 or later.
</li><li>
File system abstraction: support replacing existing files using move
(currently not for Windows).
</li><li>
The statement "shutdown defrag" now compresses the database (with the MVStore).
This command can greatly reduce the file size, and is relatively fast,
but is not incremental.
</li><li>
The MVStore now automatically compacts the store in the background if there is no read or write activity,
which should (after some time; sometimes about one minute) reduce the file size.
This is still work in progress, feedback is welcome!
</li><li>
Change default value of PAGE_SIZE from 2048 to 4096 to more closely match most file systems block size
(PageStore only; the MVStore already used 4096).
</li><li>
Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better
out of box experience for people with more powerful machines.
</li><li>
Handle tabs like 4 spaces in web console, patch by Martin Grajcar.
</li><li>
Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in JdbcConnection.java,
patch by BigMichi1.
</li></ul>
<h2>
Version 1.4.180 Beta (2014-07-13)
</h2>
<ul><li>
MVStore: the store is now auto-compacted automatically up to some point,
to avoid very large file sizes. This area is still work in progress.
</li><li>
Sequences of temporary tables (auto-increment or identity columns)
were persisted unnecessarily in the database file, and were not removed
when re-opening the database.
</li><li>
MVStore: an IndexOutOfBoundsException could sometimes
occur MVMap.openVersion when concurrently accessing the store.
</li><li>
The LIRS cache now re-sizes the internal hash map if needed.
</li><li>
Optionally persist session history in the H2 console. (patch from Martin Grajcar)
</li><li>
Add client-info property to get the number of servers currently in the cluster
and which servers that are available. (patch from Nikolaj Fogh)
</li><li>
Fix bug in changing encrypted DB password that kept the file handle
open when the wrong password was supplied. (test case from Jens Hohmuth).
</li><li>
Issue 567: H2 hangs for a long time then (sometimes) recovers.
Introduce a queue when doing table locking to prevent session starvation.
</li></ul>
<!-- [close] { -->
</div></td></tr></table>
<!-- } --><!-- analytics -->
</body></html>
h2/src/main/org/h2/util/ParserUtil.java
0 → 100644
浏览文件 @
714b445d
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
util
;
public
class
ParserUtil
{
/**
* A keyword.
*/
public
static
final
int
KEYWORD
=
1
;
/**
* An identifier (table name, column name,...).
*/
public
static
final
int
IDENTIFIER
=
2
;
/**
* The token "null".
*/
public
static
final
int
NULL
=
3
;
/**
* The token "true".
*/
public
static
final
int
TRUE
=
4
;
/**
* The token "false".
*/
public
static
final
int
FALSE
=
5
;
/**
* The token "rownum".
*/
public
static
final
int
ROWNUM
=
6
;
private
ParserUtil
()
{
// utility class
}
/**
* Checks if this string is a SQL keyword.
*
* @param s the token to check
* @param supportOffsetFetch if OFFSET and FETCH are keywords
* @return true if it is a keyword
*/
public
static
boolean
isKeyword
(
String
s
,
boolean
supportOffsetFetch
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
return
false
;
}
return
getSaveTokenType
(
s
,
supportOffsetFetch
,
false
)
!=
IDENTIFIER
;
}
/**
* Is this a simple identifier (in the JDBC specification sense).
*
* @param s identifier to check
* @param functionsAsKeywords treat system functions as keywords
* @return is specified identifier may be used without quotes
* @throws NullPointerException if s is {@code null}
*/
public
static
boolean
isSimpleIdentifier
(
String
s
,
boolean
functionsAsKeywords
)
{
if
(
s
.
length
()
==
0
)
{
return
false
;
}
char
c
=
s
.
charAt
(
0
);
// lowercase a-z is quoted as well
if
((!
Character
.
isLetter
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
false
;
}
for
(
int
i
=
1
,
length
=
s
.
length
();
i
<
length
;
i
++)
{
c
=
s
.
charAt
(
i
);
if
((!
Character
.
isLetterOrDigit
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
false
;
}
}
return
getSaveTokenType
(
s
,
true
,
functionsAsKeywords
)
==
IDENTIFIER
;
}
/**
* Get the token type.
*
* @param s the token
* @param supportOffsetFetch whether offset / fetch are supported
* @param functionsAsKeywords whether "current data / time" functions are keywords
* @return the token type
*/
public
static
int
getSaveTokenType
(
String
s
,
boolean
supportOffsetFetch
,
boolean
functionsAsKeywords
)
{
switch
(
s
.
charAt
(
0
))
{
case
'A'
:
return
getKeywordOrIdentifier
(
s
,
"ALL"
,
KEYWORD
);
case
'C'
:
if
(
"CHECK"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"CONSTRAINT"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"CROSS"
.
equals
(
s
))
{
return
KEYWORD
;
}
if
(
functionsAsKeywords
)
{
if
(
"CURRENT_DATE"
.
equals
(
s
)
||
"CURRENT_TIME"
.
equals
(
s
)
||
"CURRENT_TIMESTAMP"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'D'
:
return
getKeywordOrIdentifier
(
s
,
"DISTINCT"
,
KEYWORD
);
case
'E'
:
if
(
"EXCEPT"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"EXISTS"
,
KEYWORD
);
case
'F'
:
if
(
"FROM"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"FOR"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"FOREIGN"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"FULL"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
supportOffsetFetch
&&
"FETCH"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"FALSE"
,
FALSE
);
case
'G'
:
return
getKeywordOrIdentifier
(
s
,
"GROUP"
,
KEYWORD
);
case
'H'
:
return
getKeywordOrIdentifier
(
s
,
"HAVING"
,
KEYWORD
);
case
'I'
:
if
(
"INNER"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"INTERSECT"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"IS"
,
KEYWORD
);
case
'J'
:
return
getKeywordOrIdentifier
(
s
,
"JOIN"
,
KEYWORD
);
case
'L'
:
if
(
"LIMIT"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"LIKE"
,
KEYWORD
);
case
'M'
:
return
getKeywordOrIdentifier
(
s
,
"MINUS"
,
KEYWORD
);
case
'N'
:
if
(
"NOT"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"NATURAL"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"NULL"
,
NULL
);
case
'O'
:
if
(
"ON"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
supportOffsetFetch
&&
"OFFSET"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"ORDER"
,
KEYWORD
);
case
'P'
:
return
getKeywordOrIdentifier
(
s
,
"PRIMARY"
,
KEYWORD
);
case
'R'
:
return
getKeywordOrIdentifier
(
s
,
"ROWNUM"
,
ROWNUM
);
case
'S'
:
if
(
"SELECT"
.
equals
(
s
))
{
return
KEYWORD
;
}
if
(
functionsAsKeywords
)
{
if
(
"SYSDATE"
.
equals
(
s
)
||
"SYSTIME"
.
equals
(
s
)
||
"SYSTIMESTAMP"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'T'
:
if
(
"TRUE"
.
equals
(
s
))
{
return
TRUE
;
}
if
(
functionsAsKeywords
)
{
if
(
"TODAY"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'U'
:
if
(
"UNIQUE"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"UNION"
,
KEYWORD
);
case
'W'
:
if
(
"WITH"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"WHERE"
,
KEYWORD
);
default
:
return
IDENTIFIER
;
}
}
private
static
int
getKeywordOrIdentifier
(
String
s1
,
String
s2
,
int
keywordType
)
{
if
(
s1
.
equals
(
s2
))
{
return
keywordType
;
}
return
IDENTIFIER
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论