mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved db2 parser create table support.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.db2.ast.stmt;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.db2.ast.DB2Statement;
|
||||
import com.alibaba.druid.sql.dialect.db2.visitor.DB2ASTVisitor;
|
||||
@@ -24,6 +25,9 @@ public class DB2CreateTableStatement extends SQLCreateTableStatement implements
|
||||
private boolean dataCaptureNone;
|
||||
private boolean dataCaptureChanges;
|
||||
|
||||
protected SQLName database;
|
||||
protected SQLName validproc;
|
||||
|
||||
public boolean isDataCaptureNone() {
|
||||
return dataCaptureNone;
|
||||
}
|
||||
@@ -40,6 +44,28 @@ public class DB2CreateTableStatement extends SQLCreateTableStatement implements
|
||||
this.dataCaptureChanges = dataCaptureChanges;
|
||||
}
|
||||
|
||||
public SQLName getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(SQLName database) {
|
||||
if (database != null) {
|
||||
database.setParent(this);
|
||||
}
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public SQLName getValidproc() {
|
||||
return validproc;
|
||||
}
|
||||
|
||||
public void setValidproc(SQLName validproc) {
|
||||
if (validproc != null) {
|
||||
validproc.setParent(this);
|
||||
}
|
||||
this.validproc = validproc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor instanceof DB2ASTVisitor) {
|
||||
@@ -57,6 +83,8 @@ public class DB2CreateTableStatement extends SQLCreateTableStatement implements
|
||||
this.acceptChild(visitor, tableElementList);
|
||||
this.acceptChild(visitor, inherits);
|
||||
this.acceptChild(visitor, select);
|
||||
this.acceptChild(visitor, database);
|
||||
this.acceptChild(visitor, validproc);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,9 @@ public class DB2CreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.DATABASE) {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
lexer.nextToken();
|
||||
SQLName database = this.exprParser.name();
|
||||
createTable.setDatabase(database);
|
||||
} else if (lexer.identifierEquals("tablespace")) {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
} else {
|
||||
@@ -164,6 +166,10 @@ public class DB2CreateTableParser extends SQLCreateTableParser {
|
||||
acceptIdentifier("HASHING");
|
||||
createTable.setPartitioning(partitionBy);
|
||||
continue;
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.VALIDPROC)) {
|
||||
lexer.nextToken();
|
||||
SQLName validproc = this.exprParser.name();
|
||||
createTable.setValidproc(validproc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,20 @@ public class DB2OutputVisitor extends SQLASTOutputVisitor implements DB2ASTVisit
|
||||
tablespace.accept(this);
|
||||
}
|
||||
|
||||
SQLName database = x.getDatabase();
|
||||
if (database != null) {
|
||||
println();
|
||||
print("IN DATABASE ");
|
||||
database.accept(this);
|
||||
}
|
||||
|
||||
SQLName validproc = x.getValidproc();
|
||||
if (validproc != null) {
|
||||
println();
|
||||
print("VALIDPROC ");
|
||||
validproc.accept(this);
|
||||
}
|
||||
|
||||
SQLPartitionBy partitionBy = x.getPartitioning();
|
||||
if (partitionBy != null) {
|
||||
println();
|
||||
|
||||
@@ -512,5 +512,6 @@ public final class FnvHash {
|
||||
long LATERAL = fnv1a_64_lower("LATERAL");
|
||||
long NONE = fnv1a_64_lower("NONE");
|
||||
long PARTITIONING = fnv1a_64_lower("PARTITIONING");
|
||||
long VALIDPROC = fnv1a_64_lower("VALIDPROC");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user