mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
+6
-7
@@ -28,8 +28,7 @@ import com.alibaba.druid.util.JdbcConstants;
|
||||
public class PGDeleteStatement extends SQLDeleteStatement implements PGSQLStatement {
|
||||
|
||||
private boolean returning;
|
||||
private String alias;
|
||||
|
||||
|
||||
public PGDeleteStatement() {
|
||||
super (JdbcConstants.POSTGRESQL);
|
||||
}
|
||||
@@ -43,15 +42,16 @@ public class PGDeleteStatement extends SQLDeleteStatement implements PGSQLStatem
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
if (tableSource == null) {
|
||||
return null;
|
||||
}
|
||||
return tableSource.getAlias();
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
this.tableSource.setAlias(alias);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((PGASTVisitor) visitor);
|
||||
}
|
||||
@@ -73,7 +73,6 @@ public class PGDeleteStatement extends SQLDeleteStatement implements PGSQLStatem
|
||||
cloneTo(x);
|
||||
|
||||
x.returning = returning;
|
||||
x.alias = alias;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,14 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
this.inputParameters = parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.1.5
|
||||
*/
|
||||
public void setOutputParameters(List<Object> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public int getIndentCount() {
|
||||
return indentCount;
|
||||
}
|
||||
@@ -2286,10 +2294,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
public boolean visit(SQLDeleteStatement x) {
|
||||
SQLTableSource from = x.getFrom();
|
||||
String alias = x.getAlias();
|
||||
|
||||
if (from == null) {
|
||||
print0(ucase ? "DELETE FROM " : "delete from ");
|
||||
printTableSourceExpr(x.getTableName());
|
||||
|
||||
if (alias != null) {
|
||||
print(' ');
|
||||
print0(alias);
|
||||
}
|
||||
} else {
|
||||
print0(ucase ? "DELETE " : "delete ");
|
||||
printTableSourceExpr(x.getTableName());
|
||||
|
||||
@@ -18,9 +18,7 @@ package com.alibaba.druid.support.calcite;
|
||||
import com.google.common.collect.*;
|
||||
import org.apache.calcite.linq4j.tree.Expression;
|
||||
import org.apache.calcite.materialize.Lattice;
|
||||
import org.apache.calcite.schema.Function;
|
||||
import org.apache.calcite.schema.Schema;
|
||||
import org.apache.calcite.schema.SchemaPlus;
|
||||
import org.apache.calcite.schema.*;
|
||||
import org.apache.calcite.schema.Table;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -105,6 +103,11 @@ public class DDLSchema implements Schema, SchemaPlus {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema snapshot(SchemaVersion version) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> clazz) {
|
||||
return null;
|
||||
@@ -124,12 +127,10 @@ public class DDLSchema implements Schema, SchemaPlus {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentsHaveChangedSince(long lastCheck, long now) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema snapshot(long now) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@ package com.alibaba.druid.support.calcite;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
|
||||
import org.apache.calcite.config.CalciteConnectionConfig;
|
||||
import org.apache.calcite.rel.type.*;
|
||||
import org.apache.calcite.schema.Schema;
|
||||
import org.apache.calcite.schema.Statistic;
|
||||
import org.apache.calcite.schema.Table;
|
||||
import org.apache.calcite.sql.SqlCollation;
|
||||
import org.apache.calcite.sql.SqlIdentifier;
|
||||
import org.apache.calcite.sql.SqlIntervalQualifier;
|
||||
import org.apache.calcite.sql.*;
|
||||
import org.apache.calcite.sql.type.SqlTypeName;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
@@ -70,6 +69,16 @@ public class DDLTable implements Table, RelDataType {
|
||||
return Schema.TableType.TABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRolledUp(String column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rolledUpColumnValidInsideAgg(String column, SqlCall call, SqlNode parent, CalciteConnectionConfig config) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isStruct() {
|
||||
|
||||
Reference in New Issue
Block a user