## org.h2.table
Class TableFilter

    java.lang.Object
      org.h2.table.TableFilter

All Implemented Interfaces:
  ColumnResolver

    public class TableFilter

extends java.lang.Object
implements ColumnResolver

A table filter represents a table that is used in a query. There is one such object whenever a table (or view) is used in a query. For example the following query has 2 table filters: SELECT * FROM TEST T1, TEST T2.

Nested Class Summary
`static interface` `TableFilter.TableFilterVisitor` A visitor for table filters.

Field Summary
`protected boolean` `joinOuterIndirect` Whether this is a direct or indirect (nested) outer join
`protected Session` `session`

Constructor Summary
`TableFilter(Session session, Table table, java.lang.String alias, boolean rightsChecked, Select select)` Create a new table filter object.

Method Summary
`void` `addFilterCondition(Expression condition, boolean isJoin)` Add a filter condition.
`void` `addIndexCondition(IndexCondition condition)` Add an index condition.
`void` `addJoin(TableFilter filter, boolean outer, boolean nested, Expression on)` Add a joined table.
`void` `addNaturalJoinColumn(Column c)` Add a column to the natural join key column list.
`Row` `get()` Get the current row.
`PlanItem` `getBestPlanItem(Session s, int level)` Get the best plan item (index, cost) to use use for the current join order.
`Column[]` `getColumns()` Get the column list.
`Expression` `getFilterCondition()`
`Index` `getIndex()`
`TableFilter` `getJoin()`
`Expression` `getJoinCondition()`
`TableFilter` `getNestedJoin()`
`java.lang.String` `getPlanSQL(boolean isJoin)` Get the query execution plan text to use for this table filter.
`Column` `getRowIdColumn()` Get the row id pseudo column, if there is one.
`java.lang.String` `getSchemaName()` Get the schema name.
`Select` `getSelect()` Get the select statement.
`Session` `getSession()`
`Column[]` `getSystemColumns()` Get the system columns that this table understands.
`Table` `getTable()`
`java.lang.String` `getTableAlias()` Get the table alias name.
`TableFilter` `getTableFilter()` Get the table filter.
`Value` `getValue(Column column)` Get the value for the given column.
`int` `hashCode()`
`boolean` `hasInComparisons()` Are there any index conditions that involve IN(...).
`boolean` `isEvaluatable()`
`boolean` `isJoinOuter()` Whether this is an outer joined table.
`boolean` `isJoinOuterIndirect()` Whether this is indirectly an outer joined table (nested within an inner join).
`boolean` `isNaturalJoinColumn(Column c)` Check if the given column is a natural join column.
`boolean` `isUsed()`
`void` `lock(Session s, boolean exclusive, boolean force)` Lock the table.
`void` `lockRowAdd(java.util.ArrayList<Row> rows)` Add the current row to the array, if there is a current row.
`void` `lockRows(java.util.ArrayList<Row> forUpdateRows)` Lock the given rows.
`void` `mapAndAddFilter(Expression on)` Map the columns and add the join condition.
`boolean` `next()` Check if there are more rows to read.
`Expression` `optimize(ExpressionColumn expressionColumn, Column column)` Get the expression that represents this column.
`void` `prepare()` Prepare reading rows.
`void` `removeFilterCondition()` Remove the filter condition.
`void` `removeJoin()` Remove the joined table
`void` `removeJoinCondition()` Remove the join condition.
`void` `reset()` Reset to the current position.
`void` `set(Row current)` Set the current row.
`void` `setAlias(java.lang.String alias)`
`void` `setEvaluatable(boolean evaluatable)`
`void` `setEvaluatable(TableFilter filter, boolean b)` Update the filter and join conditions of this and all joined tables with the information that the given table filter and all nested filter can now return rows or not.
`void` `setFullCondition(Expression condition)`
`void` `setIndex(Index index)`
`protected void` `setNullRow()` Set the state of this and all nested tables to the NULL row.
`void` `setPlanItem(PlanItem item)` Set what plan item (index, cost) to use use.
`void` `setUsed(boolean used)`
`void` `startQuery(Session s)` Start the query.
`java.lang.String` `toString()`
`void` `visit(TableFilter.TableFilterVisitor visitor)` Visit this and all joined or nested table filters.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### session

    protected Session session

