# Release Notes for Derby 10.2.1.6

- Overview
- JDBC 4.0 Support
- XML Support
- New Features
- Bug Fixes
- Issues
- Build Environment

## Overview

These notes describe the difference between Derby release 10.2.1.6 and the preceding release 10.1.3.1.

Derby is a pure Java relational database engine using standard SQL and JDBC as its APIs. 10.2.1.6 is a feature release.

The following improvements distinguish 10.2.1.6 from 10.1.3.1:

- Tools
  - The ij sql interpreter now has command-line help and two new commands: show tables and describe.
  - The ij connect statement now works in the J2ME/CDC environment.
  - Tools can now be invoked without specifying a classpath just by typing java -jar derbyrun.jar toolName.
- Security
  - Databases can now be re-encrypted. See DERBY-1156.
  - Secure connections can now be required. See DERBY-928.
  - Support has been added for DRDA userid/password substitution. See DERBY-528.
  - SQL Standard GRANT/REVOKE support has been added for authenticated users. See the "User authorizations" section of the Developer's Guide.
- Administration
  - New scripts have been added in the bin directory which follow Apache conventions. The scripts in the frameworks directory are deprecated and may be removed in future releases.
  - System tables have been added for access to diagnostic information previously available only through non-standard VTIs.
  - Online backup is now available through new system procedures.
  - Various Net Servlet improvements. See DERBY-117.
  - The network server now logs startup/shutdown messages to derby.log.
- JDBC
  - The network driver now supports statement timeouts.
  - Large object streaming has been improved in the network driver.
  - The FOR UPDATE clause is no longer required when declaring an updatable ResultSet.
  - Scrollable, updatable, insensitive ResultSets are now supported.
  - Network client messages have been internationalized. See DERBY-400.
- SQL
  - Expressions are now allowed in the GROUP BY clause.
  - Identity columns can be reset to start at a new value. Please consult documentation on the RESTART WITH clause of ALTER TABLE (found in the Reference Guide).
  - XPath/XQuery support has been improved.
  - New builtin math functions have been added and wired-in as JDBC escape functions. See the "Built-in functions" section of the Reference Guide.
  - Unary +/- are now allowed for ? parameters.
  - Optimizer overrides have been added.
  - Triggers can now call Java procedures.
  - The nullability of a column can be changed now.

For a comprehensive list of changes, consult the lists of new features and bug fixes below.

10.2.1.6 functionality includes:

- Embedded engine with JDBC driver
- Network Server
- Network client JDBC driver
- Command line tools: ij (SQL scripting), dblook (schema dump) and sysinfo (system info)

SQL support:

- Schemas, tables, temporary tables, views, triggers, indexes, savepoints
- Java procedures and functions
- Standard datatypes including XML, BLOB, and CLOB
- Sub-queries and joins
- Primary key, foreign key, unique and check constraints
- Referential actions
- GRANT/REVOKE support for databases with SQL authorization.

Other features:

- Full ACID transaction support with all four isolation levels
- Row and table level locking
- Configurable authentication including LDAP support
- Import/Export
- On-line backup and recovery support
- Optional on-disk encryption including re-encryption of existing encrypted databases
- Platform independent database format
- Full support for Java 2 Security Manager

JDK/JDBC support:

- JDK 1.3, 1.4, 1.5, and J2ME J2ME/CDC/Foundation Profile
- JSR-169, JDBC 2.1, and JDBC 3.0 support

## JDBC 4.0 Support

Derby 10.2.1.6 comes with source code for drivers which conform to a beta version of the JDBC standard, JDBC 4.0. This source code conforms to the following state of the JDBC 4.0 specification:

- The proposed final draft of the JSR 221 spec, dated July 19, 2006.
- Beta build 99 of JDK 6.

Due to license restrictions on the beta builds of JDK 6, Derby 10.2.1.6 does not contain compiled versions of JDBC 4.0 drivers. When run on Java SE 6, Derby 10.2.1.6 exposes the same JDBC 3.0 implementation seen when run on JDK 1.4 and 1.5. You may, however, compile Derby's JDBC 4.0 support yourself. This will let you use JDBC 4.0 features when you run Derby 10.2.1.6 on Java SE 6.

To build this optional JDBC 4.0 support yourself, please download the source distribution and consult BUILDING.txt. You may also follow a simplified set of instructions for building JDBC 4.0 support, which you may find in the "Building the Optional JDBC4 Support" section of the Derby 10.2 wiki page.

## XML Support

If you intend to use any of the Derby XML operators, you must ensure that you have:

- A JAXP parser in your classpath
- Apache Xalan in your classpath

Apache Derby 10.2.1.6 has been tested with Xalan-Java Version 2.7.0. If you have a version of Xalan that is earlier than 2.7, the Derby XML operators may still work. However, it is possible that you will experience unexpected errors when using the Derby XML operators.

## New Features

List the new features introduced by this release. These are features which appear in Derby 10.2.1.6 but not in the preceding release 10.1.3.1.

