Ejemplo n.º 1
0
  void collectObjectNames(Set set) {

    switch (opType) {
      case OpTypes.SEQUENCE:
        HsqlName name = sequence.getName();

        set.add(name);

        return;

      case OpTypes.MULTICOLUMN:
      case OpTypes.DYNAMIC_PARAM:
      case OpTypes.ASTERISK:
      case OpTypes.SIMPLE_COLUMN:
      case OpTypes.COALESCE:
        break;

      case OpTypes.PARAMETER:
      case OpTypes.VARIABLE:
        break;

      case OpTypes.COLUMN:
        set.add(column.getName());

        if (column.getName().parent != null) {
          set.add(column.getName().parent);
        }

        return;
    }
  }
  protected void addTableColumns(Expression expression, int start, int count, HashSet exclude) {

    Table table = getTable();
    HsqlArrayList list = new HsqlArrayList();

    for (int i = start; i < start + count; i++) {
      ColumnSchema column = table.getColumn(i);
      String columnName =
          columnAliases == null ? column.getName().name : (String) columnAliases.get(i);

      if (exclude != null && exclude.contains(columnName)) {
        continue;
      }

      Expression e = new ExpressionColumn(this, i);

      list.add(e);
    }

    Expression[] nodes = new Expression[list.size()];

    list.toArray(nodes);

    expression.nodes = nodes;
  }
Ejemplo n.º 3
0
  String getColumnName() {

    if (opType == OpTypes.COLUMN && column != null) {
      return column.getName().name;
    }

    return getAlias();
  }
Ejemplo n.º 4
0
  ExpressionColumn(ColumnSchema column) {

    super(OpTypes.COLUMN);

    this.column = column;
    this.dataType = column.getDataType();
    columnName = column.getName().name;
  }
Ejemplo n.º 5
0
 void checkCheckConstraint(
     Session paramSession, Table paramTable, ColumnSchema paramColumnSchema, Object paramObject) {
   paramSession.sessionData.currentValue = paramObject;
   boolean bool = Boolean.FALSE.equals(this.check.getValue(paramSession));
   paramSession.sessionData.currentValue = null;
   if (bool) {
     String[] arrayOfString = {
       this.name.statementName,
       paramTable == null ? "" : paramTable.getName().statementName,
       paramColumnSchema == null ? "" : paramColumnSchema.getName().statementName
     };
     throw Error.error(null, 157, 3, arrayOfString);
   }
 }
Ejemplo n.º 6
0
  public void addSessionVariable(ColumnSchema variable) {

    int index = sessionVariables.size();

    if (!sessionVariables.add(variable.getName().name, variable)) {
      throw Error.error(ErrorCode.X_42504);
    }

    Object[] vars = new Object[sessionVariables.size()];

    ArrayUtil.copyArray(routineVariables, vars, routineVariables.length);

    routineVariables = vars;
    routineVariables[index] = variable.getDefaultValue(session);
  }
  SimpleName getSimpleName() {

    if (alias != null) {
      return alias;
    }

    if (column != null) {
      return column.getName();
    }

    if (opType == OpTypes.COALESCE) {
      return nodes[LEFT].getSimpleName();
    }

    return null;
  }
  public String getSQL() {

    StringBuffer sb = new StringBuffer();

    switch (type) {
      case StatementTypes.SIGNAL:
        sb.append(Tokens.T_SIGNAL);
        break;

      case StatementTypes.RESIGNAL:
        sb.append(Tokens.T_RESIGNAL);
        break;

        // todo
      case StatementTypes.ITERATE:
        sb.append(Tokens.T_ITERATE).append(' ').append(label);
        break;

      case StatementTypes.LEAVE:
        sb.append(Tokens.T_LEAVE).append(' ').append(label);
        break;

      case StatementTypes.RETURN:
        /*
                        sb.append(Tokens.T_RETURN);

                        if (expression != null) {
                            sb.append(' ').append(expression.getSQL());
                        }
                        break;
        */
        return sql;

      case StatementTypes.CONDITION:
        sb.append(expression.getSQL());
        break;

      case StatementTypes.ASSIGNMENT:
        sb.append(Tokens.T_SET).append(' ');
        sb.append(variable.getName().statementName).append(' ');
        sb.append('=').append(' ').append(expression.getSQL());
        break;
    }

    return sb.toString();
  }
  /** Add all columns to a list of expressions */
  public int addTableColumns(HsqlArrayList exprList, int position, HashSet exclude) {

    Table table = getTable();
    int count = table.getColumnCount();

    for (int i = 0; i < count; i++) {
      ColumnSchema column = table.getColumn(i);
      String columnName =
          columnAliases == null ? column.getName().name : (String) columnAliases.get(i);

      if (exclude != null && exclude.contains(columnName)) {
        continue;
      }

      Expression e = new ExpressionColumn(this, i);

      exprList.add(position++, e);
    }

    return position;
  }
