Package com.alibaba.druid.sql.ast.statement

Examples of com.alibaba.druid.sql.ast.statement.SQLAlterTableDropIndex


        } else if (lexer.token() == Token.DROP) {
          lexer.nextToken();
          if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
          } else {
            if (identifierEquals("COLUMN")) {
              lexer.nextToken();
            }
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            item.setColumnName(this.exprParser.name());
            stmt.getItems().add(item);
          }
        } else if (identifierEquals("DISABLE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("ENABLE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("RENAME")) {
          lexer.nextToken();
          WaspSqlRenameTableStatement renameStmt = new WaspSqlRenameTableStatement();
          WaspSqlRenameTableStatement.Item item = new WaspSqlRenameTableStatement.Item();
          item.setName(stmt.getTableSource().getExpr());
          item.setTo(this.exprParser.name());
          renameStmt.getItems().add(item);

          return renameStmt;
        } else if (lexer.token() == Token.ORDER) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("CONVERT")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (lexer.token() == Token.DEFAULT) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("DISCARD")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("IMPORT")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("FORCE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("TRUNCATE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("COALESCE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());

        } else if (identifierEquals("REORGANIZE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("EXCHANGE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("ANALYZE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("CHECK")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("OPTIMIZE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("REBUILD")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("REPAIR")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals("REMOVE")) {
          throw new ParserException("TODO " + lexer.token() + " "
              + lexer.stringVal());
        } else if (identifierEquals(CHARACTER)) {
          lexer.nextToken();
          accept(Token.SET);
          accept(Token.EQ);
          WaspSqlAlterTableCharacter item = new WaspSqlAlterTableCharacter();
          item.setCharacterSet(this.exprParser.primary());
          if (lexer.token() == Token.COMMA) {
            lexer.nextToken();
            acceptIdentifier(COLLATE2);
            accept(Token.EQ);
            item.setCollate(this.exprParser.primary());
          }
          stmt.getItems().add(item);
        } else {
          break;
        }
View Full Code Here


    public void parseAlterDrop(SQLAlterTableStatement stmt) {
        lexer.nextToken();
        if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.FOREIGN) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropForeignKey item = new SQLAlterTableDropForeignKey();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.PRIMARY) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.CONSTRAINT) {
            lexer.nextToken();
            SQLAlterTableDropConstraint item = new SQLAlterTableDropConstraint();
            item.setConstraintName(this.exprParser.name());
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.COLUMN) {
            lexer.nextToken();
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();

            SQLName name = exprParser.name();
            name.setParent(item);
            item.getColumns().add(name);

            while (lexer.token() == Token.COMMA) {
                lexer.mark();
                lexer.nextToken();
                if (identifierEquals("CHANGE")) {
                    lexer.reset();
                    break;
                }

                if (lexer.token() == Token.IDENTIFIER) {
                    name = exprParser.name();
                    name.setParent(item);
                } else {
                    lexer.reset();
                    break;
                }
            }

            stmt.getItems().add(item);
        } else if (lexer.token() == Token.IDENTIFIER) {
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            this.exprParser.names(item.getColumns());
            stmt.getItems().add(item);
        } else {
            super.parseAlterDrop(stmt);
        }
    }
View Full Code Here

    public void parseAlterDrop(SQLAlterTableStatement stmt) {
        lexer.nextToken();
        if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.FOREIGN) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropForeinKey item = new SQLAlterTableDropForeinKey();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.PRIMARY) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.CONSTRAINT) {
            lexer.nextToken();
            SQLAlterTableDropConstraint item = new SQLAlterTableDropConstraint();
            item.setConstraintName(this.exprParser.name());
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.COLUMN) {
            lexer.nextToken();
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();

            SQLName name = exprParser.name();
            name.setParent(item);
            item.getColumns().add(name);

            while (lexer.token() == Token.COMMA) {
                lexer.mark();
                lexer.nextToken();
                if (identifierEquals("CHANGE")) {
                    lexer.reset();
                    break;
                }

                if (lexer.token() == Token.IDENTIFIER) {
                    name = exprParser.name();
                    name.setParent(item);
                } else {
                    lexer.reset();
                    break;
                }
            }

            stmt.getItems().add(item);
        } else if (lexer.token() == Token.IDENTIFIER) {
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            this.exprParser.names(item.getColumns());
            stmt.getItems().add(item);
        } else {
            super.parseAlterDrop(stmt);
        }
    }
