Issue Details (XML | Word | Printable)

Key: DERBY-1314
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Knut Anders Hatlen
Reporter: Knut Anders Hatlen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Differences between client and embedded when invoking stored procedures using Statement.executeUpdate()

Created: 10/May/06 08:30 PM   Updated: 18/Sep/06 03:26 PM
Return to search
Component/s: JDBC
Affects Version/s: 10.2.1.6
Fix Version/s: 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works derby-1314-v1.diff 2006-06-13 06:38 PM Knut Anders Hatlen 4 kB
Text File Licensed for inclusion in ASF works derby-1314-v1.stat 2006-06-13 06:38 PM Knut Anders Hatlen 0.2 kB
Issue Links:
Reference
 

Issue & fix info: Patch Available, Release Note Needed
Resolution Date: 23/Jun/06 07:23 PM


 Description  « Hide
When invoking a stored procedure using Statement.executeUpdate(), the
client driver and the embedded driver behave differently.

If the stored procedure does not return any result set, the embedded
driver returns 0, whereas the client returns -1.

If the stored procedure returns one or more result sets, the embedded
driver returns -1, whereas the client fails with an exception.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Knut Anders Hatlen added a comment - 10/May/06 08:31 PM
The JDBC 3.0 javadoc for Statement.executeUpdate() says:

  Returns: either the row count for INSERT, UPDATE or DELETE
    statements, or 0 for SQL statements that return nothing

  Throws: SQLException - if a database access error occurs or the
    given SQL statement produces a ResultSet object

Embedded behaves correctly when no result sets are produced by the
stored procedure, and the client behaves correctly when result sets
are produced.

Knut Anders Hatlen made changes - 10/May/06 08:35 PM
Field Original Value New Value
Link This issue is related to DERBY-211 [ DERBY-211 ]
Knut Anders Hatlen made changes - 06/Jun/06 04:51 PM
Assignee Knut Anders Hatlen [ knutanders ]
Knut Anders Hatlen added a comment - 13/Jun/06 06:38 PM
The attached patch fixes the issue on the client. When executeUpdate() is used to invoke a stored procedure, an update count of -1 (indicating that no update count is returned) is changed to 0, as the javadoc for executeUpdate() says. With this patch, four more of the test cases in jdbcapi/ProcedureTest.junit succeed with the client driver (but the test will not be enabled until the patch for DERBY-501 is checked in).

executeUpdate() on the embedded driver will be fixed as part of DERBY-501.

Derbyall didn't show any failures with the patch. Please review. Thanks!

Knut Anders Hatlen made changes - 13/Jun/06 06:38 PM
Attachment derby-1314-v1.stat [ 12335378 ]
Attachment derby-1314-v1.diff [ 12335377 ]
Knut Anders Hatlen added a comment - 13/Jun/06 06:50 PM
Proposal for release note (DERBY-501 and DERBY-1314):

The behaviour of executeQuery() and executeUpdate() has been modified
to follow the JDBC standard when executing stored procedures. For the
embedded driver, this means that

  a) it is now possible to use executeQuery() to execute a stored
     procedure that returns exactly one ResultSet (this would fail in
     previous releases of Derby)

  b) executeUpdate() will raise an exception if it is used to execute
     a stored procedure that returns one or more ResultSets (this
     would succeed in previous releases of Derby)

For the client driver, the following has changed:

  a) PreparedStatement.executeUpdate() will raise an exception if it
     is used to execute a stored procedure that returns one or more
     ResultSets (previously, it would succeed, whereas Statement and
     CallableStatement correctly raised an exception)

  b) executeUpdate() will return 0 when executing a stored procedure
     which doesn't return a ResultSet (previously it would return -1)

Knut Anders Hatlen made changes - 13/Jun/06 06:50 PM
Derby Info [Patch Available, Release Note Needed]
Repository Revision Date User Message
ASF #414795 Fri Jun 16 10:17:14 UTC 2006 kahatlen DERBY-501: Client and embedded drivers differ on invoking a procedure
that returns a single Dynamic resultSet using CallableStatement.executeQuery()

This patch modifies EmbedStatement.processDynamicResults() so that it
returns the number of dynamic results instead of a
boolean. EmbedStatement.executeStatement() uses this number to decide
whether an exception is to be raised. With this change, the
executeQuery and executeUpdate parameters are no longer needed in
GenericPreparedStatement.execute().

ProcedureTest.junit is now enabled in derbyall (all frameworks). Seven
of the test cases run in the embedded framework only, but I expect all
of them to succeed with the client driver after DERBY-1314 and
DERBY-1364 have been fixed.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/PreparedStatement.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java

Knut Anders Hatlen made changes - 21/Jun/06 08:22 PM
Status Open [ 1 ] In Progress [ 3 ]
Knut Anders Hatlen added a comment - 21/Jun/06 08:25 PM
Does anyone have comments to the patch? If not, I plan to commit in a couple of days.

Repository Revision Date User Message
ASF #416696 Fri Jun 23 12:19:51 UTC 2006 kahatlen DERBY-1314: Differences between client and embedded when invoking
stored procedures using Statement.executeUpdate()

Make executeUpdate() return 0 on the client when executing a stored
procedure.
Files Changed
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java

Knut Anders Hatlen added a comment - 23/Jun/06 07:23 PM
Committed revision 416696.

Knut Anders Hatlen made changes - 23/Jun/06 07:23 PM
Status In Progress [ 3 ] Closed [ 6 ]
Resolution Fixed [ 1 ]
Fix Version/s 10.2.0.0 [ 11187 ]
Knut Anders Hatlen added a comment - 18/Sep/06 03:26 PM
PROBLEM

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

SYMPTOMS

(1) 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.

(2) 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.

(3) 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.

Repository Revision Date User Message
ASF #447505 Mon Sep 18 19:06:53 UTC 2006 rhillegas DERBY-1860: Incorporate release notes for DERBY-1295, DERBY-1314, and DERBY-1323 submitted by Fernanda, Knut Anders, and Dag.
Files Changed
MODIFY /db/derby/code/branches/10.2/RELEASE-NOTES.html