Ejemplo n.º 10
0
  SimpleName getSimpleName() {

    if (alias != null) {
      return alias;
    }

    if (rangeVariable != null && rangeVariable.hasColumnAlias()) {
      return rangeVariable.getColumnAlias(columnIndex);
    }

    if (column != null) {
      return column.getName();
    }

    if (opType == OpTypes.COALESCE) {
      return nodes[LEFT].getSimpleName();
    } else if (opType == OpTypes.ROWNUM) {
      return rownumName;
    }

    return null;
  }
Ejemplo n.º 11
0
  protected String describe(Session session, int blanks) {

    StringBuffer sb = new StringBuffer(64);

    sb.append('\n');

    for (int i = 0; i < blanks; i++) {
      sb.append(' ');
    }

    switch (opType) {
      case OpTypes.DEFAULT:
        sb.append(Tokens.T_DEFAULT);
        break;

      case OpTypes.ASTERISK:
        sb.append("OpTypes.ASTERISK ");
        break;

      case OpTypes.VARIABLE:
        sb.append("VARIABLE: ");
        sb.append(column.getName().name);
        break;

      case OpTypes.PARAMETER:
        sb.append(Tokens.T_PARAMETER).append(": ");
        sb.append(column.getName().name);
        break;

      case OpTypes.COALESCE:
        sb.append(Tokens.T_COLUMN).append(": ");
        sb.append(columnName);

        if (alias != null) {
          sb.append(" AS ").append(alias.name);
        }
        break;

      case OpTypes.COLUMN:
        sb.append(Tokens.T_COLUMN).append(": ");
        sb.append(column.getName().getSchemaQualifiedStatementName());

        if (alias != null) {
          sb.append(" AS ").append(alias.name);
        }
        break;

      case OpTypes.DYNAMIC_PARAM:
        sb.append("DYNAMIC PARAM: ");
        sb.append(", TYPE = ").append(dataType.getNameString());
        break;

      case OpTypes.SEQUENCE:
        sb.append(Tokens.T_SEQUENCE).append(": ");
        sb.append(sequence.getName().name);
        break;

      case OpTypes.MULTICOLUMN:

        // shouldn't get here
    }

    return sb.toString();
  }
Ejemplo n.º 12
0
  public String getSQL() {

    switch (opType) {
      case OpTypes.DEFAULT:
        return Tokens.T_DEFAULT;

      case OpTypes.DYNAMIC_PARAM:
        return Tokens.T_QUESTION;

      case OpTypes.ASTERISK:
        return "*";

      case OpTypes.COALESCE:
        return alias.getStatementName();

      case OpTypes.DIAGNOSTICS_VARIABLE:
      case OpTypes.VARIABLE:
      case OpTypes.PARAMETER:
        return column.getName().statementName;

      case OpTypes.ROWNUM:
        {
          StringBuffer sb = new StringBuffer(Tokens.T_ROWNUM);

          sb.append('(').append(')');
        }
      case OpTypes.COLUMN:
        {
          if (column == null) {
            if (alias != null) {
              return alias.getStatementName();
            } else {
              return columnName;
            }
          }

          if (rangeVariable.tableAlias == null) {
            return column.getName().getSchemaQualifiedStatementName();
          } else {
            StringBuffer sb = new StringBuffer();

            sb.append(rangeVariable.tableAlias.getStatementName());
            sb.append('.');
            sb.append(column.getName().statementName);

            return sb.toString();
          }
        }
      case OpTypes.MULTICOLUMN:
        {
          if (nodes.length == 0) {
            return "*";
          }

          StringBuffer sb = new StringBuffer();

          for (int i = 0; i < nodes.length; i++) {
            Expression e = nodes[i];

            if (i > 0) {
              sb.append(',');
            }

            String s = e.getSQL();

            sb.append(s);
          }

          return sb.toString();
        }
      default:
        throw Error.runtimeError(ErrorCode.U_S0500, "ExpressionColumn");
    }
  }
Ejemplo n.º 13
0
 public HsqlName getBaseColumnHsqlName() {
   return column.getName();
 }