View Full Code Here

                } else if (lexer.token() == Token.DROP) {
                    lexer.nextToken();
                    if (lexer.token() == Token.INDEX) {
                        lexer.nextToken();
                        SQLName indexName = this.exprParser.name();
                        SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
                        item.setIndexName(indexName);
                        stmt.getItems().add(item);
                    } else {
                        if (identifierEquals("COLUMN")) {
                            lexer.nextToken();
                        }
                        SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
                        item.setColumnName(this.exprParser.name());
                        stmt.getItems().add(item);
                    }
                } else if (identifierEquals("DISABLE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("ENABLE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("RENAME")) {
                    lexer.nextToken();
                    MySqlRenameTableStatement renameStmt = new MySqlRenameTableStatement();
                    MySqlRenameTableStatement.Item item = new MySqlRenameTableStatement.Item();
                    item.setName(stmt.getTableSource().getExpr());
                    item.setTo(this.exprParser.name());
                    renameStmt.getItems().add(item);

                    return renameStmt;
                } else if (lexer.token() == Token.ORDER) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CONVERT")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (lexer.token() == Token.DEFAULT) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("DISCARD")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("IMPORT")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("FORCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("TRUNCATE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("COALESCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());

                } else if (identifierEquals("REORGANIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("EXCHANGE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("ANALYZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CHECK")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("OPTIMIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REBUILD")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REPAIR")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REMOVE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals(ENGINE)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(ENGINE, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals(COLLATE2)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(COLLATE2, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals("PACK_KEYS")) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    if (identifierEquals("PACK")) {
                        lexer.nextToken();
                        accept(Token.ALL);
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", "PACK ALL"));
                    } else {
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", lexer.stringVal()));
                        lexer.nextToken();
                    }
                } else if (identifierEquals(CHARACTER)) {
                    lexer.nextToken();
                    accept(Token.SET);
                    accept(Token.EQ);
                    MySqlAlterTableCharacter item = new MySqlAlterTableCharacter();
                    item.setCharacterSet(this.exprParser.primary());
                    if (lexer.token() == Token.COMMA) {
                        lexer.nextToken();
                        acceptIdentifier(COLLATE2);
                        accept(Token.EQ);
                        item.setCollate(this.exprParser.primary());
                    }
                    stmt.getItems().add(item);
                } else {
                    break;
                }
