Bug #675 A call to ResultSet.getXXX while on insert row fails
Submitted: 18 Jun 2003 13:47 Modified: 19 Jun 2003 13:32
Reporter: David Marquis Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0+ OS:Any (Any)
Assigned to: Mark Matthews CPU Architecture:Any

[18 Jun 2003 13:47] David Marquis
Description:
When a Connector/J UpdatableResultSet is on the insert row (moveToInsertRow())and some calls to updateXXX() have been made, subsequent calls to getXXX() return the field values of the 'current row' (that is, the row that was selected just before the call to moveToInsertRow)

The expected getXXX behavior at this time would be to return the insert row's values.

How to repeat:
ResultSet set = conn.createStatement().execute("some select sql");

set.first();

System.out.println("'name' is " + set.getString("name"));
// *** Will output the first record's 'name' field's value.

set.moveToInsertRow();
set.updateString("name", "my new name");

System.out.println("'name' is " + set.getString("name"));
// *** Will output exactly the same thing as the first System.out

Suggested fix:
Maybe 'thisRow' (in ResultSet) should point to the insert row when calling moveToInsertRow() ?
[18 Jun 2003 14:06] David Marquis
Please refer to :

http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame5.html

"The ResultSet.moveToInsertRow() method is used to position the result set's cursor on the insert row. The ResultSet.updateXXX() and ResultSet.getXXX() methods are used to update and retrieve individual column values from the insert row. The contents of the insert row is undefined immediately after calling ResultSet.moveToInsertRow() . In other words, the value returned by calling a ResultSet.getXXX() method is undefined after moveToInsertRow() is called until the value is set by calling ResultSet.updateXXX()."
[19 Jun 2003 13:32] Mark Matthews
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

Thank you for your bug report. This is now fixed in the development trees for 3.0.x and 3.1.x. You can check out a nightly snapshot of either from http://mmmysql.sourceforge.net/snapshots/ after 00:00 GMT 20-Jun-03.