mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for pg sql parser. for issue #1950
This commit is contained in:
@@ -183,16 +183,17 @@ public class PGExprParser extends SQLExprParser {
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
return super.primaryRest(expr);
|
||||
}
|
||||
|
||||
|
||||
if ("TIMESTAMP".equalsIgnoreCase(ident)) {
|
||||
if (lexer.token() != Token.LITERAL_ALIAS //
|
||||
&& lexer.token() != Token.LITERAL_CHARS //
|
||||
&& lexer.token() != Token.WITH) {
|
||||
return new SQLIdentifierExpr("TIMESTAMP");
|
||||
return super.primaryRest(
|
||||
new SQLIdentifierExpr(ident));
|
||||
}
|
||||
|
||||
SQLTimestampExpr timestamp = new SQLTimestampExpr();
|
||||
|
||||
|
||||
if (lexer.token() == Token.WITH) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("TIME");
|
||||
@@ -214,8 +215,35 @@ public class PGExprParser extends SQLExprParser {
|
||||
accept(Token.LITERAL_CHARS);
|
||||
}
|
||||
|
||||
|
||||
return primaryRest(timestamp);
|
||||
|
||||
return primaryRest(timestamp);
|
||||
} else if ("TIMESTAMPTZ".equalsIgnoreCase(ident)) {
|
||||
if (lexer.token() != Token.LITERAL_ALIAS //
|
||||
&& lexer.token() != Token.LITERAL_CHARS //
|
||||
&& lexer.token() != Token.WITH) {
|
||||
return super.primaryRest(
|
||||
new SQLIdentifierExpr(ident));
|
||||
}
|
||||
|
||||
SQLTimestampExpr timestamp = new SQLTimestampExpr();
|
||||
timestamp.setWithTimeZone(true);
|
||||
|
||||
String literal = lexer.stringVal();
|
||||
timestamp.setLiteral(literal);
|
||||
accept(Token.LITERAL_CHARS);
|
||||
|
||||
if (lexer.identifierEquals("AT")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("TIME");
|
||||
acceptIdentifier("ZONE");
|
||||
|
||||
String timezone = lexer.stringVal();
|
||||
timestamp.setTimeZone(timezone);
|
||||
accept(Token.LITERAL_CHARS);
|
||||
}
|
||||
|
||||
|
||||
return primaryRest(timestamp);
|
||||
} else if ("EXTRACT".equalsIgnoreCase(ident)) {
|
||||
accept(Token.LPAREN);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user