You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2014/11/13 03:39:40 UTC
svn commit: r1639238 - in /db/derby/code/branches/10.10: ./
java/client/org/apache/derby/client/am/
java/client/org/apache/derby/client/net/
java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Author: mamta
Date: Thu Nov 13 02:39:40 2014
New Revision: 1639238
URL: http://svn.apache.org/r1639238
Log:
DERBY-6228 (DisconnectException when executing an SELECT [LOB column] ORDER BY [...] statement with TYPE_SCROLL_[IN]SENSITIVE and CONCUR_UPDATABLE)
Back porting the changes to 10.10. The only issue was that the original commit to trunk(subsequent backport to 10.11) changed file java/client/org/apache/derby/client/am/ClientResultSet.java which does not exist in 10.10. The corresponding file in 10.10 is java/client/org/apache/derby/client/am/ResultSet.java. I have hand done the changes into ResultSet.java to copy the changes made in ClientResultSet.java.
junit and derbyall ran fine
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/LOBStateTracker.java
db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/ResultSet.java
db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/Sqlca.java
db/derby/code/branches/10.10/java/client/org/apache/derby/client/net/NetResultSetReply.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1537881
Modified: db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/LOBStateTracker.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/LOBStateTracker.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/LOBStateTracker.java (original)
+++ db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/LOBStateTracker.java Thu Nov 13 02:39:40 2014
@@ -104,7 +104,9 @@ class LOBStateTracker {
*/
void checkCurrentRow(Cursor cursor)
throws SqlException {
- if (this.doRelease) {
+ // If we are on a delete hole, there are no locators to release, and
+ // trying to release them will cause an error. See DERBY-6228.
+ if (this.doRelease && !cursor.getIsUpdateDeleteHole()) {
CallableLocatorProcedures procs = cursor.getLocatorProcedures();
for (int i=0; i < this.columns.length; i++) {
// Note the conversion from 1-based to 0-based index when
Modified: db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/ResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/ResultSet.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/ResultSet.java (original)
+++ db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/ResultSet.java Thu Nov 13 02:39:40 2014
@@ -131,6 +131,7 @@ public abstract class ResultSet implemen
// and getter methods cannot be called.
// Also, if a cursor is exhausted (+100), the cursor position is invalid.
public boolean isValidCursorPosition_ = false;
+ private boolean savedIsValidCursorPosition_ = false;
public boolean cursorHold_;
@@ -373,7 +374,6 @@ public abstract class ResultSet implemen
// else
// fetch the next rowset from the server
else {
-
// These flags will only be used for dynamic cursors where we don't know the row count
// and can't keep track of the absolute position of the cursor.
isAfterLast_ = false;
@@ -3769,9 +3769,21 @@ public abstract class ResultSet implemen
checkForUpdatableResultSet("moveToInsertRow");
resetUpdatedColumnsForInsert();
-
+
+ // Note that even though we navigate "away" from the current row
+ // we do not clean up the current row (i.e. release locators), so
+ // locators will still be valid when returning to the current row.
+ // See DERBY-6228.
isOnInsertRow_ = true;
isOnCurrentRow_ = false;
+
+ // It is possible to navigate from a row for which
+ // isValidCursorPosition_==false to the insert row. By
+ // saving the old value here we can restore it when leaving
+ // the insert row. This is important since attempting to
+ // release locators for a non-valid cursor position will trigger
+ // an error on the server. See DERBY-6228.
+ savedIsValidCursorPosition_ = isValidCursorPosition_;
isValidCursorPosition_ = true;
}
}
@@ -3814,7 +3826,8 @@ public abstract class ResultSet implemen
if (currentRowInRowset_ > 0) {
updateColumnInfoFromCache();
}
- isValidCursorPosition_ = true;
+ // Restore the old value when leaving the insert row. See DERBY-6228.
+ isValidCursorPosition_ = savedIsValidCursorPosition_;
}
if (isValidCursorPosition_) {
// isOnInsertRow must be false here.
@@ -5430,7 +5443,6 @@ public abstract class ResultSet implemen
private final int checkRowsetSqlca(int row) throws SqlException {
int sqlcode = 0;
if (!isRowsetCursor_ || rowsetSqlca_ == null || rowsetSqlca_[row] == null) {
- warnings_ = null; // clear any previous warnings
return sqlcode;
}
Modified: db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/Sqlca.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/Sqlca.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/Sqlca.java (original)
+++ db/derby/code/branches/10.10/java/client/org/apache/derby/client/am/Sqlca.java Thu Nov 13 02:39:40 2014
@@ -277,7 +277,10 @@ public abstract class Sqlca {
synchronized (connection_) {
try {
cs = connection_.prepareMessageProc("call SYSIBM.SQLCAMESSAGE(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
-
+ // Cannot let this statement commit the transaction. Otherwise,
+ // calling getWarnings while navigating a ResultSet will
+ // release and invalidate locators used by the cursor.
+ cs.isAutoCommittableStatement_ = false;
String errmc = null;
String sqlState = null;
Modified: db/derby/code/branches/10.10/java/client/org/apache/derby/client/net/NetResultSetReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/client/org/apache/derby/client/net/NetResultSetReply.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/client/org/apache/derby/client/net/NetResultSetReply.java (original)
+++ db/derby/code/branches/10.10/java/client/org/apache/derby/client/net/NetResultSetReply.java Thu Nov 13 02:39:40 2014
@@ -122,6 +122,10 @@ public class NetResultSetReply extends N
}
peekCP = peekCodePoint();
+ if (peekCP == CodePoint.SQLCARD) {
+ NetSqlca netSqlca = parseSQLCARD(((ResultSet) resultSetI).rowsetSqlca_);
+ resultSetI.completeSqlca(netSqlca);
+ }
if (peekCP == CodePoint.RDBUPDRM) {
parseRDBUPDRM();
peekCP = peekCodePoint();
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java Thu Nov 13 02:39:40 2014
@@ -421,11 +421,12 @@ public class ConcurrencyTest extends SUR
ps2.executeUpdate();
con2.commit();
- ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?)");
+ ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?,?)");
ps2.setInt(1, firstKey);
ps2.setInt(2, -1);
ps2.setInt(3, -1);
ps2.setString(4, "UPDATED TUPLE");
+ ps2.setString(5, "UPDATED CLOB");
assertEquals("Expected one record to be inserted", 1,
ps2.executeUpdate());
println("T4: Inserted record (" + firstKey + ",-1,-1)" );
@@ -505,11 +506,12 @@ public class ConcurrencyTest extends SUR
con2.commit();
println("T3: commit");
- ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?)");
+ ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?,?)");
ps2.setInt(1, firstKey);
ps2.setInt(2, valA);
ps2.setInt(3, valB);
ps2.setString(4, "UPDATE TUPLE " + firstKey);
+ ps2.setString(5, "UPDATED CLOB " + firstKey);
assertEquals("Expected one record to be inserted", 1,
ps2.executeUpdate());
println("T4: Inserted record (" + firstKey + "," + valA + "," +
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java Thu Nov 13 02:39:40 2014
@@ -473,7 +473,7 @@ public class HoldabilityTest extends SUR
// Now reinsert the tuples:
PreparedStatement ps =
- prepareStatement("insert into t1 values (?,?,?,?)");
+ prepareStatement("insert into t1 values (?,?,?,?,?)");
for (int i=0; i<recordCount*2; i++) {
int recordId = i + recordCount + 1000;
@@ -481,6 +481,7 @@ public class HoldabilityTest extends SUR
ps.setInt(2, recordId);
ps.setInt(3, recordId *2 + 17);
ps.setString(4, "m" + recordId);
+ ps.setString(5, "c"+recordId);
ps.addBatch();
}
ps.executeBatch();
@@ -544,7 +545,7 @@ public class HoldabilityTest extends SUR
// Now reinsert the tuples:
PreparedStatement ps =
- prepareStatement("insert into t1 values (?,?,?,?)");
+ prepareStatement("insert into t1 values (?,?,?,?,?)");
for (int i=0; i<recordCount*2; i++) {
int recordId = i + recordCount + 1000;
@@ -552,6 +553,7 @@ public class HoldabilityTest extends SUR
ps.setInt(2, recordId);
ps.setInt(3, recordId *2 + 17);
ps.setString(4, "m" + recordId);
+ ps.setString(5, "c" + recordId);
ps.addBatch();
}
ps.executeBatch();
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java Thu Nov 13 02:39:40 2014
@@ -66,8 +66,8 @@ abstract public class SURBaseTest extend
int b = rs.getInt(3);
int sum = a + id + 17;
println("Reading tuple:(" + id + "," + a + "," + b + ",'" +
- rs.getString(4) + "')");
- assertEquals("Expecting b==id+a+17", b, sum);
+ rs.getString(4) + "', '"+rs.getString(5)+"'");
+ assertEquals("Expecting b==id+a+17", sum, b);
}
/**
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java?rev=1639238&r1=1639237&r2=1639238&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java Thu Nov 13 02:39:40 2014
@@ -79,13 +79,14 @@ public class SURDataModelSetup extends B
/** Populate with data */
PreparedStatement ps = con.
- prepareStatement("insert into t1 values (?,?,?,?)");
+ prepareStatement("insert into t1 values (?,?,?,?,?)");
for (int i=0; i<records; i++) {
ps.setInt(1, i);
ps.setInt(2, i);
ps.setInt(3, i*2 + 17);
ps.setString(4, "Tuple " +i);
+ ps.setString(5, "C-tuple "+i);
ps.addBatch();
}
ps.executeBatch();
@@ -204,8 +205,8 @@ public class SURDataModelSetup extends B
*/
public String getCreateTableStatement() {
return hasPrimaryKey()
- ? "create table t1 (id int primary key, a int, b int, c varchar(5000))"
- : "create table t1 (id int, a int, b int, c varchar(5000))";
+ ? "create table t1 (id int primary key, a int, b int, c varchar(5000), d clob)"
+ : "create table t1 (id int, a int, b int, c varchar(5000), d clob)";
}
/**