db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r630784 - in /db/derby/code/trunk/java/client/org/apache/derby/client/am: LogicalStatementEntity.java ResultSet.java Statement.java
Date Mon, 25 Feb 2008 09:55:07 GMT
Author: kristwaa
Date: Mon Feb 25 01:55:05 2008
New Revision: 630784

URL: http://svn.apache.org/viewvc?rev=630784&view=rev
Log:
DERBY-3446: Make ResultSet.getStatement return the correct statement when created by a logical
statement.
Made LogicalStatementEntity constructor set itself as the statement owner in am.Statement,
and ResultSet return the owner of the creating statement if set. If not set, the statement
itself will be returned (as before).
Patch file: derby-3446-2c_rs_getstatement_alternative.diff


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalStatementEntity.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalStatementEntity.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalStatementEntity.java?rev=630784&r1=630783&r2=630784&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalStatementEntity.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalStatementEntity.java
Mon Feb 25 01:55:05 2008
@@ -46,7 +46,8 @@
  * synchronized in the physical statement itself .
  */
 //@ThreadSafe
-class LogicalStatementEntity {
+abstract class LogicalStatementEntity
+        implements java.sql.Statement {
 
     /**
      * Tells if we're holding a callable statement or not.
@@ -103,6 +104,7 @@
             this.hasCallableStmt = false;
             this.physicalCs = null;
         }
+        ((PreparedStatement)physicalPs).setOwner(this);
     }
 
     /**
@@ -153,6 +155,9 @@
             // Nullify both references.
             physicalPs = null;
             physicalCs = null;
+
+            // Reset the owner of the physical statement.
+            temporaryPsRef.setOwner(null);
 
             // If the underlying statement has become closed, don't cache it.
             if (temporaryPsRef.isClosed()) {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java?rev=630784&r1=630783&r2=630784&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java Mon Feb 25 01:55:05
2008
@@ -3788,7 +3788,12 @@
         if (agent_.loggingEnabled()) {
             agent_.logWriter_.traceExit(this, "getStatement", statement_);
         }
-        return statement_;
+        if (statement_.getOwner() != null) {
+            return statement_.getOwner();
+        } else {
+            return statement_;
+        }
+
     }
 
     //-------------------------- JDBC 3.0 ----------------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=630784&r1=630783&r2=630784&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Mon Feb 25 01:55:05
2008
@@ -51,6 +51,8 @@
     public Section section_;
     Agent agent_;
 
+    /** The owner of this statement, if any. */
+    private java.sql.Statement owner = null;
     ResultSet resultSet_;
 
     // Use -1, if there is no update count returned, ie. when result set is returned. 0 is
a valid update count for DDL.
@@ -1561,6 +1563,23 @@
         updateCount_ = updateCount;
     }
 
+    /**
+     * Designates the owner of this statement, typically a logical statement.
+     *
+     * @param owner the owning statement, if any
+     */
+    protected final void setOwner(java.sql.Statement owner) {
+        this.owner = owner;
+    }
+
+    /**
+     * Returns the owner of this statement, if any.
+     *
+     * @return The designated owner of this statement, or {@code null} if none.
+     */
+    final java.sql.Statement getOwner() {
+        return this.owner;
+    }
 
     private boolean willTickleServer(int number, boolean allowAutoCommits) throws SqlException
{
         boolean requiresAutocommit = false;



Mime
View raw message