Master JIRA | New Feature
DERBY-31 | Statement.setQueryTimeout() support
DERBY-117 | Improvements on the NetServlet
DERBY-119 | ALTER TABLE change nullability
DERBY-239 | Online backup
DERBY-231 | FOR UPDATE clause
DERBY-326 | Improve Network Server large object streaming
DERBY-400 | Network client message strings not internationalized
DERBY-464 | Grant Revoke
DERBY-475 | New functions: ACOS, ASIN, ATAN, COS, SIN, TAN, PI, DEGREES, RADIANS, EXP, LN, LOG, LOG10, CEIL, CEILING, FLOOR
DERBY-506 | Client timeout mechanism
DERBY-515 | Network Server should log server start and shutdown time to derby.log
DERBY-551 | Invoke Java procedures from triggers
DERBY-528 | DRDA USRSSBPWD Security Mechanism
DERBY-571 | New syntax for invoking diagnostic VTIs
DERBY-573 | Optimizer directives
DERBY-582 | Unary plus/minus for parameters
DERBY-592 | New JDBC escape functions: ACOS, ASIN, ATAN, COS, SIN, TAN, PI, DEGREES, RADIANS, EXP, LOG, LOG10, CEILING, FLOOR
DERBY-597 | Enhance ij connect statement to work in J2ME/CDC/FP
DERBY-688 | Xml support for XPath
DERBY-690 | Scrollable Updatable ResultSet
DERBY-783 | Identity value restart
DERBY-883 | Enhance GROUP BY clause to support expressions
DERBY-928 | Restrict client connections,derby.drda.securityMechanism
DERBY-1019 | Simplify tool invocation
DERBY-1032 | Scripts adhering to Apache's conventions
DERBY-1156 | Database re-encryption
DERBY-1164 | 'show tables' and 'describe' commands in ij
DERBY-1216 | Command line help for ij

## Bug Fixes

List the bugs fixed by this release. These are bug fixes which turn up in Derby 10.2.1.6 but not in the preceding 10.1.3.1 release.

