Class FromVTI
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ResultSetNode
org.apache.derby.impl.sql.compile.FromTable
org.apache.derby.impl.sql.compile.FromVTI
- All Implemented Interfaces:
Optimizable, Visitable, VTIEnvironment
A FromVTI represents a VTI in the FROM list of a DML statement.
-
Nested Class Summary
Nested classes/interfaces inherited from class ResultSetNode
ResultSetNode.QueryExpressionClauses -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FormatableHashtableprivate boolean(package private) JBitSet(package private) JBitSet(package private) double(package private) double(package private) TableNameprivate boolean(package private) boolean(package private) boolean(package private) boolean(package private) boolean(package private) boolean(package private) MethodCallNodeprivate JavaValueNode[]protected int(package private) booleanprivate String[]private PreparedStatementprivate PredicateListprivate int(package private) ResultSet(package private) SubqueryList(package private) booleanprotected boolean(package private) booleanprivate RestrictionFields inherited from class FromTable
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategyFields inherited from class QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX -
Constructor Summary
ConstructorsConstructorDescriptionFromVTI(MethodCallNode invocation, String correlationName, ResultColumnList derivedRCL, Properties tableProperties, ContextManager cm) Constructor.FromVTI(MethodCallNode invocation, String correlationName, ResultColumnList derivedRCL, Properties tableProperties, TableName exposedTableName, ContextManager cm) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) voidAccept the visitor for all visitable children of this node.voidaddOuterFromList(FromList fromList) Add a FromList to the collection of FromLists which bindExpressions() checks when vetting VTI arguments which reference columns in other tables.(package private) voidNotify the underlying result set tree that the optimizer has chosen to "eliminate" a sort.(package private) voidbindExpressions(FromList fromListParam) Bind the expressions in this VTI.(package private) ResultSetNodebindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) Bind the non VTI tables in this ResultSetNode.(package private) ResultSetNodebindVTITables(FromList fromListParam) Bind this VTI that appears in the FROM list.private booleancanBePushedDown(Predicate predicate) Return true if the predicate can be pushed into a RestrictedVTIprivate FromTablecolumnInFromList(FromList fromList, ColumnReference ref) If the referenced column appears in the indicated FROM list, then return the table it appears in.Fills in the array of projected column names suitable for handing to RestrictedVTI.initScan().(package private) voidcomputeProjectionAndRestriction(PredicateList parentPredicates) Compute the projection and restriction to be pushed to the external table function if it is a RestrictedVTI.private voidcomputeRestriction(PredicateList parentPredicates, HashMap<String, String> columnNameMap) Fills in the restriction to be handed to a RestrictedVTI at run-time.private voidconstructorMinion(MethodCallNode invocation, ResultColumnList derivedRCL, TableName exposedTableName) private voidAdd result columns for a Derby-style Table FunctionestimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate.private intflipOperator(int rawOperator) Flip the sense of a comparison(package private) voidgenerate(ActivationClassBuilder acb, MethodBuilder mb) Generation on a FromVTI creates a wrapper around the user's java.sql.ResultSetprivate voidgenerateConstructor(ActivationClassBuilder acb, MethodBuilder mb, boolean reuseablePs) protected ResultSetNodegenProjectRestrict(int numTables) Put a ProjectRestrictNode on top of each FromTable in the FromList.private ResultColumnList(package private) ResultColumnListgetAllResultColumns(TableName allTableName) Expand a "*" into a ResultColumnList with all of the result columns from the subquery.Get the DeferModification interface associated with this VTI(package private) StringGet the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.(package private) ResultColumngetMatchingColumn(ColumnReference columnReference) Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name in the given ColumnReference.(package private) final MethodCallNodeReturn the constructor or static method invoked from this nodeprivate ObjectgetNodesFromParameters(Class<T> nodeClass) Get all of the nodes of the specified class from the parameters to this VTI.Return the SQL text of the original SQL statement.(package private) ResultSetMetaDataGet the ResultSetMetaData for the class/object.intprivate intgetSharedState(String key) Get an object associated with a key from set of objects maintained with the statement plan.private UUIDgetSpecialTriggerVTITableName(LanguageConnectionContext lcc, String className) Check and see if we have a special trigger VTI.final intGet the specific JDBC isolation of the statement.private VTICostingGet the VTICosting implementation for this optimizable VTI.(package private) Stringprivate RestrictioniAmConfused(ValueNode clause) This is a handy place to put instrumentation for tracing trees which we don't understandprivate booleanimplementsDerbyStyleVTICosting(String className) Return true if this Derby Style Table Function implements the VTICosting interface.final booleanReturn true if this instance of the Table Function has been created for compilation, false if it is for runtime execution.(package private) booleanReturn true if this VTI is a constructor.booleanReturn true if this is a user-defined table functionbooleanTell whether this Optimizable is materializable(package private) booleanbooleanlegalJoinOrder(JBitSet assignedTableMap) Can this Optimizable appear at the current location in the join order.private Class<?> lookupClass(String className) Lookup the class that holds the VTI.private RestrictionmakeIsNullRestriction(IsNullNode clause, HashMap<String, String> columnNameMap) Makes an IS NULL comparison of a column in the VTI.private RestrictionmakeLeafRestriction(BinaryRelationalOperatorNode clause, HashMap<String, String> columnNameMap) Makes a Restriction out of a comparison between a constant and a column in the VTI.private RestrictionmakeRestriction(ValueNode clause, HashMap<String, String> columnNameMap) Turn a compile-time WHERE clause fragment into a run-time Restriction.private intmapOperator(int rawOperator) Map internal operator constants to user-visible onesmodifyAccessPath(JBitSet outerTables) Modify the access path for this Optimizable, as necessary.(package private) boolean(package private) booleanperformMaterialization(JBitSet outerTables) Return whether or not to materialize this ResultSet tree.(package private) ResultSetNodepreprocess(int numTables, GroupByList gbl, FromList fromList) Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode.(package private) voidprintSubNodes(int depth) Prints the sub-nodes of this object.booleanpushOptPredicate(OptimizablePredicate optimizablePredicate) Push an OptimizablePredicate down, if this node accepts it.(package private) booleanreferencesTarget(String name, boolean baseTable) Search to see if a query references the specifed table name.private voidRemap the column references in vti arguments.voidsetSharedState(String key, Serializable value) Saves an object associated with a key that will be maintained for the lifetime of the statement plan.(package private) voidMark this VTI as the target of a delete or update.private ObjectsqueezeConstantValue(ValueNode valueNode) Get the constant or parameter reference out of a comparand.private intstoreObjectInPS(ActivationClassBuilder acb, Object obj) Store an object in the prepared statement.booleanTell whether this Optimizable can be instantiated multiple timestoString()Convert this object to a String.Methods inherited from class FromTable
assignCostEstimate, canBeOrdered, columnsAreUpdatable, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, decrementLevel, feasibleJoinStrategy, fillInReferencedTableMap, flatten, forUpdate, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCorrelationName, getCostEstimate, getCurrentAccessPath, getFinalCostEstimate, getFromTableByName, getLevel, getMergeTableID, getName, getNumColumnsReturned, getOrigTableName, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getTrulyTheBestAccessPath, getUserSpecifiedJoinStrategy, hashKeyColumns, hasLargeObjectColumns, hasTableNumber, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isJoinColumnForRightOuterJoin, isOneRowScan, isTargetTable, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, nextAccessPath, optimizeIt, optimizeSubqueries, pullOptPredicates, pushExpressions, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setCostEstimateCost, setHashKeyColumns, setLevel, setMergeTableID, setOrigTableName, setProperties, setTableNumber, startOptimizing, tellRowOrderingAboutConstantColumns, transformOuterJoins, uniqueJoin, updateBestPlanMap, verifyPropertiesMethods inherited from class ResultSetNode
addNewPredicate, adjustForSortElimination, assignResultSetNumber, bindExpressionsWithTables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, changeAccessPath, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genProjectRestrict, genProjectRestrictForReordering, getCandidateFinalCostEstimate, getCostEstimate, getCursorTargetTable, getFromList, getNewCostEstimate, getOptimizer, getOptimizerImpl, getRCLForInsert, getReferencedTableMap, getResultColumns, getResultSetNumber, getScratchCostEstimate, isCursorTargetTable, isInsertSource, isNotExists, isOneRowResultSet, isOrderedOn, isPossibleDistinctScan, isStatementResultSet, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, modifyAccessPaths, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, optimize, parseDefault, printQueryExpressionSuffixClauses, projectResultColumns, pushOffsetFetchFirst, pushOrderByList, pushQueryExpressionSuffix, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceOrForbidDefaults, returnsAtMostOneRow, setCandidateFinalCostEstimate, setCostEstimate, setCursorTargetTable, setInsertSource, setOptimizer, setReferencedTableMap, setResultColumns, setResultSetNumber, setResultToBooleanTrueNode, setScratchCostEstimate, setTableConstructorTypes, subqueryReferencesTarget, updateTargetLockMode, verifySelectStarSubqueryMethods inherited from class QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExistMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Optimizable
getDataDictionary, getOptimizerTracer, getReferencedTableMap, getResultSetNumber, optimizerTracingIsOnMethods inherited from interface Visitable
accept, addTag, taggedWith
-
Field Details
-
correlationMap
JBitSet correlationMap -
dependencyMap
JBitSet dependencyMap -
methodCall
MethodCallNode methodCall -
exposedName
TableName exposedName -
subqueryList
SubqueryList subqueryList -
implementsVTICosting
boolean implementsVTICosting -
optimized
boolean optimized -
materializable
boolean materializable -
isTarget
boolean isTarget -
isDerbyStyleTableFunction
boolean isDerbyStyleTableFunction -
isRestrictedTableFunction
boolean isRestrictedTableFunction -
rs
ResultSet rs -
compileTimeConstants
-
numVTICols
protected int numVTICols -
restrictionList
-
estimatedCost
double estimatedCost -
estimatedRowCount
double estimatedRowCount -
supportsMultipleInstantiations
boolean supportsMultipleInstantiations -
vtiCosted
boolean vtiCosted -
version2
protected boolean version2 -
implementsPushable
private boolean implementsPushable -
ps
-
methodParms
-
controlsDeferral
private boolean controlsDeferral -
resultSetType
private int resultSetType -
projectedColumnNames
-
vtiRestriction
-
outerFromLists
-
argSources
-
-
Constructor Details
-
FromVTI
FromVTI(MethodCallNode invocation, String correlationName, ResultColumnList derivedRCL, Properties tableProperties, ContextManager cm) throws StandardException Constructor.- Parameters:
invocation- The constructor or static method for the VTIcorrelationName- The correlation namederivedRCL- The derived column listtableProperties- Properties list associated with the table- Throws:
StandardException- Thrown on error
-
FromVTI
FromVTI(MethodCallNode invocation, String correlationName, ResultColumnList derivedRCL, Properties tableProperties, TableName exposedTableName, ContextManager cm) Constructor.- Parameters:
invocation- The constructor or static method for the VTIcorrelationName- The correlation namederivedRCL- The derived column listtableProperties- Properties list associated with the tableexposedTableName- The table name (TableName class)cm- The context manager
-
-
Method Details
-
constructorMinion
private void constructorMinion(MethodCallNode invocation, ResultColumnList derivedRCL, TableName exposedTableName) -
estimateCost
public CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException Description copied from interface:OptimizableEstimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate. It is assumed that the predicate list has already been classified. This cost estimate is just for one scan, not for the life of the query.- Specified by:
estimateCostin interfaceOptimizable- Overrides:
estimateCostin classFromTable- Parameters:
predList- The predicate list to optimize againstcd- The conglomerate descriptor to get the cost ofouterCost- The estimated cost of the part of the plan outer to this optimizable.optimizer- The optimizer to use to help estimate the costrowOrdering- The row ordering for all the tables in the join order, including this one.- Returns:
- The estimated cost of doing the scan
- Throws:
StandardException- Thrown on error- See Also:
-
legalJoinOrder
Description copied from interface:OptimizableCan this Optimizable appear at the current location in the join order. In other words, have the Optimizable's dependencies been satisfied?- Specified by:
legalJoinOrderin interfaceOptimizable- Overrides:
legalJoinOrderin classFromTable- Parameters:
assignedTableMap- The tables that have been placed so far in the join order.- Returns:
- Where or not this Optimizable can appear at the current location in the join order.
- See Also:
-
isMaterializable
public boolean isMaterializable()Description copied from interface:OptimizableTell whether this Optimizable is materializable- Specified by:
isMaterializablein interfaceOptimizable- Overrides:
isMaterializablein classFromTable- See Also:
-
supportsMultipleInstantiations
public boolean supportsMultipleInstantiations()Description copied from interface:OptimizableTell whether this Optimizable can be instantiated multiple times- Specified by:
supportsMultipleInstantiationsin interfaceOptimizable- Overrides:
supportsMultipleInstantiationsin classFromTable- See Also:
-
isDerbyStyleTableFunction
public boolean isDerbyStyleTableFunction()Return true if this is a user-defined table function -
adjustForSortElimination
void adjustForSortElimination()Description copied from class:ResultSetNodeNotify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. Sort elimination can happen as part of preprocessing (see esp. SelectNode.preprocess(...)) or it can happen if the optimizer chooses an access path that inherently returns the rows in the correct order (also known as a "sort avoidance" plan). In either case we drop the sort and rely on the underlying result set tree to return its rows in the correct order. For most types of ResultSetNodes we automatically get the rows in the correct order if the sort was eliminated. One exception to this rule, though, is the case of an IndexRowToBaseRowNode, for which we have to disable bulk fetching on the underlying base table. Otherwise the index scan could return rows out of order if the base table is updated while the scan is "in progress" (i.e. while the result set is open). In order to account for this (and potentially other, similar issues in the future) this method exists to notify the result set node that it is expected to return rows in the correct order. The result set can then take necessary action to satsify this requirement--such as disabling bulk fetch in the case of IndexRowToBaseRowNode. All of that said, any ResultSetNodes for which we could potentially eliminate sorts should override this method accordingly. So we don't ever expect to get here.- Overrides:
adjustForSortEliminationin classResultSetNode- See Also:
-
modifyAccessPath
Description copied from interface:OptimizableModify the access path for this Optimizable, as necessary. This includes things like adding a result set to translate from index rows to base rows- Specified by:
modifyAccessPathin interfaceOptimizable- Overrides:
modifyAccessPathin classFromTable- Parameters:
outerTables- Bit map of the tables that are outer to this one in the join order.- Returns:
- The (potentially new) Optimizable at the top of the tree.
- Throws:
StandardException- Thrown on error- See Also:
-
addOuterFromList
Add a FromList to the collection of FromLists which bindExpressions() checks when vetting VTI arguments which reference columns in other tables. See DERBY-5554 and DERBY-5779. -
pushOptPredicate
Description copied from interface:OptimizablePush an OptimizablePredicate down, if this node accepts it.- Specified by:
pushOptPredicatein interfaceOptimizable- Overrides:
pushOptPredicatein classFromTable- Parameters:
optimizablePredicate- OptimizablePredicate to push down.- Returns:
- Whether or not the predicate was pushed down.
- Throws:
StandardException- Thrown on error- See Also:
-
toString
-
printSubNodes
void printSubNodes(int depth) Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.- Overrides:
printSubNodesin classResultSetNode- Parameters:
depth- The depth of this node in the tree
-
isConstructor
boolean isConstructor()Return true if this VTI is a constructor. Otherwise, it is a static method. -
getMethodCall
Return the constructor or static method invoked from this node -
getExposedName
String getExposedName()Get the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.- Overrides:
getExposedNamein classFromTable- Returns:
- The exposed name for this table.
-
getExposedTableName
- Returns:
- the table name used for matching with column references.
-
setTarget
void setTarget()Mark this VTI as the target of a delete or update. -
bindNonVTITables
ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException Bind the non VTI tables in this ResultSetNode. This includes getting their descriptors from the data dictionary and numbering them.- Overrides:
bindNonVTITablesin classResultSetNode- Parameters:
dataDictionary- The DataDictionary to use for bindingfromListParam- FromList to use/append to.- Returns:
- ResultSetNode
- Throws:
StandardException- Thrown on error
-
getVTIName
String getVTIName()- Returns:
- The name of the VTI, mainly for debugging and error messages.
-
bindVTITables
Bind this VTI that appears in the FROM list.- Overrides:
bindVTITablesin classResultSetNode- Parameters:
fromListParam- FromList to use/append to.- Returns:
- ResultSetNode The bound FromVTI.
- Throws:
StandardException- Thrown on error
-
getResultSetMetaData
Get the ResultSetMetaData for the class/object. We first look for the optional static method which has the same signature as the constructor. If it doesn't exist, then we instantiate an object and get the ResultSetMetaData from that object.- Returns:
- The ResultSetMetaData from the class/object.
- Throws:
StandardException- Thrown on error
-
getNewInstance
- Throws:
StandardException
-
getDeferralControl
Get the DeferModification interface associated with this VTI- Returns:
- null if the VTI uses the default modification deferral
- Throws:
StandardException
-
getResultSetType
public int getResultSetType()- Returns:
- the ResultSet type of the VTI, TYPE_FORWARD_ONLY if the getResultSetType() method of the VTI class throws an exception.
-
bindExpressions
Bind the expressions in this VTI. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.- Overrides:
bindExpressionsin classResultSetNode- Parameters:
fromListParam- FromList to use/append to.- Throws:
StandardException- Thrown on error
-
columnInFromList
If the referenced column appears in the indicated FROM list, then return the table it appears in.- Throws:
StandardException
-
getNodesFromParameters
Get all of the nodes of the specified class from the parameters to this VTI.- Parameters:
nodeClass- The Class of interest.- Returns:
- A list containing all of the nodes of interest.
- Throws:
StandardException- Thrown on error
-
getAllResultColumns
Expand a "*" into a ResultColumnList with all of the result columns from the subquery.- Overrides:
getAllResultColumnsin classResultSetNode- Parameters:
allTableName- The qualifier on the "*"- Returns:
- ResultColumnList The expanded list, or
nullifallTableNameis non-null and doesn't match a table name in this result set - Throws:
StandardException- Thrown on error
-
getMatchingColumn
Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name in the given ColumnReference.- Overrides:
getMatchingColumnin classResultSetNode- Parameters:
columnReference- The columnReference whose name we're looking for in the given table.- Returns:
- A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.
- Throws:
StandardException- Thrown on error
-
preprocess
ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode. o Putting the WHERE and HAVING clauses in conjunctive normal form (CNF). o Converting the WHERE and HAVING clauses into PredicateLists and classifying them. o Ensuring that a ProjectRestrictNode is generated on top of every FromBaseTable and generated in place of every FromSubquery. o Pushing single table predicates down to the new ProjectRestrictNodes.- Overrides:
preprocessin classResultSetNode- Parameters:
numTables- The number of tables in the DML Statementgbl- The group by list, if anyfromList- The from list, if any- Returns:
- ResultSetNode at top of preprocessed tree.
- Throws:
StandardException- Thrown on error
-
genProjectRestrict
Put a ProjectRestrictNode on top of each FromTable in the FromList. ColumnReferences must continue to point to the same ResultColumn, so that ResultColumn must percolate up to the new PRN. However, that ResultColumn will point to a new expression, a VirtualColumnNode, which points to the FromTable and the ResultColumn that is the source for the ColumnReference. (The new PRN will have the original of the ResultColumnList and the ResultColumns from that list. The FromTable will get shallow copies of the ResultColumnList and its ResultColumns. ResultColumn.expression will remain at the FromTable, with the PRN getting a new VirtualColumnNode for each ResultColumn.expression.) We then project out the non-referenced columns. If there are no referenced columns, then the PRN's ResultColumnList will consist of a single ResultColumn whose expression is 1.- Overrides:
genProjectRestrictin classResultSetNode- Parameters:
numTables- Number of tables in the DML Statement- Returns:
- The generated ProjectRestrictNode atop the original FromTable.
- Throws:
StandardException- Thrown on error
-
performMaterialization
Return whether or not to materialize this ResultSet tree.- Overrides:
performMaterializationin classResultSetNode- Returns:
- Whether or not to materialize this ResultSet tree. would return valid results.
- Throws:
StandardException- Thrown on error
-
computeProjectionAndRestriction
Compute the projection and restriction to be pushed to the external table function if it is a RestrictedVTI. This method is called by the parent ProjectRestrictNode at code generation time. See DERBY-4357.- Parameters:
parentPredicates- The full list of predicates to be applied by the parent ProjectRestrictNode- Throws:
StandardException
-
computeProjection
Fills in the array of projected column names suitable for handing to RestrictedVTI.initScan(). Returns a map of the exposed column names to the actual names of columns in the table function. This is useful because the predicate refers to the exposed column names.- Throws:
StandardException
-
computeRestriction
private void computeRestriction(PredicateList parentPredicates, HashMap<String, String> columnNameMap) throws StandardExceptionFills in the restriction to be handed to a RestrictedVTI at run-time.- Parameters:
parentPredicates- The full list of predicates to be applied by the parent ProjectRestrictNodecolumnNameMap- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.- Throws:
StandardException
-
canBePushedDown
Return true if the predicate can be pushed into a RestrictedVTI- Throws:
StandardException
-
makeRestriction
private Restriction makeRestriction(ValueNode clause, HashMap<String, String> columnNameMap) throws StandardExceptionTurn a compile-time WHERE clause fragment into a run-time Restriction. Returns null if the clause could not be understood.- Parameters:
clause- The clause which should be turned into a Restriction.columnNameMap- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.- Throws:
StandardException
-
makeLeafRestriction
private Restriction makeLeafRestriction(BinaryRelationalOperatorNode clause, HashMap<String, String> columnNameMap) throws StandardExceptionMakes a Restriction out of a comparison between a constant and a column in the VTI.- Parameters:
clause- The clause which should be turned into a Restriction.columnNameMap- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.- Throws:
StandardException
-
makeIsNullRestriction
private Restriction makeIsNullRestriction(IsNullNode clause, HashMap<String, String> columnNameMap) throws StandardExceptionMakes an IS NULL comparison of a column in the VTI.- Parameters:
clause- The IS NULL (or IS NOT NULL) nodecolumnNameMap- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.- Throws:
StandardException
-
iAmConfused
This is a handy place to put instrumentation for tracing trees which we don't understand- Throws:
StandardException
-
flipOperator
Flip the sense of a comparison- Throws:
StandardException
-
mapOperator
Map internal operator constants to user-visible ones- Throws:
StandardException
-
squeezeConstantValue
Get the constant or parameter reference out of a comparand. Return null if we are confused. A parameter reference is wrapped in an integer array to distinguish it from a constant integer.- Throws:
StandardException
-
generate
Generation on a FromVTI creates a wrapper around the user's java.sql.ResultSet- Overrides:
generatein classQueryTreeNode- Parameters:
acb- The ActivationClassBuilder for the class being builtmb- The MethodBuilder for the execute() method to be built- Throws:
StandardException- Thrown on error
-
remapBaseTableColumns
Remap the column references in vti arguments. Point those column references at the result columns for the base table. This prevents us from code-generating the args from references to unfilled columns in higher join nodes. See DERBY-5554.
- Throws:
StandardException
-
getScanArguments
- Throws:
StandardException
-
storeObjectInPS
Store an object in the prepared statement. Returns -1 if the object is null. Otherwise returns the object's retrieval handle.- Throws:
StandardException
-
generateConstructor
private void generateConstructor(ActivationClassBuilder acb, MethodBuilder mb, boolean reuseablePs) throws StandardException - Throws:
StandardException
-
referencesTarget
Search to see if a query references the specifed table name.- Overrides:
referencesTargetin classResultSetNode- Parameters:
name- Table name (String) to search for.baseTable- Whether or not name is for a base table- Returns:
- true if found, else false
- Throws:
StandardException- Thrown on error
-
acceptChildren
Accept the visitor for all visitable children of this node.- Overrides:
acceptChildrenin classFromTable- Parameters:
v- the visitor- Throws:
StandardException- on error
-
getSpecialTriggerVTITableName
private UUID getSpecialTriggerVTITableName(LanguageConnectionContext lcc, String className) throws StandardException Check and see if we have a special trigger VTI. If it cannot be bound (because we aren't actually compiling or executing a trigger), then throw an exception.- Returns:
- null if not a special trigger vti, or the table id if it is
- Throws:
StandardException
-
genResultColList
- Throws:
StandardException
-
needsSpecialRCLBinding
boolean needsSpecialRCLBinding()- Overrides:
needsSpecialRCLBindingin classFromTable
-
isUpdatableCursor
- Throws:
StandardException
-
isCompileTime
public final boolean isCompileTime()Description copied from interface:VTIEnvironmentReturn true if this instance of the Table Function has been created for compilation, false if it is for runtime execution.- Specified by:
isCompileTimein interfaceVTIEnvironment
-
getOriginalSQL
Description copied from interface:VTIEnvironmentReturn the SQL text of the original SQL statement.- Specified by:
getOriginalSQLin interfaceVTIEnvironment
-
getStatementIsolationLevel
public final int getStatementIsolationLevel()Description copied from interface:VTIEnvironmentGet the specific JDBC isolation of the statement. If it returns Connection.TRANSACTION_NONE then no isolation was specified and the connection's isolation level is implied.- Specified by:
getStatementIsolationLevelin interfaceVTIEnvironment
-
createResultColumnsForTableFunction
Add result columns for a Derby-style Table Function- Throws:
StandardException
-
implementsDerbyStyleVTICosting
Return true if this Derby Style Table Function implements the VTICosting interface. The class must satisfy the following conditions:- Implements VTICosting
- Has a public, no-arg constructor
- Throws:
StandardException
-
getVTICosting
Get the VTICosting implementation for this optimizable VTI.- Throws:
StandardException
-
lookupClass
Lookup the class that holds the VTI.- Throws:
StandardException
-