예제 #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;
  }
예제 #2
0
  @Override
  public boolean visit(SQLAlterTableAddColumn x) {
    SQLAlterTableStatement stmt = (SQLAlterTableStatement) x.getParent();
    String table = stmt.getName().toString();

    for (SQLColumnDefinition column : x.getColumns()) {
      String columnName = column.getName().toString();
      addColumn(table, columnName);
    }
    return false;
  }
예제 #3
0
  public boolean visit(SQLAllColumnExpr x) {
    String currentTable = getCurrentTable();

    if (subQueryMap.containsKey(currentTable)) {
      return false;
    }

    if (currentTable != null) {
      addColumn(currentTable, "*");
    }
    return false;
  }
예제 #4
0
  public boolean visit(SQLColumnDefinition x) {
    String tableName = null;
    {
      SQLObject parent = x.getParent();
      if (parent instanceof SQLCreateTableStatement) {
        tableName = ((SQLCreateTableStatement) parent).getName().toString();
      }
    }

    if (tableName == null) {
      return true;
    }

    String columnName = x.getName().toString();
    addColumn(tableName, columnName);

    return false;
  }
예제 #5
0
  @Override
  public boolean visit(SQLForeignKeyImpl x) {

    for (SQLName column : x.getReferencedColumns()) {
      column.accept(this);
    }

    String table = x.getReferencedTableName().getSimpleName();
    setCurrentTable(table);

    TableStat stat = getTableStat(table);
    stat.incrementReferencedCount();
    for (SQLName column : x.getReferencedColumns()) {
      String columnName = column.getSimpleName();
      addColumn(table, columnName);
    }

    return false;
  }