Issue Id | Description
DERBY-23 | just booting jdbc driver and shutting down seem to leak memory
DERBY-137 | Derby metadata always returns JDBC 2 result sets, even when JDBC 3 result sets are required.
DERBY-147 | ERROR 42X79 not consistant ? - same column name specified twice
DERBY-156 | Delete with alias on column fails
DERBY-171 | Need Correlation ID in UPDATE/DELETE statements
DERBY-176 | Derby throws ERROR XBCM1: Java linkage error thrown during load of generated class org.apache.derby.exe.aced07c066x0102xca87x3319x00004aa5686e1 during execution of large query
DERBY-213 | ResultSet.next() after last row of FORWARD_ONLY cursor throws an SQL Exception with Network Server
DERBY-231 | "FOR UPDATE" required for updatable result set to work
DERBY-253 | Client should throw not implemented exception for depricated setUnicodeStream/getUnicodeStream
DERBY-254 | SQLStates for SQLExceptions thrown from the client should not be null and should match embedded where possible
DERBY-304 | If by mistake you give he location for the db backup as the db itself , then windows created directories recursively until windows crashes!
DERBY-333 | Malformed if statement in org.apache.derby.impl.drda.Database.getDRDAStatement()
DERBY-336 | The wrong overload of StandardException::newException() is used in some cases
DERBY-349 | setByte() with executeBatch causes hang with client if mapping is invalid, e.g. setByte to DATE
DERBY-352 | Clobs on insert using streams should not instantiate into memory
DERBY-353 | It is desirable to have IDENTITY_VAL_LOCAL() function return last recent user specified value or system generated value for BY DEFAULT identity columns.
DERBY-404 | org.apache.derby.iapi.store.access.RowUtil.isRowEmpty has (never exercised) bug
DERBY-412 | Connection toString should show type information and the meaning of the identifier that it prints
DERBY-418 | outofmemory error when running large query in autocommit=false mode
DERBY-427 | An error message when running in XA environment says cloudscape.LOG rather than derby.log
DERBY-428 | NetworkClient PreparedStatement.executeBatch() hangs if batch is too large (ArrayIndexOutOfBoundsException in Network Server)
DERBY-438 | Update triggers on tables with BLOB and CLOB columns fail at execution time if the triggered-SQL-statement references the LOB column(s).
DERBY-445 | Client data sources lose the value of the connectionAttributes property when they are stored using the Reference interface
DERBY-446 | Client data source implementations cause security exception on storage to/from a Reference object
DERBY-471 | DatabaseMetaData.getXXXFunctions() methods return incorrect values.
DERBY-479 | Passing the return of a RETURN NULL ON NULL INPUT function to another function call throws linkage error.
DERBY-483 | Error message X0X07 has incorrect property name, db2j.database.classpath instead of derby.database.classpath
DERBY-501 | Client and embedded drivers differ on invoking a procedure that returns a single Dynamic resultSet using CallableStatement.executeQuery()
DERBY-517 | ResultSet - relative(int rows) behaves different in embedded and client/server mode when the positioning before the first row or after the last row.
DERBY-523 | Non logged operation that starts before the log archive mode is enabled can not be recovered during rollforward recovery.
DERBY-525 | getAsciiStreamshould replace non-ASCII characters with 0x3f, '?' to match embedded
DERBY-536 | The current build.properties for the Derby Help Plug-in for Eclipse does not work for creating a deployable plug-in
DERBY-541 | Read-only databases fail to boot after soft upgrade. Raises error message: 40XD1: Container was opened in read-only mode.
DERBY-555 | Unable to restart after disk is full
DERBY-567 | Improve Derby XML support to use XML parser found in JVM instead of using a hard-coded parser name (Xerces).
DERBY-569 | Derby network server is printing connection activity on System.out instead of logging it to derby.log
DERBY-578 | Grouped select from temporary table raises null pointer exception in byte code generator
DERBY-579 | Query timeout set for one statement may affect other statements with the same SQL string
DERBY-582 | Dynamic parameter should be allowed to be the operand of unary operator "-". Derby throws exception 42X36: The '-' operator is not allowed to take a ? parameter as an operand."
DERBY-592 | Expand table driven system function defintion added in DERBY-475 to allow definition of JDBC escaped functions.
DERBY-596 | jdbcapi/resultsetStream.java fails in DerbyNetClient Framework
DERBY-599 | Using setBlob interface, should not materialize the entire blob value into memory.
DERBY-609 | Returning ByteArrayInputStream from ResultSet is not appropriate
DERBY-611 | Network client: updateRow() causes a commit when autoCommit = true
DERBY-622 | sysinfo incorrectly requires permission on Derby jar files
DERBY-634 | Subquery materialization can cause stack overflow
DERBY-635 | Client socket connection doesn't report real socket exception
DERBY-648 | ij 'show connections' statement does not work in JSR169
DERBY-655 | getImportedKeys returns duplicate rows in some cases
DERBY-660 | CREATE PROCEDURE incorrectly allows the RETURNS NULL ON NULL INPUT clause
DERBY-694 | Statement exceptions cause all the connection's result sets to be closed with the client driver
DERBY-707 | providing RowLocation for deleted+purged row to GenericConglomerateController causes nullpointerexception
DERBY-709 | SecurityException thrown when passing a relative path name when backing up database
DERBY-714 | NullPointerException or ClassCastException if UPDATE or DELETE is performed on a diagnostic VTI
DERBY-718 | Network client: deleteRow() makes getter methods return nulls for the following rows.
DERBY-721 | State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
DERBY-730 | SQL statements that fail to parse remain in the statement cache.
DERBY-732 | ERROR XBCM1: Java linkage error thrown during load of generated class for query with large number of logical operators and substitution parameters.
DERBY-733 | Starvation in RAFContainer.readPage()
DERBY-756 | OutOfMemory Error on continous execution of select statement using COUNT() and DISTINCT on same connection
DERBY-781 | Materialize subqueries in select list where possible to avoid creating invariant resultsets many times.
DERBY-782 | Improvement on org.apache.derby.impl.jdbc.EmbedBlob#length()
DERBY-786 | Casting to a CLOB value does not truncate.
DERBY-787 | cursor closed as a sideeffect of closing another cursor with the same name on another connection
DERBY-802 | OutofMemory Error when reading large blob when statement type is ResultSet.TYPE_SCROLL_INSENSITIVE
DERBY-818 | Read-only embedded ResultSets incur performance penalty due to updateable ResultSet code.
DERBY-821 | Client driver: Implicitly close exhausted result sets on the server
DERBY-826 | sysinfo does not report the version of derby.jar if the class does not explictly contain it.
DERBY-836 | ResultSetMetaData.getColumnDisplaySize sometimes returns wrong values for DECIMAL columns
DERBY-876 | DatabaseMetaData.getSchemas() is not JDBC 3.0 compliant
DERBY-915 | EmbedDatabaseMetadata, EmbedDatabaseMetadata40, and client.net.NetDatabaseMetadata40 should not throw a "not implemented" exception
DERBY-922 | getSQLException() method in client.am.SqlException does not correctly chain exceptions
DERBY-939 | NullPointerException at ResultSet.close() time for simple query using UNION and INTERSECT
DERBY-959 | Allow use of DRDA QRYDTA block sizes greater than 32K
DERBY-965 | DatabaseMetadata method supportsResultSetConcurrency returns wrong result on network client
DERBY-982 | sysinfo api does not provide genus name for client
DERBY-992 | A corner case bug and missing optimization in ScrollInsensitiveResultSet
DERBY-1000 | For LDAP authentication: derby.authentication.server should support ldaps:// as part of the server url.
DERBY-1043 | Invalid column references are not caught in a trigger action statement when the referencing table of the column is the triggered table
DERBY-1060 | ResultSet methods should throw exception when the ResultSet is closed
DERBY-1064 | Delete cascade causes NULL values inserted into table when after delete Trigger fires
DERBY-1080 | Connection reset when using security mechanism=EUSRIDPWD results in protocol error.
DERBY-1087 | Updatable result sets behave different depending on the type of query used to generate the result set
DERBY-1095 | Closing an embedded connection does not seem to close associated EmbedStatements
DERBY-1113 | transaction logs files requried for recovery are getting deleted when backup and checkpointas are running in parallel.
DERBY-1117 | SQLException can lose stacktrace in some cases.
DERBY-1119 | Creating a schema with DumpParseTree, DumpBindTree properties set causes NullPointException.
DERBY-1142 | Metadata calls leak memory
DERBY-1172 | incorrect error message in updateRow() after a commit on a held scroll insensitive resultset
DERBY-1177 | updateObject with null as argument causes network driver to fail with NullPointerException
DERBY-1183 | Client java.sql.ResultSet.getCursorName() does not return the correct cursor name for Statements after the first execution
DERBY-1184 | 'CallableStatement.registerOutParameter(int,int,String)' does nothing in client driver
DERBY-1190 | Network Server reports wrong product name when logging connections to derby.log
DERBY-1196 | Network server closes prepared statements prematurely if exception occurs during OPNQRY and can cause "'Statement' already closed" exception on reexecution
DERBY-1202 | SQLState DATA_SQLDATA_READ_INSTANTIATION_EXCEPTION has no message associated with it
DERBY-1234 | Verify that we raise SQLException when calling methods on closed java.sql objects
DERBY-1236 | Verify that applications can't manipulate the transaction state while inside a distributed transaction.
DERBY-1241 | When booting a database under security manager, boot may fail with message java.sql.SQLException: Java exception: 'access denied (java.io.FilePermission for logmirror.ctrl if database was not shutdown cleanly after previous access
DERBY-1249 | cursor operation conflict incorrectly handled in scrollable updatable resultsets
DERBY-1251 | cancelRowUpdates() affects rows updated with updateRow() in scrollable updatable resultsets
DERBY-1258 | Wrong value returned in a row trigger action statement if the table has column names that are identical when upper-cased.
DERBY-1266 | Client: Attempted deleteRow or updateRow while on insert row gives wrong error message
DERBY-1274 | Network Server does not shutdown the databases it has booted when started and shutdown from the command line
DERBY-1276 | Calling ResultSet.isLast() on a scrollable insensitive resultset, causes the entire ResultSet to be populated
DERBY-1277 | Call to rs.isLast() may cause rs.getXXX() return values from the last row instead of the current row in scrollable resultsets
DERBY-1279 | Bad column name in DatabaseMetaData.getColumns()
DERBY-1292 | ClassCastException in ClientDriver when using CLOB columns and batch updates
DERBY-1295 | Result sets of type TYPE_SCROLL_INSENSITIVE should not implicitly close due to positioning in autocommit mode
DERBY-1296 | Setting property derby.system.bootAll causes an Exception
DERBY-1304 | DROP view does not always completely remove view
DERBY-1313 | SUR: Use DRDA's extended diagnostic to send ROW_UPDATED and ROW_DELETED warnings.
DERBY-1314 | Differences between client and embedded when invoking stored procedures using Statement.executeUpdate()
DERBY-1322 | Missing resets of isOnInsertRow state in net client when navigating away via other than ResultSet#next
DERBY-1323 | Detectability methods rowUpdated, rowInserted, rowDeleted can be called from illegal states in both clients
DERBY-1326 | Network server may abandon sessions when Derby system is shutdown and this causes intermittent hangs in the client
DERBY-1356 | Positioned update/delete when positioned after last or before first causes NullPointerException
DERBY-1357 | Short-circuit logic in optimizer appears to be incorrect...
DERBY-1361 | positioned updates and deletes allowed after a commit without repositioning the cursor - if the table is indexed on the columns selected
DERBY-1364 | Client driver does not roll back the effects of a stored procedure when incorrectly invoked by executeQuery()/executeUpdate()
DERBY-1373 | Encrypted databases cannot be booted using the jar subprotocol (and possibly also using http/https/classpath)
DERBY-1382 | client: lobs fails silently with result sets of type TYPE_SCROLL_INSENSITIVE
DERBY-1384 | Increase default BLOB/CLOB length to maximum supported (2G?)
DERBY-1393 | PreparedStatement.setObject(int,Object,int) should throw SQLFeatureNotSupportedException for unsupported types
DERBY-1395 | Change the client SQLState to match that of embedded for the exception thrown on a closed statement whose connection is also closed
DERBY-1396 | ReEncodedInputStream may fail to read all of source Reader.
DERBY-1421 | ResultSet.updateBinaryStream fails when the result type is TYPE_SCROLL_INSENSITIVE
DERBY-1464 | runtimestatistics can show that an index is being used even when it isn't
DERBY-1473 | Add cut-off and truncation logic to streaming classes in the embedded driver
DERBY-1476 | PreparedStatement.setNull(int,int) should throw SQLFeatureNotSupportedException for unsupported types
DERBY-1481 | Client driver: ResultSet.beforeFirst() gives protocol error on scrollable, updatable result sets that are downgraded to read-only
DERBY-1493 | EmbeddedDriver does not implement PreparedStatement.setNull(int, int, String)
DERBY-1500 | PreparedStatement#setObject(int parameterIndex, Object x) throws SQL Exception when binding Short value in embedded mode
DERBY-1510 | 'SQLBinary.readFromStream' can enter endless loop
DERBY-1533 | ArrayIndexOutOfBoundsException in DDMReader, on a specific data size
DERBY-1547 | Add svn version number to DatabaseMetaData getDatabaseProductVersion and getDriverVersion() to improve supportability
DERBY-1554 | IDENTITY_VAL_LOCAL() returned value is modified incorrectly by a multi-row INSERT statement.
DERBY-1571 | NetworkServerControlImpl.consoleExceptionPrintTrace() prints stack trace even when logWriter is null
DERBY-1574 | NullPointerException in UPDATE with COALESCE and subquery
DERBY-1586 | The attributesAsPassword property doesn't work correctly with EmbeddedConnectionPoolDataSource
DERBY-1587 | INTEGER function cannot be abbreviated
DERBY-1589 | CREATE TABLE throws NullPointerException in Derby SQL Standard Authorization after DROPs and REVOKES
DERBY-1619 | Sysinfo in 10.2 shows multiple entries if the derby jars reside in a directory with spaces in its name
DERBY-1621 | Trigger action statement is not recompile when there is a change that would affect it.
DERBY-1633 | Regression: The fields of views are not being calculated properly since 10.1.2.4
DERBY-1652 | Update trigger updating the same rows as the original update does not throw an exception ERROR 54038: "Maximum depth of nested triggers was exceeded" as it should
DERBY-1660 | SYSCS_BULK_INSERT fails with syntax error at PROPERTIES clause.
DERBY-1661 | Create index on large tables fails with too many open files , FileNotFoundException.
DERBY-1675 | Network Server should not send to client that it supports EUSRIDPWD when running against Sun JVM
DERBY-1681 | Regression (wrong results): Join predicate can be ignored for left-most child in a chain of nested unions.
DERBY-1692 | Client driver does not use the query timeout value set using Statement.setQueryTimeout() for subsequent executions using the same statement object
DERBY-1706 | NullPointerException occurs when trying to create a table in schema SESSION
DERBY-1707 | Specifying an incorrect optimizer property (constraint=null) gives NullPointerException
DERBY-1708 | Unprivileged user can perform lock table statement on a table which he/she does not have any access rights
DERBY-1714 | huge single insert statements fail with JVM error due to size of generated method
DERBY-1756 | Revert change in client that defaults the secmec to eusridpwd.
DERBY-1767 | insertRow(), updateRow() and deleteRow() cannot handle table names and column names containing double quotes
DERBY-1777 | Regression: query works in 10.1.2.1 but fails with NullPointerException in 10.2.1.1
DERBY-1784 | When qualifying a column name with its synonym name in the select list, Derby throws SQLSTATE 42X04.
DERBY-1786 | a crash during re-encryption of an existing database with lot of tables can make database unrecoverable on a next boot.
DERBY-1809 | Built-in functions not working in views.
DERBY-1811 | Embedded ResultSet.getTimestamp on a TIME column returns a java.sql.Timestamp with a date portion that can be incorrect.
DERBY-1817 | Race condition in network server's thread pool
DERBY-1854 | SYSCS_COMPRESS_TABLE corrupts table with a single column which is both a primary key and a foreign key
DERBY-1858 | A schema can be dropped by a non-schema owner in SQL authorization mode
DERBY-1866 | Assert failure in sane mode for queries that used to work in 10.1.2.1
DERBY-1891 | error 58009.C.19 refers to non-existent codepoint secktn - needs correcting
DERBY-1900 | The scripts under the /bin of the distribution does not have the executable permission

