Package com.alibaba.druid.sql.ast

Examples of com.alibaba.druid.sql.ast.SQLStatement


   * Parse sql and generate Execute Plan:CREATE,DROP,ALTER
   *
   */
  @Override
  public void generatePlan(ParseContext context) throws IOException {
    SQLStatement stmt = context.getStmt();
    MetaEventOperation metaEventOperation = new FMetaEventOperation(
        context.getTsr());
    if (stmt instanceof WaspSqlCreateTableStatement) {
      // This is a Create Table SQL
      getCreateTablePlan(context, (WaspSqlCreateTableStatement) stmt,
View Full Code Here


  /**
   * Parse sql and generate QueryPlan SELECT,UPDATE,INSERT,DELETE
   */
  @Override
  public void generatePlan(ParseContext context) throws IOException {
    SQLStatement stmt = context.getStmt();
    MetaEventOperation metaEventOperation = new FMetaEventOperation(
        context.getTsr());
    if (stmt instanceof SQLUpdateStatement) {
      // This is a Update SQL
      getUpdatePlan(context, (SQLUpdateStatement) stmt, metaEventOperation);
View Full Code Here

  /**
   * @see com.alibaba.wasp.plan.parser.Parser#generatePlan(com.alibaba.wasp.plan.parser.ParseContext)
   */
  @Override
  public void generatePlan(ParseContext context) throws IOException {
    SQLStatement stmt = context.getStmt();
    MetaEventOperation metaEventOperation = new FMetaEventOperation(
        context.getTsr());
    if (stmt instanceof SQLSelectStatement) {
      // This is a select SQL
      getSelectPlan(context, (SQLSelectStatement) stmt, metaEventOperation);
View Full Code Here

    return stmt;
  }

  public boolean parseStatementListDialect(List<SQLStatement> statementList) {
    if (lexer.token() == Token.KILL) {
      SQLStatement stmt = parseKill();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("PREPARE")) {
      WaspSqlPrepareStatement stmt = parsePrepare();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("EXECUTE")) {
      WaspSqlExecuteStatement stmt = parseExecute();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("LOAD")) {
      SQLStatement stmt = parseLoad();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("START")) {
      WaspSqlStartTransactionStatement stmt = parseStart();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("SHOW")) {
      SQLStatement stmt = parseShow();
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals("HELP")) {
      lexer.nextToken();
      WaspSqlHelpStatement stmt = new WaspSqlHelpStatement();
      stmt.setContent(this.exprParser.primary());
      statementList.add(stmt);
      return true;
    }

    if (identifierEquals(DESC) || identifierEquals(DESCRIBE)) {
      SQLStatement stmt = parseDescribe();
      statementList.add(stmt);
      return true;
    }

    if (lexer.token() == Token.LOCK) {
      lexer.nextToken();
      acceptIdentifier(TABLES);

      WaspSqlLockTableStatement stmt = new WaspSqlLockTableStatement();
      stmt.setTableSource(this.exprParser.name());

      if (identifierEquals(READ)) {
        lexer.nextToken();
        if (identifierEquals(LOCAL)) {
          lexer.nextToken();
          stmt.setLockType(LockType.READ_LOCAL);
        } else {
          stmt.setLockType(LockType.READ);
        }
      } else if (identifierEquals(WRITE)) {
        stmt.setLockType(LockType.WRITE);
      } else if (identifierEquals(LOW_PRIORITY)) {
        lexer.nextToken();
        acceptIdentifier(WRITE);
        stmt.setLockType(LockType.LOW_PRIORITY_WRITE);
      }

      statementList.add(stmt);
      return true;
    }
View Full Code Here

  }

  protected SQLStatement parseLoad() {
    acceptIdentifier("LOAD");
    if (identifierEquals("DATA")) {
      SQLStatement stmt = parseLoadDataInFile();
      return stmt;
    }
    if (identifierEquals("XML")) {
      SQLStatement stmt = parseLoadXml();
      return stmt;
    }
    throw new ParserException("TODO");
  }
View Full Code Here

  }

   @Override
  public SQLType getSQLType(ParseContext context) throws IOException {
    parseSqlToStatement(context);
    SQLStatement stmt = context.getStmt();
    boolean isDDL = false;
    boolean isDQL = false;
    if (stmt instanceof WaspSqlCreateTableStatement) {
      // This is a Create Table SQL
      isDDL = true;
View Full Code Here

    for (int i = 0; i < sqlList.length; i++) {
      String sql = sqlList[i];
      context.setSql(sql);
      try {
        druidParser.parseSqlToStatement(context);
        SQLStatement stmt = context.getStmt();
        if (stmt instanceof SQLSelectStatement) {
          MemFMetaStore fmetaServices = new MemFMetaStore();
          TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(
              conf, fmetaServices);
          reader.addSchema(table.getTableName(), table);
View Full Code Here

        return stmt;
    }

    public boolean parseStatementListDialect(List<SQLStatement> statementList) {
        if (lexer.token() == Token.KILL) {
            SQLStatement stmt = parseKill();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("PREPARE")) {
            MySqlPrepareStatement stmt = parsePrepare();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("EXECUTE")) {
            MySqlExecuteStatement stmt = parseExecute();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("LOAD")) {
            SQLStatement stmt = parseLoad();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("REPLACE")) {
            MySqlReplicateStatement stmt = parseReplicate();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("START")) {
            MySqlStartTransactionStatement stmt = parseStart();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("COMMIT")) {
            MySqlCommitStatement stmt = parseCommit();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("ROLLBACK")) {
            MySqlRollbackStatement stmt = parseRollback();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("SHOW")) {
            SQLStatement stmt = parseShow();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("BINLOG")) {
            SQLStatement stmt = parseBinlog();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("RESET")) {
            SQLStatement stmt = parseReset();
            statementList.add(stmt);
            return true;
        }

        if (identifierEquals("DESCRIBE")) {
            SQLStatement stmt = parseDescribe();
            statementList.add(stmt);
            return true;
        }

        return false;
View Full Code Here

    protected SQLStatement parseLoad() throws ParserException {
        acceptIdentifier("LOAD");

        if (identifierEquals("DATA")) {
            SQLStatement stmt = parseLoadDataInFile();
            return stmt;
        }

        if (identifierEquals("XML")) {
            SQLStatement stmt = parseLoadXml();
            return stmt;
        }

        throw new ParserException("TODO");
    }
View Full Code Here

                statementList.add(parseCreate());
                continue;
            }

            if (lexer.token() == (Token.INSERT)) {
                SQLStatement insertStatement = parseInsert();
                statementList.add(insertStatement);

                continue;
            }

            if (lexer.token() == (Token.DELETE)) {
                statementList.add(parseDeleteStatement());
                continue;
            }

            if (lexer.token() == Token.SET) {
                statementList.add(parseSet());
                continue;
            }

            if (lexer.token() == Token.ALTER) {
                throw new ParserException("TODO");
            }

            if (lexer.token() == Token.DROP) {
                lexer.nextToken();

                if (lexer.token() == Token.TABLE) {

                    SQLDropTableStatement stmt = parseDropTable(false);

                    statementList.add(stmt);
                    continue;
                } else if (lexer.token() == Token.USER) {
                    SQLStatement stmt = parseDropUser();
                    statementList.add(stmt);
                    continue;
                } else {
                    throw new ParserException("TODO " + lexer.token());
                }
            }

            if (lexer.token() == Token.TRUNCATE) {
                SQLStatement stmt = parseTruncate();
                statementList.add(stmt);
                continue;
            }
           
            if (lexer.token() == Token.USE) {
                SQLStatement stmt = parseUse();
                statementList.add(stmt);
                continue;
            }

            if (identifierEquals("CALL")) {
View Full Code Here

TOP

Related Classes of com.alibaba.druid.sql.ast.SQLStatement

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.