--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.execute.GenericResultSetFactory\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.execute;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.services.loader.GeneratedMethod;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.sql.Activation;\r
+import org.apache.derby.iapi.sql.ResultSet;\r
+import org.apache.derby.iapi.sql.conn.Authorizer;\r
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;\r
+import org.apache.derby.iapi.sql.execute.NoPutResultSet;\r
+import org.apache.derby.iapi.sql.execute.ResultSetFactory;\r
+import org.apache.derby.iapi.store.access.Qualifier;\r
+import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;\r
+import org.apache.derby.iapi.types.DataValueDescriptor;\r
+/**\r
+ * ResultSetFactory provides a wrapper around all of\r
+ * the result sets used in this execution implementation.\r
+ * This removes the need of generated classes to do a new\r
+ * and of the generator to know about all of the result\r
+ * sets. Both simply know about this interface to getting\r
+ * them.\r
+ * <p>\r
+ * In terms of modularizing, we can create just an interface\r
+ * to this class and invoke the interface. Different implementations\r
+ * would get the same information provided but could potentially\r
+ * massage/ignore it in different ways to satisfy their\r
+ * implementations. The practicality of this is to be seen.\r
+ * <p>\r
+ * The cost of this type of factory is that once you touch it,\r
+ * you touch *all* of the possible result sets, not just\r
+ * the ones you need. So the first time you touch it could\r
+ * be painful ... that might be a problem for execution.\r
+ *\r
+ */\r
+public class GenericResultSetFactory implements ResultSetFactory \r
+{\r
+ //\r
+ // ResultSetFactory interface\r
+ //\r
+ public GenericResultSetFactory()\r
+ {\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getInsertResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getInsertResultSet(NoPutResultSet source, \r
+ GeneratedMethod checkGM)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new InsertResultSet(source, checkGM, activation );\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getInsertVTIResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getInsertVTIResultSet(NoPutResultSet source, \r
+ NoPutResultSet vtiRS\r
+ )\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new InsertVTIResultSet(source, vtiRS, activation );\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getDeleteVTIResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getDeleteVTIResultSet(NoPutResultSet source)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new DeleteVTIResultSet(source, activation);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getDeleteResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getDeleteResultSet(NoPutResultSet source)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new DeleteResultSet(source, activation );\r
+ }\r
+\r
+\r
+ /**\r
+ @see ResultSetFactory#getDeleteCascadeResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getDeleteCascadeResultSet(NoPutResultSet source, \r
+ int constantActionItem,\r
+ ResultSet[] dependentResultSets,\r
+ String resultSetId)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new DeleteCascadeResultSet(source, activation, \r
+ constantActionItem,\r
+ dependentResultSets, \r
+ resultSetId);\r
+ }\r
+\r
+\r
+\r
+ /**\r
+ @see ResultSetFactory#getUpdateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getUpdateResultSet(NoPutResultSet source,\r
+ GeneratedMethod checkGM)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ //The stress test failed with null pointer exception in here once and then\r
+ //it didn't happen again. It can be a jit problem because after this null\r
+ //pointer exception, the cleanup code in UpdateResultSet got a null\r
+ //pointer exception too which can't happen since the cleanup code checks\r
+ //for null value before doing anything.\r
+ //In any case, if this ever happens again, hopefully the following\r
+ //assertion code will catch it.\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ SanityManager.ASSERT(getAuthorizer(activation) != null, "Authorizer is null");\r
+ }\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new UpdateResultSet(source, checkGM, activation);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getUpdateVTIResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getUpdateVTIResultSet(NoPutResultSet source)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new UpdateVTIResultSet(source, activation);\r
+ }\r
+\r
+\r
+\r
+ /**\r
+ @see ResultSetFactory#getDeleteCascadeUpdateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getDeleteCascadeUpdateResultSet(NoPutResultSet source,\r
+ GeneratedMethod checkGM,\r
+ int constantActionItem,\r
+ int rsdItem)\r
+ throws StandardException\r
+ {\r
+ Activation activation = source.getActivation();\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);\r
+ return new UpdateResultSet(source, checkGM, activation,\r
+ constantActionItem, rsdItem);\r
+ }\r
+\r
+\r
+ /**\r
+ @see ResultSetFactory#getCallStatementResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getCallStatementResultSet(GeneratedMethod methodCall,\r
+ Activation activation)\r
+ throws StandardException\r
+ {\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_CALL_OP);\r
+ return new CallStatementResultSet(methodCall, activation);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getProjectRestrictResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getProjectRestrictResultSet(NoPutResultSet source,\r
+ GeneratedMethod restriction, \r
+ GeneratedMethod projection, int resultSetNumber,\r
+ GeneratedMethod constantRestriction,\r
+ int mapRefItem,\r
+ boolean reuseResult,\r
+ boolean doesProjection,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new ProjectRestrictResultSet(source, source.getActivation(), \r
+ restriction, projection, resultSetNumber, \r
+ constantRestriction, mapRefItem, \r
+ reuseResult,\r
+ doesProjection,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getHashTableResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getHashTableResultSet(NoPutResultSet source,\r
+ GeneratedMethod singleTableRestriction, \r
+ Qualifier[][] equijoinQualifiers,\r
+ GeneratedMethod projection, int resultSetNumber,\r
+ int mapRefItem,\r
+ boolean reuseResult,\r
+ int keyColItem,\r
+ boolean removeDuplicates,\r
+ long maxInMemoryRowCount,\r
+ int initialCapacity,\r
+ float loadFactor,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new HashTableResultSet(source, source.getActivation(), \r
+ singleTableRestriction, \r
+ equijoinQualifiers,\r
+ projection, resultSetNumber, \r
+ mapRefItem, \r
+ reuseResult,\r
+ keyColItem, removeDuplicates,\r
+ maxInMemoryRowCount,\r
+ initialCapacity,\r
+ loadFactor,\r
+ true, // Skip rows with 1 or more null key columns\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getSortResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getSortResultSet(NoPutResultSet source,\r
+ boolean distinct, \r
+ boolean isInSortedOrder,\r
+ int orderItem,\r
+ GeneratedMethod rowAllocator, \r
+ int maxRowSize,\r
+ int resultSetNumber, \r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new SortResultSet(source, \r
+ distinct, \r
+ isInSortedOrder,\r
+ orderItem,\r
+ source.getActivation(), \r
+ rowAllocator, \r
+ maxRowSize,\r
+ resultSetNumber, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getScalarAggregateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getScalarAggregateResultSet(NoPutResultSet source,\r
+ boolean isInSortedOrder,\r
+ int aggregateItem,\r
+ int orderItem,\r
+ GeneratedMethod rowAllocator, \r
+ int maxRowSize,\r
+ int resultSetNumber, \r
+ boolean singleInputRow,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost) \r
+ throws StandardException\r
+ {\r
+ return new ScalarAggregateResultSet(\r
+ source, isInSortedOrder, aggregateItem, source.getActivation(),\r
+ rowAllocator, resultSetNumber, singleInputRow,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getDistinctScalarAggregateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getDistinctScalarAggregateResultSet(NoPutResultSet source,\r
+ boolean isInSortedOrder,\r
+ int aggregateItem,\r
+ int orderItem,\r
+ GeneratedMethod rowAllocator, \r
+ int maxRowSize,\r
+ int resultSetNumber, \r
+ boolean singleInputRow,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost) \r
+ throws StandardException\r
+ {\r
+ return new DistinctScalarAggregateResultSet(\r
+ source, isInSortedOrder, aggregateItem, orderItem, source.getActivation(),\r
+ rowAllocator, maxRowSize, resultSetNumber, singleInputRow,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getGroupedAggregateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getGroupedAggregateResultSet(NoPutResultSet source,\r
+ boolean isInSortedOrder,\r
+ int aggregateItem,\r
+ int orderItem,\r
+ GeneratedMethod rowAllocator, \r
+ int maxRowSize,\r
+ int resultSetNumber, \r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost) \r
+ throws StandardException\r
+ {\r
+ return new GroupedAggregateResultSet(\r
+ source, isInSortedOrder, aggregateItem, orderItem, source.getActivation(),\r
+ rowAllocator, maxRowSize, resultSetNumber, optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getDistinctGroupedAggregateResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getDistinctGroupedAggregateResultSet(NoPutResultSet source,\r
+ boolean isInSortedOrder,\r
+ int aggregateItem,\r
+ int orderItem,\r
+ GeneratedMethod rowAllocator, \r
+ int maxRowSize,\r
+ int resultSetNumber, \r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost) \r
+ throws StandardException\r
+ {\r
+ return new DistinctGroupedAggregateResultSet(\r
+ source, isInSortedOrder, aggregateItem, orderItem, source.getActivation(),\r
+ rowAllocator, maxRowSize, resultSetNumber, optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+ \r
+\r
+ /**\r
+ @see ResultSetFactory#getAnyResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getAnyResultSet(NoPutResultSet source,\r
+ GeneratedMethod emptyRowFun, int resultSetNumber,\r
+ int subqueryNumber, int pointOfAttachment,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new AnyResultSet(source,\r
+ source.getActivation(), emptyRowFun, resultSetNumber,\r
+ subqueryNumber, pointOfAttachment,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getOnceResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getOnceResultSet(NoPutResultSet source,\r
+ GeneratedMethod emptyRowFun,\r
+ int cardinalityCheck, int resultSetNumber,\r
+ int subqueryNumber, int pointOfAttachment,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new OnceResultSet(source,\r
+ source.getActivation(), emptyRowFun, \r
+ cardinalityCheck, resultSetNumber,\r
+ subqueryNumber, pointOfAttachment,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getRowResultSet\r
+ */\r
+ public NoPutResultSet getRowResultSet(Activation activation, GeneratedMethod row,\r
+ boolean canCacheRow,\r
+ int resultSetNumber,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ {\r
+ return new RowResultSet(activation, row, canCacheRow, resultSetNumber, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getVTIResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getVTIResultSet(Activation activation, GeneratedMethod row,\r
+ int resultSetNumber,\r
+ GeneratedMethod constructor,\r
+ String javaClassName,\r
+ Qualifier[][] pushedQualifiers,\r
+ int erdNumber,\r
+ boolean version2,\r
+ boolean reuseablePs,\r
+ int ctcNumber,\r
+ boolean isTarget,\r
+ int scanIsolationLevel,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new VTIResultSet(activation, row, resultSetNumber, \r
+ constructor,\r
+ javaClassName,\r
+ pushedQualifiers,\r
+ erdNumber,\r
+ version2, reuseablePs,\r
+ ctcNumber,\r
+ isTarget,\r
+ scanIsolationLevel,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ a hash scan generator, for ease of use at present.\r
+ @see ResultSetFactory#getHashScanResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getHashScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ GeneratedMethod startKeyGetter,\r
+ int startSearchOperator,\r
+ GeneratedMethod stopKeyGetter,\r
+ int stopSearchOperator,\r
+ boolean sameStartStopPosition,\r
+ Qualifier[][] scanQualifiers,\r
+ Qualifier[][] nextQualifiers,\r
+ int initialCapacity,\r
+ float loadFactor,\r
+ int maxCapacity,\r
+ int hashKeyColumn,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ boolean forUpdate,\r
+ int colRefItem,\r
+ int indexColItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)(activation.getPreparedStatement().\r
+ getSavedObject(scociItem));\r
+\r
+ return new HashScanResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ startKeyGetter,\r
+ startSearchOperator,\r
+ stopKeyGetter,\r
+ stopSearchOperator,\r
+ sameStartStopPosition,\r
+ scanQualifiers,\r
+ nextQualifiers,\r
+ initialCapacity,\r
+ loadFactor,\r
+ maxCapacity,\r
+ hashKeyColumn,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ forUpdate,\r
+ colRefItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ true, // Skip rows with 1 or more null key columns\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ a distinct scan generator, for ease of use at present.\r
+ @see ResultSetFactory#getHashScanResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getDistinctScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ int hashKeyColumn,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ int colRefItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)(activation.getPreparedStatement().\r
+ getSavedObject(scociItem));\r
+ return new DistinctScanResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ hashKeyColumn,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ colRefItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ a minimal table scan generator, for ease of use at present.\r
+ @see ResultSetFactory#getTableScanResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getTableScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ GeneratedMethod startKeyGetter,\r
+ int startSearchOperator,\r
+ GeneratedMethod stopKeyGetter,\r
+ int stopSearchOperator,\r
+ boolean sameStartStopPosition,\r
+ Qualifier[][] qualifiers,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ boolean forUpdate,\r
+ int colRefItem,\r
+ int indexColItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ boolean oneRowScan,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)(activation.getPreparedStatement().\r
+ getSavedObject(scociItem));\r
+ return new TableScanResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ startKeyGetter,\r
+ startSearchOperator,\r
+ stopKeyGetter,\r
+ stopSearchOperator,\r
+ sameStartStopPosition,\r
+ qualifiers,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ forUpdate,\r
+ colRefItem,\r
+ indexColItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ 1, // rowsPerRead is 1 if not a bulkTableScan\r
+ oneRowScan,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ Table/Index scan where rows are read in bulk\r
+ @see ResultSetFactory#getBulkTableScanResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getBulkTableScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ GeneratedMethod startKeyGetter,\r
+ int startSearchOperator,\r
+ GeneratedMethod stopKeyGetter,\r
+ int stopSearchOperator,\r
+ boolean sameStartStopPosition,\r
+ Qualifier[][] qualifiers,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ boolean forUpdate,\r
+ int colRefItem,\r
+ int indexColItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ int rowsPerRead,\r
+ boolean oneRowScan,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ //Prior to Cloudscape 10.0 release, holdability was false by default. Programmers had to explicitly\r
+ //set the holdability to true using JDBC apis. Since holdability was not true by default, we chose to disable the\r
+ //prefetching for RR and Serializable when holdability was explicitly set to true. \r
+ //But starting Cloudscape 10.0 release, in order to be DB2 compatible, holdability is set to true by default.\r
+ //Because of that, we can not continue to disable the prefetching for RR and Serializable, since it causes\r
+ //severe performance degradation - bug 5953. \r
+\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)(activation.getPreparedStatement().\r
+ getSavedObject(scociItem));\r
+ return new BulkTableScanResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ startKeyGetter,\r
+ startSearchOperator,\r
+ stopKeyGetter,\r
+ stopSearchOperator,\r
+ sameStartStopPosition,\r
+ qualifiers,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ forUpdate,\r
+ colRefItem,\r
+ indexColItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ rowsPerRead,\r
+ oneRowScan,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ Multi-probing scan that probes an index for specific values contained\r
+ in the received probe list.\r
+\r
+ All index rows for which the first column equals probeVals[0] will\r
+ be returned, followed by all rows for which the first column equals\r
+ probeVals[1], and so on. Assumption is that we only get here if\r
+ probeVals has at least one value.\r
+\r
+ @see ResultSetFactory#getMultiProbeTableScanResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getMultiProbeTableScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ GeneratedMethod startKeyGetter,\r
+ int startSearchOperator,\r
+ GeneratedMethod stopKeyGetter,\r
+ int stopSearchOperator,\r
+ boolean sameStartStopPosition,\r
+ Qualifier[][] qualifiers,\r
+ DataValueDescriptor [] probeVals,\r
+ int sortRequired,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ boolean forUpdate,\r
+ int colRefItem,\r
+ int indexColItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ boolean oneRowScan,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)\r
+ activation.getPreparedStatement().getSavedObject(scociItem);\r
+\r
+ return new MultiProbeTableScanResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ startKeyGetter,\r
+ startSearchOperator,\r
+ stopKeyGetter,\r
+ stopSearchOperator,\r
+ sameStartStopPosition,\r
+ qualifiers,\r
+ probeVals,\r
+ sortRequired,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ forUpdate,\r
+ colRefItem,\r
+ indexColItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ oneRowScan,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getIndexRowToBaseRowResultSet\r
+ @exception StandardException Thrown on error\r
+ */\r
+ public NoPutResultSet getIndexRowToBaseRowResultSet(\r
+ long conglomId,\r
+ int scociItem,\r
+ NoPutResultSet source,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ String indexName,\r
+ int heapColRefItem,\r
+ int allColRefItem,\r
+ int heapOnlyColRefItem,\r
+ int indexColMapItem,\r
+ GeneratedMethod restriction,\r
+ boolean forUpdate,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new IndexRowToBaseRowResultSet(\r
+ conglomId,\r
+ scociItem,\r
+ source.getActivation(),\r
+ source,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ indexName,\r
+ heapColRefItem,\r
+ allColRefItem,\r
+ heapOnlyColRefItem,\r
+ indexColMapItem,\r
+ restriction,\r
+ forUpdate,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getNestedLoopJoinResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+\r
+ public NoPutResultSet getNestedLoopJoinResultSet(NoPutResultSet leftResultSet,\r
+ int leftNumCols,\r
+ NoPutResultSet rightResultSet,\r
+ int rightNumCols,\r
+ GeneratedMethod joinClause,\r
+ int resultSetNumber,\r
+ boolean oneRowRightSide,\r
+ boolean notExistsRightSide,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ String userSuppliedOptimizerOverrides)\r
+ throws StandardException\r
+ {\r
+ return new NestedLoopJoinResultSet(leftResultSet, leftNumCols,\r
+ rightResultSet, rightNumCols,\r
+ leftResultSet.getActivation(), joinClause,\r
+ resultSetNumber, \r
+ oneRowRightSide, \r
+ notExistsRightSide, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ userSuppliedOptimizerOverrides);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getHashJoinResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+\r
+ public NoPutResultSet getHashJoinResultSet(NoPutResultSet leftResultSet,\r
+ int leftNumCols,\r
+ NoPutResultSet rightResultSet,\r
+ int rightNumCols,\r
+ GeneratedMethod joinClause,\r
+ int resultSetNumber,\r
+ boolean oneRowRightSide,\r
+ boolean notExistsRightSide,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ String userSuppliedOptimizerOverrides)\r
+ throws StandardException\r
+ {\r
+ return new HashJoinResultSet(leftResultSet, leftNumCols,\r
+ rightResultSet, rightNumCols,\r
+ leftResultSet.getActivation(), joinClause,\r
+ resultSetNumber, \r
+ oneRowRightSide, \r
+ notExistsRightSide, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ userSuppliedOptimizerOverrides);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getNestedLoopLeftOuterJoinResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+\r
+ public NoPutResultSet getNestedLoopLeftOuterJoinResultSet(NoPutResultSet leftResultSet,\r
+ int leftNumCols,\r
+ NoPutResultSet rightResultSet,\r
+ int rightNumCols,\r
+ GeneratedMethod joinClause,\r
+ int resultSetNumber,\r
+ GeneratedMethod emptyRowFun,\r
+ boolean wasRightOuterJoin,\r
+ boolean oneRowRightSide,\r
+ boolean notExistsRightSide,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ String userSuppliedOptimizerOverrides)\r
+ throws StandardException\r
+ {\r
+ return new NestedLoopLeftOuterJoinResultSet(leftResultSet, leftNumCols,\r
+ rightResultSet, rightNumCols,\r
+ leftResultSet.getActivation(), joinClause,\r
+ resultSetNumber, \r
+ emptyRowFun, \r
+ wasRightOuterJoin,\r
+ oneRowRightSide,\r
+ notExistsRightSide,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ userSuppliedOptimizerOverrides);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getHashLeftOuterJoinResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+\r
+ public NoPutResultSet getHashLeftOuterJoinResultSet(NoPutResultSet leftResultSet,\r
+ int leftNumCols,\r
+ NoPutResultSet rightResultSet,\r
+ int rightNumCols,\r
+ GeneratedMethod joinClause,\r
+ int resultSetNumber,\r
+ GeneratedMethod emptyRowFun,\r
+ boolean wasRightOuterJoin,\r
+ boolean oneRowRightSide,\r
+ boolean notExistsRightSide,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ String userSuppliedOptimizerOverrides)\r
+ throws StandardException\r
+ {\r
+ return new HashLeftOuterJoinResultSet(leftResultSet, leftNumCols,\r
+ rightResultSet, rightNumCols,\r
+ leftResultSet.getActivation(), joinClause,\r
+ resultSetNumber, \r
+ emptyRowFun, \r
+ wasRightOuterJoin,\r
+ oneRowRightSide,\r
+ notExistsRightSide,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ userSuppliedOptimizerOverrides);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getSetTransactionResultSet\r
+ @exception StandardException thrown when unable to create the\r
+ result set\r
+ */\r
+ public ResultSet getSetTransactionResultSet(Activation activation) \r
+ throws StandardException\r
+ {\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_ARBITARY_OP); \r
+ return new SetTransactionResultSet(activation);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getMaterializedResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getMaterializedResultSet(NoPutResultSet source,\r
+ int resultSetNumber,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new MaterializedResultSet(source, source.getActivation(), \r
+ resultSetNumber, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getScrollInsensitiveResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getScrollInsensitiveResultSet(NoPutResultSet source,\r
+ Activation activation, int resultSetNumber,\r
+ int sourceRowWidth,\r
+ boolean scrollable,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ /* ResultSet tree is dependent on whether or not this is\r
+ * for a scroll insensitive cursor.\r
+ */\r
+\r
+ if (scrollable)\r
+ {\r
+ return new ScrollInsensitiveResultSet(source, activation, \r
+ resultSetNumber, \r
+ sourceRowWidth,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+ else\r
+ {\r
+ return source;\r
+ }\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getNormalizeResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getNormalizeResultSet(NoPutResultSet source,\r
+ int resultSetNumber, \r
+ int erdNumber,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ boolean forUpdate)\r
+ throws StandardException\r
+ {\r
+ return new NormalizeResultSet(source, source.getActivation(), \r
+ resultSetNumber, erdNumber, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost, forUpdate);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getCurrentOfResultSet\r
+ */\r
+ public NoPutResultSet getCurrentOfResultSet(String cursorName, \r
+ Activation activation, int resultSetNumber)\r
+ {\r
+ return new CurrentOfResultSet(cursorName, activation, resultSetNumber);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getDDLResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getDDLResultSet(Activation activation)\r
+ throws StandardException\r
+ {\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_DDL_OP);\r
+ return getMiscResultSet( activation);\r
+ }\r
+\r
+ /**\r
+ @see ResultSetFactory#getMiscResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public ResultSet getMiscResultSet(Activation activation)\r
+ throws StandardException\r
+ {\r
+ getAuthorizer(activation).authorize(activation, Authorizer.SQL_ARBITARY_OP);\r
+ return new MiscResultSet(activation);\r
+ }\r
+\r
+ /**\r
+ a minimal union scan generator, for ease of use at present.\r
+ @see ResultSetFactory#getUnionResultSet\r
+ @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getUnionResultSet(NoPutResultSet leftResultSet,\r
+ NoPutResultSet rightResultSet,\r
+ int resultSetNumber,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost)\r
+ throws StandardException\r
+ {\r
+ return new UnionResultSet(leftResultSet, rightResultSet, \r
+ leftResultSet.getActivation(),\r
+ resultSetNumber, \r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+ public NoPutResultSet getSetOpResultSet( NoPutResultSet leftSource,\r
+ NoPutResultSet rightSource,\r
+ Activation activation, \r
+ int resultSetNumber,\r
+ long optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ int opType,\r
+ boolean all,\r
+ int intermediateOrderByColumnsSavedObject,\r
+ int intermediateOrderByDirectionSavedObject)\r
+ throws StandardException\r
+ {\r
+ return new SetOpResultSet( leftSource,\r
+ rightSource,\r
+ activation,\r
+ resultSetNumber,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ opType,\r
+ all,\r
+ intermediateOrderByColumnsSavedObject,\r
+ intermediateOrderByDirectionSavedObject);\r
+ }\r
+\r
+ /**\r
+ * A last index key sresult set returns the last row from\r
+ * the index in question. It is used as an ajunct to max().\r
+ *\r
+ * @param activation the activation for this result set,\r
+ * which provides the context for the row allocation operation.\r
+ * @param resultSetNumber The resultSetNumber for the ResultSet\r
+ * @param resultRowAllocator a reference to a method in the activation\r
+ * that creates a holder for the result row of the scan. May\r
+ * be a partial row. <verbatim>\r
+ * ExecRow rowAllocator() throws StandardException; </verbatim>\r
+ * @param conglomId the conglomerate of the table to be scanned.\r
+ * @param tableName The full name of the table\r
+ * @param userSuppliedOptimizerOverrides Overrides specified by the user on the sql\r
+ * @param indexName The name of the index, if one used to access table.\r
+ * @param colRefItem An saved item for a bitSet of columns that\r
+ * are referenced in the underlying table. -1 if\r
+ * no item.\r
+ * @param lockMode The lock granularity to use (see\r
+ * TransactionController in access)\r
+ * @param tableLocked Whether or not the table is marked as using table locking\r
+ * (in sys.systables)\r
+ * @param isolationLevel Isolation level (specified or not) to use on scans\r
+ * @param optimizerEstimatedRowCount Estimated total # of rows by\r
+ * optimizer\r
+ * @param optimizerEstimatedCost Estimated total cost by optimizer\r
+ *\r
+ * @return the scan operation as a result set.\r
+ *\r
+ * @exception StandardException thrown when unable to create the\r
+ * result set\r
+ */\r
+ public NoPutResultSet getLastIndexKeyResultSet\r
+ (\r
+ Activation activation,\r
+ int resultSetNumber,\r
+ GeneratedMethod resultRowAllocator,\r
+ long conglomId,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ int colRefItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost\r
+ ) throws StandardException\r
+ {\r
+ return new LastIndexKeyResultSet(\r
+ activation,\r
+ resultSetNumber,\r
+ resultRowAllocator,\r
+ conglomId,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ colRefItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost);\r
+ }\r
+\r
+\r
+\r
+ /**\r
+ * a referential action dependent table scan generator.\r
+ * @see ResultSetFactory#getTableScanResultSet\r
+ * @exception StandardException thrown on error\r
+ */\r
+ public NoPutResultSet getRaDependentTableScanResultSet(\r
+ Activation activation,\r
+ long conglomId,\r
+ int scociItem,\r
+ GeneratedMethod resultRowAllocator,\r
+ int resultSetNumber,\r
+ GeneratedMethod startKeyGetter,\r
+ int startSearchOperator,\r
+ GeneratedMethod stopKeyGetter,\r
+ int stopSearchOperator,\r
+ boolean sameStartStopPosition,\r
+ Qualifier[][] qualifiers,\r
+ String tableName,\r
+ String userSuppliedOptimizerOverrides,\r
+ String indexName,\r
+ boolean isConstraint,\r
+ boolean forUpdate,\r
+ int colRefItem,\r
+ int indexColItem,\r
+ int lockMode,\r
+ boolean tableLocked,\r
+ int isolationLevel,\r
+ boolean oneRowScan,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ String parentResultSetId,\r
+ long fkIndexConglomId,\r
+ int fkColArrayItem,\r
+ int rltItem)\r
+ throws StandardException\r
+ {\r
+ StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo)(activation.getPreparedStatement().\r
+ getSavedObject(scociItem));\r
+ return new DependentResultSet(\r
+ conglomId,\r
+ scoci,\r
+ activation,\r
+ resultRowAllocator,\r
+ resultSetNumber,\r
+ startKeyGetter,\r
+ startSearchOperator,\r
+ stopKeyGetter,\r
+ stopSearchOperator,\r
+ sameStartStopPosition,\r
+ qualifiers,\r
+ tableName,\r
+ userSuppliedOptimizerOverrides,\r
+ indexName,\r
+ isConstraint,\r
+ forUpdate,\r
+ colRefItem,\r
+ lockMode,\r
+ tableLocked,\r
+ isolationLevel,\r
+ 1,\r
+ oneRowScan,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost,\r
+ parentResultSetId,\r
+ fkIndexConglomId,\r
+ fkColArrayItem,\r
+ rltItem);\r
+ }\r
+ \r
+ static private Authorizer getAuthorizer(Activation activation)\r
+ {\r
+ LanguageConnectionContext lcc = activation.getLanguageConnectionContext();\r
+ return lcc.getAuthorizer();\r
+ }\r
+\r
+\r
+ /////////////////////////////////////////////////////////////////\r
+ //\r
+ // PUBLIC MINIONS\r
+ //\r
+ /////////////////////////////////////////////////////////////////\r
+\r
+}\r