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 bp...@apache.org on 2006/09/20 03:34:21 UTC
svn commit: r448026 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/DropViewNode.java
testing/org/apache/derbyTesting/functionTests/master/views.out
testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql
Author: bpendleton
Date: Tue Sep 19 18:34:21 2006
New Revision: 448026
URL: http://svn.apache.org/viewvc?view=rev&rev=448026
Log:
DERBY-1304: DROP VIEW does not always completely remove view
This patch was contributed by Yip Ng (yipng168@gmail.com)
The problem is that DROP VIEW's binding logic is using its superclass
QueryTreeNode's bind() method which just simply returns the object itself.
So there is no actual binding done in DROP VIEW at all! It should have
created a dependency on the statement, so when its associated descriptor
gets dropped, the statement can be invalidated accordingly. This explains
why the second DROP VIEW fails since it is not invalidated by the system.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java?view=diff&rev=448026&r1=448025&r2=448026
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java Tue Sep 19 18:34:21 2006
@@ -30,8 +30,10 @@
import org.apache.derby.iapi.sql.ResultSet;
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.services.sanity.SanityManager;
@@ -63,6 +65,36 @@
return "DROP VIEW";
}
+ /**
+ * Bind the drop view node
+ *
+ * @return The bound query tree
+ *
+ * @exception StandardException Thrown on error
+ */
+
+ public QueryTreeNode bind() throws StandardException
+ {
+ DataDictionary dd = getDataDictionary();
+ CompilerContext cc = getCompilerContext();
+
+ TableDescriptor td = dd.getTableDescriptor(getRelativeName(),
+ getSchemaDescriptor());
+
+ /*
+ * Statement is dependent on the TableDescriptor
+ * If td is null, let execution throw the error like
+ * it is before.
+ */
+ if (td != null)
+ {
+ cc.createDependency(td);
+ }
+
+ return this;
+ }
+
+
// inherit generate() method from DDLStatementNode
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out?view=diff&rev=448026&r1=448025&r2=448026
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out Tue Sep 19 18:34:21 2006
@@ -340,4 +340,32 @@
0 rows inserted/updated/deleted
ij> -- reset autocommit
autocommit on;
+ij> -- DERBY-1304
+-- view not getting dropped
+-- The second drop view statement fails before the patch
+CREATE SCHEMA TEST_SCHEMA;
+0 rows inserted/updated/deleted
+ij> CREATE TABLE TEST_SCHEMA.T1 (TABLE_COLUMN LONG VARCHAR);
+0 rows inserted/updated/deleted
+ij> CREATE VIEW TEST_SCHEMA.V1 AS SELECT TABLE_COLUMN AS VIEW_COLUMN FROM TEST_SCHEMA.T1;
+0 rows inserted/updated/deleted
+ij> DROP VIEW TEST_SCHEMA.V1;
+0 rows inserted/updated/deleted
+ij> DROP TABLE TEST_SCHEMA.T1;
+0 rows inserted/updated/deleted
+ij> DROP SCHEMA TEST_SCHEMA RESTRICT;
+0 rows inserted/updated/deleted
+ij> -- reiterate
+CREATE SCHEMA TEST_SCHEMA;
+0 rows inserted/updated/deleted
+ij> CREATE TABLE TEST_SCHEMA.T1 (TABLE_COLUMN LONG VARCHAR);
+0 rows inserted/updated/deleted
+ij> CREATE VIEW TEST_SCHEMA.V1 AS SELECT TABLE_COLUMN AS VIEW_COLUMN FROM TEST_SCHEMA.T1;
+0 rows inserted/updated/deleted
+ij> DROP VIEW TEST_SCHEMA.V1;
+0 rows inserted/updated/deleted
+ij> DROP TABLE TEST_SCHEMA.T1;
+0 rows inserted/updated/deleted
+ij> DROP SCHEMA TEST_SCHEMA RESTRICT;
+0 rows inserted/updated/deleted
ij>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql?view=diff&rev=448026&r1=448025&r2=448026
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql Tue Sep 19 18:34:21 2006
@@ -163,3 +163,23 @@
-- reset autocommit
autocommit on;
+
+-- DERBY-1304
+-- view not getting dropped
+-- The second drop view statement fails before the patch
+CREATE SCHEMA TEST_SCHEMA;
+CREATE TABLE TEST_SCHEMA.T1 (TABLE_COLUMN LONG VARCHAR);
+CREATE VIEW TEST_SCHEMA.V1 AS SELECT TABLE_COLUMN AS VIEW_COLUMN FROM TEST_SCHEMA.T1;
+
+DROP VIEW TEST_SCHEMA.V1;
+DROP TABLE TEST_SCHEMA.T1;
+DROP SCHEMA TEST_SCHEMA RESTRICT;
+
+-- reiterate
+CREATE SCHEMA TEST_SCHEMA;
+CREATE TABLE TEST_SCHEMA.T1 (TABLE_COLUMN LONG VARCHAR);
+CREATE VIEW TEST_SCHEMA.V1 AS SELECT TABLE_COLUMN AS VIEW_COLUMN FROM TEST_SCHEMA.T1;
+
+DROP VIEW TEST_SCHEMA.V1;
+DROP TABLE TEST_SCHEMA.T1;
+DROP SCHEMA TEST_SCHEMA RESTRICT;