mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
+10
-1
@@ -29,6 +29,7 @@ public class PGInsertStatement extends SQLInsertStatement implements PGSQLStatem
|
||||
private PGWithClause with;
|
||||
private List<ValuesClause> valuesList = new ArrayList<ValuesClause>();
|
||||
private SQLExpr returning;
|
||||
private boolean defaultValues = false;
|
||||
|
||||
public SQLExpr getReturning() {
|
||||
return returning;
|
||||
@@ -70,7 +71,15 @@ public class PGInsertStatement extends SQLInsertStatement implements PGSQLStatem
|
||||
valuesList.add(valueClause);
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
public boolean isDefaultValues() {
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
public void setDefaultValues(boolean defaultValues) {
|
||||
this.defaultValues = defaultValues;
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((PGASTVisitor) visitor);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ public class PGLexer extends Lexer {
|
||||
hasSpecial = true;
|
||||
}
|
||||
|
||||
putChar('\\');
|
||||
switch (ch) {
|
||||
case '\0':
|
||||
putChar('\0');
|
||||
@@ -139,6 +140,7 @@ public class PGLexer extends Lexer {
|
||||
arraycopy(mark + 1, buf, 0, bufPos);
|
||||
hasSpecial = true;
|
||||
putChar('\'');
|
||||
putChar('\'');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+23
-1
@@ -21,6 +21,7 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCurrentOfCursorExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAlterTableAlterColumn;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
@@ -101,6 +102,12 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.DEFAULT) {
|
||||
lexer.nextToken();
|
||||
accept(Token.VALUES);
|
||||
stmt.setDefaultValues(true);
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
lexer.nextToken();
|
||||
@@ -152,6 +159,14 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
SQLName tableName = exprParser.name();
|
||||
|
||||
deleteStatement.setTableName(tableName);
|
||||
|
||||
if (lexer.token() == Token.AS) {
|
||||
accept(Token.AS);
|
||||
}
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
deleteStatement.setAlias(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.USING) {
|
||||
lexer.nextToken();
|
||||
@@ -225,7 +240,14 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
|
||||
private PGWithQuery withQuery() {
|
||||
PGWithQuery withQuery = new PGWithQuery();
|
||||
withQuery.setName(this.exprParser.expr());
|
||||
|
||||
if (lexer.token() == Token.LITERAL_ALIAS) {
|
||||
withQuery.setName(new SQLIdentifierExpr("\"" + lexer.stringVal()
|
||||
+ "\""));
|
||||
} else {
|
||||
withQuery.setName(new SQLIdentifierExpr(lexer.stringVal()));
|
||||
}
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -259,11 +259,10 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) {
|
||||
String alias = this.as();
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
SQLExprTableSource exprTableSource = (SQLExprTableSource) tableSource;
|
||||
|
||||
String alias = this.as();
|
||||
PGFunctionTableSource functionTableSource = new PGFunctionTableSource(exprTableSource.getExpr());
|
||||
functionTableSource.setAlias(alias);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user