public boolean visit(MySqlCreateTableStatement x) { if (isPrettyFormat() && x.hasBeforeComment()) { printlnComments(x.getBeforeCommentsDirect()); for (SQLCommentHint hint : x.getHints()) { hint.accept(this); print(' '); if (SQLCreateTableStatement.Type.GLOBAL_TEMPORARY.equals(x.getType())) { print0(ucase ? "TEMPORARY TABLE " : "temporary table "); } else { if (x.isIfNotExiists()) { print0(ucase ? "IF NOT EXISTS " : "if not exists "); printTableSourceExpr(x.getName()); if (x.getLike() != null) { print0(ucase ? " LIKE " : " like "); x.getLike().accept(this); printTableElements(x.getTableElementList()); for (Map.Entry<String, SQLObject> option : x.getTableOptions().entrySet()) { String key = option.getKey(); SQLExpr comment = x.getComment(); if (comment != null) { print0(ucase ? " COMMENT " : " comment ");
public void accept0(MySqlASTVisitor visitor) { if (visitor.visit(this)) { this.acceptChild(visitor, getHints()); this.acceptChild(visitor, getTableSource()); this.acceptChild(visitor, getTableElementList()); this.acceptChild(visitor, getLike()); this.acceptChild(visitor, getSelect()); } visitor.endVisit(this); }
public MySqlCreateTableStatement clone() { MySqlCreateTableStatement x = new MySqlCreateTableStatement(); cloneTo(x); return x; }
@Override public boolean visit(MySqlCreateTableStatement x) { if (repository != null && x.getParent() == null) { repository.resolve(x); } boolean val = super.visit((SQLCreateTableStatement) x); for (SQLObject option : x.getTableOptions().values()) { if (option instanceof SQLTableSource) { option.accept(this); } } return val; }
public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) { MySqlCreateTableStatement stmt = new MySqlCreateTableStatement(); if (acceptCreate) { if (lexer.hasComment() && lexer.isKeepComments()) { stmt.addBeforeComment(lexer.readAndResetComments()); stmt.setType(SQLCreateTableStatement.Type.GLOBAL_TEMPORARY); stmt.setIfNotExiists(true); stmt.setName(this.exprParser.name()); stmt.setLike(name); lexer.nextTokenValue(); SQLName name = this.exprParser.name(); stmt.setLike(name); } else if (lexer.token() == Token.SELECT) { SQLSelect query = new MySqlSelectParser(this.exprParser).select(); stmt.setSelect(query); } else { for (;;) { MySqlKey fulltextKey = (MySqlKey) parseConstraint(); fulltextKey.setIndexType("FULLTEXT"); stmt.getTableElementList().add(fulltextKey); if (lexer.token() == Token.RPAREN) { break; stmt.getTableElementList().add(idx);
for (SQLCommentHint hint : x.getHints()) { hint.accept(this); print(' '); if (SQLCreateTableStatement.Type.GLOBAL_TEMPORARY.equals(x.getType())) { print0(ucase ? "TEMPORARY TABLE " : "temporary table "); } else { if (x.isIfNotExiists()) { print0(ucase ? "IF NOT EXISTS " : "if not exists "); processTableName(x.getName()); if (x.getLike() != null) { print0(ucase ? " LIKE " : " like "); x.getLike().accept(this); int size = x.getTableElementList().size(); if (size > 0) { print0(" ("); x.getTableElementList().get(i).accept(this); for (Map.Entry<String, SQLObject> option : x.getTableOptions().entrySet()) { String key = option.getKey(); if (x.getPartitioning() != null) { println(); x.getPartitioning().accept(this);
rrs.setDdlType(DDLInfo.DDLType.CREATE_TABLE); if (createStmt.getSelect() != null) { String msg = "create table from other table not supported :" + stmt; LOGGER.info(msg); SchemaInfo schemaInfo = SchemaUtil.getSchemaInfo(sc.getUser(), schemaName, createStmt.getTableSource()); StructureMeta.TableMeta tableMeta = DbleServer.getInstance().getTmManager().getSyncTableMeta(schemaInfo.getSchema(), schemaInfo.getTable()); if (tableMeta != null && !createStmt.isIfNotExiists()) { String msg = "Table '" + schemaInfo.getSchema() + "." + schemaInfo.getTable() + "' or table meta already exists"; throw new SQLException(msg, "42S01", ErrorCode.ER_TABLE_EXISTS_ERROR); if (createStmt.getLike() != null) { SchemaInfo likeSchemaInfo = SchemaUtil.getSchemaInfo(sc.getUser(), schemaName, createStmt.getLike()); StructureMeta.TableMeta likeTableMeta = DbleServer.getInstance().getTmManager().getSyncTableMeta(likeSchemaInfo.getSchema(), likeSchemaInfo.getTable()); if (likeTableMeta == null) {
boolean acceptCreateTable(MySqlCreateTableStatement x) { SQLExprTableSource like = x.getLike(); if (like != null) { SchemaObject table = findTable((SQLName) like.getExpr()); if (table != null) { MySqlCreateTableStatement stmt = (MySqlCreateTableStatement) table.getStatement(); MySqlCreateTableStatement stmtCloned = stmt.clone(); stmtCloned.setName(x.getName().clone()); acceptCreateTable((SQLCreateTableStatement) stmtCloned); return false; } } return acceptCreateTable((SQLCreateTableStatement) x); }
for (SQLTableElement element : x.getTableElementList()) { if (element instanceof SQLColumnDefinition) { SQLColumnDefinition column = (SQLColumnDefinition) element; if (x.isPrimaryColumn(name)) { print("PRI"); } else if (x.isUNI(name)) { print("UNI"); } else if (x.isMUL(name)) { print("MUL"); } else {
private boolean parseTableOptionCharsetOrCollate(MySqlCreateTableStatement stmt) { if (lexer.identifierEquals("CHARACTER")) { lexer.nextToken(); accept(Token.SET); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("CHARACTER SET", this.exprParser.expr()); return true; } if (lexer.identifierEquals("CHARSET")) { lexer.nextToken(); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("CHARSET", this.exprParser.expr()); return true; } if (lexer.identifierEquals("COLLATE")) { lexer.nextToken(); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("COLLATE", this.exprParser.expr()); return true; } return false; }
private String addColumnIfCreate(MySqlCreateTableStatement createStmt) { removeGlobalColumnIfExist(createStmt); createStmt.getTableElementList().add(GlobalTableUtil.createCheckColumn()); return createStmt.toString(); }
public boolean visit(MySqlCreateTableStatement x) { resolve(this, x); SQLExprTableSource like = x.getLike(); if (like != null) { like.accept(this); } return false; }
stmt.setHints(hints); stmt.addBeforeComment(comments);
} else if (statement instanceof MySqlCreateTableStatement) { MySqlCreateTableStatement createStment = (MySqlCreateTableStatement) statement; SQLExpr expr = createStment.getTableSource().getExpr(); if (expr instanceof SQLPropertyExpr) { SQLPropertyExpr propertyExpr = (SQLPropertyExpr) expr;
public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) { MySqlCreateTableStatement stmt = new MySqlCreateTableStatement(); if (acceptCreate) { if (lexer.hasComment() && lexer.isKeepComments()) { stmt.addBeforeComment(lexer.readAndResetComments()); stmt.setType(SQLCreateTableStatement.Type.GLOBAL_TEMPORARY); stmt.setIfNotExiists(true); stmt.setName(this.exprParser.name()); stmt.setLike(name); lexer.nextTokenValue(); SQLName name = this.exprParser.name(); stmt.setLike(name); } else if (lexer.token() == Token.SELECT) { SQLSelect query = new MySqlSelectParser(this.exprParser).select(); stmt.setSelect(query); } else { for (;;) { MySqlKey fulltextKey = (MySqlKey) parseConstraint(); fulltextKey.setIndexType("FULLTEXT"); stmt.getTableElementList().add(fulltextKey); if (lexer.token() == Token.RPAREN) { break; stmt.getTableElementList().add(idx);
boolean acceptCreateTable(MySqlCreateTableStatement x) { SQLExprTableSource like = x.getLike(); if (like != null) { SchemaObject table = findTable((SQLName) like.getExpr()); if (table != null) { MySqlCreateTableStatement stmt = (MySqlCreateTableStatement) table.getStatement(); MySqlCreateTableStatement stmtCloned = stmt.clone(); stmtCloned.setName(x.getName().clone()); acceptCreateTable((SQLCreateTableStatement) stmtCloned); return false; } } return acceptCreateTable((SQLCreateTableStatement) x); }
for (SQLTableElement element : x.getTableElementList()) { if (element instanceof SQLColumnDefinition) { SQLColumnDefinition column = (SQLColumnDefinition) element; if (x.isPrimaryColumn(name)) { print("PRI"); } else if (x.isUNI(name)) { print("UNI"); } else if (x.isMUL(name)) { print("MUL"); } else {
private boolean parseTableOptionCharsetOrCollate(MySqlCreateTableStatement stmt) { if (lexer.identifierEquals("CHARACTER")) { lexer.nextToken(); accept(Token.SET); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("CHARACTER SET", this.exprParser.expr()); return true; } if (lexer.identifierEquals("CHARSET")) { lexer.nextToken(); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("CHARSET", this.exprParser.expr()); return true; } if (lexer.identifierEquals("COLLATE")) { lexer.nextToken(); if (lexer.token() == Token.EQ) { lexer.nextToken(); } stmt.getTableOptions().put("COLLATE", this.exprParser.expr()); return true; } return false; }
@Override public boolean visit(MySqlCreateTableStatement x) { if (repository != null && x.getParent() == null) { repository.resolve(x); } boolean val = super.visit((SQLCreateTableStatement) x); for (SQLObject option : x.getTableOptions().values()) { if (option instanceof SQLTableSource) { option.accept(this); } } return val; }
public boolean visit(MySqlCreateTableStatement x) { resolve(this, x); SQLExprTableSource like = x.getLike(); if (like != null) { like.accept(this); } return false; }