db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r619306 - /db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java
Date Thu, 07 Feb 2008 08:46:08 GMT
Author: kristwaa
Date: Thu Feb  7 00:46:06 2008
New Revision: 619306

URL: http://svn.apache.org/viewvc?rev=619306&view=rev
Log:
DERBY-3324: JDBC statement cache implementation. Added asserts (for sane builds) to check
validity of StatementKey arguments (for instance result set holdability and concurrency).
The asserts are added because there are so many integer arguments, and they can easily be
mixed up.
Patch file: derby-3324-4a-statementkey_asserts.diff

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java?rev=619306&r1=619305&r2=619306&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/StatementKey.java
Thu Feb  7 00:46:06 2008
@@ -21,6 +21,10 @@
 
 package org.apache.derby.client.am.stmtcache;
 
+import java.sql.ResultSet;
+import java.sql.Statement;
+import org.apache.derby.shared.common.sanity.SanityManager;
+
 /**
  * A key representing a <code>java.sql.PreparedStatement</code> or a
  * <code>java.sql.CallableStatement</code>.
@@ -82,6 +86,26 @@
         this.concurrency = rsConcurrency;
         this.holdability = rsHoldability;
         this.autogeneratedKeys = autogeneratedKeys;
+        // In sane builds, make sure valid JDBC values are passed.
+        if (SanityManager.DEBUG) {
+            SanityManager.ASSERT(
+                    rsType == ResultSet.TYPE_FORWARD_ONLY ||
+                    rsType == ResultSet.TYPE_SCROLL_INSENSITIVE ||
+                    rsType == ResultSet.TYPE_SCROLL_SENSITIVE,
+                    "Invalid result set type: " + rsType);
+            SanityManager.ASSERT(
+                    rsConcurrency == ResultSet.CONCUR_READ_ONLY ||
+                    rsConcurrency == ResultSet.CONCUR_UPDATABLE,
+                    "Invalid result set concurrency: " + rsConcurrency);
+            SanityManager.ASSERT(
+                    rsHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT ||
+                    rsHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT,
+                    "Invalid result set holdability: " + rsHoldability);
+            SanityManager.ASSERT(
+                    autogeneratedKeys == Statement.NO_GENERATED_KEYS ||
+                    autogeneratedKeys == Statement.RETURN_GENERATED_KEYS,
+                    "Invalid autogenerated key value: " + autogeneratedKeys);
+        }
     }
 
     public boolean equals(Object obj) {



Mime
View raw message