db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r889876 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Sat, 12 Dec 2009 01:22:51 GMT
Author: rhillegas
Date: Sat Dec 12 01:22:50 2009
New Revision: 889876

URL: http://svn.apache.org/viewvc?rev=889876&view=rev
Log:
DERBY-651: Add dependencies of views on UDTs.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?rev=889876&r1=889875&r2=889876&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Sat
Dec 12 01:22:50 2009
@@ -1639,6 +1639,21 @@
     }
 
     /**
+     * Declare a dependency on a type. This is only used if the type is an ANSI UDT.
+     *
+     * @param dtd Type which may have a dependency declared on it.
+     */
+    public void createTypeDependency( DataTypeDescriptor dtd ) throws StandardException
+    {
+        AliasDescriptor ad = getDataDictionary().getAliasDescriptorForUDT( null, dtd );
+
+        if ( ad != null )
+        {
+            getCompilerContext().createDependency( ad );
+        }
+    }
+    
+    /**
      * Common code for the 2 checkReliability functions.  Always throws StandardException.
      *
      * @param fragmentType Type of fragment as a string, for inclusion in error messages.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=889876&r1=889875&r2=889876&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
Sat Dec 12 01:22:50 2009
@@ -271,6 +271,10 @@
 				optimizeDomainValueConversion();
 			
 			TypeDescriptor returnType = routineInfo.getReturnType();
+
+            // create type dependency if return type is an ANSI UDT
+            if ( returnType != null ) { createTypeDependency( DataTypeDescriptor.getType(
returnType ) ); }
+
 			if ( returnType != null && !returnType.isRowMultiSet() && !returnType.isUserDefinedType()
)
 			{
 				TypeId returnTypeId = TypeId.getBuiltInTypeId(returnType.getJDBCTypeId());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=889876&r1=889875&r2=889876&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Sat Dec
12 01:22:50 2009
@@ -287,6 +287,9 @@
 	public void setType(DataTypeDescriptor dataTypeServices) throws StandardException
 	{
 		this.dataTypeServices = dataTypeServices;
+
+        // create a dependency on this type if it is an ANSI UDT
+        if ( dataTypeServices != null ) { createTypeDependency( dataTypeServices ); }
 	}
 	
 	/**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java?rev=889876&r1=889875&r2=889876&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
Sat Dec 12 01:22:50 2009
@@ -46,6 +46,7 @@
     public Timestamp timeInstant;
 
     // methods to be registered as functions
+    public static Price makePrice( ) { return new Price( "USD", new BigDecimal( 1 ), DEFAULT_TIMESTAMP
); }
     public static Price makePrice( String currencyCode, BigDecimal amount, Timestamp timeInstant
) { return new Price( currencyCode, amount, timeInstant ); }
     public static String getCurrencyCode( Price price ) { return price.currencyCode; }
     public static BigDecimal getAmount( Price price ) { return price.amount; }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java?rev=889876&r1=889875&r2=889876&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
Sat Dec 12 01:22:50 2009
@@ -52,6 +52,7 @@
     public static final String NONEXISTENT_OBJECT = "42Y55";
     public static final String SYNTAX_ERROR = "42X01";
     public static final String TABLE_DEPENDS_ON_TYPE = "X0Y29";
+    public static final String VIEW_DEPENDS_ON_TYPE = "X0Y23";
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
@@ -412,6 +413,68 @@
               "drop type price_orphan4 restrict\n" );
     }
     
+    /**
+     * <p>
+     * Dependencies of views on UDTs.
+     * </p>
+     */
+    public void test_05_viewDependencies() throws Exception
+    {
+        Connection conn = getConnection();
+
+        // view with UDT in select list
+        goodStatement
+            ( conn,
+              "create type price_05_a external name 'org.apache.derbyTesting.functionTests.tests.lang.Price'
language java\n" );
+        goodStatement
+            (
+             conn,
+             "create function makePrice_05( )\n" +
+             "returns price_05_a language java parameter style java no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.makePrice'\n"
+              );
+        goodStatement
+            (
+             conn,
+             "create view udtView( a, b, c ) as\n" +
+             "select tabletype, makePrice_05( ), makePrice_05( )\n" +
+             "from sys.systables\n"
+              );
+        expectExecutionError( conn, VIEW_DEPENDS_ON_TYPE, "drop type price_05_a restrict\n"
);
+        goodStatement
+            ( conn,
+              "drop view udtView\n" );
+        goodStatement
+            ( conn,
+              "drop type price_05_a restrict\n" );
+
+        // view with UDT in where clause
+        goodStatement
+            ( conn,
+              "create type price_05_b external name 'org.apache.derbyTesting.functionTests.tests.lang.Price'
language java\n" );
+        goodStatement
+            (
+             conn,
+             "create function makePrice_05_b( )\n" +
+             "returns price_05_b language java parameter style java no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.makePrice'\n"
+              );
+        goodStatement
+            (
+             conn,
+             "create view udtView_b( a ) as\n" +
+             "select tabletype from sys.systables where makePrice_05_b() is not null\n"
+              );
+        expectExecutionError( conn, VIEW_DEPENDS_ON_TYPE, "drop type price_05_b restrict\n"
);
+        goodStatement
+            ( conn,
+              "drop view udtView_b\n" );
+        goodStatement
+            ( conn,
+              "drop type price_05_b restrict\n" );
+
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // MINIONS



Mime
View raw message