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 da...@apache.org on 2009/12/16 18:56:20 UTC

svn commit: r891350 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/util/IdUtil.java testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java

Author: dag
Date: Wed Dec 16 17:56:19 2009
New Revision: 891350

URL: http://svn.apache.org/viewvc?rev=891350&view=rev
Log:
DERBY-4475 roleName isn't trimmed as expected

Patch derby-4475, which contains a single line patch contributed by
dbrosius at mebigfatguy dot com, plus some extra test cases (mine).

The patch corrects a glitch in trimming white space around role name
when provided as strings.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java?rev=891350&r1=891349&r2=891350&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java Wed Dec 16 17:56:19 2009
@@ -746,7 +746,7 @@
 	 */
 	public static String parseRoleId(String roleName) throws StandardException
 	{
-		roleName.trim();
+		roleName = roleName.trim();
 		// NONE is a special case and is not allowed with its special
 		// meaning in SET ROLE <value specification>. Even if there is
 		// a role with case normal form "NONE", we require it to be

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java?rev=891350&r1=891349&r2=891350&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java Wed Dec 16 17:56:19 2009
@@ -1060,6 +1060,23 @@
             fail("execute of set role ? failed: [foo]" + e, e);
         }
 
+        // Test that trimming works:
+        try {
+            pstmt.setString(1, " BAR ");
+            int rowcnt = pstmt.executeUpdate();
+            assertEquals("rowcount from set role ? not 0", rowcnt, 0);
+        } catch (SQLException e) {
+            fail("execute of set role ? failed: [foo]" + e, e);
+        }
+
+        try {
+            int rowcnt = conn.createStatement().executeUpdate(
+                "set role ' BAR '");
+            assertEquals("rowcount from set role ? not 0", rowcnt, 0);
+        } catch (SQLException e) {
+            fail("execute of set role ? failed: [foo]" + e, e);
+        }
+
 
         try {
             pstmt.setString(1, "");