### joinOuterIndirect

    protected boolean joinOuterIndirect

  Whether this is a direct or indirect (nested) outer join

Constructor Detail

### TableFilter

    public TableFilter(Session session,
                       Table table,
                       java.lang.String alias,
                       boolean rightsChecked,
                       Select select)

  Create a new table filter object.

  Parameters:
    `session` - the session
    `table` - the table from where to read data
    `alias` - the alias name
    `rightsChecked` - true if rights are already checked
    `select` - the select statement

Method Detail

### getSelect

    public Select getSelect()

  Description copied from interface: `ColumnResolver`
  Get the select statement.

  Specified by:
    `getSelect` in interface `ColumnResolver`
  Returns:
    the select statement

### getTable

    public Table getTable()

### lock

    public void lock(Session s,
                     boolean exclusive,
                     boolean force)

  Lock the table. This will also lock joined tables.

  Parameters:
    `s` - the session
    `exclusive` - true if an exclusive lock is required
    `force` - lock even in the MVCC mode

### getBestPlanItem

    public PlanItem getBestPlanItem(Session s,
                                    int level)

  Get the best plan item (index, cost) to use use for the current join order.

  Parameters:
    `s` - the session
    `level` - 1 for the first table in a join, 2 for the second, and so on
  Returns:
    the best plan item

### setPlanItem

    public void setPlanItem(PlanItem item)

  Set what plan item (index, cost) to use use.

  Parameters:
    `item` - the plan item

### prepare

    public void prepare()

  Prepare reading rows. This method will remove all index conditions that can not be used, and optimize the conditions.

### startQuery

    public void startQuery(Session s)

  Start the query. This will reset the scan counts.

  Parameters:
    `s` - the session

### reset

    public void reset()

  Reset to the current position.

### next

    public boolean next()

  Check if there are more rows to read.

  Returns:
    true if there are

### setNullRow

    protected void setNullRow()

  Set the state of this and all nested tables to the NULL row.

### get

    public Row get()

  Get the current row.

  Returns:
    the current row, or null

### set

    public void set(Row current)

  Set the current row.

  Parameters:
    `current` - the current row

### getTableAlias

    public java.lang.String getTableAlias()

  Get the table alias name. If no alias is specified, the table name is returned.

  Specified by:
    `getTableAlias` in interface `ColumnResolver`
  Returns:
    the alias name

### addIndexCondition

    public void addIndexCondition(IndexCondition condition)

  Add an index condition.

  Parameters:
    `condition` - the index condition

### addFilterCondition

    public void addFilterCondition(Expression condition,
                                   boolean isJoin)

  Add a filter condition.

  Parameters:
    `condition` - the condition
    `isJoin` - if this is in fact a join condition

### addJoin

    public void addJoin(TableFilter filter,
                        boolean outer,
                        boolean nested,
                        Expression on)

  Add a joined table.

  Parameters:
    `filter` - the joined table filter
    `outer` - if this is an outer join
    `nested` - if this is a nested join
    `on` - the join condition

### mapAndAddFilter

    public void mapAndAddFilter(Expression on)

  Map the columns and add the join condition.

  Parameters:
    `on` - the condition

### getJoin

    public TableFilter getJoin()

### isJoinOuter

    public boolean isJoinOuter()

  Whether this is an outer joined table.

  Returns:
    true if it is

### isJoinOuterIndirect

    public boolean isJoinOuterIndirect()

  Whether this is indirectly an outer joined table (nested within an inner join).

  Returns:
    true if it is

### getPlanSQL

    public java.lang.String getPlanSQL(boolean isJoin)

  Get the query execution plan text to use for this table filter.

  Parameters:
    `isJoin` - if this is a joined table
  Returns:
    the SQL statement snippet

### getIndex

    public Index getIndex()

