mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser derby support, bug fixed for issue #3020
This commit is contained in:
@@ -17,6 +17,7 @@ package com.alibaba.druid.sql.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.hive.stmt.HiveCreateTableStatement;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
public class SQLParser {
|
||||
protected final Lexer lexer;
|
||||
@@ -79,8 +80,11 @@ public class SQLParser {
|
||||
}
|
||||
|
||||
if (token == Token.IDENTIFIER) {
|
||||
String ident = lexer.stringVal;
|
||||
if (ident.equalsIgnoreCase("START") || ident.equalsIgnoreCase("CONNECT")) {
|
||||
long hash = lexer.hash_lower;
|
||||
if (hash == FnvHash.Constants.START
|
||||
|| hash == FnvHash.Constants.CONNECT
|
||||
|| hash == FnvHash.Constants.OFFSET
|
||||
|| hash == FnvHash.Constants.LIMIT) {
|
||||
if (must) {
|
||||
throw new ParserException("illegal alias. " + lexer.info());
|
||||
}
|
||||
|
||||
@@ -444,6 +444,7 @@ public final class FnvHash {
|
||||
long LESS = fnv1a_64_lower("LESS");
|
||||
long MAXVALUE = fnv1a_64_lower("MAXVALUE");
|
||||
long OFFSET = fnv1a_64_lower("OFFSET");
|
||||
long LIMIT = fnv1a_64_lower("LIMIT");
|
||||
long RAW = fnv1a_64_lower("RAW");
|
||||
long LONG_RAW = fnv1a_64_lower("LONG RAW");
|
||||
long LONG = fnv1a_64_lower("LONG");
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.alibaba.druid.bvt.sql.derby;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class DerbySelectTest extends TestCase {
|
||||
public void test_for_derby() throws Exception {
|
||||
String sql = "select * from sys_user offset ? rows fetch next ? rows only";
|
||||
|
||||
SQLUtils.parseSingleStatement(sql, JdbcConstants.DERBY);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user