db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1651284 - in /db/derby/code/trunk/java: build/org/apache/derbyBuild/lastgoodjarcontents/ engine/org/apache/derby/catalog/ engine/org/apache/derby/impl/sql/catalog/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/de...
Date Tue, 13 Jan 2015 06:37:08 GMT
Author: mamta
Date: Tue Jan 13 06:37:08 2015
New Revision: 1651284

URL: http://svn.apache.org/r1651284
Log:
DERBY-6725(Add a system function which returns the name of the database.)


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
  (with props)
Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/insane.derbyTesting.jar.lastcontents
    db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/sane.derbyTesting.jar.lastcontents
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/insane.derbyTesting.jar.lastcontents
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/insane.derbyTesting.jar.lastcontents?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/insane.derbyTesting.jar.lastcontents
(original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/insane.derbyTesting.jar.lastcontents
Tue Jan 13 06:37:08 2015
@@ -313,6 +313,7 @@ org.apache.derbyTesting.functionTests.te
 org.apache.derbyTesting.functionTests.tests.lang.Derby5866TriggerOrderTest.class
 org.apache.derbyTesting.functionTests.tests.lang.Derby6131.class
 org.apache.derbyTesting.functionTests.tests.lang.Derby6587Test.class
+org.apache.derbyTesting.functionTests.tests.lang.Derby6725GetDatabaseName.class
 org.apache.derbyTesting.functionTests.tests.lang.DistinctTest.class
 org.apache.derbyTesting.functionTests.tests.lang.DropTableTest.class
 org.apache.derbyTesting.functionTests.tests.lang.DummyAwareVTI.class

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/sane.derbyTesting.jar.lastcontents
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/sane.derbyTesting.jar.lastcontents?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/sane.derbyTesting.jar.lastcontents
(original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/lastgoodjarcontents/sane.derbyTesting.jar.lastcontents
Tue Jan 13 06:37:08 2015
@@ -313,6 +313,7 @@ org.apache.derbyTesting.functionTests.te
 org.apache.derbyTesting.functionTests.tests.lang.Derby5866TriggerOrderTest.class
 org.apache.derbyTesting.functionTests.tests.lang.Derby6131.class
 org.apache.derbyTesting.functionTests.tests.lang.Derby6587Test.class
+org.apache.derbyTesting.functionTests.tests.lang.Derby6725GetDatabaseName.class
 org.apache.derbyTesting.functionTests.tests.lang.DistinctTest.class
 org.apache.derbyTesting.functionTests.tests.lang.DropTableTest.class
 org.apache.derbyTesting.functionTests.tests.lang.DummyAwareVTI.class

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=1651284&r1=1651283&r2=1651284&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 Tue Jan
13 06:37:08 2015
@@ -2489,7 +2489,20 @@ public class SystemProcedures  {
             return IdUtil.getUserAuthorizationId( userName );
         } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); }
     }