### setIndex

    public void setIndex(Index index)

### setUsed

    public void setUsed(boolean used)

### isUsed

    public boolean isUsed()

### removeJoin

    public void removeJoin()

  Remove the joined table

### getJoinCondition

    public Expression getJoinCondition()

### removeJoinCondition

    public void removeJoinCondition()

  Remove the join condition.

### getFilterCondition

    public Expression getFilterCondition()

### removeFilterCondition

    public void removeFilterCondition()

  Remove the filter condition.

### setFullCondition

    public void setFullCondition(Expression condition)

### setEvaluatable

    public void setEvaluatable(TableFilter filter,
                               boolean b)

  Update the filter and join conditions of this and all joined tables with the information that the given table filter and all nested filter can now return rows or not.

  Parameters:
    `filter` - the table filter
    `b` - the new flag

### setEvaluatable

    public void setEvaluatable(boolean evaluatable)

### getSchemaName

    public java.lang.String getSchemaName()

  Description copied from interface: `ColumnResolver`
  Get the schema name.

  Specified by:
    `getSchemaName` in interface `ColumnResolver`
  Returns:
    the schema name

### getColumns

    public Column[] getColumns()

  Description copied from interface: `ColumnResolver`
  Get the column list.

  Specified by:
    `getColumns` in interface `ColumnResolver`
  Returns:
    the column list

### getSystemColumns

    public Column[] getSystemColumns()

  Get the system columns that this table understands. This is used for compatibility with other databases. The columns are only returned if the current mode supports system columns.

  Specified by:
    `getSystemColumns` in interface `ColumnResolver`
  Returns:
    the system columns

### getRowIdColumn

    public Column getRowIdColumn()

  Description copied from interface: `ColumnResolver`
  Get the row id pseudo column, if there is one.

  Specified by:
    `getRowIdColumn` in interface `ColumnResolver`
  Returns:
    the row id column or null

### getValue

    public Value getValue(Column column)

  Description copied from interface: `ColumnResolver`
  Get the value for the given column.

  Specified by:
    `getValue` in interface `ColumnResolver`
  Parameters:
    `column` - the column
  Returns:
    the value

### getTableFilter

    public TableFilter getTableFilter()

  Description copied from interface: `ColumnResolver`
  Get the table filter.

  Specified by:
    `getTableFilter` in interface `ColumnResolver`
  Returns:
    the table filter

### setAlias

    public void setAlias(java.lang.String alias)

### optimize

    public Expression optimize(ExpressionColumn expressionColumn,
                               Column column)

  Description copied from interface: `ColumnResolver`
  Get the expression that represents this column.

  Specified by:
    `optimize` in interface `ColumnResolver`
  Parameters:
    `expressionColumn` - the expression column
    `column` - the column
  Returns:
    the optimized expression

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### addNaturalJoinColumn

    public void addNaturalJoinColumn(Column c)

  Add a column to the natural join key column list.

  Parameters:
    `c` - the column to add

### isNaturalJoinColumn

    public boolean isNaturalJoinColumn(Column c)

  Check if the given column is a natural join column.

  Parameters:
    `c` - the column to check
  Returns:
    true if this is a joined natural join column

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### hasInComparisons

    public boolean hasInComparisons()

  Are there any index conditions that involve IN(...).

  Returns:
    whether there are IN(...) comparisons

### lockRowAdd

    public void lockRowAdd(java.util.ArrayList<Row> rows)

  Add the current row to the array, if there is a current row.

  Parameters:
    `rows` - the rows to lock

### lockRows

    public void lockRows(java.util.ArrayList<Row> forUpdateRows)

  Lock the given rows.

  Parameters:
    `forUpdateRows` - the rows to lock

### getNestedJoin

    public TableFilter getNestedJoin()

### visit

    public void visit(TableFilter.TableFilterVisitor visitor)

  Visit this and all joined or nested table filters.

  Parameters:
    `visitor` - the visitor

### isEvaluatable

    public boolean isEvaluatable()

### getSession

    public Session getSession()