Package com.caucho.db.table

Examples of com.caucho.db.table.Column


  /**
   * The cost of a match of the expr.
   */
  protected long lookupCost(ArrayList<FromItem> fromList)
  {
    Column column = findColumn(fromList);
    if (column == null)
      return Integer.MAX_VALUE;
   
    FromItem fromItem = fromList.get(fromList.size() - 1);

    Table table = fromItem.getTable();

    column = table.getColumn(_column);

    if (column == null)
      return 100 * 100 * 100;
    else if (column.isPrimaryKey())
      return 100;
    else if (column.isUnique())
      return 100 * 100;
    else
      return 100 * 100 * 100;
  }
View Full Code Here


  /**
   * The cost of a match of the expr.
   */
  public long subCost(ArrayList<FromItem> fromList)
  {
    Column column = findColumn(fromList);

    if (column == null)
      return Integer.MAX_VALUE;
    else
      return 10 * 100 * 100 * 100;
 
View Full Code Here

      for (int i = 0; i < fromItems.size(); i++) {
        FromItem fromItem = fromItems.get(i);

        Table table = fromItem.getTable();

        Column column = table.getColumn(_column);

        if (column != null)
          return column;
      }
View Full Code Here

    throws SQLException
  {
    Column []tableColumns = _table.getColumns();

    for (int i = 0; i < tableColumns.length; i++) {
      Column column = tableColumns[i];

      Expr defaultExpr = column.getDefault();

      if (column.getTypeCode() == ColumnType.IDENTITY) {
        defaultExpr = new IdentityExpr(column.getTable(), column);
      }
      else if (column.getAutoIncrement() > 0) {
        defaultExpr = new AutoIncrementExpr(column.getTable());
      }

      if (defaultExpr == null)
        continue;
View Full Code Here

    if ((token = scanToken()) == '(') {
      do {
        String columnName = parseIdentifier();

        Column column = table.getColumn(columnName);

        if (column == null)
          throw new SQLException(L.l("`{0}' is not a valid column in {1}",
                                     columnName, table.getName()));
        columns.add(column);
View Full Code Here

    int token;

    if ((token = scanToken()) != IDENTIFIER)
      throw error(L.l("expected identifier at `{0}'", tokenName(token)));

    Column column = table.getColumn(_lexeme);

    if (column == null)
      throw error(L.l("`{0}' is an unknown column in table {1}.",
                      _lexeme, table.getName()));
View Full Code Here

   */
  public int findColumn(String columnName)
    throws SQLException
  {
    for (int i = 0; i < _keys.size(); i++) {
      Column column = _keys.get(i).getColumn();

      if (column.getName().equals(columnName))
        return i + 1;
    }

    throw new SQLException(L.l("`{0}' is an unknown column.", columnName));
  }
View Full Code Here

      return COST_NO_TABLE;

    if (fromList.indexOf(fromItem) < fromList.size() - 1)
      return 0;

    final Column column = getColumn();

    if (column.isPrimaryKey())
      return COST_INDEX;
    else if (column.isUnique())
      return COST_UNIQUE;
    else
      return COST_SCAN;
  }
View Full Code Here

      do {
        TableIterator iter = rows[0];
        // iter.setDirty();

        for (int i = 0; i < setItems.length; i++) {
          Column column = setItems[i].getColumn();
          Expr expr = setItems[i].getExpr();

          column.set(xa, iter, expr, context);
        }

        context.setRowUpdateCount(++count);
      } while (nextTuple(rows, rows.length, context, xa));
    } catch (IOException e) {
View Full Code Here

        Table table = fromItems[i].getTable();

        int columnIndex = table.getColumnIndex(columnName);

        if (columnIndex >= 0) {
          Column column = table.getColumn(columnName);

          return new IdExpr(fromItems[i], column);
        }
      }

      Expr expr = bindParent(tableName, columnName);
      if (expr != null) {
        return expr;
      }

      throw new SQLException(L.l("`{0}' is an unknown column.", columnName));
    }
    else {
      for (int i = 0; i < fromItems.length; i++) {
        if (tableName.equals(fromItems[i].getName())) {
          Table table = fromItems[i].getTable();

          if ("resin_oid".equals(columnName))
            return new OidExpr(fromItems[i], table, i);

          int columnIndex = table.getColumnIndex(columnName);

          if (columnIndex < 0) {
            Expr expr = bindParent(tableName, columnName);
            if (expr != null)
              return expr;

            throw new SQLException(L.l("`{0}' is an unknown column in \n  {1}.",
                                       columnName, _sql));
          }

          Column column = table.getColumn(columnName);

          return new IdExpr(fromItems[i], column);
        }
      }
View Full Code Here

TOP

Related Classes of com.caucho.db.table.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.