## Issues

Please be aware of the following issues:

- 253 - Client should throw not implemented exception for depricated setUnicodeStream/getUnicodeStream
- 668 - SysInfo does not print the right information when Derby is not loaded through the classpath.
- 721 - State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
- 781 - Materialize subqueries in select list where possible to avoid creating invariant resultsets many times.
- 822 - Client driver: Pre-fetch data on executeQuery()
- 1130 - Client should not allow databaseName to be set with setConnectionAttributes
- 1295 - Result sets of type TYPE_SCROLL_INSENSITIVE should not implicitly close due to positioning in autocommit mode
- 1314 - Differences between client and embedded when invoking stored procedures using Statement.executeUpdate()
- 1323 - Detectability methods rowUpdated, rowInserted, rowDeleted can be called from illegal states in both clients
- 1357 - Short-circuit logic in optimizer appears to be incorrect...
- 1384 - Increase default BLOB/CLOB length to maximum supported (2G?)
- 1621 - Trigger action statement is not recompile when there is a change that would affect it.
- 1652 - Update trigger updating the same rows as the original update does not throw an exception ERROR 54038: "Maximum depth of nested triggers was exceeded" as it should
- 1867 - Document algorithm support required for using secmec 8(USRSSSBPWD) and limitation on ibm141 vm.

