001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealDeleteCascadeResultSetStatistics
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.rts;
023:
024: import org.apache.derby.iapi.services.i18n.MessageService;
025: import org.apache.derby.iapi.reference.SQLState;
026:
027: /**
028: ResultSetStatistics implemenation for DeleteCascadeResultSet.
029:
030: @author suresht
031:
032: */
033: public class RealDeleteCascadeResultSetStatistics extends
034: RealDeleteResultSetStatistics {
035:
036: /* Leave these fields public for object inspectors */
037: public ResultSetStatistics[] dependentTrackingArray;
038:
039: // CONSTRUCTORS
040:
041: /**
042: *
043: *
044: */
045: public RealDeleteCascadeResultSetStatistics(int rowCount,
046: boolean deferred, int indexesUpdated, boolean tableLock,
047: long executeTime,
048: ResultSetStatistics sourceResultSetStatistics,
049: ResultSetStatistics[] dependentTrackingArray) {
050: super (rowCount, deferred, indexesUpdated, tableLock,
051: executeTime, sourceResultSetStatistics);
052: this .dependentTrackingArray = dependentTrackingArray;
053: }
054:
055: // ResultSetStatistics interface
056:
057: /**
058: * Return the statement execution plan as a String.
059: *
060: * @param depth Indentation level.
061: *
062: * @return String The statement execution plan as a String.
063: */
064: public String getStatementExecutionPlanText(int depth) {
065:
066: String dependentInfo = "";
067:
068: initFormatInfo(depth);
069:
070: /* Dump out the statistics for any depedent table for referential actions */
071: if (dependentTrackingArray != null) {
072: boolean foundAttached = false;
073:
074: for (int index = 0; index < dependentTrackingArray.length; index++) {
075: if (dependentTrackingArray[index] != null) {
076: /* Only print referential actions on dependents message once */
077: if (!foundAttached) {
078: dependentInfo = indent
079: + "\n"
080: + MessageService
081: .getTextMessage(SQLState.RTS_REFACTION_DEPENDENT)
082: + ":\n";
083: foundAttached = true;
084: }
085: dependentInfo = dependentInfo
086: + dependentTrackingArray[index]
087: .getStatementExecutionPlanText(sourceDepth);
088: }
089: }
090: }
091:
092: return indent
093: + MessageService
094: .getTextMessage(SQLState.RTS_DELETE_CASCADE_RS_USING)
095: + " "
096: + MessageService
097: .getTextMessage(((tableLock) ? SQLState.RTS_TABLE_LOCKING
098: : SQLState.RTS_ROW_LOCKING))
099: + ":\n"
100: + indent
101: + MessageService.getTextMessage(SQLState.RTS_DEFERRED)
102: + ": "
103: + deferred
104: + "\n"
105: + indent
106: + MessageService
107: .getTextMessage(SQLState.RTS_ROWS_DELETED)
108: + " = "
109: + rowCount
110: + "\n"
111: + indent
112: + MessageService
113: .getTextMessage(SQLState.RTS_INDEXES_UPDATED)
114: + " = "
115: + indexesUpdated
116: + "\n"
117: + dumpTimeStats(indent)
118: + ((sourceResultSetStatistics == null) ? ""
119: : sourceResultSetStatistics
120: .getStatementExecutionPlanText(1))
121: + dependentInfo;
122: }
123:
124: /**
125: * Return information on the scan nodes from the statement execution
126: * plan as a String.
127: *
128: * @param depth Indentation level.
129: * @param tableName if not NULL then print information for this table only
130: * @return String The information on the scan nodes from the
131: * statement execution plan as a String.
132: */
133: public String getScanStatisticsText(String tableName, int depth) {
134: String dependentInfo = "";
135:
136: /* Dump out the statistics for any depedent table scans for referential actions */
137: if (dependentTrackingArray != null) {
138: for (int index = 0; index < dependentTrackingArray.length; index++) {
139: if (dependentTrackingArray[index] != null) {
140: dependentInfo = dependentInfo
141: + "\n"
142: + MessageService
143: .getTextMessage(SQLState.RTS_BEGIN_DEPENDENT_NUMBER)
144: + " "
145: + index
146: + "\n"
147: + dependentTrackingArray[index]
148: .getScanStatisticsText(tableName,
149: depth)
150: + MessageService
151: .getTextMessage(SQLState.RTS_END_DEPENDENT_NUMBER)
152: + " " + index + "\n\n";
153: }
154: }
155: }
156:
157: return dependentInfo
158: + ((sourceResultSetStatistics == null) ? ""
159: : sourceResultSetStatistics
160: .getScanStatisticsText(tableName, depth));
161: }
162:
163: /**
164: * Format for display, a name for this node.
165: *
166: */
167: public String getNodeName() {
168: return MessageService
169: .getTextMessage(SQLState.RTS_DELETE_CASCADE);
170: }
171: }
|