Ejemplo n.º 1
0
  /**
   * This constructor is used during from AndNode during where clause evaluation to create QueryInfo
   * Object
   *
   * @param cr ColumnReference object
   * @throws StandardException
   * @see AndNode#computeQueryInfo()
   */
  public ColumnQueryInfo(final ColumnReference cr, QueryInfoContext qic) throws StandardException {
    final ResultColumn rc = cr.getSource();
    this.tableNum = cr.getTableNumber();
    this.columnDescriptor = searchColumnDescriptor(rc);

    if (this.columnDescriptor != null) {
      this.actualColumnName = this.columnDescriptor.getColumnName();
      this.actualColumnNumber = this.columnDescriptor.getPosition();
      this.columnType = this.columnDescriptor.getType();
      this.td = this.columnDescriptor.getTableDescriptor();
    } else {
      String columnName = rc.getSourceColumnName();
      if (columnName == null) {
        columnName = rc.getActualName();
      }
      this.actualColumnName = columnName;
      this.actualColumnNumber = rc.getColumnPosition();
      this.columnType = rc.getType();
      this.td = null;
    }
    this.exposedColumnName = this.actualColumnName;
    this.virtualColumnNumber = this.actualColumnNumber;
    if (tableNum > -1) {
      DMLQueryInfo current = qic.getCurrentScopeQueryInfo();
      this.tqi = current.getTableQueryInfo(tableNum);
      if (tqi != null) {
        this.initResolverForColumnIfApplicable();
      } else {
        DMLQueryInfo root = qic.getRootQueryInfo();
        if (root.isSelect() && qic.getNestingLevelOfScope() > 0) {
          // It is possible that this column refers to an outer scope table.
          // We need to find the Scope to which it belongs
          Scope owningScope = qic.findOwningScope(tableNum);
          if (owningScope != null) {
            this.initResolverForOuterScopeColumn(cr, qic, owningScope);
            this.isOuterScope = true;
          } else {
            // the subquery flag remains set as UNSUPPORTED_CORRELATED_SUBQUERY
          }
        }
      }
    }

    // !!!:ezoerner:20090622 a null columnDescriptor is problem if we need the
    // type for byte array formatting. Allow it for now, but may cause an NPE
    // later
    /*
    assert this.columnDescriptor != null;
    */
  }
Ejemplo n.º 2
0
  /**
   * This constructor is invoked while analyzing the projection attributes
   *
   * @param rc ResultColumn
   * @throws StandardException
   * @see SelectQueryInfo#visit(com.pivotal.gemfirexd.internal.iapi.sql.compile.Visitable)
   */
  ColumnQueryInfo(final ResultColumn rc, QueryInfoContext qic) throws StandardException {
    final ColumnDescriptor cd = searchColumnDescriptor(rc);

    if (cd != null) {
      this.actualColumnName = cd.getColumnName();
      this.actualColumnNumber = cd.getPosition();
      this.columnDescriptor = cd;
      this.columnType = cd.getType();
      this.td = cd.getTableDescriptor();
    } else {
      String columnName = rc.getSourceColumnName();
      if (columnName == null) {
        columnName = rc.getActualName();
      }
      this.actualColumnName = columnName;
      this.actualColumnNumber = rc.getColumnPosition();
      this.columnType = rc.getType();
      this.td = null;
      this.columnDescriptor =
          new ColumnDescriptor(
              this.actualColumnName,
              this.actualColumnNumber,
              this.columnType,
              null, // default
              null, // defaultInfo
              (UUID) null, // table uuid
              (UUID) null, // default uuid
              0L, // autoincStart
              0L, // autoincInc
              0L,
              false); // autoincValue
    }

    if (tableNum > -1) {
      DMLQueryInfo currentTop = qic.getCurrentScopeQueryInfo();
      this.tqi = currentTop.getTableQueryInfo(tableNum);
      // TODO:Asif Should we do correlation check here?
    }
    this.exposedColumnName = rc.getName();
    this.virtualColumnNumber = rc.getVirtualColumnId();
    assert this.columnDescriptor != null;
  }