View Full Code Here

                } else if (lexer.token() == Token.DROP) {
                    lexer.nextToken();
                    if (lexer.token() == Token.INDEX) {
                        lexer.nextToken();
                        SQLName indexName = this.exprParser.name();
                        SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
                        item.setIndexName(indexName);
                        stmt.getItems().add(item);
                    } else if (lexer.token() == Token.FOREIGN) {
                        lexer.nextToken();
                        accept(Token.KEY);
                        SQLName indexName = this.exprParser.name();
                        SQLAlterTableDropForeinKey item = new SQLAlterTableDropForeinKey();
                        item.setIndexName(indexName);
                        stmt.getItems().add(item);
                    } else if (lexer.token() == Token.PRIMARY) {
                        lexer.nextToken();
                        accept(Token.KEY);
                        SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
                        stmt.getItems().add(item);
                    } else {
                        if (identifierEquals("COLUMN")) {
                            lexer.nextToken();
                        }
                        SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
                        item.setColumnName(this.exprParser.name());
                        stmt.getItems().add(item);
                    }
                } else if (identifierEquals("DISABLE")) {
                    lexer.nextToken();
                    acceptIdentifier("KEYS");
                    SQLAlterTableDisableKeys item = new SQLAlterTableDisableKeys();
                    stmt.getItems().add(item);
                } else if (identifierEquals("ENABLE")) {
                    lexer.nextToken();
                    acceptIdentifier("KEYS");
                    SQLAlterTableEnableKeys item = new SQLAlterTableEnableKeys();
                    stmt.getItems().add(item);
                } else if (identifierEquals("RENAME")) {
                    lexer.nextToken();
                    MySqlRenameTableStatement renameStmt = new MySqlRenameTableStatement();
                    MySqlRenameTableStatement.Item item = new MySqlRenameTableStatement.Item();
                    item.setName(stmt.getTableSource().getExpr());
                    item.setTo(this.exprParser.name());
                    renameStmt.getItems().add(item);

                    return renameStmt;
                } else if (lexer.token() == Token.ORDER) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CONVERT")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (lexer.token() == Token.DEFAULT) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("DISCARD")) {
                    lexer.nextToken();
                    acceptIdentifier("TABLESPACE");
                    MySqlAlterTableDiscardTablespace item = new MySqlAlterTableDiscardTablespace();
                    stmt.getItems().add(item);
                } else if (identifierEquals("IMPORT")) {
                    lexer.nextToken();
                    acceptIdentifier("TABLESPACE");
                    MySqlAlterTableImportTablespace item = new MySqlAlterTableImportTablespace();
                    stmt.getItems().add(item);
                } else if (identifierEquals("FORCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("TRUNCATE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("COALESCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());

                } else if (identifierEquals("REORGANIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("EXCHANGE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("ANALYZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CHECK")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("OPTIMIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REBUILD")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REPAIR")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REMOVE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals(ENGINE)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(ENGINE, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals(AUTO_INCREMENT)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(AUTO_INCREMENT, lexer.integerValue()));
                    lexer.nextToken();
                } else if (identifierEquals(COLLATE2)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(COLLATE2, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals("PACK_KEYS")) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    if (identifierEquals("PACK")) {
                        lexer.nextToken();
                        accept(Token.ALL);
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", "PACK ALL"));
                    } else {
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", lexer.stringVal()));
                        lexer.nextToken();
                    }
                } else if (identifierEquals(CHARACTER)) {
                    lexer.nextToken();
                    accept(Token.SET);
                    accept(Token.EQ);
                    MySqlAlterTableCharacter item = new MySqlAlterTableCharacter();
                    item.setCharacterSet(this.exprParser.primary());
                    if (lexer.token() == Token.COMMA) {
                        lexer.nextToken();
                        acceptIdentifier(COLLATE2);
                        accept(Token.EQ);
                        item.setCollate(this.exprParser.primary());
                    }
                    stmt.getItems().add(item);
                } else {
                    break;
                }
View Full Code Here

    public void parseAlterDrop(SQLAlterTableStatement stmt) {
        lexer.nextToken();
        if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.FOREIGN) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropForeinKey item = new SQLAlterTableDropForeinKey();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.PRIMARY) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
            stmt.getItems().add(item);
        } else  if (lexer.token() == Token.CONSTRAINT) {
            lexer.nextToken();
            SQLAlterTableDropConstraint item = new SQLAlterTableDropConstraint();
            item.setConstraintName(this.exprParser.name());
            stmt.getItems().add(item);
        } else if (identifierEquals("COLUMN")) {
            lexer.nextToken();
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            item.setColumnName(this.exprParser.name());
            stmt.getItems().add(item);
        } else {
            super.parseAlterDrop(stmt);
        }
    }
View Full Code Here

    public void parseAlterDrop(SQLAlterTableStatement stmt) {
        lexer.nextToken();
        if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.FOREIGN) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropForeinKey item = new SQLAlterTableDropForeinKey();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.PRIMARY) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
            stmt.getItems().add(item);
        } else  if (lexer.token() == Token.CONSTRAINT) {
            lexer.nextToken();
            SQLAlterTableDropConstraint item = new SQLAlterTableDropConstraint();
            item.setConstraintName(this.exprParser.name());
            stmt.getItems().add(item);
        } else if (identifierEquals("COLUMN")) {
            lexer.nextToken();
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            item.setColumnName(this.exprParser.name());
            stmt.getItems().add(item);
        } else {
            super.parseAlterDrop(stmt);
        }
    }