-  
+
+    /**
+     * Return the database name
+     * @return database name
+     * @throws SQLException
+     */
+    public static String SYSCS_GET_DATABASE_NAME()
+            throws SQLException
+    {
+        //DERBY-6725(Add a system function which returns the name of the database.)
+        LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
+        return(lcc.getDbname());
+    }
+
     /**
      * Peek at the current value of a sequence generator without advancing it.
      *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java Tue
Jan 13 06:37:08 2015
@@ -404,7 +404,7 @@ public	class DD_Version implements	Forma
 
         if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_5)
         {
-            // On ugrade from versions before 10.6, create system procedures
+            // On upgrade from versions before 10.6, create system procedures
             // added in 10.6.
             bootingDictionary.create_10_6_system_procedures(tc,
                     newlyCreatedRoutines);
@@ -419,7 +419,7 @@ public	class DD_Version implements	Forma
 
         if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_1)
         {
-            // On ugrade from versions before 10.2, create system procedures
+            // On upgrade from versions before 10.2, create system procedures
             // added in 10.2.
             bootingDictionary.create_10_2_system_procedures(
                 tc,
@@ -447,7 +447,7 @@ public	class DD_Version implements	Forma
 
         if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_2)
         {
-            // On ugrade from versions before 10.3, create system procedures
+            // On upgrade from versions before 10.3, create system procedures
             // added in 10.3.
             bootingDictionary.create_10_3_system_procedures(tc, newlyCreatedRoutines );
         }
@@ -490,7 +490,7 @@ public	class DD_Version implements	Forma
         
         if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_8)
         {
-            // On ugrade from versions before 10.9, create system procedures
+            // On upgrade from versions before 10.9, create system procedures
             // added in 10.9.
             bootingDictionary.create_10_9_system_procedures( tc, newlyCreatedRoutines );
             
@@ -508,7 +508,7 @@ public	class DD_Version implements	Forma
 
         if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_9)
         {
-            // On ugrade from versions before 10.10, create system procedures
+            // On upgrade from versions before 10.10, create system procedures
             // added in 10.10.
             bootingDictionary.create_10_10_system_procedures( tc, newlyCreatedRoutines );
         }
@@ -522,7 +522,7 @@ public	class DD_Version implements	Forma
                 DataDictionary.SYSTRIGGERS_CATALOG_NUM).getCatalogRowFactory(),
                 new int[] { 18 }, tc);
             
-            // On ugrade from versions before 10.11, create system procedures
+            // On upgrade from versions before 10.11, create system procedures
             // added in 10.11.
             bootingDictionary.create_10_11_system_procedures( tc, newlyCreatedRoutines );
 
@@ -530,6 +530,13 @@ public	class DD_Version implements	Forma
             bootingDictionary.createIdentitySequences( tc );
         }
 
+        if (fromMajorVersionNumber <= DataDictionary.DD_VERSION_DERBY_10_11)
+        {
+            // On upgrade from versions before 10.12, create system procedures
+            // added in 10.12.
+            bootingDictionary.create_10_12_system_procedures( tc, newlyCreatedRoutines );
+        }
+
         // Grant PUBLIC access to some system routines
         bootingDictionary.grantPublicAccessToSystemRoutines(newlyCreatedRoutines, tc, aid);
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Tue Jan 13 06:37:08 2015
@@ -463,6 +463,7 @@ public final class	DataDictionaryImpl
 												"SYSCS_GET_RUNTIMESTATISTICS", 
 												"SYSCS_PEEK_AT_SEQUENCE",
 												"SYSCS_PEEK_AT_IDENTITY",
+												"SYSCS_GET_DATABASE_NAME",
 												};
 	
 	/**
@@ -11444,6 +11445,8 @@ public final class	DataDictionaryImpl
         create_10_10_system_procedures( tc, newlyCreatedRoutines );
         // add 10.11 specific system procedures
         create_10_11_system_procedures( tc, newlyCreatedRoutines );
+        // add 10.12 specific system procedures
+        create_10_12_system_procedures( tc, newlyCreatedRoutines );
     }
 
     /**
@@ -13404,6 +13407,37 @@ public final class	DataDictionaryImpl
         }
     }
 
+    /**
+     * <p>
+     * Create system procedures that are part of the SYSCS_UTIL schema, added in version
10.12.
+     * </p>
+     *
+     * @param tc an instance of the Transaction Controller.
+     * @param newlyCreatedRoutines set of routines we are creating (used to add permissions
later on)
+     **/
+    void create_10_12_system_procedures( TransactionController   tc, HashSet<String>
newlyCreatedRoutines )
+        throws StandardException
+    {
+            UUID  sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
+
+            // void SYSCS_UTIL.SYSCS_GET_DATABASE_NAME()
+            {               
+                createSystemProcedureOrFunction(
+                    "SYSCS_GET_DATABASE_NAME",
+                    sysUtilUUID,
+                    (String[]) null,
+                    (TypeDescriptor[]) null,
+                    0,
+                    0,
+                    RoutineAliasInfo.READS_SQL_DATA,
+                    false,
+                    false,
+                    DataTypeDescriptor.getCatalogType( Types.VARCHAR ),
+                    newlyCreatedRoutines,
+                    tc);
+            }
+    }
+
 
 	/*
 	** Priv block code to load net work server meta data queries.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
Tue Jan 13 06:37:08 2015
@@ -162,6 +162,7 @@ FUNCTION_SCHEM|FUNCTION_NAME
 -------------------------------------------------------------------------------
 APP           |FUNCTTEST                   |a.b.c.d.e.f                        
 SYSCS_UTIL    |SYSCS_CHECK_TABLE           |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_DATABASE_NAME     |org.apache.derby.catalog.SystemPro&
 SYSCS_UTIL    |SYSCS_GET_DATABASE_PROPERTY |org.apache.derby.catalog.SystemPro&
 SYSCS_UTIL    |SYSCS_GET_RUNTIMESTATISTICS |org.apache.derby.catalog.SystemPro&
 SYSCS_UTIL    |SYSCS_GET_USER_ACCESS       |org.apache.derby.catalog.SystemPro&

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
Tue Jan 13 06:37:08 2015
@@ -150,6 +150,9 @@ public class TestDbMetaData extends Base
         { null, "SYSCS_UTIL", "SYSCS_CHECK_TABLE",
           "org.apache.derby.catalog.SystemProcedures.SYSCS_CHECK_TABLE",
           FUNCTION_NO_TABLE_VALUE, GENERIC_NAME },
+        { null, "SYSCS_UTIL", "SYSCS_GET_DATABASE_NAME",
+          "org.apache.derby.catalog.SystemProcedures." +
+          "SYSCS_GET_DATABASE_NAME", FUNCTION_NO_TABLE_VALUE, GENERIC_NAME },
         { null, "SYSCS_UTIL", "SYSCS_GET_DATABASE_PROPERTY",
           "org.apache.derby.catalog.SystemProcedures." +
           "SYSCS_GET_DATABASE_PROPERTY", FUNCTION_NO_TABLE_VALUE, GENERIC_NAME },

Added: 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=1651284&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
Tue Jan 13 06:37:08 2015
@@ -0,0 +1,68 @@
+/*
+ * Class org.apache.derbyTesting.functionTests.tests.lang.Derby6725GetDatabaseName
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.derbyTesting.functionTests.tests.lang;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import junit.framework.Test;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class Derby6725GetDatabaseName extends BaseJDBCTestCase {
+
+    public Derby6725GetDatabaseName(String name) {
+        super(name);
+    }
+
+    /**
+     * Construct top level suite in this JUnit test
+     *
+     * @return A suite containing embedded and client suites.
+     */
+    public static Test suite()
+    {
+        Test test;
+        test = TestConfiguration.defaultSuite(Derby6725GetDatabaseName.class);
+        test = TestConfiguration.additionalDatabaseDecorator(test, "FIRSTDB1");
+        test = TestConfiguration.additionalDatabaseDecorator(test, "SECONDDB2");
+        return test;
+    }
+
+    //Make sure we get correct db name for different databases
+    public void testDatabaseName() throws SQLException {
+    	checkDbName(getConnection(), "wombat");
+    	checkDbName(openConnection("FIRSTDB1"), "singleUse/oneuse0");
+    	checkDbName(openConnection("SECONDDB2"), "singleUse/oneuse1");
+    }
+    
+    private void checkDbName(Connection conn, String expectedDbName) throws SQLException
{
+        PreparedStatement ps = conn.prepareStatement("values syscs_util.SYSCS_GET_DATABASE_NAME()");
+        ResultSet rs = ps.executeQuery();
+        rs.next();
+        assertEquals( rs.getString( 1 ),  expectedDbName);
+        rs.close();
+        ps.close();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6725GetDatabaseName.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java
Tue Jan 13 06:37:08 2015
@@ -7288,6 +7288,7 @@ public final class GrantRevokeDDLTest ex
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
+            {"PUBLIC", "TEST_DBO", "N"},
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -7330,6 +7331,7 @@ public final class GrantRevokeDDLTest ex
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
+            {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},
             {"PUBLIC", "TEST_DBO", "N"},

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=1651284&r1=1651283&r2=1651284&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
Tue Jan 13 06:37:08 2015
@@ -598,9 +598,9 @@ public class RolesTest extends BaseJDBCT
 
         assertSysColPermsRowCount(0, 2, 2);
 
-        assertSysRoutinePermsRowCount(10, // 10 pre-existing grants to PUBLIC
-                                      11,
-                                      11);
+        assertSysRoutinePermsRowCount(11, // 11 pre-existing grants to PUBLIC
+                                      12,
+                                      12);
 
         /*
          * DROP ROLE
@@ -628,12 +628,12 @@ public class RolesTest extends BaseJDBCT
                                   // to admin is de facto to a user
                                   // named admin:
                                   2);
-        assertSysRoutinePermsRowCount(10, 10,
+        assertSysRoutinePermsRowCount(11, 11,
                                       //  nonDbo run: role admin
                                       // has been dropped, so this
                                       // run's grant to admin is de
                                       // facto to a user named admin:
-                                      11);
+                                      12);
 
         doStmt("drop role \"NONE\"",
                sqlAuthorizationRequired, null , roleDboOnly);
@@ -655,7 +655,7 @@ public class RolesTest extends BaseJDBCT
                                     1,
                                     0);
         assertSysColPermsRowCount(0,0,0);
-        assertSysRoutinePermsRowCount(10,10,10);
+        assertSysRoutinePermsRowCount(11,11,11);
 
         // roles foo and bar survive to nonDbo run and beyond:
         assertSysRolesRowCount(0, 5, 5);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java?rev=1651284&r1=1651283&r2=1651284&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
Tue Jan 13 06:37:08 2015
@@ -325,10 +325,10 @@ public class Changes10_2 extends Upgrade
                     "R.GRANTOR = '"
                         + getTestConfiguration().getUserName() + "'" +
                     " ORDER BY 1");
-            
             JDBC.assertFullResultSet(rs, new String[][]
                     {{"SYSCS_COMPRESS_TABLE"},
                     {"SYSCS_DROP_STATISTICS"},
+                    {"SYSCS_GET_DATABASE_NAME"},
                     {"SYSCS_GET_RUNTIMESTATISTICS"},
                     {"SYSCS_INPLACE_COMPRESS_TABLE"},
                     {"SYSCS_MODIFY_PASSWORD"},



Mime
View raw message