db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r631569 - in /db/derby/code/trunk/java/client/org/apache/derby/client/am: CachingLogicalConnection.java CachingLogicalConnection40.java
Date Wed, 27 Feb 2008 12:06:41 GMT
Author: kristwaa
Date: Wed Feb 27 04:06:30 2008
New Revision: 631569

URL: http://svn.apache.org/viewvc?rev=631569&view=rev
Log:
DERBY-3326: Introduce a caching logical connection and logical prepared statement in the client
driver.
Fixes a bug where all statements prepared with prepareStatement(String,String[]|int[]) in
CachingLogicalConnection were returning auto-generated keys.
Patch file: derby-3326-7a-prepare_column_indexes_names_fix.diff

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection.java?rev=631569&r1=631568&r2=631569&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection.java
Wed Feb 27 04:06:30 2008
@@ -132,8 +132,12 @@
             }
             // No caching being done, but we are able to continue.
         } else {
-            ps = cacheInteractor.prepareStatement(
-                    sql, Statement.RETURN_GENERATED_KEYS);
+            int generatedKeys = Statement.RETURN_GENERATED_KEYS;
+            // If indexes is null or empty, don't return autogenerated keys.
+            if (columnIndexes == null || columnIndexes.length == 0) {
+                generatedKeys = Statement.NO_GENERATED_KEYS;
+            }
+            ps = cacheInteractor.prepareStatement(sql, generatedKeys);
         }
         return ps;
     }
@@ -161,8 +165,12 @@
             }
             // No caching being done, but we are able to continue.
         } else {
-            ps = cacheInteractor.prepareStatement(
-                    sql, Statement.RETURN_GENERATED_KEYS);
+            int generatedKeys = Statement.RETURN_GENERATED_KEYS;
+            // If names is null or empty, don't return autogenerated keys.
+            if (columnNames == null || columnNames.length == 0) {
+                generatedKeys = Statement.NO_GENERATED_KEYS;
+            }
+            ps = cacheInteractor.prepareStatement(sql, generatedKeys);
         }
         return ps;
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java?rev=631569&r1=631568&r2=631569&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java
Wed Feb 27 04:06:30 2008
@@ -127,8 +127,12 @@
             }
             // No caching being done, but we are able to continue.
         } else {
-            ps = cacheInteractor.prepareStatement(
-                    sql, Statement.RETURN_GENERATED_KEYS);
+            int generatedKeys = Statement.RETURN_GENERATED_KEYS;
+            // If indexes is null or empty, don't return autogenerated keys.
+            if (columnIndexes == null || columnIndexes.length == 0) {
+                generatedKeys = Statement.NO_GENERATED_KEYS;
+            }
+            ps = cacheInteractor.prepareStatement(sql, generatedKeys);
         }
         return ps;
     }
@@ -156,8 +160,12 @@
             }
             // No caching being done, but we are able to continue.
         } else {
-            ps = cacheInteractor.prepareStatement(
-                    sql, Statement.RETURN_GENERATED_KEYS);
+            int generatedKeys = Statement.RETURN_GENERATED_KEYS;
+            // If names is null or empty, don't return autogenerated keys.
+            if (columnNames == null || columnNames.length == 0) {
+                generatedKeys = Statement.NO_GENERATED_KEYS;
+            }
+            ps = cacheInteractor.prepareStatement(sql, generatedKeys);
         }
         return ps;
     }



Mime
View raw message