public class TriggerWhenClauseTest extends BaseJDBCTestCase
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
HAS_DEPENDENTS |
private static java.lang.String |
HAS_PARAMETER |
private static java.lang.String |
JAVA_EXCEPTION |
private static java.lang.String |
NO_TABLE_PERMISSION |
private static java.lang.String |
NON_SCALAR_QUERY |
private static java.lang.String |
NOT_AUTHORIZED |
private static java.lang.String |
NOT_BOOLEAN |
private static java.lang.String |
NOT_SINGLE_COLUMN |
private static java.lang.String |
PROC_USED_AS_FUNC |
private static java.util.List<java.lang.Integer> |
procedureCalls
List that tracks calls to
intProcedure() . |
private static java.lang.String |
REFERENCES_SESSION_SCHEMA |
private static java.lang.String |
SYNTAX_ERROR |
private static java.lang.String |
TABLE_DOES_NOT_EXIST |
private static java.lang.String |
TRIGGER_RECURSION |
private static java.lang.String |
TRUNCATION |
private static java.lang.String |
USER_EXCEPTION |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
TriggerWhenClauseTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
protected void |
initializeConnection(java.sql.Connection conn)
Allow a sub-class to initialize a connection to provide
consistent connection state for its tests.
|
static void |
intProcedure(int i)
A procedure that takes an
int argument and adds it to the
procedureCalls list. |
protected void |
setUp() |
static junit.framework.Test |
suite() |
static boolean |
tableIsEmpty(java.lang.String table)
Stored function used by
testFunctionReadsSQLData() . |
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testAggregates()
Verify that aggregates (both built-in and user-defined) can be used
in a WHEN clause.
|
void |
testBasicSyntax() |
void |
testCloudscapeBug4821()
Verify that Cloudscape bug 4821, which was fixed long before support
for the WHEN clause was implemented, does not affect the WHEN clause.
|
void |
testCurrentUser()
Test that a WHEN clause can call the CURRENT_USER function.
|
void |
testDependencies()
Test that dropping objects referenced from the WHEN clause will
detect that the trigger depends on the object.
|
void |
testDerby4874()
Verify that DERBY-4874, which was fixed before support for the WHEN
clause was implemented, does not affect the WHEN clause.
|
void |
testDerby6783_1_1()
Derby6783_1_1 test, this test has two trigger fields and
more than 3 column references in the update statement.
|
void |
testDerby6783_1_2()
Derby6783_1_2 test, is a less complex version of Derby6783_1_1
It has only one column reference in trigger part and in update part.
|
void |
testDerby6783_2()
Derby6783_2 test, this test has a single trigger column reference
and two column reference in update statement.
|
void |
testDerby6783_3()
Derby6783_3 test, this test referes to different tables in
when clause and update clause.
|
void |
testDerby6783()
Test for Derby-6783.
|
void |
testFunctionReadsSQLData()
Test a WHEN clause that invokes a function declared with READ SQL DATA.
|
void |
testGeneratedColumns()
Test generated columns referenced from WHEN clauses.
|
void |
testGrantRevoke()
When SQL authorization is enabled, the trigger action (including the
WHEN clause) should execute with definer's rights.
|
void |
testIllegalWhenClauses()
Test various illegal WHEN clauses.
|
void |
testRecursiveTrigger()
Test that a trigger with a WHEN clause can be recursive.
|
void |
testRoutineModifiesSQLData()
SQL:2011, part 2, 11.49 <trigger definition>, syntax rule 11
says that the WHEN clause shall not contain routines that possibly
modifies SQL data.
|
void |
testRuntimeException()
Test that the trigger fails gracefully if the WHEN clause throws
a RuntimeException.
|
void |
testScalarSubquery()
Test that scalar subqueries are allowed, and that non-scalar subqueries
result in exceptions when the trigger fires.
|
void |
testSubqueryInWhenClauseNPE()
A row trigger whose WHEN clause contains a subquery, used to cause a
NullPointerException in some situations.
|
void |
testVeryLongWhenClause()
The WHEN clause text is stored in a LONG VARCHAR column in the
SYS.SYSTRIGGERS table.
|
void |
testWhenClauseInvalidation()
Verify that the SPS of a WHEN clause is invalidated when one of its
dependencies is changed in a way that requires recompilation.
|
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, 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 java.util.List<java.lang.Integer> procedureCalls
intProcedure()
. It is used to verify
that triggers have fired.private static final java.lang.String SYNTAX_ERROR
private static final java.lang.String REFERENCES_SESSION_SCHEMA
private static final java.lang.String NOT_BOOLEAN
private static final java.lang.String HAS_PARAMETER
private static final java.lang.String HAS_DEPENDENTS
private static final java.lang.String TABLE_DOES_NOT_EXIST
private static final java.lang.String TRUNCATION
private static final java.lang.String NOT_AUTHORIZED
private static final java.lang.String NO_TABLE_PERMISSION
private static final java.lang.String USER_EXCEPTION
private static final java.lang.String JAVA_EXCEPTION
private static final java.lang.String NOT_SINGLE_COLUMN
private static final java.lang.String NON_SCALAR_QUERY
private static final java.lang.String TRIGGER_RECURSION
private static final java.lang.String PROC_USED_AS_FUNC
public static junit.framework.Test suite()
protected void initializeConnection(java.sql.Connection conn) throws java.sql.SQLException
BaseJDBCTestCase
initializeConnection
in class BaseJDBCTestCase
conn
- Connection to be intializedjava.sql.SQLException
- Error setting the initial state.protected void setUp()
setUp
in class junit.framework.TestCase
protected void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
public static void intProcedure(int i)
int
argument and adds it to the
procedureCalls
list. Can be used as a stored procedure to
verify that a trigger has been called. Particularly useful in BEFORE
triggers, as they are not allowed to modify SQL data.i
- an integerpublic void testBasicSyntax() throws java.sql.SQLException
java.sql.SQLException
public void testSubqueryInWhenClauseNPE() throws java.sql.SQLException
java.sql.SQLException
public void testGeneratedColumns() throws java.sql.SQLException
java.sql.SQLException
GeneratedColumnsTest.test_024_beforeTriggers()
public void testIllegalWhenClauses() throws java.sql.SQLException
java.sql.SQLException
public void testWhenClauseInvalidation() throws java.sql.SQLException
java.sql.SQLException
public void testDependencies() throws java.sql.SQLException
java.sql.SQLException
public void testDerby4874() throws java.sql.SQLException
java.sql.SQLException
public void testCloudscapeBug4821() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6783() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6783_1_1() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6783_1_2() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6783_2() throws java.sql.SQLException
java.sql.SQLException
public void testDerby6783_3() throws java.sql.SQLException
java.sql.SQLException
public void testGrantRevoke() throws java.sql.SQLException
java.sql.SQLException
public void testRuntimeException() throws java.sql.SQLException
java.sql.SQLException
public void testScalarSubquery() throws java.sql.SQLException
java.sql.SQLException
public void testCurrentUser() throws java.sql.SQLException
java.sql.SQLException
public void testRecursiveTrigger() throws java.sql.SQLException
java.sql.SQLException
public void testVeryLongWhenClause() throws java.sql.SQLException
java.sql.SQLException
public void testFunctionReadsSQLData() throws java.sql.SQLException
java.sql.SQLException
public static boolean tableIsEmpty(java.lang.String table) throws java.sql.SQLException
testFunctionReadsSQLData()
. It
checks whether the given table is empty.table
- the table to checktrue
if the table is empty, false
otherwisejava.sql.SQLException
public void testRoutineModifiesSQLData() throws java.sql.SQLException
SQL:2011, part 2, 11.49 <trigger definition>, syntax rule 11 says that the WHEN clause shall not contain routines that possibly modifies SQL data. Derby does not currently allow functions to be declared as MODIFIES SQL DATA. It does allow procedures to be declared as MODIFIES SQL DATA, but the current grammar does not allow procedures to be invoked from a WHEN clause. So there's currently no way to invoke routines that possibly modifies SQL data from a WHEN clause.
This test case verifies that it is not possible to declare a function as MODIFIES SQL DATA, and that it is not possible to call a procedure from a WHEN clause. If support for any of those features is added, this test case will start failing as a reminder that code must be added to prevent routines that possibly modifies SQL data from being invoked from a WHEN clause.
java.sql.SQLException
public void testAggregates() throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.