KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > RealResultSetStatisticsFactory


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.RealResultSetStatisticsFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.iapi.services.io.FormatIdUtil;
27
28 import org.apache.derby.iapi.error.StandardException;
29 import org.apache.derby.iapi.services.i18n.MessageService;
30
31 import org.apache.derby.iapi.sql.Activation;
32 import org.apache.derby.iapi.sql.ResultSet;
33 import org.apache.derby.iapi.sql.PreparedStatement;
34
35 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
36 import org.apache.derby.iapi.sql.execute.ResultSetFactory;
37 import org.apache.derby.iapi.sql.execute.ResultSetStatisticsFactory;
38
39 import org.apache.derby.iapi.store.access.TransactionController;
40
41 import org.apache.derby.impl.sql.execute.AnyResultSet;
42 import org.apache.derby.impl.sql.execute.CurrentOfResultSet;
43 import org.apache.derby.impl.sql.execute.DeleteResultSet;
44 import org.apache.derby.impl.sql.execute.DeleteCascadeResultSet;
45 import org.apache.derby.impl.sql.execute.DeleteVTIResultSet;
46 import org.apache.derby.impl.sql.execute.DistinctScalarAggregateResultSet;
47 import org.apache.derby.impl.sql.execute.DistinctScanResultSet;
48 import org.apache.derby.impl.sql.execute.GroupedAggregateResultSet;
49 import org.apache.derby.impl.sql.execute.HashJoinResultSet;
50 import org.apache.derby.impl.sql.execute.HashLeftOuterJoinResultSet;
51 import org.apache.derby.impl.sql.execute.HashScanResultSet;
52 import org.apache.derby.impl.sql.execute.HashTableResultSet;
53 import org.apache.derby.impl.sql.execute.IndexRowToBaseRowResultSet;
54 import org.apache.derby.impl.sql.execute.InsertResultSet;
55 import org.apache.derby.impl.sql.execute.InsertVTIResultSet;
56 import org.apache.derby.impl.sql.execute.LastIndexKeyResultSet;
57 import org.apache.derby.impl.sql.execute.MaterializedResultSet;
58 import org.apache.derby.impl.sql.execute.NestedLoopJoinResultSet;
59 import org.apache.derby.impl.sql.execute.NestedLoopLeftOuterJoinResultSet;
60 import org.apache.derby.impl.sql.execute.NormalizeResultSet;
61 import org.apache.derby.impl.sql.execute.OnceResultSet;
62 import org.apache.derby.impl.sql.execute.ProjectRestrictResultSet;
63 import org.apache.derby.impl.sql.execute.RowResultSet;
64 import org.apache.derby.impl.sql.execute.ScalarAggregateResultSet;
65 import org.apache.derby.impl.sql.execute.ScrollInsensitiveResultSet;
66 import org.apache.derby.impl.sql.execute.SetOpResultSet;
67 import org.apache.derby.impl.sql.execute.SortResultSet;
68 import org.apache.derby.impl.sql.execute.TableScanResultSet;
69 import org.apache.derby.impl.sql.execute.UnionResultSet;
70 import org.apache.derby.impl.sql.execute.UpdateResultSet;
71 import org.apache.derby.impl.sql.execute.VTIResultSet;
72 import org.apache.derby.impl.sql.execute.DependentResultSet;
73
74 import org.apache.derby.iapi.sql.execute.RunTimeStatistics;
75 import org.apache.derby.impl.sql.execute.rts.RealAnyResultSetStatistics;
76 import org.apache.derby.impl.sql.execute.rts.RealCurrentOfStatistics;
77 import org.apache.derby.impl.sql.execute.rts.RealDeleteResultSetStatistics;
78 import org.apache.derby.impl.sql.execute.rts.RealDeleteCascadeResultSetStatistics;
79 import org.apache.derby.impl.sql.execute.rts.RealDeleteVTIResultSetStatistics;
80 import org.apache.derby.impl.sql.execute.rts.RealDistinctScalarAggregateStatistics;
81 import org.apache.derby.impl.sql.execute.rts.RealDistinctScanStatistics;
82 import org.apache.derby.impl.sql.execute.rts.RealGroupedAggregateStatistics;
83 import org.apache.derby.impl.sql.execute.rts.RealHashJoinStatistics;
84 import org.apache.derby.impl.sql.execute.rts.RealHashLeftOuterJoinStatistics;
85 import org.apache.derby.impl.sql.execute.rts.RealHashScanStatistics;
86 import org.apache.derby.impl.sql.execute.rts.RealHashTableStatistics;
87 import org.apache.derby.impl.sql.execute.rts.RealIndexRowToBaseRowStatistics;
88 import org.apache.derby.impl.sql.execute.rts.RealInsertResultSetStatistics;
89 import org.apache.derby.impl.sql.execute.rts.RealInsertVTIResultSetStatistics;
90 import org.apache.derby.impl.sql.execute.rts.RealJoinResultSetStatistics;
91 import org.apache.derby.impl.sql.execute.rts.RealLastIndexKeyScanStatistics;
92 import org.apache.derby.impl.sql.execute.rts.RealMaterializedResultSetStatistics;
93 import org.apache.derby.impl.sql.execute.rts.RealNestedLoopJoinStatistics;
94 import org.apache.derby.impl.sql.execute.rts.RealNestedLoopLeftOuterJoinStatistics;
95 import org.apache.derby.impl.sql.execute.rts.RealNormalizeResultSetStatistics;
96 import org.apache.derby.impl.sql.execute.rts.RealOnceResultSetStatistics;
97 import org.apache.derby.impl.sql.execute.rts.RealProjectRestrictStatistics;
98 import org.apache.derby.impl.sql.execute.rts.RealRowResultSetStatistics;
99 import org.apache.derby.impl.sql.execute.rts.RealScalarAggregateStatistics;
100 import org.apache.derby.impl.sql.execute.rts.RealScrollInsensitiveResultSetStatistics;
101 import org.apache.derby.impl.sql.execute.rts.RealSetOpResultSetStatistics;
102 import org.apache.derby.impl.sql.execute.rts.RealSortStatistics;
103 import org.apache.derby.impl.sql.execute.rts.RealTableScanStatistics;
104 import org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics;
105 import org.apache.derby.impl.sql.execute.rts.RealUpdateResultSetStatistics;
106 import org.apache.derby.impl.sql.execute.rts.RealVTIStatistics;
107 import org.apache.derby.impl.sql.execute.rts.ResultSetStatistics;
108 import org.apache.derby.impl.sql.execute.rts.RunTimeStatisticsImpl;
109
110 import org.apache.derby.iapi.reference.SQLState;
111
112 import java.util.Properties JavaDoc;
113
114 /**
115  * ResultSetStatisticsFactory provides a wrapper around all of
116  * objects associated with run time statistics.
117  * <p>
118  * This implementation of the protocol is for returning the "real"
119  * run time statistics. We have modularized this so that we could
120  * have an implementation that just returns null for each of the
121  * objects should we decided to provide a configuration without
122  * the run time statistics feature.
123  *
124  * @author jerry
125  */

