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 dj...@apache.org on 2005/11/18 22:25:00 UTC

svn commit: r345577 - in /db/derby/code/trunk/java: engine/org/apache/derby/diag/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/store/

Author: djd
Date: Fri Nov 18 13:24:53 2005
New Revision: 345577

URL: http://svn.apache.org/viewcvs?rev=345577&view=rev
Log:
DERBY-714 DERBY-571
Verify target table for UPDATE and DELETE for all table types, previously
VTI's were incorrectly excluded. This lead to invalid VTI table expressions
being accepted for VTIs leading to NullPointerExceptions.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TransactionTable.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TransactionTable.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java Fri Nov 18 13:24:53 2005
@@ -53,9 +53,7 @@
 	the database.
 	
 	This virtual table can be invoked by calling it directly
-	<PRE> select * from new org.apache.derby.diag.LockTable() t; </PRE>
-	or through the system alias LOCKTABLE
-	<PRE> select * from new LOCKTABLE() t; </PRE> 
+	<PRE> select * from SYSCS_DIAG.LOCK_TABLE </PRE>
 	
 	<P>The LockTable virtual table takes a snap shot of the lock table while
 	the system is in flux, so it is possible that some locks may be in

Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java Fri Nov 18 13:24:53 2005
@@ -50,9 +50,7 @@
 	
 	This virtual table can be invoked by calling it
 	directly
-	<PRE> select * from new org.apache.derby.diag.TransactionTable() t; </PRE>
-	or through the system alias TransactionTable
-	<PRE> select * from new TRANSACTIONTABLE() t; </PRE> 
+	<PRE> select * from SYSCS_DIAG.TRANSACTION_TABLE </PRE>
 
 	<P>The TransactionTable virtual table takes a snap shot of the 
 	transaction table while the system is in flux, so it is possible that some

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java Fri Nov 18 13:24:53 2005
@@ -154,7 +154,7 @@
 		CurrentRowLocationNode		rowLocationNode;
 		TableName					cursorTargetTableName = null;
 		CurrentOfNode       		currentOfNode = null;
-
+		
                 DataDictionary dataDictionary = getDataDictionary();
 		super.bindTables(dataDictionary);
 
@@ -211,12 +211,11 @@
 				}
 			}
 
-			/* descriptor must exist, tables already bound.
-			 * No need to do this for VTI as VTI was bound in
-			 * super.bindTables() above.
-			 */
-			verifyTargetTable();
+
 		}
+		
+		// descriptor must exist, tables already bound.
+		verifyTargetTable();
 
 		/* Generate a select list for the ResultSetNode - CurrentRowLocation(). */
 		if (SanityManager.DEBUG)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Fri Nov 18 13:24:53 2005
@@ -269,14 +269,13 @@
 						currentOfNode.getCursorName());
 				}
 			}
-
-			// because we verified that the tables match
-			// and we already bound the cursor or the select,
-			// the table descriptor should always be found.
-			verifyTargetTable();
 		}
-
-
+		
+		// because we verified that the tables match
+		// and we already bound the cursor or the select,
+		// the table descriptor should always be found.
+		verifyTargetTable();
+		
 		/* OVERVIEW - We generate a new ResultColumn, CurrentRowLocation(), and
 		 * prepend it to the beginning of the source ResultColumnList.  This
 		 * will tell us which row(s) to update at execution time.  However,

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TransactionTable.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TransactionTable.out?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TransactionTable.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TransactionTable.out Fri Nov 18 13:24:53 2005
@@ -231,5 +231,24 @@
 TYPE |CNT  |MODE|TABLENAME                                                                                                                       |LOCKNAME            |STATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 ij(C1)> commit;
+ij(C1)> -- ensure the system vti can not be modified.
+drop table syscs_diag.transaction_table;
+ERROR X0Y56: 'DROP TABLE' is not allowed on the System table 'SYSCS_DIAG.TRANSACTION_TABLE'.
+ij(C1)> alter table syscs_diag.transaction_table add column x int;
+ERROR 42X62: 'ALTER TABLE' is not allowed in the 'SYSCS_DIAG' schema.
+ij(C1)> update syscs_diag.transaction_table set xid = NULL;
+ERROR 42Y25: 'SYSCS_DIAG.TRANSACTION_TABLE' is a system table.  Users are not allowed to modify the contents of this table.
+ij(C1)> delete from syscs_diag.transaction_table where 1 = 1;
+ERROR 42Y25: 'SYSCS_DIAG.TRANSACTION_TABLE' is a system table.  Users are not allowed to modify the contents of this table.
+ij(C1)> insert into syscs_diag.transaction_table(xid) values('bad');
+ERROR 42Y25: 'SYSCS_DIAG.TRANSACTION_TABLE' is a system table.  Users are not allowed to modify the contents of this table.
+ij(C1)> -- ensure the old syntax still works until it is deprecated
+select xid from new org.apache.derby.diag.TransactionTable() AS t where 1 = 0;
+XID            
+---------------
+ij(C1)> update new org.apache.derby.diag.TransactionTable() set xid = NULL;
+ERROR 42X08: The constructor for class 'org.apache.derby.diag.TransactionTable' cannot be used as an external virtual table because the class does not implement 'java.sql.PreparedStatement'. 
+ij(C1)> delete from new org.apache.derby.diag.TransactionTable() where 1 = 0;
+ERROR 42X08: The constructor for class 'org.apache.derby.diag.TransactionTable' cannot be used as an external virtual table because the class does not implement 'java.sql.PreparedStatement'. 
 ij(C1)> disconnect;
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TransactionTable.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TransactionTable.sql?rev=345577&r1=345576&r2=345577&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TransactionTable.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TransactionTable.sql Fri Nov 18 13:24:53 2005
@@ -137,6 +137,18 @@
 order by lockname, mode, cnt, state;
 
 commit;
+-- ensure the system vti can not be modified.
+drop table syscs_diag.transaction_table;
+alter table syscs_diag.transaction_table add column x int;
+update syscs_diag.transaction_table set xid = NULL;
+delete from syscs_diag.transaction_table where 1 = 1;
+insert into syscs_diag.transaction_table(xid) values('bad');
+
+-- ensure the old syntax still works until it is deprecated
+select xid from new org.apache.derby.diag.TransactionTable() AS t where 1 = 0;
+update new org.apache.derby.diag.TransactionTable() set xid = NULL;
+delete from new org.apache.derby.diag.TransactionTable() where 1 = 0;
+
 disconnect;