001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealDeleteResultSetStatistics
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 DeleteResultSet.
029:
030: @author jerry
031:
032: */
033: public class RealDeleteResultSetStatistics extends
034: RealNoRowsResultSetStatistics {
035:
036: /* Leave these fields public for object inspectors */
037: public int rowCount;
038: public boolean deferred;
039: public boolean tableLock;
040: public int indexesUpdated;
041:
042: // CONSTRUCTORS
043: /**
044: *
045: *
046: */
047: public RealDeleteResultSetStatistics(int rowCount,
048: boolean deferred, int indexesUpdated, boolean tableLock,
049: long executeTime,
050: ResultSetStatistics sourceResultSetStatistics) {
051: super (executeTime, sourceResultSetStatistics);
052: this .rowCount = rowCount;
053: this .deferred = deferred;
054: this .indexesUpdated = indexesUpdated;
055: this .tableLock = tableLock;
056: this .sourceResultSetStatistics = sourceResultSetStatistics;
057: }
058:
059: // ResultSetStatistics interface
060:
061: /**
062: * Return the statement execution plan as a String.
063: *
064: * @param depth Indentation level.
065: *
066: * @return String The statement execution plan as a String.
067: */
068: public String getStatementExecutionPlanText(int depth) {
069:
070: initFormatInfo(depth);
071:
072: return indent
073: + MessageService
074: .getTextMessage(SQLState.RTS_DELETE_RS_USING)
075: + " "
076: + MessageService
077: .getTextMessage(((tableLock) ? SQLState.RTS_TABLE_LOCKING
078: : SQLState.RTS_ROW_LOCKING))
079: + ":\n"
080: + indent
081: + MessageService.getTextMessage(SQLState.RTS_DEFERRED)
082: + ": "
083: + deferred
084: + "\n"
085: + indent
086: + MessageService
087: .getTextMessage(SQLState.RTS_ROWS_DELETED)
088: + " = "
089: + rowCount
090: + "\n"
091: + indent
092: + MessageService
093: .getTextMessage(SQLState.RTS_INDEXES_UPDATED)
094: + " = "
095: + indexesUpdated
096: + "\n"
097: + dumpTimeStats(indent)
098: + ((sourceResultSetStatistics == null) ? ""
099: : sourceResultSetStatistics
100: .getStatementExecutionPlanText(1));
101: }
102:
103: /**
104: * Return information on the scan nodes from the statement execution
105: * plan as a String.
106: *
107: * @param depth Indentation level.
108: * @param tableName if not NULL then print information for this table only
109: * @return String The information on the scan nodes from the
110: * statement execution plan as a String.
111: */
112: public String getScanStatisticsText(String tableName, int depth) {
113: if (sourceResultSetStatistics == null)
114: return "";
115:
116: return sourceResultSetStatistics.getScanStatisticsText(
117: tableName, depth);
118: }
119:
120: // Class implementation
121:
122: public String toString() {
123: return getStatementExecutionPlanText(0);
124: }
125:
126: /**
127: * Format for display, a name for this node.
128: *
129: */
130: public String getNodeName() {
131: return MessageService.getTextMessage(SQLState.RTS_DELETE);
132: }
133: }
|