gt:             unresolvedSet = nodes[i].resolveColumnReferences(session,
context: /* Copyright (c) 2001-2011, The HSQL Development Group
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *
   * Redistributions of source code must retain the above copyright notice, this
   * list of conditions and the following disclaimer.
   *
   * Redistributions in binary form must reproduce the above copyright notice,
   * this list of conditions and the following disclaimer in the documentation
   * and/or other materials provided with the distribution.
   *
   * Neither the name of the HSQL Development Group nor the names of its
   * contributors may be used to endorse or promote products derived from this
   * software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
   * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  
  package org.hsqldb;
  
  import org.hsqldb.error.Error;
  import org.hsqldb.error.ErrorCode;
  import org.hsqldb.lib.HsqlList;
  import org.hsqldb.types.CharacterType;
  import org.hsqldb.types.NumberType;
  import org.hsqldb.types.Type;
  import org.hsqldb.types.Types;
  
  /**
   * Implementation of arithmetic and concatenation operations
   *
   * @author Campbell Boucher-Burnet (boucherb@users dot sourceforge.net)
   * @author Fred Toussi (fredt@users dot sourceforge.net)
   * @version 2.0.1
   * @since 1.9.0
   */
  public class ExpressionArithmetic extends Expression {
  
      ExpressionArithmetic(int type, Expression left, Expression right) {
  
          super(type);
  
          nodes        = new Expression[BINARY];
          nodes[LEFT]  = left;
          nodes[RIGHT] = right;
  
          switch (opType) {
  
              case OpTypes.ADD :
              case OpTypes.SUBTRACT :
              case OpTypes.MULTIPLY :
              case OpTypes.DIVIDE :
              case OpTypes.CONCAT :
                  return;
  
              default :
                  throw Error.runtimeError(ErrorCode.U_S0500, "Expression");
          }
      }
  
      ExpressionArithmetic(int type, Expression e) {
  
          super(type);
  
          nodes       = new Expression[UNARY];
          nodes[LEFT] = e;
  
          switch (opType) {
  
              case OpTypes.NEGATE :
                  return;
  
              default :
                  throw Error.runtimeError(ErrorCode.U_S0500, "Expression");
          }
      }
  
      public String getSQL() {
  
          StringBuffer sb = new StringBuffer(64);
  
          switch (opType) {
  
              case OpTypes.VALUE :
                  if (valueData == null) {
                      return Tokens.T_NULL;
                  }
  
                  if (dataType == null) {
                      throw Error.runtimeError(ErrorCode.U_S0500, "Expression");
                  }
  
                  return dataType.convertToSQLString(valueData);
          }
  
          String left  = getContextSQL(nodes.length > 0 ? nodes[LEFT]
                                                        : null);
          String right = getContextSQL(nodes.length > 1 ? nodes[RIGHT]
                                                        : null);
  
          switch (opType) {
  
              case OpTypes.CAST :
                  sb.append(' ').append(Tokens.T_CAST).append('(');
                  sb.append(left).append(' ').append(Tokens.T_AS).append(' ');
                  sb.append(dataType.getTypeDefinition());
                  sb.append(')');
                  break;
  
              case OpTypes.NEGATE :
                  sb.append('-').append(left);
                  break;
  
              case OpTypes.ADD :
                  sb.append(left).append('+').append(right);
                  break;
  
              case OpTypes.SUBTRACT :
                  sb.append(left).append('-').append(right);
                  break;
  
              case OpTypes.MULTIPLY :
                  sb.append(left).append('*').append(right);
                  break;
  
              case OpTypes.DIVIDE :
                  sb.append(left).append('/').append(right);
                  break;
  
              case OpTypes.CONCAT :
                  sb.append(left).append("||").append(right);
                  break;
  
              default :
                  throw Error.runtimeError(ErrorCode.U_S0500, "Expression");
          }
  
          return sb.toString();
      }
  
      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.VALUE :
                  sb.append("VALUE = ").append(
                      dataType.convertToSQLString(valueData));
                  sb.append(", TYPE = ").append(dataType.getNameString());
  
                  return sb.toString();
  
              case OpTypes.ROW :
  
              //
              case OpTypes.VALUELIST :
                  sb.append("VALUELIST ");
                  sb.append(" TYPE = ").append(dataType.getNameString());
  
                  for (int i = 0; i < nodes.length; i++) {
                      sb.append(nodes[i].describe(session, blanks + blanks));
                      sb.append(' ');
                  }
                  break;
  
              case OpTypes.NEGATE :
                  sb.append("NEGATE ");
                  break;
  
              case OpTypes.ADD :
                  sb.append("ADD ");
                  break;
  
              case OpTypes.SUBTRACT :
                  sb.append("SUBTRACT ");
                  break;
  
              case OpTypes.MULTIPLY :
                  sb.append("MULTIPLY ");
                  break;
  
              case OpTypes.DIVIDE :
                  sb.append("DIVIDE ");
                  break;
  
              case OpTypes.CONCAT :
                  sb.append("CONCAT ");
                  break;
  
              case OpTypes.CAST :
                  sb.append("CAST ");
                  sb.append(dataType.getTypeDefinition());
                  sb.append(' ');
                  break;
          }
  
          if (getLeftNode() != null) {
              sb.append(" arg_left=[");
              sb.append(nodes[LEFT].describe(session, blanks + 1));
              sb.append(']');
          }
  
          if (getRightNode() != null) {
              sb.append(" arg_right=[");
              sb.append(nodes[RIGHT].describe(session, blanks + 1));
              sb.append(']');
          }
  
          return sb.toString();
      }
  
      public HsqlList resolveColumnReferences(Session session,
              RangeGroup rangeGroup, int rangeCount,
              RangeGroup[] rangeGroups, HsqlList unresolvedSet, boolean acceptsSequences) {
  
          if (opType == OpTypes.VALUE) {
              return unresolvedSet;
          }
  
          for (int i = 0; i < nodes.length; i++) {
              if (nodes[i] == null) {
                  continue;
              }
  
  