net.sf.saffron.rel.jdbc
Class JdbcQuery

java.lang.Object
  |
  +--net.sf.saffron.rel.SaffronRel
        |
        +--net.sf.saffron.rel.jdbc.JdbcQuery

public class JdbcQuery
extends SaffronRel

A JdbcQuery is a relational expression whose source is a SQL statement executed against a JDBC data source. It has result set calling convention.

Since:
2 August, 2002
Version:
$Id: //open/saffron/src/net/sf/saffron/rel/jdbc/JdbcQuery.java#5 $
Author:
jhyde

Field Summary
protected  SaffronConnection connection
          The expression which yields the connection object.
 DataSource dataSource
           
(package private)  SqlDialect dialect
           
(package private)  String queryString
          For debug.
(package private)  SqlSelect sql
           
 
Fields inherited from class net.sf.saffron.rel.SaffronRel
cluster, digest, id, rowType
 
Constructor Summary
JdbcQuery(VolcanoCluster cluster, SaffronType rowType, SaffronConnection connection, SqlDialect dialect, SqlSelect sql, DataSource dataSource)
          Creates a JdbcQuery.
 
Method Summary
 Object clone()
           
 PlanCost computeSelfCost(SaffronPlanner planner)
          Returns the cost of this plan (not including children).
protected  SaffronType deriveRowType()
           
 SaffronConnection getConnection()
           
 CallingConvention getConvention()
          Returns a value from CallingConvention.
 String getQualifier()
           
 Object implement(RelImplementor implementor, int ordinal)
          Create a plan for this expression according to a calling convention.
 void onRegister(SaffronPlanner planner)
          This method is called just before the expression is registered.
static void register(SaffronPlanner planner)
          Registers any special rules specific to this kind of relational expression.
 
Methods inherited from class net.sf.saffron.rel.SaffronRel
childrenAccept, computeDigest, explain, getChildExps, getCluster, getCorrelVariable, getId, getInput, getInputs, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRows, getRowType, getTable, getVariablesStopped, implementFieldAccess, isAccessTo, isDistinct, recomputeDigest, registerCorrelVariable, replaceInput, setCorrelVariable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dataSource

public final DataSource dataSource

connection

protected SaffronConnection connection
The expression which yields the connection object.


dialect

SqlDialect dialect

sql

SqlSelect sql

queryString

String queryString
For debug. Set on register.

Constructor Detail

JdbcQuery

public JdbcQuery(VolcanoCluster cluster,
                 SaffronType rowType,
                 SaffronConnection connection,
                 SqlDialect dialect,
                 SqlSelect sql,
                 DataSource dataSource)
Creates a JdbcQuery.

Parameters:
cluster - VolcanoCluster this relational expression belongs to
connection - a SaffronConnection; must also implement DataSource, because that's how we will acquire the JDBC connection; if you are generating code, the must have registered the connection with OJConnectionRegistry
sql - SQL parse tree, may be null, otherwise must be a SELECT statement
dataSource - Provides a JDBC connection to run this query against. If the query is implementing a JDBC table, then the connection's schema will implement JdbcSchema, and data source will typically be the same as calling JdbcSchema.getDataSource(net.sf.saffron.core.SaffronConnection). But non-JDBC schemas are also acceptable.
Pre-condition:
connection != null, sql == null || sql.isA(SqlNode.Kind.Select), dataSource != null
Method Detail

getConnection

public SaffronConnection getConnection()

getConvention

public CallingConvention getConvention()
Description copied from class: SaffronRel
Returns a value from CallingConvention.

Overrides:
getConvention in class SaffronRel

getQualifier

public String getQualifier()
Overrides:
getQualifier in class SaffronRel

clone

public Object clone()
Specified by:
clone in class SaffronRel

computeSelfCost

public PlanCost computeSelfCost(SaffronPlanner planner)
Description copied from class: SaffronRel
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

Overrides:
computeSelfCost in class SaffronRel

onRegister

public void onRegister(SaffronPlanner planner)
Description copied from class: SaffronRel
This method is called just before the expression is registered. The implementation of this method must at least register all child expressions.

Overrides:
onRegister in class SaffronRel

register

public static void register(SaffronPlanner planner)
Description copied from class: SaffronRel
Registers any special rules specific to this kind of relational expression.

The planner calls this method this first time that it sees a relational expression of this class. The derived class should call SaffronPlanner.addRule(net.sf.saffron.opt.VolcanoRule) for each rule, and then call SaffronRel.register(net.sf.saffron.core.SaffronPlanner) on its base class.


implement

public Object implement(RelImplementor implementor,
                        int ordinal)
Description copied from class: SaffronRel
Create a plan for this expression according to a calling convention.

Overrides:
implement in class SaffronRel
Parameters:
implementor - implementor
ordinal - indicates our position in the pre-, in- and postfix walk over the tree; ordinal is -1 when called from the parent, and i when called from the ith child.

deriveRowType

protected SaffronType deriveRowType()
Specified by:
deriveRowType in class SaffronRel

SourceForge.net_Logo