mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for refactor
This commit is contained in:
@@ -35,11 +35,7 @@ public class ResultSetMetaDataBase implements ResultSetMetaData {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (iface.isAssignableFrom(ResultSetMetaDataBase.class)) {
|
||||
if (isWrapperFor(iface)) {
|
||||
return (T) this;
|
||||
}
|
||||
return null;
|
||||
@@ -50,8 +46,12 @@ public class ResultSetMetaDataBase implements ResultSetMetaData {
|
||||
if (iface == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iface.isAssignableFrom(this.getClass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ResultSetMetaDataBase.class.isAssignableFrom(iface);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnectionClosedException;
|
||||
|
||||
public abstract class StatementBase implements Statement {
|
||||
|
||||
private Connection connection;
|
||||
@@ -41,8 +43,14 @@ public abstract class StatementBase implements Statement {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
protected void checkOpen() throws SQLException {
|
||||
|
||||
protected void checkOpen() throws SQLException, MockConnectionClosedException {
|
||||
if (closed) {
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
if (this.connection != null && this.connection.isClosed()) {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,11 +206,7 @@ public abstract class StatementBase implements Statement {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (iface.isInstance(this)) {
|
||||
if (isWrapperFor(iface)) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -215,7 +219,7 @@ public abstract class StatementBase implements Statement {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iface.isInstance(this)) {
|
||||
if (iface == this.getClass() || iface.isInstance(this)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class HiveCreateTableParser extends SQLCreateTableParser {
|
||||
public SQLCreateTableStatement parseCrateTable(boolean acceptCreate) {
|
||||
HiveCreateTableStatement stmt = (HiveCreateTableStatement) super.parseCrateTable(acceptCreate);
|
||||
|
||||
if (lexer.token() == Token.PARTITIONED) {
|
||||
if (identifierEquals("PARTITIONED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
accept(Token.LPAREN);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.alibaba.druid.sql.dialect.hive.parser;
|
||||
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
|
||||
|
||||
public class HiveExprParser extends SQLExprParser {
|
||||
public HiveExprParser(String sql) throws ParserException{
|
||||
super(new HiveLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public HiveExprParser(Lexer lexer){
|
||||
super(lexer);
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,6 @@ public class HiveLexer extends Lexer {
|
||||
map.put("ANY", Token.ANY);
|
||||
|
||||
map.put("WITH", Token.WITH);
|
||||
map.put("PARTITIONED", Token.PARTITIONED);
|
||||
map.put("SHOW", Token.SHOW);
|
||||
map.put("TABLES", Token.TABLES);
|
||||
|
||||
DEFAULT_SQL_SERVER_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class HiveStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
public boolean parseStatementListDialect(List<SQLStatement> statementList) {
|
||||
if (lexer.token() == Token.SHOW) {
|
||||
if (identifierEquals("SHOW")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.TABLES) {
|
||||
if (identifierEquals("TABLES")) {
|
||||
lexer.nextToken();
|
||||
|
||||
HiveShowTablesStatement stmt = new HiveShowTablesStatement();
|
||||
@@ -41,7 +41,7 @@ public class HiveStatementParser extends SQLStatementParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.token());
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGExprParser extends SQLExprParser{
|
||||
public PGExprParser(String sql) throws ParserException{
|
||||
super(sql);
|
||||
super(new PGLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public PGExprParser(Lexer lexer){
|
||||
|
||||
@@ -185,6 +185,10 @@ public class Lexer {
|
||||
public final Token token() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return this.token + " " + this.stringVal();
|
||||
}
|
||||
|
||||
public final void nextToken() {
|
||||
sp = 0;
|
||||
|
||||
@@ -184,6 +184,13 @@ public class SQLStatementParser extends SQLParser {
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("COMMIT")) {
|
||||
SQLStatement stmt = parseCommit();
|
||||
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
char mark_ch = lexer.current();
|
||||
@@ -225,6 +232,10 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseCommit() {
|
||||
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
|
||||
public SQLUseStatement parseUse() {
|
||||
accept(Token.USE);
|
||||
|
||||
@@ -167,9 +167,6 @@ public enum Token {
|
||||
TOP("TOP"),
|
||||
|
||||
// hive
|
||||
PARTITIONED("PARTITIONED"),
|
||||
SHOW("SHOW"),
|
||||
TABLES("TABLES"),
|
||||
|
||||
EOF,
|
||||
ERROR,
|
||||
|
||||
Reference in New Issue
Block a user