Exemplo n.º 1
0
  @Override
  public boolean visit(SQLCreateIndexStatement x) {
    setMode(x, Mode.CreateIndex);

    SQLName name = (SQLName) ((SQLExprTableSource) x.getTable()).getExpr();

    String table = name.toString();
    setCurrentTable(table);

    TableStat stat = getTableStat(table);
    stat.incrementDropIndexCount();

    Map<String, String> aliasMap = getAliasMap();
    if (aliasMap != null) {
      aliasMap.put(table, table);
    }

    for (SQLSelectOrderByItem item : x.getItems()) {
      SQLExpr expr = item.getExpr();
      if (expr instanceof SQLIdentifierExpr) {
        SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
        String columnName = identExpr.getName();
        addColumn(table, columnName);
      }
    }

    return false;
  }
Exemplo n.º 2
0
 public boolean visit(SQLOrderBy x) {
   OrderByStatVisitor orderByVisitor = new OrderByStatVisitor(x);
   SQLSelectQueryBlock query = null;
   if (x.getParent() instanceof SQLSelectQueryBlock) {
     query = (SQLSelectQueryBlock) x.getParent();
   }
   if (query != null) {
     for (SQLSelectOrderByItem item : x.getItems()) {
       SQLExpr expr = item.getExpr();
       if (expr instanceof SQLIntegerExpr) {
         int intValue = ((SQLIntegerExpr) expr).getNumber().intValue() - 1;
         if (intValue < query.getSelectList().size()) {
           SQLSelectItem selectItem = query.getSelectList().get(intValue);
           selectItem.getExpr().accept(orderByVisitor);
         }
       }
     }
   }
   x.accept(orderByVisitor);
   return true;
 }
Exemplo n.º 3
0
 public OrderByStatVisitor(SQLOrderBy orderBy) {
   this.orderBy = orderBy;
   for (SQLSelectOrderByItem item : orderBy.getItems()) {
     item.getExpr().setParent(item);
   }
 }