Class SelectUnion


public class SelectUnion extends Query
Represents a union SELECT statement.
  • Field Details

    • unionType

      private final SelectUnion.UnionType unionType
    • left

      final Query left
      The left hand side of the union (the first subquery).
    • isForUpdate

      private boolean isForUpdate
  • Constructor Details

  • Method Details

    • isUnion

      public boolean isUnion()
      Description copied from class: Query
      Check if this is a UNION query.
      Specified by:
      isUnion in class Query
      Returns:
      true if this is a UNION query
    • getUnionType

      public SelectUnion.UnionType getUnionType()
    • getLeft

      public Query getLeft()
    • getRight

      public Query getRight()
    • convert

      private Value[] convert(Value[] values, int columnCount)
    • getEmptyResult

      public LocalResult getEmptyResult()
    • queryWithoutCache

      protected ResultInterface queryWithoutCache(long maxRows, ResultTarget target)
      Description copied from class: Query
      Execute the query without checking the cache. If a target is specified, the results are written to it, and the method returns null. If no target is specified, a new LocalResult is created and returned.
      Specified by:
      queryWithoutCache in class Query
      Parameters:
      maxRows - the limit as specified in the JDBC method call
      target - the target to write results to
      Returns:
      the result
    • createLocalResult

      private LocalResult createLocalResult(int columnCount)
    • init

      public void init()
      Description copied from class: Query
      Initialize the query.
      Specified by:
      init in class Query
    • prepare

      public void prepare()
      Description copied from class: Prepared
      Prepare this statement.
      Overrides:
      prepare in class Prepared
    • getCost

      public double getCost()
      Description copied from class: Query
      Calculate the cost to execute this query.
      Specified by:
      getCost in class Query
      Returns:
      the cost
    • getTables

      public HashSet<Table> getTables()
      Description copied from class: Query
      Get all tables that are involved in this query.
      Specified by:
      getTables in class Query
      Returns:
      the set of tables
    • setForUpdate

      public void setForUpdate(boolean forUpdate)
      Description copied from class: Query
      Set the 'for update' flag.
      Specified by:
      setForUpdate in class Query
      Parameters:
      forUpdate - the new setting
    • mapColumns

      public void mapColumns(ColumnResolver resolver, int level)
      Description copied from class: Query
      Map the columns to the given column resolver.
      Specified by:
      mapColumns in class Query
      Parameters:
      resolver - the resolver
      level - the subquery level (0 is the top level query, 1 is the first subquery level)
    • setEvaluatable

      public void setEvaluatable(TableFilter tableFilter, boolean b)
      Description copied from class: Query
      Change the evaluatable flag. This is used when building the execution plan.
      Specified by:
      setEvaluatable in class Query
      Parameters:
      tableFilter - the table filter
      b - the new value
    • addGlobalCondition

      public void addGlobalCondition(Parameter param, int columnId, int comparisonType)
      Description copied from class: Query
      Add a condition to the query. This is used for views.
      Specified by:
      addGlobalCondition in class Query
      Parameters:
      param - the parameter
      columnId - the column index (0 meaning the first column)
      comparisonType - the comparison type
    • getPlanSQL

      public String getPlanSQL(int sqlFlags)
      Description copied from class: Prepared
      Get the SQL statement with the execution plan.
      Overrides:
      getPlanSQL in class Prepared
      Parameters:
      sqlFlags - formatting flags
      Returns:
      the execution plan
    • isEverything

      public boolean isEverything(ExpressionVisitor visitor)
      Description copied from class: Query
      Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.
      Specified by:
      isEverything in class Query
      Parameters:
      visitor - the visitor
      Returns:
      if the criteria can be fulfilled
    • updateAggregate

      public void updateAggregate(SessionLocal s, int stage)
      Description copied from class: Query
      Update all aggregate function values.
      Specified by:
      updateAggregate in class Query
      Parameters:
      s - the session
      stage - select stage
    • fireBeforeSelectTriggers

      public void fireBeforeSelectTriggers()
      Description copied from class: Query
      Call the before triggers on all tables.
      Specified by:
      fireBeforeSelectTriggers in class Query
    • allowGlobalConditions

      public boolean allowGlobalConditions()
      Description copied from class: Query
      Check whether adding condition to the query is allowed. This is not allowed for views that have an order by and a limit, as it would affect the returned results.
      Specified by:
      allowGlobalConditions in class Query
      Returns:
      true if adding global conditions is allowed
    • isConstantQuery

      public boolean isConstantQuery()
      Description copied from class: Query
      Check if this query will always return the same value and has no side effects.
      Overrides:
      isConstantQuery in class Query
      Returns:
      if this query will always return the same value and has no side effects.