> ### DERBY-253

> #### Problem

> PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream() throw SQLException when invoked after upgrading to Apache Derby 10.2.

> #### Symptoms

> Calling either of these methods will result in an exception with SQLSTATE 0A000 and message: "Feature not implemented: ..."

> #### Cause

> PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream() have been deprecated since JDBC 2.0. Derby's implemetation of these methods was broken, and it was decided that the methods should throw a not-implemented exception instead of being fixed.

> #### Solution

> This was an intentional change. No Derby product solution is offered.

> #### Workaround

> Use setCharacterStream() and getCharacterStream() instead of setUnicodeStream() and getUnicodeStream().

> ### DERBY-668

> #### Problem

> Sysinfo classpath information was insufficiently detailed.

> #### Symptoms

> Sometimes it was hard to tell where the Derby classes were actually being loaded from in the JVM.

> #### Cause

> The algorithm that sysinfo used for analyzing and reporting on the application classpath was not robust.

> #### Solution

> The sysinfo tool now prints additional information about the origin of the classes and jars that it examines. The origin of a class might be: an entry in the application classpath, an entry in a class loader location list, a jar fetched due to being listed in the manifest entry of another jar, a standard extension in the JRE's extensions directory, a jar installed into the application server, or any of various other possibilities.

> #### Workaround

