public class ForeignKeysDeferrableTest extends BaseJDBCTestCase
<update rule>
that does not contain NO ACTION specifies a
referential update action. A <delete rule>
that does not specify NO
ACTION specifies a referential delete action. Referential update
actions and referential delete actions are collectively called
referential actions. Referential actions are carried out before, and
are not part of, the checking of a referential constraint. Deferring a
referential constraint defers the checking of the <search condition>
of the constraint (a <match predicate>
) but does not defer the
referential actions of the referential constraint.
NOTE 52 - For example, if a referential update action such as ON UPDATE
CASCADE is specified, then any UPDATE operation on the referenced table will
be cascaded to the referencing table as part of the UPDATE operation, even
if the referential constraint is deferred. Consequently, the referential
constraint cannot become violated by the UPDATE statement. On the other
hand, ON UPDATE SET DEFAULT could result in a violation of the referential
constraint if there is no matching row after the referencing column is set
to its default value. In addition, INSERT and UPDATE operations on the
referencing table do not entail any automatic enforcement of the referential
constraint. Any such violations of the constraint will be detected when the
referential constraint is eventually checked, at or before a commit.
NOTE 53 - Even if constraint checking is not deferred, ON UPDATE
RESTRICT is a stricter condition than ON UPDATE NO ACTION. ON UPDATE
RESTRICT prohibits an update to a particular row if there are any
matching rows; ON UPDATE NO ACTION does not perform its constraint
check until the entire set of rows to be updated has been processed.
NOTE 54 - Ditto for DELETE.
Line numbers in the comments refer to svn revision 1580845 of Derby trunk.Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
expImpDataFile |
private static boolean |
exportFilesCreatedClient |
private static boolean |
exportFilesCreatedEmbedded |
private static java.lang.String |
LANG_ADD_FK_CONSTRAINT_VIOLATION |
private static java.lang.String |
LANG_DEFERRED_DUPLICATE_KEY_CONSTRAINT_T |
private static java.lang.String |
LANG_DEFERRED_FK_CONSTRAINT_S |
private static java.lang.String |
LANG_DEFERRED_FK_CONSTRAINT_T |
private static java.lang.String |
LANG_FK_VIOLATION |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
ForeignKeysDeferrableTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
protected void |
setUp() |
static junit.framework.Test |
suite() |
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
test_6668()
Test that truncate table is not allowed on a referenced table.
|
void |
testAddConstraint() |
void |
testBulkInsert()
Insert using bulk insert code path, i.e.
|
void |
testDeleteDeferred()
Delete row in deferred code path.
|
void |
testDeleteDirect()
Delete row in non-deferred code path.
|
void |
testFKPlusUnique()
The referenced constraint (in the referenced table) is a deferred unique
or primary key constraint.
|
void |
testInsertDeferred()
Insert row in deferred code path.
|
void |
testInsertDirect()
Insert row in non-deferred code path.
|
void |
testInsertTrigger() |
void |
testSelfReferential() |
void |
testSharedConglomerates()
Regression test case for DERBY-6665.
|
void |
testUpdateDeferred()
Update row in deferred code path.
|
void |
testUpdateDirect()
Update row in non-deferred code path.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, toString
private static final java.lang.String LANG_DEFERRED_DUPLICATE_KEY_CONSTRAINT_T
private static final java.lang.String LANG_DEFERRED_FK_CONSTRAINT_T
private static final java.lang.String LANG_DEFERRED_FK_CONSTRAINT_S
private static final java.lang.String LANG_ADD_FK_CONSTRAINT_VIOLATION
private static final java.lang.String LANG_FK_VIOLATION
private static java.lang.String expImpDataFile
private static boolean exportFilesCreatedEmbedded
private static boolean exportFilesCreatedClient
public ForeignKeysDeferrableTest(java.lang.String name)
public static junit.framework.Test suite()
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
public void testInsertDirect() throws java.sql.SQLException
java.sql.SQLException
public void testInsertDeferred() throws java.sql.SQLException
java.sql.SQLException
public void testUpdateDirect() throws java.sql.SQLException
java.sql.SQLException
public void testUpdateDeferred() throws java.sql.SQLException
java.sql.SQLException
public void testDeleteDirect() throws java.sql.SQLException
java.sql.SQLException
public void testDeleteDeferred() throws java.sql.SQLException
java.sql.SQLException
public void testBulkInsert() throws java.sql.SQLException
java.sql.SQLException
public void testAddConstraint() throws java.sql.SQLException
java.sql.SQLException
public void testFKPlusUnique() throws java.sql.SQLException
ReferencedKeyRIChecker.doCheck(org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.execute.ExecRow, boolean, int)
and
ReferencedKeyRIChecker.postCheck()
.java.sql.SQLException
public void testSelfReferential() throws java.sql.SQLException
java.sql.SQLException
public void testInsertTrigger() throws java.sql.SQLException
java.sql.SQLException
public void test_6668() throws java.lang.Exception
java.lang.Exception
public void testSharedConglomerates() throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.