View Full Code Here

                } else if (lexer.token() == Token.DROP) {
                    lexer.nextToken();
                    if (lexer.token() == Token.INDEX) {
                        lexer.nextToken();
                        SQLName indexName = this.exprParser.name();
                        SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
                        item.setIndexName(indexName);
                        stmt.getItems().add(item);
                    } else {
                        if (identifierEquals("COLUMN")) {
                            lexer.nextToken();
                        }
                        SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
                        item.setColumnName(this.exprParser.name());
                        stmt.getItems().add(item);
                    }
                } else if (identifierEquals("DISABLE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("ENABLE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("RENAME")) {
                    lexer.nextToken();
                    MySqlRenameTableStatement renameStmt = new MySqlRenameTableStatement();
                    MySqlRenameTableStatement.Item item = new MySqlRenameTableStatement.Item();
                    item.setName(stmt.getTableSource().getExpr());
                    item.setTo(this.exprParser.name());
                    renameStmt.getItems().add(item);

                    return renameStmt;
                } else if (lexer.token() == Token.ORDER) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CONVERT")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (lexer.token() == Token.DEFAULT) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("DISCARD")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("IMPORT")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("FORCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("TRUNCATE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("COALESCE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());

                } else if (identifierEquals("REORGANIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("EXCHANGE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("ANALYZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("CHECK")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("OPTIMIZE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REBUILD")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REPAIR")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals("REMOVE")) {
                    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
                } else if (identifierEquals(ENGINE)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(ENGINE, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals(COLLATE2)) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    stmt.getItems().add(new MySqlAlterTableOption(COLLATE2, lexer.stringVal()));
                    lexer.nextToken();
                } else if (identifierEquals("PACK_KEYS")) {
                    lexer.nextToken();
                    accept(Token.EQ);
                    if (identifierEquals("PACK")) {
                        lexer.nextToken();
                        accept(Token.ALL);
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", "PACK ALL"));
                    } else {
                        stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", lexer.stringVal()));
                        lexer.nextToken();
                    }
                } else if (identifierEquals(CHARACTER)) {
                    lexer.nextToken();
                    accept(Token.SET);
                    accept(Token.EQ);
                    MySqlAlterTableCharacter item = new MySqlAlterTableCharacter();
                    item.setCharacterSet(this.exprParser.primary());
                    if (lexer.token() == Token.COMMA) {
                        lexer.nextToken();
                        acceptIdentifier(COLLATE2);
                        accept(Token.EQ);
                        item.setCollate(this.exprParser.primary());
                    }
                    stmt.getItems().add(item);
                } else {
                    break;
                }
View Full Code Here

    public void parseAlterDrop(SQLAlterTableStatement stmt) {
        lexer.nextToken();
        if (lexer.token() == Token.INDEX) {
            lexer.nextToken();
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropIndex item = new SQLAlterTableDropIndex();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.FOREIGN) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLName indexName = this.exprParser.name();
            SQLAlterTableDropForeignKey item = new SQLAlterTableDropForeignKey();
            item.setIndexName(indexName);
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.PRIMARY) {
            lexer.nextToken();
            accept(Token.KEY);
            SQLAlterTableDropPrimaryKey item = new SQLAlterTableDropPrimaryKey();
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.CONSTRAINT) {
            lexer.nextToken();
            SQLAlterTableDropConstraint item = new SQLAlterTableDropConstraint();
            item.setConstraintName(this.exprParser.name());
            stmt.getItems().add(item);
        } else if (lexer.token() == Token.COLUMN) {
            lexer.nextToken();
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();

            SQLName name = exprParser.name();
            name.setParent(item);
            item.getColumns().add(name);

            while (lexer.token() == Token.COMMA) {
                lexer.mark();
                lexer.nextToken();
                if (identifierEquals("CHANGE")) {
                    lexer.reset();
                    break;
                }

                if (lexer.token() == Token.IDENTIFIER) {
                    name = exprParser.name();
                    name.setParent(item);
                } else {
                    lexer.reset();
                    break;
                }
            }

            stmt.getItems().add(item);
        } else if (lexer.token() == Token.IDENTIFIER) {
            SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
            this.exprParser.names(item.getColumns());
            stmt.getItems().add(item);
        } else {
            super.parseAlterDrop(stmt);
        }
    }
View Full Code Here

        new SQLCommentStatement ().accept(adapter);
        new SQLDropViewStatement ().accept(adapter);
        new SQLSavePointStatement ().accept(adapter);
        new SQLReleaseSavePointStatement ().accept(adapter);
        new SQLCreateDatabaseStatement ().accept(adapter);
        new SQLAlterTableDropIndex ().accept(adapter);
        new SQLOver ().accept(adapter);
        new SQLWithSubqueryClause().accept(adapter);
        new SQLAlterTableAlterColumn ().accept(adapter);
        new SQLAlterTableStatement ().accept(adapter);
        new SQLAlterTableDisableConstraint ().accept(adapter);
View Full Code Here

TOP

Related Classes of com.alibaba.druid.sql.ast.statement.SQLAlterTableDropIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.