com.caucho.db.sql
Class Query

java.lang.Object
  extended by com.caucho.db.sql.Query
Direct Known Subclasses:
CreateQuery, SelectQuery, TempQuery

@Module
public abstract class Query
extends java.lang.Object


Field Summary
protected  Expr _whereExpr
           
 
Constructor Summary
protected Query(Database db, java.lang.String sql)
           
protected Query(Database db, java.lang.String sql, FromItem[] fromItems)
           
 
Method Summary
protected  void bind()
          Binds the query.
protected  Expr bind(java.lang.String tableName, java.lang.String columnName)
          Returns a bound expression for the specified table.column.
abstract  void execute(QueryContext queryCtx, DbTransaction xa)
          Executes the query.
 SelectCursor executeCursor(QueryContext queryCtx, DbTransaction xa)
          Executes the query.
protected  void freeRows(TableIterator[] rows, int rowLength)
          Frees any blocks for the rows.
protected  void generateWhere(Expr whereExpr)
          Optimize the where and order the from items.
 Database getDatabase()
          Returns the owning database.
 int getDataFields()
          Returns the number of temporary data fields.
 FromItem[] getFromItems()
          Returns any from items.
 java.util.ArrayList<SubSelectParamExpr> getParamExprs()
          Returns the param exprs.
 Query getParent()
          Gets the parent query
 SubSelectExpr getSubSelect()
          Gets the parent sub-select.
 Expr[] getWhereExprs()
          Returns the where exprs
 boolean isGroup()
          Sets true for group operations
 boolean isReadOnly()
           
 boolean isSelect()
          Returns true for select queries.
protected  boolean nextTuple(TableIterator[] rows, int rowLength, QueryContext queryContext, DbTransaction xa)
          Returns the next tuple from the query.
 void setDataFields(int fieldCount)
          Sets the number of temporary data fields.
protected  void setFromItems(java.util.ArrayList<FromItem> fromItems)
          Sets from items.
protected  void setFromItems(FromItem[] fromItems)
          Sets from items.
 void setGroup(boolean isGroup)
          Sets the current number of group fields.
 void setLimit(int limit)
          Sets the maximum entires
 void setParams(com.caucho.db.sql.ParamExpr[] params)
          Sets the params.
 void setParent(Query query)
          Sets the parent query
 void setSubSelect(SubSelectExpr subSelect)
          Sets the parent sub-select.
 void setWhereExpr(Expr expr)
          Sets the where expr.
protected  void setWhereExprs(Expr[] whereExprs)
          Sets the where exprs.
protected  boolean start(TableIterator[] rows, int rowLength, QueryContext queryContext, DbTransaction xa)
          Starts the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_whereExpr

protected Expr _whereExpr
Constructor Detail

Query

protected Query(Database db,
                java.lang.String sql)

Query

protected Query(Database db,
                java.lang.String sql,
                FromItem[] fromItems)
Method Detail

getDatabase

public Database getDatabase()
Returns the owning database.


setParent

public void setParent(Query query)
Sets the parent query


getParent

public Query getParent()
Gets the parent query


setSubSelect

public void setSubSelect(SubSelectExpr subSelect)
Sets the parent sub-select.


getSubSelect

public SubSelectExpr getSubSelect()
Gets the parent sub-select.


getDataFields

public int getDataFields()
Returns the number of temporary data fields.


setDataFields

public void setDataFields(int fieldCount)
Sets the number of temporary data fields.


setLimit

public void setLimit(int limit)
Sets the maximum entires


getFromItems

public final FromItem[] getFromItems()
Returns any from items.


setFromItems

protected void setFromItems(FromItem[] fromItems)
Sets from items.


setFromItems

protected void setFromItems(java.util.ArrayList<FromItem> fromItems)
Sets from items.


setWhereExpr

public void setWhereExpr(Expr expr)
Sets the where expr.


getWhereExprs

public Expr[] getWhereExprs()
Returns the where exprs


setWhereExprs

protected void setWhereExprs(Expr[] whereExprs)
Sets the where exprs.


setParams

public void setParams(com.caucho.db.sql.ParamExpr[] params)
Sets the params.


getParamExprs

public java.util.ArrayList<SubSelectParamExpr> getParamExprs()
Returns the param exprs.


isSelect

public boolean isSelect()
Returns true for select queries.


isReadOnly

public boolean isReadOnly()

setGroup

public void setGroup(boolean isGroup)
Sets the current number of group fields.


isGroup

public boolean isGroup()
Sets true for group operations


bind

protected void bind()
             throws java.sql.SQLException
Binds the query.

Throws:
java.sql.SQLException

generateWhere

protected void generateWhere(Expr whereExpr)
                      throws java.sql.SQLException
Optimize the where and order the from items.

Throws:
java.sql.SQLException

bind

protected Expr bind(java.lang.String tableName,
                    java.lang.String columnName)
             throws java.sql.SQLException
Returns a bound expression for the specified table.column.

Throws:
java.sql.SQLException

execute

public abstract void execute(QueryContext queryCtx,
                             DbTransaction xa)
                      throws java.sql.SQLException
Executes the query.

Throws:
java.sql.SQLException

executeCursor

public SelectCursor executeCursor(QueryContext queryCtx,
                                  DbTransaction xa)
                           throws java.sql.SQLException
Executes the query.

Throws:
java.sql.SQLException

start

protected boolean start(TableIterator[] rows,
                        int rowLength,
                        QueryContext queryContext,
                        DbTransaction xa)
                 throws java.sql.SQLException
Starts the query.

Throws:
java.sql.SQLException

nextTuple

protected boolean nextTuple(TableIterator[] rows,
                            int rowLength,
                            QueryContext queryContext,
                            DbTransaction xa)
                     throws java.io.IOException,
                            java.sql.SQLException
Returns the next tuple from the query.

Throws:
java.io.IOException
java.sql.SQLException

freeRows

protected void freeRows(TableIterator[] rows,
                        int rowLength)
Frees any blocks for the rows.