> No workaround. The behavior is now correct.

> ### DERBY-721

> #### Problem

> Undefined results were returned to an application which opend an InputStream twice on the same column of a ResultSet.

> #### Symptoms

> The value siphoned out of the column was erratic.

> #### Cause

> Streams were being shared between the two readers.

> #### Solution

> Now we throw an exception if the application tries to open two streams on the same column in a ResultSet.

> #### Workaround

> Users must recode Applications which open multiple streams on the same column.

> ### DERBY-781

> #### Problem

> When optimizing a query that has one or more non-flattenable subqueries in the FROM clause, Derby will now check to see if it is possible to perform a hash join with that subquery as the inner table. Prior to Derby 10.2, the optimizer would never consider a hash join with a subquery; it only did nested loop joins.

> #### Symptoms

> Execution performance of queries containing non-flattenable subqueries may change. The expectation is that the new (10.2) query plans will show improved performance over the old ones.

> Another potential symptom is that the compilation time for such queries may increase. If this happens, the increase should only occur at compilation time; execution time should either improve or, at the very least, remain the same as in earlier versions of Derby.

> #### Cause

> If the optimizer chooses to do a hash join with a subquery, Derby only has to execute the subquery a single time per statement, after which Derby can just perform the desired join against the materialized result set. Depending on how many rows are in the outer table of the join, this once-per-statement execution of the subquery can lead to major performance improvements over the once-per-outer-row execution employed by earlier versions of Derby.

> As for the extra compilation time, this is due to the simple fact that the optimizer is now doing more work--i.e. in addition to considering nested loop joins with subqueries, it is now _also_ considering hash joins with those subqueries, and that means that it could potentially take longer for the optimizer to finish its work. Note again that, if it occurs, the increased time should only occur at compilation time; execution time should either improve or, at the very least, remain the same as in earlier versions of Derby.

> #### Solution

> This was an intentional change to improve the execution plans chosen by the optimizer for queries having large and/or complex subqueries. The expectation is that the new behavior--and the subsequent query plans--will lead to improved performance over the old ones, so no further solution is required.

> #### Workaround

> There is no way to disable/workaround this new behavior since the symptom as described above is a good one for Derby.

> That said, any user who notices a negative performance change after moving to Derby 10.2, and who believes that the difference in performance is related to this optimizer enhancement, is encouraged to visit the performance diagnosis page and to follow up with his/her findings on the Derby mailing lists.

> ### DERBY-822

> #### Problem

> Queries may fail earlier and locks may be acquired earlier when executing queries. Location where errors occur in an embedded environment is different from the location where errors occur in a network environment.

> #### Symptoms

> Errors that happen as part of the normal execution path are moved earlier. For example, code to execute a query, with executeQuery() retrieve the result set metadata and then perform a next() might fail with a lock timeout on executeQuery() instead of next(). Locking changes are observed.

> #### Cause

> Pre-fetching moves execution of retrieval of data earlier for network client/server configurations.

> #### Solution

> This was an intentional behavior change to improve performance. No Derby product solution is offered.

> #### Workaround

> Application code needs to be changed to adjust error handling if needed.

> ### DERBY-1130

> #### Problem

> Derby's client DataSources were using a wrong database name when getting a connection in the following case:

> - databaseName is not set as a Derby DataSource property
> - databaseName is set as a connection attribute using setConnectionAttributes method

> #### Symptoms

> Instead of throwing an exception saying databaseName is a required Derby DataSource property and must be set, client driver was using "null" as database name and returning a connection to database named "null".

> #### Cause

> The database name was constructed wrongly in the client driver.

> #### Solution

> This was solved by setting the internal database name property in the client driver correctly. Also ensured that databaseName set as a connection attribute will not be used by Derby's client DataSources.. This fix will be available in Derby versions 10.2 and above.

> #### Workaround

> If using release prior to version 10.2, make sure database name is set only as a DataSource property when using Derby's client DataSources.

> ### DERBY-1295

> #### Problem

> Result sets of type TYPE_SCROLL_INSENSITIVE used to implicitly close when positioned at the end in autocommit mode.

> #### Symptoms

> Calling the ResultSet.next() method when positioned on the last row of a result set of type SCROLL_INSENSITIVE in auto commit mode used to cause the result set to be closed.

> #### Cause

> The JDBC specification allows a JDBC driver to implicitly close a ResultSet when the ResultSet type is TYPE_FORWARD_ONLY and the next method of ResultSet returns false. Derby also used to implicitly close result sets of type SCROLL_INSENSITIVE when the ResultSet.next() method returns false in auto commit mode.

> #### Solution

> The behavior of SCROLL_INSENSITIVE result sets in auto commit mode has been changed to comply with the JDBC4 specification. SCROLL_INSENSITIVE result sets are not implicitly closed when calling the ResultSet.next() method in auto commit mode while positioned on the last row.

> #### Workaround

> Fix applications which rely on the previous, non-standard behavior.

> ### DERBY-1314

> #### Problem

> The behaviour of executeQuery() and executeUpdate() did not match the JDBC specification when invoking stored procedures.

> #### Symptoms

