001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.GenericResultSetFactory
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute;
023:
024: import org.apache.derby.iapi.reference.SQLState;
025:
026: import org.apache.derby.iapi.error.StandardException;
027:
028: import org.apache.derby.iapi.sql.ResultSet;
029: import org.apache.derby.iapi.sql.ResultDescription;
030: import org.apache.derby.iapi.sql.Activation;
031:
032: import org.apache.derby.iapi.sql.execute.ConstantAction;
033: import org.apache.derby.iapi.sql.execute.ExecutionContext;
034: import org.apache.derby.iapi.sql.execute.NoPutResultSet;
035:
036: import org.apache.derby.iapi.sql.execute.ResultSetFactory;
037:
038: import org.apache.derby.iapi.sql.Activation;
039:
040: import org.apache.derby.iapi.services.sanity.SanityManager;
041:
042: import org.apache.derby.iapi.services.loader.GeneratedMethod;
043:
044: import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
045: import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
046: import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
047:
048: import org.apache.derby.iapi.store.access.Qualifier;
049: import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
050:
051: import org.apache.derby.iapi.sql.conn.Authorizer;
052: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
053:
054: import java.util.Properties;
055:
056: /**
057: * ResultSetFactory provides a wrapper around all of
058: * the result sets used in this execution implementation.
059: * This removes the need of generated classes to do a new
060: * and of the generator to know about all of the result
061: * sets. Both simply know about this interface to getting
062: * them.
063: * <p>
064: * In terms of modularizing, we can create just an interface
065: * to this class and invoke the interface. Different implementations
066: * would get the same information provided but could potentially
067: * massage/ignore it in different ways to satisfy their
068: * implementations. The practicality of this is to be seen.
069: * <p>
070: * The cost of this type of factory is that once you touch it,
071: * you touch *all* of the possible result sets, not just
072: * the ones you need. So the first time you touch it could
073: * be painful ... that might be a problem for execution.
074: *
075: * @author ames
076: */
077: public class GenericResultSetFactory implements ResultSetFactory {
078: //
079: // ResultSetFactory interface
080: //
081: public GenericResultSetFactory() {
082: }
083:
084: /**
085: @see ResultSetFactory#getInsertResultSet
086: @exception StandardException thrown on error
087: */
088: public ResultSet getInsertResultSet(NoPutResultSet source,
089: GeneratedMethod checkGM) throws StandardException {
090: Activation activation = source.getActivation();
091: getAuthorizer(activation).authorize(activation,
092: Authorizer.SQL_WRITE_OP);
093: return new InsertResultSet(source, checkGM, activation);
094: }
095:
096: /**
097: @see ResultSetFactory#getInsertVTIResultSet
098: @exception StandardException thrown on error
099: */
100: public ResultSet getInsertVTIResultSet(NoPutResultSet source,
101: NoPutResultSet vtiRS) throws StandardException {
102: Activation activation = source.getActivation();
103: getAuthorizer(activation).authorize(activation,
104: Authorizer.SQL_WRITE_OP);
105: return new InsertVTIResultSet(source, vtiRS, activation);
106: }
107:
108: /**
109: @see ResultSetFactory#getDeleteVTIResultSet
110: @exception StandardException thrown on error
111: */
112: public ResultSet getDeleteVTIResultSet(NoPutResultSet source)
113: throws StandardException {
114: Activation activation = source.getActivation();
115: getAuthorizer(activation).authorize(activation,
116: Authorizer.SQL_WRITE_OP);
117: return new DeleteVTIResultSet(source, activation);
118: }
119:
120: /**
121: @see ResultSetFactory#getDeleteResultSet
122: @exception StandardException thrown on error
123: */
124: public ResultSet getDeleteResultSet(NoPutResultSet source)
125: throws StandardException {
126: Activation activation = source.getActivation();
127: getAuthorizer(activation).authorize(activation,
128: Authorizer.SQL_WRITE_OP);
129: return new DeleteResultSet(source, activation);
130: }
131:
132: /**
133: @see ResultSetFactory#getDeleteCascadeResultSet
134: @exception StandardException thrown on error
135: */
136: public ResultSet getDeleteCascadeResultSet(NoPutResultSet source,
137: int constantActionItem, ResultSet[] dependentResultSets,
138: String resultSetId) throws StandardException {
139: Activation activation = source.getActivation();
140: getAuthorizer(activation).authorize(activation,
141: Authorizer.SQL_WRITE_OP);
142: return new DeleteCascadeResultSet(source, activation,
143: constantActionItem, dependentResultSets, resultSetId);
144: }
145:
146: /**
147: @see ResultSetFactory#getUpdateResultSet
148: @exception StandardException thrown on error
149: */
150: public ResultSet getUpdateResultSet(NoPutResultSet source,
151: GeneratedMethod checkGM) throws StandardException {
152: Activation activation = source.getActivation();
153: //The stress test failed with null pointer exception in here once and then
154: //it didn't happen again. It can be a jit problem because after this null
155: //pointer exception, the cleanup code in UpdateResultSet got a null
156: //pointer exception too which can't happen since the cleanup code checks
157: //for null value before doing anything.
158: //In any case, if this ever happens again, hopefully the following
159: //assertion code will catch it.
160: if (SanityManager.DEBUG) {
161: SanityManager.ASSERT(getAuthorizer(activation) != null,
162: "Authorizer is null");
163: }
164: getAuthorizer(activation).authorize(activation,
165: Authorizer.SQL_WRITE_OP);
166: return new UpdateResultSet(source, checkGM, activation);
167: }
168:
169: /**
170: @see ResultSetFactory#getUpdateVTIResultSet
171: @exception StandardException thrown on error
172: */
173: public ResultSet getUpdateVTIResultSet(NoPutResultSet source)
174: throws StandardException {
175: Activation activation = source.getActivation();
176: getAuthorizer(activation).authorize(activation,
177: Authorizer.SQL_WRITE_OP);
178: return new UpdateVTIResultSet(source, activation);
179: }
180:
181: /**
182: @see ResultSetFactory#getDeleteCascadeUpdateResultSet
183: @exception StandardException thrown on error
184: */
185: public ResultSet getDeleteCascadeUpdateResultSet(
186: NoPutResultSet source, GeneratedMethod checkGM,
187: int constantActionItem, int rsdItem)
188: throws StandardException {
189: Activation activation = source.getActivation();
190: getAuthorizer(activation).authorize(activation,
191: Authorizer.SQL_WRITE_OP);
192: return new UpdateResultSet(source, checkGM, activation,
193: constantActionItem, rsdItem);
194: }
195:
196: /**
197: @see ResultSetFactory#getCallStatementResultSet
198: @exception StandardException thrown on error
199: */
200: public ResultSet getCallStatementResultSet(
201: GeneratedMethod methodCall, Activation activation)
202: throws StandardException {
203: getAuthorizer(activation).authorize(activation,
204: Authorizer.SQL_CALL_OP);
205: return new CallStatementResultSet(methodCall, activation);
206: }
207:
208: /**
209: @see ResultSetFactory#getProjectRestrictResultSet
210: @exception StandardException thrown on error
211: */
212: public NoPutResultSet getProjectRestrictResultSet(
213: NoPutResultSet source, GeneratedMethod restriction,
214: GeneratedMethod projection, int resultSetNumber,
215: GeneratedMethod constantRestriction, int mapRefItem,
216: boolean reuseResult, boolean doesProjection,
217: double optimizerEstimatedRowCount,
218: double optimizerEstimatedCost) throws StandardException {
219: return new ProjectRestrictResultSet(source, source
220: .getActivation(), restriction, projection,
221: resultSetNumber, constantRestriction, mapRefItem,
222: reuseResult, doesProjection,
223: optimizerEstimatedRowCount, optimizerEstimatedCost);
224: }
225:
226: /**
227: @see ResultSetFactory#getHashTableResultSet
228: @exception StandardException thrown on error
229: */
230: public NoPutResultSet getHashTableResultSet(NoPutResultSet source,
231: GeneratedMethod singleTableRestriction,
232: Qualifier[][] equijoinQualifiers,
233: GeneratedMethod projection, int resultSetNumber,
234: int mapRefItem, boolean reuseResult, int keyColItem,
235: boolean removeDuplicates, long maxInMemoryRowCount,
236: int initialCapacity, float loadFactor,
237: double optimizerEstimatedRowCount,
238: double optimizerEstimatedCost) throws StandardException {
239: return new HashTableResultSet(source, source.getActivation(),
240: singleTableRestriction, equijoinQualifiers, projection,
241: resultSetNumber, mapRefItem, reuseResult, keyColItem,
242: removeDuplicates, maxInMemoryRowCount, initialCapacity,
243: loadFactor, true, // Skip rows with 1 or more null key columns
244: optimizerEstimatedRowCount, optimizerEstimatedCost);
245: }
246:
247: /**
248: @see ResultSetFactory#getSortResultSet
249: @exception StandardException thrown on error
250: */
251: public NoPutResultSet getSortResultSet(NoPutResultSet source,
252: boolean distinct, boolean isInSortedOrder, int orderItem,
253: GeneratedMethod rowAllocator, int maxRowSize,
254: int resultSetNumber, double optimizerEstimatedRowCount,
255: double optimizerEstimatedCost) throws StandardException {
256: return new SortResultSet(source, distinct, isInSortedOrder,
257: orderItem, source.getActivation(), rowAllocator,
258: maxRowSize, resultSetNumber,
259: optimizerEstimatedRowCount, optimizerEstimatedCost);
260: }
261:
262: /**
263: @see ResultSetFactory#getScalarAggregateResultSet
264: @exception StandardException thrown on error
265: */
266: public NoPutResultSet getScalarAggregateResultSet(
267: NoPutResultSet source, boolean isInSortedOrder,
268: int aggregateItem, int orderItem,
269: GeneratedMethod rowAllocator, int maxRowSize,
270: int resultSetNumber, boolean singleInputRow,
271: double optimizerEstimatedRowCount,
272: double optimizerEstimatedCost) throws StandardException {
273: return new ScalarAggregateResultSet(source, isInSortedOrder,
274: aggregateItem, source.getActivation(), rowAllocator,
275: resultSetNumber, singleInputRow,
276: optimizerEstimatedRowCount, optimizerEstimatedCost);
277: }
278:
279: /**
280: @see ResultSetFactory#getDistinctScalarAggregateResultSet
281: @exception StandardException thrown on error
282: */
283: public NoPutResultSet getDistinctScalarAggregateResultSet(
284: NoPutResultSet source, boolean isInSortedOrder,
285: int aggregateItem, int orderItem,
286: GeneratedMethod rowAllocator, int maxRowSize,
287: int resultSetNumber, boolean singleInputRow,
288: double optimizerEstimatedRowCount,
289: double optimizerEstimatedCost) throws StandardException {
290: return new DistinctScalarAggregateResultSet(source,
291: isInSortedOrder, aggregateItem, orderItem, source
292: .getActivation(), rowAllocator, maxRowSize,
293: resultSetNumber, singleInputRow,
294: optimizerEstimatedRowCount, optimizerEstimatedCost);
295: }
296:
297: /**
298: @see ResultSetFactory#getGroupedAggregateResultSet
299: @exception StandardException thrown on error
300: */
301: public NoPutResultSet getGroupedAggregateResultSet(
302: NoPutResultSet source, boolean isInSortedOrder,
303: int aggregateItem, int orderItem,
304: GeneratedMethod rowAllocator, int maxRowSize,
305: int resultSetNumber, double optimizerEstimatedRowCount,
306: double optimizerEstimatedCost) throws StandardException {
307: return new GroupedAggregateResultSet(source, isInSortedOrder,
308: aggregateItem, orderItem, source.getActivation(),
309: rowAllocator, maxRowSize, resultSetNumber,
310: optimizerEstimatedRowCount, optimizerEstimatedCost);
311: }
312:
313: /**
314: @see ResultSetFactory#getDistinctGroupedAggregateResultSet
315: @exception StandardException thrown on error
316: */
317: public NoPutResultSet getDistinctGroupedAggregateResultSet(
318: NoPutResultSet source, boolean isInSortedOrder,
319: int aggregateItem, int orderItem,
320: GeneratedMethod rowAllocator, int maxRowSize,
321: int resultSetNumber, double optimizerEstimatedRowCount,
322: double optimizerEstimatedCost) throws StandardException {
323: return new DistinctGroupedAggregateResultSet(source,
324: isInSortedOrder, aggregateItem, orderItem, source
325: .getActivation(), rowAllocator, maxRowSize,
326: resultSetNumber, optimizerEstimatedRowCount,
327: optimizerEstimatedCost);
328: }
329:
330: /**
331: @see ResultSetFactory#getAnyResultSet
332: @exception StandardException thrown on error
333: */
334: public NoPutResultSet getAnyResultSet(NoPutResultSet source,
335: GeneratedMethod emptyRowFun, int resultSetNumber,
336: int subqueryNumber, int pointOfAttachment,
337: double optimizerEstimatedRowCount,
338: double optimizerEstimatedCost) throws StandardException {
339: return new AnyResultSet(source, source.getActivation(),
340: emptyRowFun, resultSetNumber, subqueryNumber,
341: pointOfAttachment, optimizerEstimatedRowCount,
342: optimizerEstimatedCost);
343: }
344:
345: /**
346: @see ResultSetFactory#getOnceResultSet
347: @exception StandardException thrown on error
348: */
349: public NoPutResultSet getOnceResultSet(NoPutResultSet source,
350: GeneratedMethod emptyRowFun, int cardinalityCheck,
351: int resultSetNumber, int subqueryNumber,
352: int pointOfAttachment, double optimizerEstimatedRowCount,
353: double optimizerEstimatedCost) throws StandardException {
354: return new OnceResultSet(source, source.getActivation(),
355: emptyRowFun, cardinalityCheck, resultSetNumber,
356: subqueryNumber, pointOfAttachment,
357: optimizerEstimatedRowCount, optimizerEstimatedCost);
358: }
359:
360: /**
361: @see ResultSetFactory#getRowResultSet
362: */
363: public NoPutResultSet getRowResultSet(Activation activation,
364: GeneratedMethod row, boolean canCacheRow,
365: int resultSetNumber, double optimizerEstimatedRowCount,
366: double optimizerEstimatedCost) {
367: return new RowResultSet(activation, row, canCacheRow,
368: resultSetNumber, optimizerEstimatedRowCount,
369: optimizerEstimatedCost);
370: }
371:
372: /**
373: @see ResultSetFactory#getVTIResultSet
374: @exception StandardException thrown on error
375: */
376: public NoPutResultSet getVTIResultSet(Activation activation,
377: GeneratedMethod row, int resultSetNumber,
378: GeneratedMethod constructor, String javaClassName,
379: Qualifier[][] pushedQualifiers, int erdNumber,
380: boolean version2, boolean reuseablePs, int ctcNumber,
381: boolean isTarget, int scanIsolationLevel,
382: double optimizerEstimatedRowCount,
383: double optimizerEstimatedCost) throws StandardException {
384: return new VTIResultSet(activation, row, resultSetNumber,
385: constructor, javaClassName, pushedQualifiers,
386: erdNumber, version2, reuseablePs, ctcNumber, isTarget,
387: scanIsolationLevel, optimizerEstimatedRowCount,
388: optimizerEstimatedCost);
389: }
390:
391: /**
392: a hash scan generator, for ease of use at present.
393: @see ResultSetFactory#getHashScanResultSet
394: @exception StandardException thrown on error
395: */
396: public NoPutResultSet getHashScanResultSet(Activation activation,
397: long conglomId, int scociItem,
398: GeneratedMethod resultRowAllocator, int resultSetNumber,
399: GeneratedMethod startKeyGetter, int startSearchOperator,
400: GeneratedMethod stopKeyGetter, int stopSearchOperator,
401: boolean sameStartStopPosition,
402: Qualifier[][] scanQualifiers, Qualifier[][] nextQualifiers,
403: int initialCapacity, float loadFactor, int maxCapacity,
404: int hashKeyColumn, String tableName,
405: String userSuppliedOptimizerOverrides, String indexName,
406: boolean isConstraint, boolean forUpdate, int colRefItem,
407: int indexColItem, int lockMode, boolean tableLocked,
408: int isolationLevel, double optimizerEstimatedRowCount,
409: double optimizerEstimatedCost) throws StandardException {
410: StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo) (activation
411: .getPreparedStatement().getSavedObject(scociItem));
412:
413: return new HashScanResultSet(conglomId, scoci, activation,
414: resultRowAllocator, resultSetNumber, startKeyGetter,
415: startSearchOperator, stopKeyGetter, stopSearchOperator,
416: sameStartStopPosition, scanQualifiers, nextQualifiers,
417: initialCapacity, loadFactor, maxCapacity,
418: hashKeyColumn, tableName,
419: userSuppliedOptimizerOverrides, indexName,
420: isConstraint, forUpdate, colRefItem, lockMode,
421: tableLocked, isolationLevel, true, // Skip rows with 1 or more null key columns
422: optimizerEstimatedRowCount, optimizerEstimatedCost);
423: }
424:
425: /**
426: a distinct scan generator, for ease of use at present.
427: @see ResultSetFactory#getHashScanResultSet
428: @exception StandardException thrown on error
429: */
430: public NoPutResultSet getDistinctScanResultSet(
431: Activation activation, long conglomId, int scociItem,
432: GeneratedMethod resultRowAllocator, int resultSetNumber,
433: int hashKeyColumn, String tableName,
434: String userSuppliedOptimizerOverrides, String indexName,
435: boolean isConstraint, int colRefItem, int lockMode,
436: boolean tableLocked, int isolationLevel,
437: double optimizerEstimatedRowCount,
438: double optimizerEstimatedCost) throws StandardException {
439: StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo) (activation
440: .getPreparedStatement().getSavedObject(scociItem));
441: return new DistinctScanResultSet(conglomId, scoci, activation,
442: resultRowAllocator, resultSetNumber, hashKeyColumn,
443: tableName, userSuppliedOptimizerOverrides, indexName,
444: isConstraint, colRefItem, lockMode, tableLocked,
445: isolationLevel, optimizerEstimatedRowCount,
446: optimizerEstimatedCost);
447: }
448:
449: /**
450: a minimal table scan generator, for ease of use at present.
451: @see ResultSetFactory#getTableScanResultSet
452: @exception StandardException thrown on error
453: */
454: public NoPutResultSet getTableScanResultSet(Activation activation,
455: long conglomId, int scociItem,
456: GeneratedMethod resultRowAllocator, int resultSetNumber,
457: GeneratedMethod startKeyGetter, int startSearchOperator,
458: GeneratedMethod stopKeyGetter, int stopSearchOperator,
459: boolean sameStartStopPosition, Qualifier[][] qualifiers,
460: String tableName, String userSuppliedOptimizerOverrides,
461: String indexName, boolean isConstraint, boolean forUpdate,
462: int colRefItem, int indexColItem, int lockMode,
463: boolean tableLocked, int isolationLevel,
464: boolean oneRowScan, double optimizerEstimatedRowCount,
465: double optimizerEstimatedCost) throws StandardException {
466: StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo) (activation
467: .getPreparedStatement().getSavedObject(scociItem));
468: return new TableScanResultSet(conglomId, scoci, activation,
469: resultRowAllocator, resultSetNumber, startKeyGetter,
470: startSearchOperator, stopKeyGetter, stopSearchOperator,
471: sameStartStopPosition, qualifiers, tableName,
472: userSuppliedOptimizerOverrides, indexName,
473: isConstraint, forUpdate, colRefItem, indexColItem,
474: lockMode, tableLocked, isolationLevel,
475: 1, // rowsPerRead is 1 if not a bulkTableScan
476: oneRowScan, optimizerEstimatedRowCount,
477: optimizerEstimatedCost);
478: }
479:
480: /**
481: Table/Index scan where rows are read in bulk
482: @see ResultSetFactory#getBulkTableScanResultSet
483: @exception StandardException thrown on error
484: */
485: public NoPutResultSet getBulkTableScanResultSet(
486: Activation activation, long conglomId, int scociItem,
487: GeneratedMethod resultRowAllocator, int resultSetNumber,
488: GeneratedMethod startKeyGetter, int startSearchOperator,
489: GeneratedMethod stopKeyGetter, int stopSearchOperator,
490: boolean sameStartStopPosition, Qualifier[][] qualifiers,
491: String tableName, String userSuppliedOptimizerOverrides,
492: String indexName, boolean isConstraint, boolean forUpdate,
493: int colRefItem, int indexColItem, int lockMode,
494: boolean tableLocked, int isolationLevel, int rowsPerRead,
495: boolean oneRowScan, double optimizerEstimatedRowCount,
496: double optimizerEstimatedCost) throws StandardException {
497: //Prior to Cloudscape 10.0 release, holdability was false by default. Programmers had to explicitly
498: //set the holdability to true using JDBC apis. Since holdability was not true by default, we chose to disable the
499: //prefetching for RR and Serializable when holdability was explicitly set to true.
500: //But starting Cloudscape 10.0 release, in order to be DB2 compatible, holdability is set to true by default.
501: //Because of that, we can not continue to disable the prefetching for RR and Serializable, since it causes
502: //severe performance degradation - bug 5953.
503:
504: StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo) (activation
505: .getPreparedStatement().getSavedObject(scociItem));
506: return new BulkTableScanResultSet(conglomId, scoci, activation,
507: resultRowAllocator, resultSetNumber, startKeyGetter,
508: startSearchOperator, stopKeyGetter, stopSearchOperator,
509: sameStartStopPosition, qualifiers, tableName,
510: userSuppliedOptimizerOverrides, indexName,
511: isConstraint, forUpdate, colRefItem, indexColItem,
512: lockMode, tableLocked, isolationLevel, rowsPerRead,
513: oneRowScan, optimizerEstimatedRowCount,
514: optimizerEstimatedCost);
515: }
516:
517: /**
518: @see ResultSetFactory#getIndexRowToBaseRowResultSet
519: @exception StandardException Thrown on error
520: */
521: public NoPutResultSet getIndexRowToBaseRowResultSet(long conglomId,
522: int scociItem, NoPutResultSet source,
523: GeneratedMethod resultRowAllocator, int resultSetNumber,
524: String indexName, int heapColRefItem, int indexColRefItem,
525: int indexColMapItem, GeneratedMethod restriction,
526: boolean forUpdate, double optimizerEstimatedRowCount,
527: double optimizerEstimatedCost) throws StandardException {
528: return new IndexRowToBaseRowResultSet(conglomId, scociItem,
529: source.getActivation(), source, resultRowAllocator,
530: resultSetNumber, indexName, heapColRefItem,
531: indexColRefItem, indexColMapItem, restriction,
532: forUpdate, optimizerEstimatedRowCount,
533: optimizerEstimatedCost);
534: }
535:
536: /**
537: @see ResultSetFactory#getNestedLoopJoinResultSet
538: @exception StandardException thrown on error
539: */
540:
541: public NoPutResultSet getNestedLoopJoinResultSet(
542: NoPutResultSet leftResultSet, int leftNumCols,
543: NoPutResultSet rightResultSet, int rightNumCols,
544: GeneratedMethod joinClause, int resultSetNumber,
545: boolean oneRowRightSide, boolean notExistsRightSide,
546: double optimizerEstimatedRowCount,
547: double optimizerEstimatedCost,
548: String userSuppliedOptimizerOverrides)
549: throws StandardException {
550: return new NestedLoopJoinResultSet(leftResultSet, leftNumCols,
551: rightResultSet, rightNumCols, leftResultSet
552: .getActivation(), joinClause, resultSetNumber,
553: oneRowRightSide, notExistsRightSide,
554: optimizerEstimatedRowCount, optimizerEstimatedCost,
555: userSuppliedOptimizerOverrides);
556: }
557:
558: /**
559: @see ResultSetFactory#getHashJoinResultSet
560: @exception StandardException thrown on error
561: */
562:
563: public NoPutResultSet getHashJoinResultSet(
564: NoPutResultSet leftResultSet, int leftNumCols,
565: NoPutResultSet rightResultSet, int rightNumCols,
566: GeneratedMethod joinClause, int resultSetNumber,
567: boolean oneRowRightSide, boolean notExistsRightSide,
568: double optimizerEstimatedRowCount,
569: double optimizerEstimatedCost,
570: String userSuppliedOptimizerOverrides)
571: throws StandardException {
572: return new HashJoinResultSet(leftResultSet, leftNumCols,
573: rightResultSet, rightNumCols, leftResultSet
574: .getActivation(), joinClause, resultSetNumber,
575: oneRowRightSide, notExistsRightSide,
576: optimizerEstimatedRowCount, optimizerEstimatedCost,
577: userSuppliedOptimizerOverrides);
578: }
579:
580: /**
581: @see ResultSetFactory#getNestedLoopLeftOuterJoinResultSet
582: @exception StandardException thrown on error
583: */
584:
585: public NoPutResultSet getNestedLoopLeftOuterJoinResultSet(
586: NoPutResultSet leftResultSet, int leftNumCols,
587: NoPutResultSet rightResultSet, int rightNumCols,
588: GeneratedMethod joinClause, int resultSetNumber,
589: GeneratedMethod emptyRowFun, boolean wasRightOuterJoin,
590: boolean oneRowRightSide, boolean notExistsRightSide,
591: double optimizerEstimatedRowCount,
592: double optimizerEstimatedCost,
593: String userSuppliedOptimizerOverrides)
594: throws StandardException {
595: return new NestedLoopLeftOuterJoinResultSet(leftResultSet,
596: leftNumCols, rightResultSet, rightNumCols,
597: leftResultSet.getActivation(), joinClause,
598: resultSetNumber, emptyRowFun, wasRightOuterJoin,
599: oneRowRightSide, notExistsRightSide,
600: optimizerEstimatedRowCount, optimizerEstimatedCost,
601: userSuppliedOptimizerOverrides);
602: }
603:
604: /**
605: @see ResultSetFactory#getHashLeftOuterJoinResultSet
606: @exception StandardException thrown on error
607: */
608:
609: public NoPutResultSet getHashLeftOuterJoinResultSet(
610: NoPutResultSet leftResultSet, int leftNumCols,
611: NoPutResultSet rightResultSet, int rightNumCols,
612: GeneratedMethod joinClause, int resultSetNumber,
613: GeneratedMethod emptyRowFun, boolean wasRightOuterJoin,
614: boolean oneRowRightSide, boolean notExistsRightSide,
615: double optimizerEstimatedRowCount,
616: double optimizerEstimatedCost,
617: String userSuppliedOptimizerOverrides)
618: throws StandardException {
619: return new HashLeftOuterJoinResultSet(leftResultSet,
620: leftNumCols, rightResultSet, rightNumCols,
621: leftResultSet.getActivation(), joinClause,
622: resultSetNumber, emptyRowFun, wasRightOuterJoin,
623: oneRowRightSide, notExistsRightSide,
624: optimizerEstimatedRowCount, optimizerEstimatedCost,
625: userSuppliedOptimizerOverrides);
626: }
627:
628: /**
629: @see ResultSetFactory#getSetTransactionResultSet
630: @exception StandardException thrown when unable to create the
631: result set
632: */
633: public ResultSet getSetTransactionResultSet(Activation activation)
634: throws StandardException {
635: getAuthorizer(activation).authorize(activation,
636: Authorizer.SQL_ARBITARY_OP);
637: return new SetTransactionResultSet(activation);
638: }
639:
640: /**
641: @see ResultSetFactory#getMaterializedResultSet
642: @exception StandardException thrown on error
643: */
644: public NoPutResultSet getMaterializedResultSet(
645: NoPutResultSet source, int resultSetNumber,
646: double optimizerEstimatedRowCount,
647: double optimizerEstimatedCost) throws StandardException {
648: return new MaterializedResultSet(source,
649: source.getActivation(), resultSetNumber,
650: optimizerEstimatedRowCount, optimizerEstimatedCost);
651: }
652:
653: /**
654: @see ResultSetFactory#getScrollInsensitiveResultSet
655: @exception StandardException thrown on error
656: */
657: public NoPutResultSet getScrollInsensitiveResultSet(
658: NoPutResultSet source, Activation activation,
659: int resultSetNumber, int sourceRowWidth,
660: boolean scrollable, double optimizerEstimatedRowCount,
661: double optimizerEstimatedCost) throws StandardException {
662: /* ResultSet tree is dependent on whether or not this is
663: * for a scroll insensitive cursor.
664: */
665:
666: if (scrollable) {
667: return new ScrollInsensitiveResultSet(source, activation,
668: resultSetNumber, sourceRowWidth,
669: optimizerEstimatedRowCount, optimizerEstimatedCost);
670: } else {
671: return source;
672: }
673: }
674:
675: /**
676: @see ResultSetFactory#getNormalizeResultSet
677: @exception StandardException thrown on error
678: */
679: public NoPutResultSet getNormalizeResultSet(NoPutResultSet source,
680: int resultSetNumber, int erdNumber,
681: double optimizerEstimatedRowCount,
682: double optimizerEstimatedCost, boolean forUpdate)
683: throws StandardException {
684: return new NormalizeResultSet(source, source.getActivation(),
685: resultSetNumber, erdNumber, optimizerEstimatedRowCount,
686: optimizerEstimatedCost, forUpdate);
687: }
688:
689: /**
690: @see ResultSetFactory#getCurrentOfResultSet
691: */
692: public NoPutResultSet getCurrentOfResultSet(String cursorName,
693: Activation activation, int resultSetNumber, String psName) {
694: return new CurrentOfResultSet(cursorName, activation,
695: resultSetNumber, psName);
696: }
697:
698: /**
699: @see ResultSetFactory#getDDLResultSet
700: @exception StandardException thrown on error
701: */
702: public ResultSet getDDLResultSet(Activation activation)
703: throws StandardException {
704: getAuthorizer(activation).authorize(activation,
705: Authorizer.SQL_DDL_OP);
706: return getMiscResultSet(activation);
707: }
708:
709: /**
710: @see ResultSetFactory#getMiscResultSet
711: @exception StandardException thrown on error
712: */
713: public ResultSet getMiscResultSet(Activation activation)
714: throws StandardException {
715: getAuthorizer(activation).authorize(activation,
716: Authorizer.SQL_ARBITARY_OP);
717: return new MiscResultSet(activation);
718: }
719:
720: /**
721: a minimal union scan generator, for ease of use at present.
722: @see ResultSetFactory#getUnionResultSet
723: @exception StandardException thrown on error
724: */
725: public NoPutResultSet getUnionResultSet(
726: NoPutResultSet leftResultSet,
727: NoPutResultSet rightResultSet, int resultSetNumber,
728: double optimizerEstimatedRowCount,
729: double optimizerEstimatedCost) throws StandardException {
730: return new UnionResultSet(leftResultSet, rightResultSet,
731: leftResultSet.getActivation(), resultSetNumber,
732: optimizerEstimatedRowCount, optimizerEstimatedCost);
733: }
734:
735: public NoPutResultSet getSetOpResultSet(NoPutResultSet leftSource,
736: NoPutResultSet rightSource, Activation activation,
737: int resultSetNumber, long optimizerEstimatedRowCount,
738: double optimizerEstimatedCost, int opType, boolean all,
739: int intermediateOrderByColumnsSavedObject,
740: int intermediateOrderByDirectionSavedObject)
741: throws StandardException {
742: return new SetOpResultSet(leftSource, rightSource, activation,
743: resultSetNumber, optimizerEstimatedRowCount,
744: optimizerEstimatedCost, opType, all,
745: intermediateOrderByColumnsSavedObject,
746: intermediateOrderByDirectionSavedObject);
747: }
748:
749: /**
750: * A last index key sresult set returns the last row from
751: * the index in question. It is used as an ajunct to max().
752: *
753: * @param activation the activation for this result set,
754: * which provides the context for the row allocation operation.
755: * @param resultSetNumber The resultSetNumber for the ResultSet
756: * @param resultRowAllocator a reference to a method in the activation
757: * that creates a holder for the result row of the scan. May
758: * be a partial row. <verbatim>
759: * ExecRow rowAllocator() throws StandardException; </verbatim>
760: * @param conglomId the conglomerate of the table to be scanned.
761: * @param tableName The full name of the table
762: * @param userSuppliedOptimizerOverrides Overrides specified by the user on the sql
763: * @param indexName The name of the index, if one used to access table.
764: * @param colRefItem An saved item for a bitSet of columns that
765: * are referenced in the underlying table. -1 if
766: * no item.
767: * @param lockMode The lock granularity to use (see
768: * TransactionController in access)
769: * @param tableLocked Whether or not the table is marked as using table locking
770: * (in sys.systables)
771: * @param isolationLevel Isolation level (specified or not) to use on scans
772: * @param optimizerEstimatedRowCount Estimated total # of rows by
773: * optimizer
774: * @param optimizerEstimatedCost Estimated total cost by optimizer
775: *
776: * @return the scan operation as a result set.
777: *
778: * @exception StandardException thrown when unable to create the
779: * result set
780: */
781: public NoPutResultSet getLastIndexKeyResultSet(
782: Activation activation, int resultSetNumber,
783: GeneratedMethod resultRowAllocator, long conglomId,
784: String tableName, String userSuppliedOptimizerOverrides,
785: String indexName, int colRefItem, int lockMode,
786: boolean tableLocked, int isolationLevel,
787: double optimizerEstimatedRowCount,
788: double optimizerEstimatedCost) throws StandardException {
789: return new LastIndexKeyResultSet(activation, resultSetNumber,
790: resultRowAllocator, conglomId, tableName,
791: userSuppliedOptimizerOverrides, indexName, colRefItem,
792: lockMode, tableLocked, isolationLevel,
793: optimizerEstimatedRowCount, optimizerEstimatedCost);
794: }
795:
796: /**
797: * a referential action dependent table scan generator.
798: * @see ResultSetFactory#getTableScanResultSet
799: * @exception StandardException thrown on error
800: */
801: public NoPutResultSet getRaDependentTableScanResultSet(
802: Activation activation, long conglomId, int scociItem,
803: GeneratedMethod resultRowAllocator, int resultSetNumber,
804: GeneratedMethod startKeyGetter, int startSearchOperator,
805: GeneratedMethod stopKeyGetter, int stopSearchOperator,
806: boolean sameStartStopPosition, Qualifier[][] qualifiers,
807: String tableName, String userSuppliedOptimizerOverrides,
808: String indexName, boolean isConstraint, boolean forUpdate,
809: int colRefItem, int indexColItem, int lockMode,
810: boolean tableLocked, int isolationLevel,
811: boolean oneRowScan, double optimizerEstimatedRowCount,
812: double optimizerEstimatedCost, String parentResultSetId,
813: long fkIndexConglomId, int fkColArrayItem, int rltItem)
814: throws StandardException {
815: StaticCompiledOpenConglomInfo scoci = (StaticCompiledOpenConglomInfo) (activation
816: .getPreparedStatement().getSavedObject(scociItem));
817: return new DependentResultSet(conglomId, scoci, activation,
818: resultRowAllocator, resultSetNumber, startKeyGetter,
819: startSearchOperator, stopKeyGetter, stopSearchOperator,
820: sameStartStopPosition, qualifiers, tableName,
821: userSuppliedOptimizerOverrides, indexName,
822: isConstraint, forUpdate, colRefItem, lockMode,
823: tableLocked, isolationLevel, 1, oneRowScan,
824: optimizerEstimatedRowCount, optimizerEstimatedCost,
825: parentResultSetId, fkIndexConglomId, fkColArrayItem,
826: rltItem);
827: }
828:
829: static private Authorizer getAuthorizer(Activation activation) {
830: LanguageConnectionContext lcc = activation
831: .getLanguageConnectionContext();
832: return lcc.getAuthorizer();
833: }
834:
835: /////////////////////////////////////////////////////////////////
836: //
837: // PUBLIC MINIONS
838: //
839: /////////////////////////////////////////////////////////////////
840:
841: }
|