Package org.apache.derby.diag
Class LockTable
- java.lang.Object
-
- org.apache.derby.vti.VTITemplate
-
- org.apache.derby.diag.LockTable
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.sql.ResultSet,java.sql.Wrapper,AwareVTI,VTICosting
public class LockTable extends VTITemplate implements VTICosting
LockTable is a virtual table that shows all locks currently held in the database. This virtual table can be invoked by calling it directlyselect * from SYSCS_DIAG.LOCK_TABLE
The LockTable virtual table takes a snap shot of the lock table while the system is in flux, so it is possible that some locks may be in transition state while the snap shot is taken. We choose to do this rather then impose extranous timing restrictions so that the use of this tool will not alter the normal timing and flow of execution in the application.
The LockTable virtual table has the following columns:
- XID varchar(15) - not nullable. The transaction id, this can be joined with the TransactionTable virtual table's XID.
- TYPE varchar(5) - nullable. The type of lock, ROW, TABLE, or LATCH
- MODE varchar(4) - not nullable. The mode of the lock, "S", "U", "X", "IS", "IX".
- S is shared lock (N/A to Latch)
- U is update lock (N/A to Latch)
- X is exclusive lock
- IS is intent shared lock (N/A to Latch or Row lock)
- IX is intent exclusive lock (N/A to Latch or Row lock)
- TABLENAME varchar(128) - not nullable. The name of the base table the lock is for
- LOCKNAME varchar(20) - not nullable. The name of the lock
- STATE varchar(5) - nullable. GRANT or WAIT
- TABLETYPE varchar(9) - not nullable. 'T' for user table, 'S' for system table
- LOCKCOUNT varchar(5) - not nullable. Internal lock count.
- INDEXNAME varchar(128) - normally null. If non-null, a lock is held on the index.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.vti.VTITemplate
VTITemplate.ColumnDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description static intALLreturn all locks and latchesprivate static ResultColumnDescriptor[]columnInfoprivate java.util.HashtablecurrentRowprivate intflagprivate booleaninitializedstatic intLATCHreturn only latchesprivate java.util.EnumerationlockTableprivate static java.sql.ResultSetMetaDatametadataprivate TableNameInfotabInfostatic intTABLE_AND_ROWLOCKreturn only table and row locksprivate TransactionControllertcprivate booleanwasNull-
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
-
Fields inherited from interface org.apache.derby.vti.VTICosting
defaultEstimatedCost, defaultEstimatedRowCount
-
-
Constructor Summary
Constructors Constructor Description LockTable()The normal way of instantiating a LockTable, equivalent to LockTable(org.apache.derby.diag.LockTable->TABLE_AND_ROWLOCK).LockTable(int flag)This call is intrusive and should only be used under the supervision of technical support.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private java.util.Hashtable<java.lang.String,java.lang.Object>dumpLock(Latch lock)Convert the lock information into a hashtable.doublegetEstimatedCostPerInstantiation(VTIEnvironment vtiEnvironment)Get the estimated cost for a single instantiation of a Table Function.doublegetEstimatedRowCount(VTIEnvironment vtiEnvironment)Get the estimated row count for a single scan of a Table Function.java.sql.ResultSetMetaDatagetMetaData()java.lang.StringgetString(int columnNumber)All columns in TransactionTable VTI are of String type.booleannext()booleansupportsMultipleInstantiations(VTIEnvironment vtiEnvironment)Find out if the ResultSet of the Table Function can be instantiated multiple times.booleanwasNull()-
Methods inherited from class org.apache.derby.vti.VTITemplate
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getContext, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getReturnTableSignature, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, notImplemented, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setContext, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
-
-
-
-
Field Detail
-
LATCH
public static final int LATCH
return only latches- See Also:
- Constant Field Values
-
TABLE_AND_ROWLOCK
public static final int TABLE_AND_ROWLOCK
return only table and row locks- See Also:
- Constant Field Values
-
ALL
public static final int ALL
return all locks and latches- See Also:
- Constant Field Values
-
tc
private TransactionController tc
-
currentRow
private java.util.Hashtable currentRow
-
lockTable
private java.util.Enumeration lockTable
-
wasNull
private boolean wasNull
-
initialized
private boolean initialized
-
flag
private final int flag
-
tabInfo
private TableNameInfo tabInfo
-
columnInfo
private static final ResultColumnDescriptor[] columnInfo
-
metadata
private static final java.sql.ResultSetMetaData metadata
-
-
Constructor Detail
-
LockTable
public LockTable()
The normal way of instantiating a LockTable, equivalent to LockTable(org.apache.derby.diag.LockTable->TABLE_AND_ROWLOCK). Only shows row and table lock and not latches. Latches are generally held for very short duration and are not of interest to Derby users. Only under abnormal circumstances will one be interested in looking at latches.
-
LockTable
public LockTable(int flag)
This call is intrusive and should only be used under the supervision of technical support. Create an instance of the lock table which has transient latches as well as locks.
-
-
Method Detail
-
getMetaData
public java.sql.ResultSetMetaData getMetaData()
- Specified by:
getMetaDatain interfacejava.sql.ResultSet- Overrides:
getMetaDatain classVTITemplate- See Also:
ResultSet.getMetaData()
-
next
public boolean next() throws java.sql.SQLException- Specified by:
nextin interfacejava.sql.ResultSet- Throws:
java.sql.SQLException- if no transaction context can be found, or other Derby internal errors are encountered.- See Also:
ResultSet.next()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.ResultSet- See Also:
ResultSet.close()
-
getString
public java.lang.String getString(int columnNumber)
All columns in TransactionTable VTI are of String type.- Specified by:
getStringin interfacejava.sql.ResultSet- Overrides:
getStringin classVTITemplate- See Also:
ResultSet.getString(int)
-
wasNull
public boolean wasNull()
- Specified by:
wasNullin interfacejava.sql.ResultSet- Overrides:
wasNullin classVTITemplate- See Also:
ResultSet.wasNull()
-
getEstimatedRowCount
public double getEstimatedRowCount(VTIEnvironment vtiEnvironment)
Description copied from interface:VTICostingGet the estimated row count for a single scan of a Table Function.- Specified by:
getEstimatedRowCountin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- The estimated row count for a single scan of the Table Function.
- See Also:
VTICosting.getEstimatedRowCount(org.apache.derby.vti.VTIEnvironment)
-
getEstimatedCostPerInstantiation
public double getEstimatedCostPerInstantiation(VTIEnvironment vtiEnvironment)
Description copied from interface:VTICostingGet the estimated cost for a single instantiation of a Table Function.- Specified by:
getEstimatedCostPerInstantiationin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- The estimated cost for a single instantiation of the Table Function.
- See Also:
VTICosting.getEstimatedCostPerInstantiation(org.apache.derby.vti.VTIEnvironment)
-
supportsMultipleInstantiations
public boolean supportsMultipleInstantiations(VTIEnvironment vtiEnvironment)
Description copied from interface:VTICostingFind out if the ResultSet of the Table Function can be instantiated multiple times.- Specified by:
supportsMultipleInstantiationsin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- false
- See Also:
VTICosting.supportsMultipleInstantiations(org.apache.derby.vti.VTIEnvironment)
-
dumpLock
private java.util.Hashtable<java.lang.String,java.lang.Object> dumpLock(Latch lock) throws StandardException
Convert the lock information into a hashtable.- Throws:
StandardException
-
-