Package com.mckoi.database.interpret
Class Select
- java.lang.Object
-
- com.mckoi.database.interpret.Statement
-
- com.mckoi.database.interpret.Select
-
public class Select extends Statement
Logic for interpreting an SQL SELECT statement.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList
order_by
The list of all columns to order by.private Variable[]
order_cols
The list of columns in the 'order_by' clause fully resolved.private QueryPlanNode
plan
The plan for evaluating this select expression.private TableSelectExpression
select_expression
The TableSelectExpression representing the select query itself.
-
Constructor Summary
Constructors Constructor Description Select()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static void
checkUserSelectPermissions(DatabaseQueryContext context, User user, QueryPlanNode plan)
Checks the permissions for this user to determine if they are allowed to select (read) from tables in this plan.Table
evaluate()
Evaluates the select statement with the given Database context.void
prepare()
Prepares the select statement with a Database object.java.lang.String
toString()
Outputs information for debugging.-
Methods inherited from class com.mckoi.database.interpret.Statement
addTable, Debug, existsTableWithColumn, findTableInQuery, findTableWithColumn, init, reset, resolveAgainstAliases, resolveColumn, resolveExpression, resolveTableName, resolveTree, resolveVariableName
-
-
-
-
Field Detail
-
select_expression
private TableSelectExpression select_expression
The TableSelectExpression representing the select query itself.
-
order_by
private java.util.ArrayList order_by
The list of all columns to order by. (ByColumn)
-
order_cols
private Variable[] order_cols
The list of columns in the 'order_by' clause fully resolved.
-
plan
private QueryPlanNode plan
The plan for evaluating this select expression.
-
-
Method Detail
-
checkUserSelectPermissions
static final void checkUserSelectPermissions(DatabaseQueryContext context, User user, QueryPlanNode plan) throws UserAccessException, DatabaseException
Checks the permissions for this user to determine if they are allowed to select (read) from tables in this plan. If the user is not allowed to select from a table in the plan, a UserAccessException is thrown. This is a static method.- Throws:
UserAccessException
DatabaseException
-
prepare
public void prepare() throws DatabaseException
Prepares the select statement with a Database object. This sets up internal state so that it correctly maps to a database. Also, this checks format to ensure there are no run-time syntax problems. This must be called because we 'evaluate' the statement.NOTE: Care must be taken to ensure that all methods called here are safe in as far as modifications to the data occuring. The rules for safety should be as follows. If the database is in EXCLUSIVE mode, then we need to wait until it's switched back to SHARED mode before this method is called. All collection of information done here should not involve any table state info. except for column count, column names, column types, etc. Queries such as obtaining the row count, selectable scheme information, and certainly 'getCellContents' must never be called during prepare. When prepare finishes, the affected tables are locked and the query ia safe to 'evaluate' at which time table state is safe to inspect.
- Specified by:
prepare
in classStatement
- Throws:
DatabaseException
-
evaluate
public Table evaluate() throws DatabaseException
Evaluates the select statement with the given Database context.- Specified by:
evaluate
in classStatement
- Throws:
DatabaseException
-
toString
public java.lang.String toString()
Outputs information for debugging.- Overrides:
toString
in classjava.lang.Object
-
-