db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r366544 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/conn/ engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/conn/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTe...
Date Fri, 06 Jan 2006 18:00:57 GMT
Author: bandaram
Date: Fri Jan  6 09:59:54 2006
New Revision: 366544

URL: http://svn.apache.org/viewcvs?rev=366544&view=rev
Log:
DERBY-464: Enable Grant and Revoke DDLs again that were disabled because of two test failures.

Submitted by Satheesh Bandaram (satheesh@sourcery.org)

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connect.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/connect.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java Fri Jan
 6 09:59:54 2006
@@ -125,12 +125,4 @@
 	 @exception StandardException Oops.
 	 */
    public void refresh() throws StandardException;  
-
-	/**
- 	  * @return true if the authorizer uses the SQL standard permissions (grant/revoke),
-	  *         false if the legacy Derby permissions system is used.
-	  *
-	  * @exception StandardException standard error policy.
-	 */
-	public boolean usesSqlStandardPermissions() throws StandardException;
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
Fri Jan  6 09:59:54 2006
@@ -1111,4 +1111,10 @@
 	 */
 	public String getDbname();
 
+	/**
+	 * Check if in SQL standard mode, with support for Grant & Revoke
+	 *
+	 * @return True if SQL standard permissions are being used
+	 */
+	public boolean usesSqlStandardPermissions();
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
Fri Jan  6 09:59:54 2006
@@ -693,18 +693,14 @@
 		requiredColumnPrivileges = null;
 		requiredTablePrivileges = null;
 		requiredRoutinePrivileges = null;
-		try
+		LanguageConnectionContext lcc = (LanguageConnectionContext)
+		getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
+		if( lcc.usesSqlStandardPermissions())
 		{
-			LanguageConnectionContext lcc = (LanguageConnectionContext)
-			getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
-			if( lcc.getAuthorizer().usesSqlStandardPermissions())
-			{
-				requiredColumnPrivileges = new HashMap();
-				requiredTablePrivileges = new HashMap();
-				requiredRoutinePrivileges = new HashMap();
-			}
+			requiredColumnPrivileges = new HashMap();
+			requiredTablePrivileges = new HashMap();
+			requiredRoutinePrivileges = new HashMap();
 		}
-		catch( StandardException se){}
 	} // end of initRequiredPriv
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Jan
 6 09:59:54 2006
@@ -326,7 +326,7 @@
     */
 	private void checkSqlStandardAccess( String command) throws StandardException
 	{
-		if( getLanguageConnectionContext().getAuthorizer().usesSqlStandardPermissions())
+		if( getLanguageConnectionContext().usesSqlStandardPermissions())
 			return;
 
 		throw StandardException.newException(SQLState.LANG_GRANT_REVOKE_WITH_LEGACY_ACCESS,
@@ -11736,8 +11736,7 @@
 {
 	<EXTERNAL> <SECURITY>
 	{
-		// GrantRevoke TODO: This needs to check for 10.2 version
-		checkVersion( DataDictionary.DD_VERSION_DERBY_10_1, "EXTERNAL SECURITY");
+		checkVersion( DataDictionary.DD_VERSION_DERBY_10_2, "EXTERNAL SECURITY");
 		checkSqlStandardAccess( "EXTERNAL SECURITY");
 	}
 	( invocationType = securityDefinerInvoker())
@@ -11771,8 +11770,7 @@
 {
 	<GRANT>
 	{
-		// GrantRevoke TODO: This needs to check for 10.2 version
-		checkVersion( DataDictionary.DD_VERSION_DERBY_10_1, "GRANT");
+		checkVersion( DataDictionary.DD_VERSION_DERBY_10_2, "GRANT");
 		checkSqlStandardAccess( "GRANT");
 	}
 	( node = tableGrantStatement() | node = routineGrantStatement() )

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
Fri Jan  6 09:59:54 2006
@@ -284,21 +284,4 @@
 		if (userAccessLevel == NO_ACCESS)
 			throw StandardException.newException(SQLState.AUTH_DATABASE_CONNECTION_REFUSED);
 	}
-
-    public boolean usesSqlStandardPermissions() throws StandardException
-    {
-		// GrantRevoke TODO: Disabling this mode because of two failing tests.
-		if (true)
-		return false;
-
-		// RESOLVE use getDefaultAccessLevel() when SQL standard permissions are fully implemented
-		// GrantRevoke TODO: May need to make database property value override system value
-		PersistentSet tc = lcc.getTransactionExecute();
-		String modeS = (String)
-		PropertyUtil.getServiceProperty(tc,
-									Property.DEFAULT_CONNECTION_MODE_PROPERTY);
-		if( modeS == null)
-            return false;
-		return StringUtil.SQLEqualsIgnoreCase(modeS, Property.SQL_STANDARD_ACCESS);
-    } // end of usesSqlStandardPermissions
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Fri Jan  6 09:59:54 2006
@@ -188,6 +188,7 @@
 	protected String userName = null; //The name the user connects with.
 	                                  //May still be quoted.
 	
+	protected boolean usesSqlPermissions = false;
 	protected SchemaDescriptor	sd;
 
 	// RESOLVE - How do we want to set the default.
@@ -302,6 +303,13 @@
 					"derby.language.logQueryPlan");
 		logQueryPlan = Boolean.valueOf(logQueryPlanProperty).booleanValue();
 
+		// GrantRevoke TODO: May need to make database property value override system value
+		String modeS = PropertyUtil.getServiceProperty(getTransactionCompile(),
+									Property.DEFAULT_CONNECTION_MODE_PROPERTY);
+		if (modeS != null &&
+			 StringUtil.SQLEqualsIgnoreCase(modeS, Property.SQL_STANDARD_ACCESS))
+			usesSqlPermissions = true;
+
 		setRunTimeStatisticsMode(logQueryPlan);
 
 		lockEscalationThreshold = 
@@ -395,6 +403,14 @@
 	public boolean getLogQueryPlan()
 	{
 		return logQueryPlan;
+	}
+
+	/**
+	 * @see LanguageConnectionContext#usesSqlStandardPermissions
+	 */
+	public boolean usesSqlStandardPermissions()
+	{
+		return usesSqlPermissions;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connect.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connect.out?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connect.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connect.out
Fri Jan  6 09:59:54 2006
@@ -29,4 +29,14 @@
 ij> -- and this should succeed (no database name in URL)
 connect 'jdbc:derby:;databaseName=wombat';
 ij> disconnect;
+ij> -- Doing some simple grant/revoke negative tests in legacy database.
+-- All should fail with errors.
+connect 'jdbc:derby:wombat';
+ij> create table mytab(i int);
+0 rows inserted/updated/deleted
+ij> grant select on mytab to satheesh;
+ERROR 42Z60: GRANT not allowed unless database property derby.database.defaultConnectionMode
has value 'sqlStandard'.
+ij> revoke select on mytab to satheesh;
+ERROR 42Z60: REVOKE not allowed unless database property derby.database.defaultConnectionMode
has value 'sqlStandard'.
+ij> disconnect;
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/connect.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/connect.sql?rev=366544&r1=366543&r2=366544&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/connect.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/connect.sql
Fri Jan  6 09:59:54 2006
@@ -26,3 +26,13 @@
 -- and this should succeed (no database name in URL)
 connect 'jdbc:derby:;databaseName=wombat';
 disconnect;
+
+-- Doing some simple grant/revoke negative tests in legacy database.
+-- All should fail with errors.
+
+connect 'jdbc:derby:wombat';
+create table mytab(i int);
+
+grant select on mytab to satheesh;
+revoke select on mytab to satheesh;
+disconnect;



Mime
View raw message