126 public class RealResultSetStatisticsFactory
127         implements ResultSetStatisticsFactory
128 {
129
130     //
131
// ExecutionFactory interface
132
//
133
//
134
// ResultSetStatisticsFactory interface
135
//
136

137     /**
138         @see ResultSetStatisticsFactory#getRunTimeStatistics
139      */

140     public RunTimeStatistics getRunTimeStatistics(
141             Activation activation,
142             ResultSet rs,
143             NoPutResultSet[] subqueryTrackingArray)
144         throws StandardException
145     {
146         PreparedStatement preStmt = activation.getPreparedStatement();
147
148         // If the prepared statement is null then the result set is being
149
// finished as a result of a activation being closed during a recompile.
150
// In this case statistics should not be generated.
151
if (preStmt == null)
152             return null;
153
154
155
156
157         ResultSetStatistics topResultSetStatistics;
158
159         if (rs instanceof NoPutResultSet)
160         {
161             topResultSetStatistics =
162                                     getResultSetStatistics((NoPutResultSet) rs);
163         }
164         else
165         {
166             topResultSetStatistics = getResultSetStatistics(rs);
167         }
168
169         /* Build up the info on the materialized subqueries */
170         int subqueryTrackingArrayLength =
171                 (subqueryTrackingArray == null) ? 0 :
172                     subqueryTrackingArray.length;
173         ResultSetStatistics[] subqueryRSS =
174                 new ResultSetStatistics[subqueryTrackingArrayLength];
175         boolean anyAttached = false;
176         for (int index = 0; index < subqueryTrackingArrayLength; index++)
177         {
178             if (subqueryTrackingArray[index] != null &&
179                 subqueryTrackingArray[index].getPointOfAttachment() == -1)
180             {
181                 subqueryRSS[index] =
182                         getResultSetStatistics(subqueryTrackingArray[index]);
183                 anyAttached = true;
184             }
185         }
186         if (anyAttached == false)
187         {
188             subqueryRSS = null;
189         }
190
191         // Get the info on all of the materialized subqueries (attachment point = -1)
192
return new RunTimeStatisticsImpl(
193                                 preStmt.getSPSName(),
194                                 activation.getCursorName(),
195                                 preStmt.getSource(),
196                                 preStmt.getCompileTimeInMillis(),
197                                 preStmt.getParseTimeInMillis(),
198                                 preStmt.getBindTimeInMillis(),
199                                 preStmt.getOptimizeTimeInMillis(),
200                                 preStmt.getGenerateTimeInMillis(),
201                                 rs.getExecuteTime(),
202                                 preStmt.getBeginCompileTimestamp(),
203                                 preStmt.getEndCompileTimestamp(),
204                                 rs.getBeginExecutionTimestamp(),
205                                 rs.getEndExecutionTimestamp(),
206                                 subqueryRSS,
207                                 topResultSetStatistics);
208     }
209
210     /**
211         @see ResultSetStatisticsFactory#getResultSetStatistics
212      */

213     public ResultSetStatistics getResultSetStatistics(ResultSet rs)
214     {
215         if (!rs.returnsRows())
216         {
217             return getNoRowsResultSetStatistics(rs);
218         }
219         else if (rs instanceof NoPutResultSet)
220         {
221             return getResultSetStatistics((NoPutResultSet) rs);
222         }
223         else
224         {
225             return null;
226         }
227     }
228
229     public ResultSetStatistics getNoRowsResultSetStatistics(ResultSet rs)
230     {
231         ResultSetStatistics retval = null;
232
233         /* We need to differentiate based on instanceof in order
234          * to find the right constructor to call. This is ugly,
235          * but if we don't do instanceof then rs is always seen as an
236          * interface instead of a class when we try to overload
237          * a method with both.
238          */

239         if( rs instanceof InsertResultSet)
240         {
241             InsertResultSet irs = (InsertResultSet) rs;
242
243             retval = new RealInsertResultSetStatistics(
244                                     irs.rowCount,
245                                     irs.constants.deferred,
246                                     irs.constants.irgs.length,
247                                     irs.userSpecifiedBulkInsert,
248                                     irs.bulkInsertPerformed,
249                                     irs.constants.lockMode ==
250                                         TransactionController.MODE_TABLE,
251                                     irs.getExecuteTime(),
252                                     getResultSetStatistics(irs.savedSource)
253                                     );
254
255             irs.savedSource = null;
256         }
257         else if( rs instanceof InsertVTIResultSet)
258         {
259             InsertVTIResultSet iVTIrs = (InsertVTIResultSet) rs;
260
261             retval = new RealInsertVTIResultSetStatistics(
262                                     iVTIrs.rowCount,
263                                     iVTIrs.constants.deferred,
264                                     iVTIrs.getExecuteTime(),
265                                     getResultSetStatistics(iVTIrs.savedSource)
266                                     );
267
268             iVTIrs.savedSource = null;
269         }
270         else if( rs instanceof UpdateResultSet)
271         {
272             UpdateResultSet urs = (UpdateResultSet) rs;
273
274             retval = new RealUpdateResultSetStatistics(
275                                     urs.rowCount,
276                                     urs.constants.deferred,
277                                     urs.constants.irgs.length,
278                                     urs.constants.lockMode ==
279                                         TransactionController.MODE_TABLE,
280                                     urs.getExecuteTime(),
281                                     getResultSetStatistics(urs.savedSource)
282                                     );
283
284             urs.savedSource = null;
285         }
286         else if( rs instanceof DeleteCascadeResultSet)
287         {
288             DeleteCascadeResultSet dcrs = (DeleteCascadeResultSet) rs;
289             int dependentTrackingArrayLength =
290                 (dcrs.dependentResultSets == null) ? 0 :
291                     dcrs.dependentResultSets.length;
292             ResultSetStatistics[] dependentTrackingArray =
293                 new ResultSetStatistics[dependentTrackingArrayLength];
294             boolean anyAttached = false;
295             for (int index = 0; index < dependentTrackingArrayLength; index++)
296             {
297                 if (dcrs.dependentResultSets[index] != null)
298                 {
299                     dependentTrackingArray[index] =
300                                         getResultSetStatistics(
301                                             dcrs.dependentResultSets[index]);
302                     anyAttached = true;
303                 }
304             }
305             if (! anyAttached)
306             {
307                 dependentTrackingArray = null;
308             }
309
310             retval = new RealDeleteCascadeResultSetStatistics(
311                                     dcrs.rowCount,
312                                     dcrs.constants.deferred,
313                                     dcrs.constants.irgs.length,
314                                     dcrs.constants.lockMode ==
315                                         TransactionController.MODE_TABLE,
316                                     dcrs.getExecuteTime(),
317                                     getResultSetStatistics(dcrs.savedSource),
318                                     dependentTrackingArray
319                                     );
320
321             dcrs.savedSource = null;
322         }
323         else if( rs instanceof DeleteResultSet)
324         {
325             DeleteResultSet drs = (DeleteResultSet) rs;
326
327             retval = new RealDeleteResultSetStatistics(
328                                     drs.rowCount,
329                                     drs.constants.deferred,
330                                     drs.constants.irgs.length,
331                                     drs.constants.lockMode ==
332                                         TransactionController.MODE_TABLE,
333                                     drs.getExecuteTime(),
334                                     getResultSetStatistics(drs.savedSource)
335                                     );
336
337             drs.savedSource = null;
338         }
339         else if( rs instanceof DeleteVTIResultSet)
340         {
341             DeleteVTIResultSet dVTIrs = (DeleteVTIResultSet) rs;
342
343             retval = new RealDeleteVTIResultSetStatistics(
344                                     dVTIrs.rowCount,
345                                     dVTIrs.getExecuteTime(),
346                                     getResultSetStatistics(dVTIrs.savedSource)
347                                     );
348
349             dVTIrs.savedSource = null;
350         }
351
352
353         return retval;
354     }
355
356     public ResultSetStatistics getResultSetStatistics(NoPutResultSet rs)
357     {
358         /* We need to differentiate based on instanceof in order
359          * to find the right constructor to call. This is ugly,
360          * but if we don't do instanceof then rs is always seen as an
361          * interface instead of a class when we try to overload
362          * a method with both.
363          */

364         if( rs instanceof ProjectRestrictResultSet)
365         {
366             ProjectRestrictResultSet prrs = (ProjectRestrictResultSet) rs;
367             int subqueryTrackingArrayLength =
368                 (prrs.subqueryTrackingArray == null) ? 0 :
369                     prrs.subqueryTrackingArray.length;
370             ResultSetStatistics[] subqueryTrackingArray =
371                 new ResultSetStatistics[subqueryTrackingArrayLength];
372             boolean anyAttached = false;
373             for (int index = 0; index < subqueryTrackingArrayLength; index++)
374             {
375                 if (prrs.subqueryTrackingArray[index] != null &&
376                     prrs.subqueryTrackingArray[index].getPointOfAttachment() ==
377                         prrs.resultSetNumber)
378                 {
379                     subqueryTrackingArray[index] =
380                                         getResultSetStatistics(
381                                             prrs.subqueryTrackingArray[index]);
382                     anyAttached = true;
383                 }
384             }
385             if (! anyAttached)
386             {
387                 subqueryTrackingArray = null;
388             }
389
390             return new RealProjectRestrictStatistics(
391                                             prrs.numOpens,
392                                             prrs.rowsSeen,
393                                             prrs.rowsFiltered,
394                                             prrs.constructorTime,
395                                             prrs.openTime,
396                                             prrs.nextTime,
397                                             prrs.closeTime,
398                                             prrs.resultSetNumber,
399                                             prrs.restrictionTime,
400                                             prrs.projectionTime,
401                                             subqueryTrackingArray,
402                                             (prrs.restriction != null),
403                                             prrs.doesProjection,
404                                             prrs.optimizerEstimatedRowCount,
405                                             prrs.optimizerEstimatedCost,
406                                             getResultSetStatistics(prrs.source)
407                                             );
408         }
409         else if (rs instanceof SortResultSet)
410         {
411             SortResultSet srs = (SortResultSet) rs;
412
413             return new RealSortStatistics(
414                                             srs.numOpens,
415                                             srs.rowsSeen,
416                                             srs.rowsFiltered,
417                                             srs.constructorTime,
418                                             srs.openTime,
419                                             srs.nextTime,
420                                             srs.closeTime,
421                                             srs.resultSetNumber,
422                                             srs.rowsInput,
423                                             srs.rowsReturned,
424                                             srs.distinct,
425                                             srs.isInSortedOrder,
426                                             srs.sortProperties,
427                                             srs.optimizerEstimatedRowCount,
428                                             srs.optimizerEstimatedCost,
429                                             getResultSetStatistics(srs.source)
430                                         );
431         }
432         else if (rs instanceof DistinctScalarAggregateResultSet)
433         {
434             DistinctScalarAggregateResultSet dsars = (DistinctScalarAggregateResultSet) rs;
435
436             return new RealDistinctScalarAggregateStatistics(
437                                             dsars.numOpens,
438                                             dsars.rowsSeen,
439                                             dsars.rowsFiltered,
440                                             dsars.constructorTime,
441                                             dsars.openTime,
442                                             dsars.nextTime,
443                                             dsars.closeTime,
444                                             dsars.resultSetNumber,
445                                             dsars.rowsInput,
446                                             dsars.optimizerEstimatedRowCount,
447                                             dsars.optimizerEstimatedCost,
448                                             getResultSetStatistics(dsars.source)
449                                         );
450         }
451         else if (rs instanceof ScalarAggregateResultSet)
452         {
453             ScalarAggregateResultSet sars = (ScalarAggregateResultSet) rs;
454
455             return new RealScalarAggregateStatistics(
456                                             sars.numOpens,
457                                             sars.rowsSeen,
458                                             sars.rowsFiltered,
459                                             sars.constructorTime,
460                                             sars.openTime,
461                                             sars.nextTime,
462                                             sars.closeTime,
463                                             sars.resultSetNumber,
464                                             sars.singleInputRow,
465                                             sars.rowsInput,
466                                             sars.optimizerEstimatedRowCount,
467                                             sars.optimizerEstimatedCost,
468                                             getResultSetStatistics(sars.source)
469                                         );
470         }
471         else if (rs instanceof GroupedAggregateResultSet)
472         {
473             GroupedAggregateResultSet gars = (GroupedAggregateResultSet) rs;
474
475             return new RealGroupedAggregateStatistics(
476                                             gars.numOpens,
477                                             gars.rowsSeen,
478                                             gars.rowsFiltered,
479                                             gars.constructorTime,
480                                             gars.openTime,
481                                             gars.nextTime,
482                                             gars.closeTime,
483                                             gars.resultSetNumber,
484                                             gars.rowsInput,
485                                             gars.hasDistinctAggregate,
486                                             gars.isInSortedOrder,
487                                             gars.sortProperties,
488                                             gars.optimizerEstimatedRowCount,
489                                             gars.optimizerEstimatedCost,
490                                             getResultSetStatistics(gars.source)
491                                         );
492         }
493         else if (rs instanceof TableScanResultSet)
494         {
495             boolean instantaneousLocks = false;
496             TableScanResultSet tsrs = (TableScanResultSet) rs;
497             String JavaDoc startPosition = null;
498             String JavaDoc stopPosition = null;
499             String JavaDoc isolationLevel = null;
500             String JavaDoc lockString = null;
501             String JavaDoc lockRequestString = null;
502
503             switch (tsrs.isolationLevel)
504             {
505                 case TransactionController.ISOLATION_SERIALIZABLE:
506                     isolationLevel =
507                         MessageService.getTextMessage(
508                             SQLState.LANG_SERIALIZABLE);
509                     break;
510
511                 case TransactionController.ISOLATION_REPEATABLE_READ:
512                     isolationLevel =
513                         MessageService.getTextMessage(
514                             SQLState.LANG_REPEATABLE_READ);
515                     break;
516
517                 case TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK:
518                     instantaneousLocks = true;
519                     //fall through
520
case TransactionController.ISOLATION_READ_COMMITTED:
521                     isolationLevel = MessageService.getTextMessage(
522                                                 SQLState.LANG_READ_COMMITTED);
523                     break;
524
525                 case TransactionController.ISOLATION_READ_UNCOMMITTED:
526                     isolationLevel =
527                         MessageService.getTextMessage(
528                             SQLState.LANG_READ_UNCOMMITTED);
529                     break;
530             }
531
532             if (tsrs.forUpdate)
533             {
534                 lockString = MessageService.getTextMessage(
535                                                 SQLState.LANG_EXCLUSIVE);
536             }
537             else
538             {
539                 if (instantaneousLocks)
540                 {
541                     lockString = MessageService.getTextMessage(
542                                             SQLState.LANG_INSTANTANEOUS_SHARE);
543                 }
544                 else
545                 {
546                     lockString = MessageService.getTextMessage(
547                                                         SQLState.LANG_SHARE);
548                 }
549             }
550
551             switch (tsrs.lockMode)
552             {
553                 case TransactionController.MODE_TABLE:
554                     // RESOLVE: Not sure this will really work, as we
555
// are tacking together English words to make a phrase.
556
// Will this work in other languages?
557
lockRequestString = lockString + " " +
558                                         MessageService.getTextMessage(
559                                             SQLState.LANG_TABLE);
560                     break;
561
562                 case TransactionController.MODE_RECORD:
563                     // RESOLVE: Not sure this will really work, as we
564
// are tacking together English words to make a phrase.
565
// Will this work in other languages?
566
lockRequestString = lockString + " " +
567                                         MessageService.getTextMessage(
568                                             SQLState.LANG_ROW);
569                     break;
570             }
571
572             if (tsrs.indexName != null)
573             {
574                 /* Start and stop position strings will be non-null
575                 * if the TSRS has been closed. Otherwise, we go off
576                 * and build the strings now.
577                 */

578                 startPosition = tsrs.startPositionString;
579                 if (startPosition == null)
580                 {
581                     startPosition = tsrs.printStartPosition();
582                 }
583                 stopPosition = tsrs.stopPositionString;
584                 if (stopPosition == null)
585                 {
586                     stopPosition = tsrs.printStopPosition();
587                 }
588             }
589
590             return new
591                 RealTableScanStatistics(
592                     tsrs.numOpens,
593                     tsrs.rowsSeen,
594                     tsrs.rowsFiltered,
595                     tsrs.constructorTime,
596                     tsrs.openTime,
597                     tsrs.nextTime,
598                     tsrs.closeTime,
599                     tsrs.resultSetNumber,
600                     tsrs.tableName,
601                     tsrs.userSuppliedOptimizerOverrides,
602                     tsrs.indexName,
603                     tsrs.isConstraint,
604                     tsrs.printQualifiers(tsrs.qualifiers),
605                     tsrs.getScanProperties(),
606                     startPosition,
607                     stopPosition,
608                     isolationLevel,
609                     lockRequestString,
610                     tsrs.rowsPerRead,
611                     tsrs.coarserLock,
612                     tsrs.optimizerEstimatedRowCount,
613                     tsrs.optimizerEstimatedCost);
614         }
615
616         else if (rs instanceof LastIndexKeyResultSet )
617         {
618             LastIndexKeyResultSet lrs = (LastIndexKeyResultSet) rs;
619             String JavaDoc isolationLevel = null;
620             String JavaDoc lockRequestString = null;
621
622             switch (lrs.isolationLevel)
623             {
624                 case TransactionController.ISOLATION_SERIALIZABLE:
625                     isolationLevel =
626                         MessageService.getTextMessage(
627                             SQLState.LANG_SERIALIZABLE);
628                     break;
629
630                 case TransactionController.ISOLATION_REPEATABLE_READ:
631                     isolationLevel =
632                         MessageService.getTextMessage(
633                             SQLState.LANG_REPEATABLE_READ);
634                     break;
635
636                 case TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK:
637                 case TransactionController.ISOLATION_READ_COMMITTED:
638                     isolationLevel = MessageService.getTextMessage(
639                                                 SQLState.LANG_READ_COMMITTED);
640                     break;
641
642                 case TransactionController.ISOLATION_READ_UNCOMMITTED:
643                     isolationLevel = MessageService.getTextMessage(
644                                                 SQLState.LANG_READ_UNCOMMITTED);
645                     break;
646             }
647
648             switch (lrs.lockMode)
649             {
650                 case TransactionController.MODE_TABLE:
651                     lockRequestString = MessageService.getTextMessage(
652                                                     SQLState.LANG_SHARE_TABLE);
653                     break;
654
655                 case TransactionController.MODE_RECORD:
656                     lockRequestString = MessageService.getTextMessage(
657                                                     SQLState.LANG_SHARE_ROW);
658                     break;
659             }
660
661             return new RealLastIndexKeyScanStatistics(
662                                             lrs.numOpens,
663                                             lrs.constructorTime,
664                                             lrs.openTime,
665                                             lrs.nextTime,
666                                             lrs.closeTime,
667                                             lrs.resultSetNumber,
668                                             lrs.tableName,
669                                             lrs.indexName,
670                                             isolationLevel,
671                                             lockRequestString,
672                                             lrs.optimizerEstimatedRowCount,
673                                             lrs.optimizerEstimatedCost);
674         }
675         else if (rs instanceof HashLeftOuterJoinResultSet)
676         {
677             HashLeftOuterJoinResultSet hlojrs =
678                 (HashLeftOuterJoinResultSet) rs;
679
680             return new RealHashLeftOuterJoinStatistics(
681                                             hlojrs.numOpens,
682                                             hlojrs.rowsSeen,
683                                             hlojrs.rowsFiltered,
684                                             hlojrs.constructorTime,
685                                             hlojrs.openTime,
686                                             hlojrs.nextTime,
687                                             hlojrs.closeTime,
688                                             hlojrs.resultSetNumber,
689                                             hlojrs.rowsSeenLeft,
690                                             hlojrs.rowsSeenRight,
691                                             hlojrs.rowsReturned,
692                                             hlojrs.restrictionTime,
693                                             hlojrs.optimizerEstimatedRowCount,
694                                             hlojrs.optimizerEstimatedCost,
695                                             hlojrs.userSuppliedOptimizerOverrides,
696                                             getResultSetStatistics(
697                                                 hlojrs.leftResultSet),
698                                             getResultSetStatistics(
699                                                 hlojrs.rightResultSet),
700                                             hlojrs.emptyRightRowsReturned);
701         }
702         else if (rs instanceof NestedLoopLeftOuterJoinResultSet)
703         {
704             NestedLoopLeftOuterJoinResultSet nllojrs =
705                 (NestedLoopLeftOuterJoinResultSet) rs;
706
707             return new RealNestedLoopLeftOuterJoinStatistics(
708                                             nllojrs.numOpens,
709                                             nllojrs.rowsSeen,
710                                             nllojrs.rowsFiltered,
711                                             nllojrs.constructorTime,
712                                             nllojrs.openTime,
713                                             nllojrs.nextTime,
714                                             nllojrs.closeTime,
715                                             nllojrs.resultSetNumber,
716                                             nllojrs.rowsSeenLeft,
717                                             nllojrs.rowsSeenRight,
718                                             nllojrs.rowsReturned,
719                                             nllojrs.restrictionTime,
720                                             nllojrs.optimizerEstimatedRowCount,
721                                             nllojrs.optimizerEstimatedCost,
722                                             nllojrs.userSuppliedOptimizerOverrides,
723                                             getResultSetStatistics(
724                                                 nllojrs.leftResultSet),
725                                             getResultSetStatistics(
726                                                 nllojrs.rightResultSet),
727                                             nllojrs.emptyRightRowsReturned);
728         }
729         else if (rs instanceof HashJoinResultSet)
730         {
731             HashJoinResultSet hjrs = (HashJoinResultSet) rs;
732
733             return new RealHashJoinStatistics(
734                                             hjrs.numOpens,
735                                             hjrs.rowsSeen,
736                                             hjrs.rowsFiltered,
737                                             hjrs.constructorTime,
738                                             hjrs.openTime,
739                                             hjrs.nextTime,
740                                             hjrs.closeTime,
741                                             hjrs.resultSetNumber,
742                                             hjrs.rowsSeenLeft,
743                                             hjrs.rowsSeenRight,
744                                             hjrs.rowsReturned,
745                                             hjrs.restrictionTime,
746                                             hjrs.oneRowRightSide,
747                                             hjrs.optimizerEstimatedRowCount,
748                                             hjrs.optimizerEstimatedCost,
749                                             hjrs.userSuppliedOptimizerOverrides,
750                                             getResultSetStatistics(
751                                                 hjrs.leftResultSet),
752                                             getResultSetStatistics(
753                                                 hjrs.rightResultSet)
754                                             );
755         }
756         else if (rs instanceof NestedLoopJoinResultSet)
757         {
758             NestedLoopJoinResultSet nljrs = (NestedLoopJoinResultSet) rs;
759
760             return new RealNestedLoopJoinStatistics(
761                                             nljrs.numOpens,
762                                             nljrs.rowsSeen,
763                                             nljrs.rowsFiltered,
764                                             nljrs.constructorTime,
765                                             nljrs.openTime,
766                                             nljrs.nextTime,
767                                             nljrs.closeTime,
768                                             nljrs.resultSetNumber,
769                                             nljrs.rowsSeenLeft,
770                                             nljrs.rowsSeenRight,
771                                             nljrs.rowsReturned,
772                                             nljrs.restrictionTime,
773                                             nljrs.oneRowRightSide,
774                                             nljrs.optimizerEstimatedRowCount,
775                                             nljrs.optimizerEstimatedCost,
776                                             nljrs.userSuppliedOptimizerOverrides,
777                                             getResultSetStatistics(
778                                                 nljrs.leftResultSet),
779                                             getResultSetStatistics(
780                                                 nljrs.rightResultSet)
781                                             );
782         }
783         else if (rs instanceof IndexRowToBaseRowResultSet)
784         {
785             IndexRowToBaseRowResultSet irtbrrs =
786                                             (IndexRowToBaseRowResultSet) rs;
787
788             return new RealIndexRowToBaseRowStatistics(
789                                             irtbrrs.numOpens,
790                                             irtbrrs.rowsSeen,
791                                             irtbrrs.rowsFiltered,
792                                             irtbrrs.constructorTime,
793                                             irtbrrs.openTime,
794                                             irtbrrs.nextTime,
795                                             irtbrrs.closeTime,
796                                             irtbrrs.resultSetNumber,
797                                             irtbrrs.indexName,
798                                             irtbrrs.accessedHeapCols,
799                                             irtbrrs.optimizerEstimatedRowCount,
800                                             irtbrrs.optimizerEstimatedCost,
801                                             getResultSetStatistics(
802                                                                 irtbrrs.source)
803                                             );
804         }
805         else if (rs instanceof RowResultSet)
806         {
807             RowResultSet rrs = (RowResultSet) rs;
808
809             return new RealRowResultSetStatistics(
810                                             rrs.numOpens,
811                                             rrs.rowsSeen,
812                                             rrs.rowsFiltered,
813                                             rrs.constructorTime,
814                                             rrs.openTime,
815                                             rrs.nextTime,
816                                             rrs.closeTime,
817                                             rrs.resultSetNumber,
818                                             rrs.rowsReturned,
819                                             rrs.optimizerEstimatedRowCount,
820                                             rrs.optimizerEstimatedCost);
821         }
822         else if (rs instanceof SetOpResultSet)
823         {
824             SetOpResultSet srs = (SetOpResultSet) rs;
825
826             return new RealSetOpResultSetStatistics(
827                                             srs.getOpType(),
828                                             srs.numOpens,
829                                             srs.rowsSeen,
830                                             srs.rowsFiltered,
831                                             srs.constructorTime,
832                                             srs.openTime,
833                                             srs.nextTime,
834                                             srs.closeTime,
835                                             srs.getResultSetNumber(),
836                                             srs.getRowsSeenLeft(),
837                                             srs.getRowsSeenRight(),
838                                             srs.getRowsReturned(),
839                                             srs.optimizerEstimatedRowCount,
840                                             srs.optimizerEstimatedCost,
841                                             getResultSetStatistics(srs.getLeftSourceInput()),
842                                             getResultSetStatistics(srs.getRightSourceInput())
843                                             );
844         }
845         else if (rs instanceof UnionResultSet)
846         {
847             UnionResultSet urs = (UnionResultSet)rs;
848
849             return new RealUnionResultSetStatistics(
850                                             urs.numOpens,
851                                             urs.rowsSeen,
852                                             urs.rowsFiltered,
853                                             urs.constructorTime,
854                                             urs.openTime,
855                                             urs.nextTime,
856                                             urs.closeTime,
857                                             urs.resultSetNumber,
858                                             urs.rowsSeenLeft,
859                                             urs.rowsSeenRight,
860                                             urs.rowsReturned,
861                                             urs.optimizerEstimatedRowCount,
862                                             urs.optimizerEstimatedCost,
863                                             getResultSetStatistics(urs.source1),
864                                             getResultSetStatistics(urs.source2)
865                                             );
866         }
867         else if (rs instanceof AnyResultSet)
868         {
869             AnyResultSet ars = (AnyResultSet) rs;
870
871             return new RealAnyResultSetStatistics(
872                                             ars.numOpens,
873                                             ars.rowsSeen,
874                                             ars.rowsFiltered,
875                                             ars.constructorTime,
876                                             ars.openTime,
877                                             ars.nextTime,
878                                             ars.closeTime,
879                                             ars.resultSetNumber,
880                                             ars.subqueryNumber,
881                                             ars.pointOfAttachment,
882                                             ars.optimizerEstimatedRowCount,
883                                             ars.optimizerEstimatedCost,
884                                             getResultSetStatistics(ars.source)
885                                             );
886         }
887         else if (rs instanceof OnceResultSet)
888         {
889             OnceResultSet ors = (OnceResultSet) rs;
890
891             return new RealOnceResultSetStatistics(
892                                             ors.numOpens,
893                                             ors.rowsSeen,
894                                             ors.rowsFiltered,
895                                             ors.constructorTime,
896                                             ors.openTime,
897                                             ors.nextTime,
898                                             ors.closeTime,
899                                             ors.resultSetNumber,
900                                             ors.subqueryNumber,
901                                             ors.pointOfAttachment,
902                                             ors.optimizerEstimatedRowCount,
903                                             ors.optimizerEstimatedCost,
904                                             getResultSetStatistics(ors.source)
905                                             );
906         }
907         else if (rs instanceof NormalizeResultSet)
908         {
909             NormalizeResultSet nrs = (NormalizeResultSet) rs;
910
911             return new RealNormalizeResultSetStatistics(
912                                             nrs.numOpens,
913                                             nrs.rowsSeen,
914                                             nrs.rowsFiltered,
915                                             nrs.constructorTime,
916                                             nrs.openTime,
917                                             nrs.nextTime,
918                                             nrs.closeTime,
919                                             nrs.resultSetNumber,
920                                             nrs.optimizerEstimatedRowCount,
921                                             nrs.optimizerEstimatedCost,
922                                             getResultSetStatistics(nrs.source)
923                                             );
924         }
925         else if (rs instanceof MaterializedResultSet)
926         {
927             MaterializedResultSet mrs = (MaterializedResultSet) rs;
928
929             return new RealMaterializedResultSetStatistics(
930                                             mrs.numOpens,
931                                             mrs.rowsSeen,
932                                             mrs.rowsFiltered,
933                                             mrs.constructorTime,
934                                             mrs.openTime,
935                                             mrs.nextTime,
936                                             mrs.closeTime,
937                                             mrs.createTCTime,
938                                             mrs.fetchTCTime,
939                                             mrs.resultSetNumber,
940                                             mrs.optimizerEstimatedRowCount,
941                                             mrs.optimizerEstimatedCost,
942                                             getResultSetStatistics(mrs.source)
943                                             );
944         }
945         else if (rs instanceof ScrollInsensitiveResultSet)
946         {
947             ScrollInsensitiveResultSet sirs = (ScrollInsensitiveResultSet) rs;
948
949             return new RealScrollInsensitiveResultSetStatistics(
950                                             sirs.numOpens,
951                                             sirs.rowsSeen,
952                                             sirs.rowsFiltered,
953                                             sirs.constructorTime,
954                                             sirs.openTime,
955                                             sirs.nextTime,
956                                             sirs.closeTime,
957                                             sirs.numFromHashTable,
958                                             sirs.numToHashTable,
959                                             sirs.resultSetNumber,
960                                             sirs.optimizerEstimatedRowCount,
961                                             sirs.optimizerEstimatedCost,
962                                             getResultSetStatistics(sirs.source)
963                                             );
964         }
965         else if (rs instanceof CurrentOfResultSet)
966         {
967             CurrentOfResultSet cors = (CurrentOfResultSet) rs;
968
969             return new RealCurrentOfStatistics(
970                                             cors.numOpens,
971                                             cors.rowsSeen,
972                                             cors.rowsFiltered,
973                                             cors.constructorTime,
974                                             cors.openTime,
975                                             cors.nextTime,
976                                             cors.closeTime,
977                                             cors.resultSetNumber
978                                             );
979         }
980         else if (rs instanceof HashScanResultSet)
981         {
982             boolean instantaneousLocks = false;
983             HashScanResultSet hsrs = (HashScanResultSet) rs;
984             String JavaDoc startPosition = null;
985             String JavaDoc stopPosition = null;
986             String JavaDoc isolationLevel = null;
987             String JavaDoc lockString = null;
988
989             switch (hsrs.isolationLevel)
990             {
991                 case TransactionController.ISOLATION_SERIALIZABLE:
992                     isolationLevel =
993                         MessageService.getTextMessage(
994                             SQLState.LANG_SERIALIZABLE);
995                     break;
996
997                 case TransactionController.ISOLATION_REPEATABLE_READ:
998                     isolationLevel =
999                         MessageService.getTextMessage(
1000                            SQLState.LANG_REPEATABLE_READ);
1001                    break;
1002
1003                case TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK:
1004                    instantaneousLocks = true;
1005                    //fall through
1006
case TransactionController.ISOLATION_READ_COMMITTED:
1007                    isolationLevel = MessageService.getTextMessage(
1008                                                SQLState.LANG_READ_COMMITTED);
1009                    break;
1010
1011            }
1012
1013            if (hsrs.forUpdate)
1014            {
1015                lockString = MessageService.getTextMessage(
1016                                                    SQLState.LANG_EXCLUSIVE);
1017            }
1018            else
1019            {
1020                if (instantaneousLocks)
1021                {
1022                    lockString = MessageService.getTextMessage(
1023                                            SQLState.LANG_INSTANTANEOUS_SHARE);
1024                }
1025                else
1026                {
1027                    lockString = MessageService.getTextMessage(
1028                                                        SQLState.LANG_SHARE);
1029                }
1030            }
1031
1032            switch (hsrs.lockMode)
1033            {
1034                case TransactionController.MODE_TABLE:
1035                    // RESOLVE: Not sure this will really work, as we
1036
// are tacking together English words to make a phrase.
1037
// Will this work in other languages?
1038
lockString = lockString + " " +
1039                                    MessageService.getTextMessage(
1040                                                        SQLState.LANG_TABLE);
1041                    break;
1042
1043                case TransactionController.MODE_RECORD:
1044                    // RESOLVE: Not sure this will really work, as we
1045
// are tacking together English words to make a phrase.
1046
// Will this work in other languages?
1047
lockString = lockString + " " +
1048                                    MessageService.getTextMessage(
1049                                                            SQLState.LANG_ROW);
1050                    break;
1051            }
1052
1053            if (hsrs.indexName != null)
1054            {
1055                /* Start and stop position strings will be non-null
1056                * if the HSRS has been closed. Otherwise, we go off
1057                * and build the strings now.
1058                */

1059                startPosition = hsrs.startPositionString;
1060                if (startPosition == null)
1061                {
1062                    startPosition = hsrs.printStartPosition();
1063                }
1064                stopPosition = hsrs.stopPositionString;
1065                if (stopPosition == null)
1066                {
1067                    stopPosition = hsrs.printStopPosition();
1068                }
1069            }
1070
1071            // DistinctScanResultSet is simple sub-class of
1072
// HashScanResultSet
1073
if (rs instanceof DistinctScanResultSet)
1074            {
1075                return new RealDistinctScanStatistics(
1076                                            hsrs.numOpens,
1077                                            hsrs.rowsSeen,
1078                                            hsrs.rowsFiltered,
1079                                            hsrs.constructorTime,
1080                                            hsrs.openTime,
1081                                            hsrs.nextTime,
1082                                            hsrs.closeTime,
1083                                            hsrs.resultSetNumber,
1084                                            hsrs.tableName,
1085                                            hsrs.indexName,
1086                                            hsrs.isConstraint,
1087                                            hsrs.hashtableSize,
1088                                            hsrs.keyColumns,
1089                                            hsrs.printQualifiers(
1090                                                hsrs.scanQualifiers),
1091                                            hsrs.printQualifiers(
1092                                                hsrs.nextQualifiers),
1093                                            hsrs.getScanProperties(),
1094                                            startPosition,
1095                                            stopPosition,
1096                                            isolationLevel,
1097                                            lockString,
1098                                            hsrs.optimizerEstimatedRowCount,
1099                                            hsrs.optimizerEstimatedCost
1100                                            );
1101            }
1102            else
1103            {
1104                return new RealHashScanStatistics(
1105                                            hsrs.numOpens,
1106                                            hsrs.rowsSeen,
1107                                            hsrs.rowsFiltered,
1108                                            hsrs.constructorTime,
1109                                            hsrs.openTime,
1110                                            hsrs.nextTime,
1111                                            hsrs.closeTime,
1112                                            hsrs.resultSetNumber,
1113                                            hsrs.tableName,
1114                                            hsrs.indexName,
1115                                            hsrs.isConstraint,
1116                                            hsrs.hashtableSize,
1117                                            hsrs.keyColumns,
1118                                            hsrs.printQualifiers(
1119                                                hsrs.scanQualifiers),
1120                                            hsrs.printQualifiers(
1121                                                hsrs.nextQualifiers),
1122                                            hsrs.getScanProperties(),
1123                                            startPosition,
1124                                            stopPosition,
1125                                            isolationLevel,
1126                                            lockString,
1127                                            hsrs.optimizerEstimatedRowCount,
1128                                            hsrs.optimizerEstimatedCost
1129                                            );
1130            }
1131        }
1132        else if (rs instanceof HashTableResultSet)
1133        {
1134            HashTableResultSet htrs = (HashTableResultSet) rs;
1135            int subqueryTrackingArrayLength =
1136                (htrs.subqueryTrackingArray == null) ? 0 :
1137                    htrs.subqueryTrackingArray.length;
1138            ResultSetStatistics[] subqueryTrackingArray =
1139                new ResultSetStatistics[subqueryTrackingArrayLength];
1140            boolean anyAttached = false;
1141            for (int index = 0; index < subqueryTrackingArrayLength; index++)
1142            {
1143                if (htrs.subqueryTrackingArray[index] != null &&
1144                    htrs.subqueryTrackingArray[index].getPointOfAttachment() ==
1145                        htrs.resultSetNumber)
1146                {
1147                    subqueryTrackingArray[index] =
1148                                        getResultSetStatistics(
1149                                            htrs.subqueryTrackingArray[index]);
1150                    anyAttached = true;
1151                }
1152            }
1153            if (! anyAttached)
1154            {
1155                subqueryTrackingArray = null;
1156            }
1157
1158            return new
1159                RealHashTableStatistics(
1160                    htrs.numOpens,
1161                    htrs.rowsSeen,
1162                    htrs.rowsFiltered,
1163                    htrs.constructorTime,
1164                    htrs.openTime,
1165                    htrs.nextTime,
1166                    htrs.closeTime,
1167                    htrs.resultSetNumber,
1168                    htrs.hashtableSize,
1169                    htrs.keyColumns,
1170                    HashScanResultSet.printQualifiers(
1171                        htrs.nextQualifiers),
1172                    htrs.scanProperties,
1173                    htrs.optimizerEstimatedRowCount,
1174                    htrs.optimizerEstimatedCost,
1175                    subqueryTrackingArray,
1176                    getResultSetStatistics(htrs.source)
1177                    );
1178        }
1179        else if (rs instanceof VTIResultSet)
1180        {
1181            VTIResultSet vtirs = (VTIResultSet) rs;
1182
1183            return new RealVTIStatistics(
1184                                        vtirs.numOpens,
1185                                        vtirs.rowsSeen,
1186                                        vtirs.rowsFiltered,
1187                                        vtirs.constructorTime,
1188                                        vtirs.openTime,
1189                                        vtirs.nextTime,
1190                                        vtirs.closeTime,
1191                                        vtirs.resultSetNumber,
1192                                        vtirs.javaClassName,
1193                                        vtirs.optimizerEstimatedRowCount,
1194                                        vtirs.optimizerEstimatedCost
1195                                        );
1196        }
1197
1198        else if (rs instanceof DependentResultSet)
1199        {
1200            boolean instantaneousLocks = false;
1201            DependentResultSet dsrs = (DependentResultSet) rs;
1202            String JavaDoc startPosition = null;
1203            String JavaDoc stopPosition = null;
1204            String JavaDoc isolationLevel = null;
1205            String JavaDoc lockString = null;
1206            String JavaDoc lockRequestString = null;
1207
1208            switch (dsrs.isolationLevel)
1209            {
1210                case TransactionController.ISOLATION_SERIALIZABLE:
1211                    isolationLevel =
1212                        MessageService.getTextMessage(
1213                            SQLState.LANG_SERIALIZABLE);
1214                    break;
1215
1216                case TransactionController.ISOLATION_REPEATABLE_READ:
1217                    isolationLevel =
1218                        MessageService.getTextMessage(
1219                            SQLState.LANG_REPEATABLE_READ);
1220                    break;
1221
1222                case TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK:
1223                    instantaneousLocks = true;
1224                    //fall through
1225
case TransactionController.ISOLATION_READ_COMMITTED:
1226                    isolationLevel = MessageService.getTextMessage(
1227                                                SQLState.LANG_READ_COMMITTED);
1228                    break;
1229
1230                case TransactionController.ISOLATION_READ_UNCOMMITTED:
1231                    isolationLevel =
1232                        MessageService.getTextMessage(
1233                            SQLState.LANG_READ_UNCOMMITTED);
1234                    break;
1235            }
1236
1237            if (dsrs.forUpdate)
1238            {
1239                lockString = MessageService.getTextMessage(
1240                                                SQLState.LANG_EXCLUSIVE);
1241            }
1242            else
1243            {
1244                if (instantaneousLocks)
1245                {
1246                    lockString = MessageService.getTextMessage(
1247                                            SQLState.LANG_INSTANTANEOUS_SHARE);
1248                }
1249                else
1250                {
1251                    lockString = MessageService.getTextMessage(
1252                                                        SQLState.LANG_SHARE);
1253                }
1254            }
1255
1256            switch (dsrs.lockMode)
1257            {
1258                case TransactionController.MODE_TABLE:
1259                    // RESOLVE: Not sure this will really work, as we
1260
// are tacking together English words to make a phrase.
1261
// Will this work in other languages?
1262
lockRequestString = lockString + " " +
1263                                        MessageService.getTextMessage(
1264                                            SQLState.LANG_TABLE);
1265                    break;
1266
1267                case TransactionController.MODE_RECORD:
1268                    // RESOLVE: Not sure this will really work, as we
1269
// are tacking together English words to make a phrase.
1270
// Will this work in other languages?
1271
lockRequestString = lockString + " " +
1272                                        MessageService.getTextMessage(
1273                                            SQLState.LANG_ROW);
1274                    break;
1275            }
1276
1277            /* Start and stop position strings will be non-null
1278             * if the dSRS has been closed. Otherwise, we go off
1279             * and build the strings now.
1280             */

1281            startPosition = dsrs.startPositionString;
1282            if (startPosition == null)
1283            {
1284                startPosition = dsrs.printStartPosition();
1285            }
1286            stopPosition = dsrs.stopPositionString;
1287            if (stopPosition == null)
1288            {
1289                stopPosition = dsrs.printStopPosition();
1290            }
1291        
1292            return new
1293                RealTableScanStatistics(
1294                    dsrs.numOpens,
1295                    dsrs.rowsSeen,
1296                    dsrs.rowsFiltered,
1297                    dsrs.constructorTime,
1298                    dsrs.openTime,
1299                    dsrs.nextTime,
1300                    dsrs.closeTime,
1301                    dsrs.resultSetNumber,
1302                    dsrs.tableName,
1303                    null,
1304                    dsrs.indexName,
1305                    dsrs.isConstraint,
1306                    dsrs.printQualifiers(),
1307                    dsrs.getScanProperties(),
1308                    startPosition,
1309                    stopPosition,
1310                    isolationLevel,
1311                    lockRequestString,
1312                    dsrs.rowsPerRead,
1313                    dsrs.coarserLock,
1314                    dsrs.optimizerEstimatedRowCount,
1315                    dsrs.optimizerEstimatedCost);
1316        }
1317        else
1318        {
1319            return null;
1320        }
1321    }
1322
1323    //
1324
// class interface
1325
//
1326
public RealResultSetStatisticsFactory()
1327    {
1328    }
1329
1330}
1331
Popular Tags