> - When invoking a stored procedure with executeQuery() or executeUpdate(), an exception was thrown indicating that the procedure did not return the correct number of ResultSet objects, although the correct number of ResultSet objects was in fact returned.
> - When invoking a stored procedure with executeQuery() or executeUpdate(), and the procedure did not return the correct number of ResultSet objects, the query executed successfully.
> - With the network client driver, when invoking a stored procedure with executeUpdate(), the return value was -1, whereas the JDBC specification says it should be 0.

> #### Cause

> The methods executeQuery() and executeUpdate() were not implemented in compliance with the JDBC specification.

> #### Solution

> In Derby 10.2, the behaviour of the methods executeQuery() and executeUpdate() has been changed to match the JDBC specification.

> #### Workaround

> Use execute() instead of executeUpdate()/executeQuery() to invoke a stored procedure which does not return exactly 0 or 1 ResultSet objects.

WORKAROUND None.

> ### DERBY-1323

> #### Problem

> For a JDBC ResultSet with type TYPE_FORWARD_ONLY, the methods rowUpdated, rowDeleted and rowInserted could previously be called while not on a row, i.e. before positioning in the result set, while on insertRow, after updateRow before new positioning, after deleteRow before new positioning and when after last row. This is now disallowed.

> #### Symptoms

> Calls to any of these methods while not on a row will now throw SQLException with SQLState 24000.

> #### Cause

> Derby now disallows these calls when not on a row.

> #### Solution

> Change the application to not call these methods unless on a row. Note that using them at all is rather meaningless for a ResultSet of type TYPE_FORWARD_ONLY since the returned result will always be 'false'. This is because once you modify a row, it can no longer be accessed, you need to move to the next row, if there is one, to get a new current row. Presently in Derby, these methods are only really meaningfully used for result sets of type TYPE_SCROLL_INSENSITIVE and of concurrency CONCUR_UPDATABLE in which case updated and deleted rows can be detected.

> #### Workaround

> Fix applications which rely on this non-standard behavior.

> ### DERBY-1357

> #### Problem

> The optimizer will now abandon sub-optimal join orders as soon as it realizes that they cost more than the best join order so far.

> This fix also ensures that, in the case of short-circuited join orders, Derby will still generate (and execute) an overall plan that matches the "best path" decisions made by the optimizer--which was not always the case prior to these changes.

> #### Symptoms

> Execution performance of large queries (esp. those with nested subqueries and/or with large FROM clauses) may change. The expectation is that the new (10.2) query plans will show improved performance over the old ones.

> #### Cause

> Since the optimizer is now spending less time evaluating sub-optimal join orders, it is possible that it will be able to try out more join orders before optimizer "timeout" occurs. As a result the optimizer can sometimes find better plans than it did in earlier versions of Derby.

> #### Solution

> This was an intentional change to fix behavior that was not working correctly in earlier versions of Derby. The expectation is that the new behavior--and the subsequent query plans--will lead to improved performance over the old ones, so no further solution is required.

> #### Workaround

> There is no way to disable/workaround this new behavior since the symptom as described above is a good one for Derby.

> That said, any user who notices a negative performance change after moving to Derby 10.2, and who believes that the difference in performance is related to this optimizer change, is encouraged to visit the performance diagnosis page and to follow up with his/her findings on the Derby mailing lists.

> ### DERBY-1384

> #### Problem

> Default BLOB/CLOB length should be the maximum length supported by Derby (2G-1)

> #### Symptoms

> An application that used BLOB will current reject values greater than 1M, changing the default means the application will now silently accept those values.

> #### Cause

> The allowable size of Derby LOBs has been increased.

> #### Solution

> This was an intentional change to make Derby conform to its own documentation.

> #### Workaround

> Fix applications which rely on Derby rejecting LOBs that are bigger than 1M.

> ### DERBY-1621

> #### Problem

> Trigger action statement is not recompile when there is a change that would affect it.

> #### Symptoms

> (1) Trigger action such as an INSERT statement does not get recompiled when the underlying table is affected by a CREATE or DROP INDEX statement. e.g.:

> >              create table t (i int);
> >              create table t2 (i int);
> >              create trigger tt after insert on t for each statement mode db2sql insert into t2 values 1;
> >              insert into t values 1;
> >              select * from t2;
> >              create unique index tu on t2(i);
> >              insert into t values 1;
> >              select * from t2;
> >              insert into t values 1;
> >              1 row inserted/updated/deleted

> The above example creates an unique index on table t2. when the trigger is fired, it did not raise an unique constraint error.

> (2) When the trigger action statement underlying view gets dropped, the trigger statement did not get recompiled. e.g.:

> >              create table t11 (c111 int not null primary key, c112 int);
> >              insert into t11 values(1,1);
> >              insert into t11 values(2,2);
> >              create view v21 as select * from user1.t11;
> >              create table t31 (c311 int);
> >              create table t32 (c321 int);
> >              create trigger tr31t31 after insert on t31 for each statement mode db2sql insert into t32 values (select c111 from user1.v21 where c112=1);
> >              insert into t31 values(1);
> >              select * from t31;
> >              select * from t32;
> >              drop view v21;
> >              insert into t31 values(1);

> In the above example, a view which the trigger action references is dropped; however, the last SQL INSERT statement did not throw an error.

