Search in sources :

Example 1 with AwareVTI

use of org.apache.derby.vti.AwareVTI in project derby by apache.

the class VTIResultSet method openCore.

// 
// ResultSet interface (leftover from NoPutResultSet)
// 
/**
 * Sets state to 'open'.
 *
 * @exception StandardException thrown if activation closed.
 */
public void openCore() throws StandardException {
    beginTime = getCurrentTimeMillis();
    if (SanityManager.DEBUG)
        SanityManager.ASSERT(!isOpen, "VTIResultSet already open");
    isOpen = true;
    numOpens++;
    /* We need to Instantiate the user's ResultSet on the each open since
		 * there is no way to close and then reopen a java.sql.ResultSet.
		 * For Version 2 VTIs, we may be able to skip instantiated their
		 * PreparedStatement here.
		 */
    try {
        if (version2) {
            userPS = (PreparedStatement) constructor.invoke(activation);
            if (userPS instanceof org.apache.derby.vti.Pushable) {
                org.apache.derby.vti.Pushable p = (org.apache.derby.vti.Pushable) userPS;
                if (referencedColumns != null) {
                    pushedProjection = p.pushProjection(this, getProjectedColList());
                }
            }
            if (userPS instanceof org.apache.derby.vti.IQualifyable) {
                org.apache.derby.vti.IQualifyable q = (org.apache.derby.vti.IQualifyable) userPS;
                q.setQualifiers(this, pushedQualifiers);
            }
            fastPath = userPS instanceof IFastPath ? (IFastPath) userPS : null;
            if (isTarget && userPS instanceof DeferModification && activation.getConstantAction() instanceof UpdatableVTIConstantAction) {
                UpdatableVTIConstantAction constants = (UpdatableVTIConstantAction) activation.getConstantAction();
                ((DeferModification) userPS).modificationNotify(constants.statementType, constants.deferred);
            }
            if ((fastPath != null) && fastPath.executeAsFastPath())
                ;
            else
                userVTI = userPS.executeQuery();
            /* Save off the target VTI */
            if (isTarget) {
                activation.setTargetVTI(userVTI);
            }
        } else {
            userVTI = (ResultSet) constructor.invoke(activation);
            if (userVTI instanceof RestrictedVTI) {
                RestrictedVTI restrictedVTI = (RestrictedVTI) userVTI;
                restrictedVTI.initScan(vtiProjection, cloneRestriction(activation));
            }
            if (userVTI instanceof AwareVTI) {
                AwareVTI awareVTI = (AwareVTI) userVTI;
                awareVTI.setContext(new VTIContext(vtiSchema, vtiName, activation.getLanguageConnectionContext().getStatementContext().getStatementText()));
            }
        }
        // Set up the nullablity of the runtime columns, may be delayed
        setNullableColumnList();
    } catch (Throwable t) {
        throw StandardException.unexpectedUserException(t);
    }
    openTime += getElapsedMillis(beginTime);
}
Also used : DeferModification(org.apache.derby.vti.DeferModification) AwareVTI(org.apache.derby.vti.AwareVTI) VTIContext(org.apache.derby.vti.VTIContext) RestrictedVTI(org.apache.derby.vti.RestrictedVTI) IFastPath(org.apache.derby.vti.IFastPath)

Aggregations

AwareVTI (org.apache.derby.vti.AwareVTI)1 DeferModification (org.apache.derby.vti.DeferModification)1 IFastPath (org.apache.derby.vti.IFastPath)1 RestrictedVTI (org.apache.derby.vti.RestrictedVTI)1 VTIContext (org.apache.derby.vti.VTIContext)1