Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

public abstract Class GenericRIChecker

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.execute.ReferencedKeyRIChecker, org.apache.derby.impl.sql.execute.ForeignKeyRIChecker
Imports
java.util.Enumeration, .Hashtable, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.store.access.BackingStoreHashtable, .DynamicCompiledOpenConglomInfo, .ScanController, .StaticCompiledOpenConglomInfo, .TransactionController, org.apache.derby.iapi.types.DataValueDescriptor

Generic implementation of a Referential Integrity checker. Abstract.

Field Summary

Modifier and TypeField and Description
protected BackingStoreHashtable
deferredRowsHashTable

Cached value (for efficiency) of the intermediate table of violations we use in the presence of deferred FK constraints.

protected DynamicCompiledOpenConglomInfo[]
protected FKInfo
protected StaticCompiledOpenConglomInfo[]
protected int[]
pack-priv final IndexRow
protected LanguageConnectionContext
protected final int
protected DynamicCompiledOpenConglomInfo
protected StaticCompiledOpenConglomInfo
private final Hashtable<Long, ScanController>
protected TransactionController

Constructor Summary

AccessConstructor and Description
pack-priv
GenericRIChecker(LanguageConnectionContext
the language connection context
lcc
,
TransactionController
the xact controller
tc
,
FKInfo
the foreign key information
fkinfo
)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close()

Clean up all scan controllers

pack-priv abstract void
doCheck(Activation
The activation
a
,
ExecRow
The row to check
row
,
boolean
true if the check is relevant only for RESTRICTED referential action.
restrictCheckOnly
,
int
For referenced keys: The required number of duplicates that need to be present. Only used if postCheck==false.
deferredRowReq
)

Check the validity of this row

pack-priv int

Returns:

The isolation level for the scan for the RI check.
getRICheckIsolationLevel
()

Get the isolation level for the scan for the RI check.

protected ScanController

Returns:

scan controller
getScanController
(long
the particular conglomerate we are interested in
conglomNumber
,
StaticCompiledOpenConglomInfo scoci, DynamicCompiledOpenConglomInfo dcoci, ExecRow
the row to match
searchRow
)

Get a scan controller positioned using searchRow as the start/stop position.

pack-priv boolean

Returns:

true if any are null
isAnyFieldNull
(ExecRow
the row to check for null fields
baseRow
)

Are any of the fields null in the row passed in. The only fields that are checked are those corresponding to the colArray in fkInfo.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

deferredRowsHashTableback to summary
protected BackingStoreHashtable deferredRowsHashTable

Cached value (for efficiency) of the intermediate table of violations we use in the presence of deferred FK constraints.

fkDcocisback to summary
protected DynamicCompiledOpenConglomInfo[] fkDcocis
fkInfoback to summary
protected FKInfo fkInfo
fkScocisback to summary
protected StaticCompiledOpenConglomInfo[] fkScocis
identityMapback to summary
protected int[] identityMap
indexQualifierRowback to summary
pack-priv final IndexRow indexQualifierRow
lccback to summary
protected LanguageConnectionContext lcc
numColumnsback to summary
protected final int numColumns
refDcociback to summary
protected DynamicCompiledOpenConglomInfo refDcoci
refScociback to summary
protected StaticCompiledOpenConglomInfo refScoci
scanControllersback to summary
private final Hashtable<Long, ScanController> scanControllers
tcback to summary
protected TransactionController tc

Constructor Detail

GenericRICheckerback to summary
pack-priv GenericRIChecker(LanguageConnectionContext lcc, TransactionController tc, FKInfo fkinfo) throws StandardException
Parameters
lcc:LanguageConnectionContext

the language connection context

tc:TransactionController

the xact controller

fkinfo:FKInfo

the foreign key information

Exceptions
StandardException:
Thrown on failure

Method Detail

closeback to summary
pack-priv void close() throws StandardException

Clean up all scan controllers

Exceptions
StandardException:
on error
doCheckback to summary
pack-priv abstract void doCheck(Activation a, ExecRow row, boolean restrictCheckOnly, int deferredRowReq) throws StandardException

Check the validity of this row

Parameters
a:Activation

The activation

row:ExecRow

The row to check

restrictCheckOnly:boolean

true if the check is relevant only for RESTRICTED referential action.

deferredRowReq:int

For referenced keys: The required number of duplicates that need to be present. Only used if postCheck==false.

Exceptions
StandardException:
on error
getRICheckIsolationLevelback to summary
pack-priv int getRICheckIsolationLevel()

Get the isolation level for the scan for the RI check.

Note

The level will eventually be instantaneous locking once the implementation changes.

Returns:int

The isolation level for the scan for the RI check.

getScanControllerback to summary
protected ScanController getScanController(long conglomNumber, StaticCompiledOpenConglomInfo scoci, DynamicCompiledOpenConglomInfo dcoci, ExecRow searchRow) throws StandardException

Get a scan controller positioned using searchRow as the start/stop position. The assumption is that searchRow is of the same format as the index being opened. The scan is set up to return no columns.

Note

We only need an instantaneous lock on the table that we are probing as we are just checking for the existence of a row. All updaters, whether to the primary or foreign key tables, will hold an X lock on the table that they are updating and will be probing the other table, so instantaneous locks will not change the semantics.

Resolve

Due to the current RI implementation we cannot always get instantaneous locks. We will call a method to find out what kind of locking to do until the implementation changes.

Parameters
conglomNumber:long

the particular conglomerate we are interested in

searchRow:ExecRow

the row to match

Returns:ScanController

scan controller

Exceptions
StandardException:
on error
isAnyFieldNullback to summary
pack-priv boolean isAnyFieldNull(ExecRow baseRow)

Are any of the fields null in the row passed in. The only fields that are checked are those corresponding to the colArray in fkInfo.

Parameters
baseRow:ExecRow

the row to check for null fields

Returns:boolean

true if any are null

setupQualifierRowback to summary
private void setupQualifierRow(ExecRow baseRow)