> (3) Conglomerate does not exist occurs in a specific case after dropping a table referenced by a trigger. The trigger action is not being recompiled and raises SQLSTATE XSAI2 even though the table being dropped was recreated again. e.g.:

> >              create table t1 (id int, name varchar(20));
> >              create table t2 (id int);
> >              create trigger test_trigger after insert on t2 for each row mode db2sql insert into t1 values(100, 'hundred');
> >              insert into t2 values(1);
> >              insert into t2 values(1);
> >              select * from t1;
> >              drop table t1;
> >              insert into t2 values(1);
> >              create table t1 (id int, name varchar(20));
> >              insert into t2 values(1);

> In the above example, a table which the trigger action references is dropped. The last INSERT statement should execute successfully but it raises SQLSTATE XSAI2: The conglomerate (896) requested does not exist.

> #### Cause

> Derby did not perform invalidation of the trigger action when object(s) that the trigger references are modified or dropped; hence, resulting in the stated problem above. The affected versions are Derby 10.0 and 10.1.

> #### Solution

> A fix to resolve the above Derby symptoms is available in 10.2.

> #### Workaround

> None.

> ### DERBY-1652

> #### Problem

> In some cases, an after update trigger does not get fired upon itself when its trigger action contains an update statement on the trigger's subject table.

> #### Symptoms

> (1) When defining a trigger for the first time for a table, e.g.:

> >             CREATE TABLE "TEST" ("TESTID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
> >                                  "INFO" INTEGER NOT NULL,
> >                                  "TIMESTAMP" TIMESTAMP NOT NULL DEFAULT '1980-01-01-00.00.00.000000');

> >             CREATE TRIGGER UPDATE_TEST
> >             AFTER UPDATE ON TEST
> >             REFERENCING OLD AS OLD
> >             FOR EACH ROW MODE DB2SQL
> >                 UPDATE TEST SET TIMESTAMP = CURRENT_TIMESTAMP WHERE TESTID = OLD.TESTID;

> >             INSERT INTO TEST (INFO) VALUES (1), (2), (3);

> >             UPDATE TEST SET INFO = 1 WHERE TESTID = 2;

> The above update statement executes successfully which it is incorrect. The system should have issued SQLSTATE 54038 since it self-triggers to its maximum depth of 16.

> (2) With the above example, when an user upgrades to a higher version and issues the same update statement:

> >             UPDATE TEST SET INFO = 1 WHERE TESTID = 2;
> >             ERROR 54038: Maximum depth of nested triggers was exceeded.

> The SQLSTATE 54038 is issued in this case because after database upgrade, the trigger action will be invalidated by the system and will force a recompilation of the trigger when it is fired. The system generates the correct execution plan this time and since the trigger behavior have changed, this might cause applications to break unexpectedly.

> #### Cause

> Derby's did not generate the correct execution plan for self-trigger invocation when such a trigger is declared for the first time on the subject table; hence, resulting in the stated problem above. The affected version is Derby 10.0 and 10.1.

> #### Solution

> A fix to resolve the above Derby symptom is available in 10.1 and 10.2. thrown now.

> #### Workaround

> If self-trigger invocation was not intended by the application, the application can select which column(s) on the update statement can cause the trigger to fire in the CREATE TRIGGER statement. i.e.:

> >        CREATE TRIGGER update_test
> >        AFTER UPDATE OF INFO ON test
> >        REFERENCING OLD AS old
> >        FOR EACH ROW MODE DB2SQL
> >            UPDATE test SET timestamp=current_timestamp WHERE testid=old.testid;

> In the above statement, the trigger will only fire when an update is made to the "info" column instead of any column(s).

> ### DERBY-1867

> #### Problem

> With IBM 1.4.1 JVM, trying to connect to the server using the derby client with security mechanism 8 (USRSSSBPWD) will result in error.

> #### Symptoms

> Connecting using the client driver with security mechanism 8 will throw the following error ERROR XJ112: Security exception encountered, see next exception for details. The stack trace will show that the problem is caused by java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available

> #### Cause

> Current USRSSBPWD implementation uses SHA1PRNG algorithm to generate random number(seed) that gets exchanged between client and the server. The SHA1PRNG algorithm is not available with the JCE provider that comes with IBM JVM version 1.4.1.

> #### Solution

> You must use another JCE provider.

> #### Workaround

> If you need to use the security mechanism 8, then make sure that support for SHA1PRNG is available in the JCE provider that is available with a particular JVM. For e.g. Use IBM 1.4.2 JVM that has support for SHA1PRNG or the Sun JVMs.

## Build Environment

Derby release 10.2.1.6 was built using the following environment:

- Branch - Source code came from the 10.2 branch.
- Machine - Cygwin on Microsoft Windows XP Professional Version 2002 Service Pack 2.
- Ant - Apache Ant version 1.6.5 compiled on June 2 2005.
- JDK 1.4 - Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03).
- JDK 1.3 - Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_16-b06).
- JDK 1.6 - The optional JDBC4 drivers were not compiled.
- OSGi - The osgi.jar was used to build org.apache.derby.osgi.EmbeddedActivator.
- Compiler - The 1.4.2_08-b03 javac was used to compile all classes.
- JSR 169 - J2ME support was built using java.sun.com/j2me (j2me_cdc_fp-1_0_2).