db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-3404) EmbedResultSet.getString() returns wrong value after auto-commit with CLOSE_CURSORS_AT_COMMIT
Date Thu, 14 Feb 2008 13:31:08 GMT

     [ https://issues.apache.org/jira/browse/DERBY-3404?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Knut Anders Hatlen updated DERBY-3404:
--------------------------------------

    Attachment: d3404-v1.stat
                d3404-v1.diff

The attached patch attempts to fix this problem by checking
theResults.isClosed() in EmbedResultSet.checkIfClosed(). If
theResults.isClosed() returns true and the isClosed field is false, it
sets isClosed to true and calls closeCurrentStream() (similar to what
checkExecIfClosed() does if it detects that the connection is closed).

I have also added a test case in jdbc4/ResultSetTest. This test case
verifies that ResultSet.isClosed() returns true on non-holdable
ResultSets after commit. Without the patch, it failed on embedded and
passed on the client. With the patch, it passes on both.

I needed to make the following changes to existing tests:

- jdbcapi/J2EEDataSourceTest - one SQL state changed in embedded
  (Connection closed -> ResultSet closed). The client already expected
  this SQL state, so now the test didn't have to check which driver it
  used.

- lang/nestedCommit.sql - one of the test cases evaluated a function
  which committed the transaction. The returned result set was not
  holdable, and was therefore closed by the commit. Before the patch,
  ij would be able to read the first row before it failed when it
  called next() a second time, whereas now it fails when it tries to
  read a column in the first row. Since the ResultSet is closed at
  that time, I believe this is the correct behaviour.

- lang/closed.java - a "No current connection" error was replaced with
  a "ResultSet not open" error.

I have started suites.All and derbyall on the patch.

> EmbedResultSet.getString() returns wrong value after auto-commit with CLOSE_CURSORS_AT_COMMIT
> ---------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3404
>                 URL: https://issues.apache.org/jira/browse/DERBY-3404
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.1.4, 10.3.2.1, 10.4.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: CloseOnCommit.java, d3404-v1.diff, d3404-v1.stat
>
>
> The following code prints "null" to the console with the embedded driver:
>         Statement s = c.createStatement(ResultSet.TYPE_FORWARD_ONLY,
>                                         ResultSet.CONCUR_READ_ONLY,
>                                         ResultSet.CLOSE_CURSORS_AT_COMMIT);
>         ResultSet rs = s.executeQuery("select * from sysibm.sysdummy1");
>         rs.next();
>         c.createStatement().executeQuery("values 1").close(); // causes auto-commit
>         System.out.println(rs.getString(1));
> The call to rs.getString() should perhaps have thrown SQLException, since the auto-commit
between next() and getString() should close the ResultSet when the holdability is CLOSE_CURSORS_AT_COMMIT,
I think. Anyway, the value stored in SYSIBM.SYSDUMMY1 is 'Y' and not NULL, so it should definitely
not return null.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message