db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1717646 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/SystemProcedures.java testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
Date Wed, 02 Dec 2015 14:58:03 GMT
Author: rhillegas
Date: Wed Dec  2 14:58:02 2015
New Revision: 1717646

URL: http://svn.apache.org/viewvc?rev=1717646&view=rev
Log:
DERBY-6725: Canonicalize the database names returned by syscs_get_database_name(); comit derby-6725-02-aa-canonicalize.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=1717646&r1=1717645&r2=1717646&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Wed Dec
 2 14:58:02 2015
@@ -47,6 +47,8 @@ import org.apache.derby.iapi.security.Se
 import org.apache.derby.iapi.security.SecurityUtil;
 import org.apache.derby.iapi.services.cache.CacheManager;
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.services.monitor.ModuleFactory;
+import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.property.PropertyUtil;
 import org.apache.derby.iapi.sql.conn.Authorizer;
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
@@ -2489,11 +2491,13 @@ public class SystemProcedures  {
      * @throws SQLException
      */
     public static String SYSCS_GET_DATABASE_NAME()
-            throws SQLException
+        throws SQLException
     {
         //DERBY-6725(Add a system function which returns the name of the database.)
         LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
-        return(lcc.getDbname());
+        try {
+            return( getMonitor().getCanonicalServiceName( lcc.getDbname() ) );
+        } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); }
     }
 
     /**
@@ -2528,4 +2532,21 @@ public class SystemProcedures  {
         } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); }
     }
 
+    /**
+     * Helper routine which looks up the monitor.
+     */
+    private static  ModuleFactory  getMonitor()
+    {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ModuleFactory>()
+             {
+                 public ModuleFactory run()
+                 {
+                     return Monitor.getMonitor();
+                 }
+             }
+             );
+    }
+
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java?rev=1717646&r1=1717645&r2=1717646&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
Wed Dec  2 14:58:02 2015
@@ -21,12 +21,14 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import java.io.File;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import junit.framework.Test;
 
+import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -58,10 +60,14 @@ public class Derby6725GetDatabaseName ex
     }
     
     private void checkDbName(Connection conn, String expectedDbName) throws SQLException
{
+        File    systemDir = new File( "system" );
+        File    dbDir = new File( systemDir, expectedDbName );
+        String  databasePath = PrivilegedFileOpsForTests.getAbsolutePath( dbDir );
+
         PreparedStatement ps = conn.prepareStatement("values syscs_util.SYSCS_GET_DATABASE_NAME()");
         ResultSet rs = ps.executeQuery();
         rs.next();
-        assertEquals( rs.getString( 1 ),  expectedDbName);
+        assertEquals( databasePath, rs.getString( 1 ) );
         rs.close();
         ps.close();
     }



Mime
View raw message