DERBY-3155: Improve handling of correlation names for the target tables in MERGE statements; commit derby-3155-09-aa-correlationNames.diff.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1547585 13f79535-47bb-0310-9956-ffa450edef68
DERBY-2041: Trigger should register a dependency on tables and columns used in its body

Add an upgrade test to verify how the dependencies are handled after
upgrade and downgrade.

Skip some cross checking between getColumns() and ResultSetMetaData
for views in DatabaseMetaDataTest, since those checks only pass for
tables. The upgrade test case adds a view that upsets the meta-data
test. (This is the first upgrade test that uses views.)

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548032 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6421: Cast to UDT in CHECK constraint causes NPE or assert failure

Delay binding of target UDT in CastNode till bind time.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548104 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6362: CHECK constraint uses wrong schema for unqualified routine invocations

Part 1: Make sure visitors descend into all TableName nodes.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548127 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6362: CHECK constraint uses wrong schema for unqualified routine invocations

Part 2: Fix offset of qualified table names. Their begin offset
pointed to the beginning of the table name token, but should point to
the beginning of the schema name token if they have one.

Also leave begin and end offset unspecified (-1 implied) for some
synthetic table name nodes that previously set the offsets to 0
explicitly. This makes it easier to tell whether they are synthetic
later.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548128 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6362: CHECK constraint uses wrong schema for unqualified routine invocations

Part 3:

- Refactor code that rewrites trigger actions so that it can be reused
  for rewriting CHECK constraints.

- Rewrite CHECK constraints and make all identifiers schema qualified
  before storing them in the dictionary.

- Make the parser preserve the TableName node for the target type in
  CAST expressions for user-defined types, so that they get detected
  by the rewrite logic.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548132 13f79535-47bb-0310-9956-ffa450edef68
DERBY-3155: Improve support for correlation names for the source tables of MERGE statements; tests passed cleanly for me on derby-3155-10-aa-correlationNames.diff.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1548298 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6256: Fix typo in javadoc header of XmlVTI; commit derby-6256-05-aa-javadocTypo.diff.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1549938 13f79535-47bb-0310-9956-ffa450edef68
DERBY-3155: Add tests to verify that BEFORE triggers can't fire MERGE statements, just as they can't fire INSERT/UPDATE/DELETE statements; commit derby-3155-11-ab-beforeTriggersCantFireMerge.diff.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1549948 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6354 DatabaseMetaDataTest.testGetColumnsReadOnly fails with NPE when releasing page

Diagnostics patch; to be removed when issue is fixed.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1549983 13f79535-47bb-0310-9956-ffa450edef68
DERBY-5416: SYSCS_COMPRESS_TABLE causes an OutOfMemoryError when the
heap is full at call time and then gets mostly garbage collected later
on.

Improve the accuracy of the code that estimates the memory requirement
of the sort buffer. When it detects that the current memory usage is
lower than the initial memory usage, it now records the current usage
and uses that value instead of the initial memory usage in future
calculations.

This compensates to some degree, but not fully, for the skew in the
estimates due to garbage collection happening after the initial memory
usage. The memory requirement will not be as badly underestimated, and
the likelihood of OutOfMemoryErrors is reduced.

There is no regression test case for this bug, since the only
reliable, reproducible test case that we currently have, needs too
much time, disk space and memory to be included in the regression test
suite.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550103 13f79535-47bb-0310-9956-ffa450edef68
DERBY-532 Support deferrable constraints

A patch ("derby-532-fix-metadata-1") that fixes broken database
metadata for deferred constraint indexes: the metadata query used the
method IndexDescriptor#isUnique to determine logical uniqueness, but
it really represents physical uniqueness now. For deferred unique
constraints, the method that should be used is
"isUniqueDeferrable". Added a test, and also added client/server run
of the regression test for deferred constraints.

Before the fix, the added test fixture "testDatabaseMetaData" failed
in that the index in question was identified as non unique, but it is
logically unique and so should be reported as such.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550113 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6419 Make BTree scan honor OPENMODE_LOCK_NOWAIT for row locks

Patch derby-6419-1 introduces a mode to avoid waiting for row locks in
BTeee scans.  Using the debugger I can see that the current wait in
ConstraintCharactericsTest#testLocking, line 417 as of svn 1545394 is
no longer waiting with the patch, and stepping through the code in
IndexChanger I can see that the second next() which currently waits
returns immediately with an exception as desired.

Instead of overloading the current flag OPENMODE_LOCK_NOWAIT, I
introduced a new flag OPENMODE_LOCK_ROW_NOWAIT instead. The short
circuiting logic was added in B2IRowLocking3#LockRowOnPage: I had to
added an accessor to HeapController to get at the open_mode of the
base table's conglomerate; not sure if that's kosher or not. An
alternative could be to keep to flag in the B2IForwardScan object.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550135 13f79535-47bb-0310-9956-ffa450edef68
DERBY-532 Support deferrable constraints

Patch derby-532-nullableUniqueFix. When we changed the implementation from
special treatment of deferrable constraints in the BTree, a couple of extra
predicates needed to be added were omitted - added those here: we should not
mark the physical index with "uniqueWithDuplicateNulls" if it is deferrable.
This error was found when running the regressions with default deferrable for
all pk and unique constraints.

We also removed an unused flag "hasDeferrableChecking" in the same places (it is
not longer used by the physical index).

Added a new test case, testCompressTable, which tests the
"uniqueWithDuplicateNulls" case.

We also change the behavior in the following way for deferrable, but not
deferred constraints: if we hit a time-out or dead-lock when checking uniqueness
(in the BTree scan), we throw that time-out or dead-lock. Up till now we
converted it to a duplicate exception. We will only assume it can be a duplicate
- for later checking - iff the constraint mode is deferrable.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550152 13f79535-47bb-0310-9956-ffa450edef68
DERBY-532 Support deferrable constraints

Patch derby-532-fix-drop-not-nullable. Fixes a broken predicate when
recreating the index when going from UNIQUE NOT NULL to plain UNIQUE:
the existing predicate missed the deferrable case, so the index was not
recreated.

Added a test case.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550284 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6426 Fix isLoginException
code treats any StandardException as a login exception due to curious no-op code. Added login state check to make it work as expected. 

Contributed by Dave Brosius



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550287 13f79535-47bb-0310-9956-ffa450edef68
DERBY-6419 Make BTree scan honor OPENMODE_LOCK_NOWAIT for row locks

A follow-up patch: derby-6419-followup.

Only short circuit waiting for lock in BTree scan to check duplicates
for a deferred unique/pk constraint if constraint mode is deferred
(i.e. not if immediate).

Added a test case lifted from UniqueConstraintMultiThreadedTest, which
exposed the issue when we run the regressions with default deferrable
by default (see DERBY-532).



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550299 13f79535-47bb-0310-9956-ffa450edef68
DERBY-532 Support deferrable constraints

Patch derby-532-test-speedup changes ConstraintCharacteristicsTest to
use a main memory database for some tests for increased speed. It also
changes the way SystemPropertyTestSetup for static properties closes
down the database to not deregister the driver; without this change we
saw a test setup try to connect via the client driver to a Derby server
engine without a registered driver.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550308 13f79535-47bb-0310-9956-ffa450edef68
DERBY-5196; Correct the layout of log.ctrl as described on the Derby web site
   fixing the header in the source file


git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1550525 13f79535-47bb-0310-9956-ffa450edef68