org.eigenbase.sql
Class SqlExplain

java.lang.Object
  extended by org.eigenbase.sql.SqlNode
      extended by org.eigenbase.sql.SqlCall
          extended by org.eigenbase.sql.SqlExplain
All Implemented Interfaces:
Cloneable

public class SqlExplain
extends SqlCall

A SqlExplain is a node of a parse tree which represents an EXPLAIN PLAN statement.


Nested Class Summary
static class SqlExplain.Depth
          The level of abstraction with which to display the plan.
 
Field Summary
static int AS_XML_OPERAND
           
static int DEPTH_OPERAND
           
static int DETAIL_LEVEL_OPERAND
           
static int EXPLICANDUM_OPERAND
           
private  int nDynamicParams
           
static int OPERAND_COUNT
           
 
Fields inherited from class org.eigenbase.sql.SqlCall
operands
 
Fields inherited from class org.eigenbase.sql.SqlNode
emptyArray
 
Constructor Summary
SqlExplain(SqlSpecialOperator operator, SqlNode explicandum, SqlLiteral detailLevel, SqlLiteral depth, SqlLiteral asXml, int nDynamicParams, SqlParserPos pos)
           
 
Method Summary
 SqlExplain.Depth getDepth()
          Returns the level of abstraction at which this plan should be displayed.
 SqlExplainLevel getDetailLevel()
           
 int getDynamicParamCount()
           
 SqlNode getExplicandum()
           
 boolean isXml()
          Returns whether result is to be in XML format.
 void unparse(SqlWriter writer, int leftPrec, int rightPrec)
          Writes a SQL representation of this node to a writer.
 boolean withImplementation()
           
 boolean withType()
           
 
Methods inherited from class org.eigenbase.sql.SqlCall
accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getKind, getMonotonicity, getOperands, getOperator, isA, isCountStar, isExpanded, isName, setOperand, setOperator, validate
 
Methods inherited from class org.eigenbase.sql.SqlNode
clone, cloneArray, equalDeep, getParserPosition, toSqlString, toSqlString, toString, validateExpr
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXPLICANDUM_OPERAND

public static final int EXPLICANDUM_OPERAND
See Also:
Constant Field Values

DETAIL_LEVEL_OPERAND

public static final int DETAIL_LEVEL_OPERAND
See Also:
Constant Field Values

DEPTH_OPERAND

public static final int DEPTH_OPERAND
See Also:
Constant Field Values

AS_XML_OPERAND

public static final int AS_XML_OPERAND
See Also:
Constant Field Values

OPERAND_COUNT

public static final int OPERAND_COUNT
See Also:
Constant Field Values

nDynamicParams

private final int nDynamicParams
Constructor Detail

SqlExplain

public SqlExplain(SqlSpecialOperator operator,
                  SqlNode explicandum,
                  SqlLiteral detailLevel,
                  SqlLiteral depth,
                  SqlLiteral asXml,
                  int nDynamicParams,
                  SqlParserPos pos)
Method Detail

getExplicandum

public SqlNode getExplicandum()
Returns:
the underlying SQL statement to be explained

getDetailLevel

public SqlExplainLevel getDetailLevel()
Returns:
detail level to be generated

getDepth

public SqlExplain.Depth getDepth()
Returns the level of abstraction at which this plan should be displayed.


getDynamicParamCount

public int getDynamicParamCount()
Returns:
the number of dynamic parameters in the statement

withImplementation

public boolean withImplementation()
Returns:
whether physical plan implementation should be returned

withType

public boolean withType()
Returns:
whether type should be returned

isXml

public boolean isXml()
Returns whether result is to be in XML format.


unparse

public void unparse(SqlWriter writer,
                    int leftPrec,
                    int rightPrec)
Description copied from class: SqlNode
Writes a SQL representation of this node to a writer.

The leftPrec and rightPrec parameters give us enough context to decide whether we need to enclose the expression in parentheses. For example, we need parentheses around "2 + 3" if preceded by "5 *". This is because the precedence of the "*" operator is greater than the precedence of the "+" operator.

The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.

If SqlWriter.isAlwaysUseParentheses() is true, we use parentheses even when they are not required by the precedence rules.

For the details of this algorithm, see SqlCall.unparse(org.eigenbase.sql.SqlWriter, int, int).

Overrides:
unparse in class SqlCall
Parameters:
writer - Target writer
leftPrec - The precedence of the SqlNode immediately preceding this node in a depth-first scan of the parse tree
rightPrec - The precedence of the SqlNode immediately