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 2007/01/05 07:04:33 UTC

svn commit: r492919 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/catalog/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: bpendleton
Date: Thu Jan  4 22:04:32 2007
New Revision: 492919

URL: http://svn.apache.org/viewvc?view=rev&rev=492919
Log:
DERBY-1847: SELECT statement asserts with added column in sqlAuth mode

This is a follow-on patch for DERBY-1847. The problem is that
when DataDictionaryImpl.updateSYSCOLPERMSforAddColumnToUserTable
updates the SYSCOLPERMS table, it updates the table by partial
key value. That means that each time the updateRow() call is made,
the COLUMNS column in SYSCOLPERMS is updated for *all* the
SYSCOLPERMS in that particular table, not just for the particular
SYSCOLPERMS row that we are working with at that instant.

The routine uses a partial key to find all the ColPermsDescriptor
entries for this table, but when it updates those rows, it needs
to use a full key, not a partial key.

DataDictionaryImpl.updateSYSCOLPERMSforAddColumnToUserTable
actually has the correct index row available, because it's just used
that row to fetch the base table row to update. So the fix is 
to pass that index row to the ti.updateRow() call and
specify the COLPERMSID_INDEX_NUM rather than the TABLEID_INDEX_NUM.

Modified:
    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/grantRevokeDDL.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql

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?view=diff&rev=492919&r1=492918&r2=492919
==============================================================================
--- 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 Thu Jan  4 22:04:32 2007
@@ -2496,8 +2496,8 @@
 	        columns.grow(currentLength+1);
 	        curRow.setColumn(SYSCOLPERMSRowFactory.COLUMNS_COL_NUM,
 					  dvf.getDataValue((Object) columns));
-			ti.updateRow(keyRow, curRow,
-					SYSCOLPERMSRowFactory.TABLEID_INDEX_NUM,
+			ti.updateRow(uuidKey, curRow,
+					SYSCOLPERMSRowFactory.COLPERMSID_INDEX_NUM,
 					 bArray, 
 					 colsToUpdate,
 					 tc);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out?view=diff&rev=492919&r1=492918&r2=492919
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out Thu Jan  4 22:04:32 2007
@@ -3230,4 +3230,32 @@
 IJ ERROR: Unable to establish cursor
 ij(USER2)> autocommit on;
 ij(USER2)> set connection user1;
+ij(USER1)> -- Another test for DERBY-1847: verify that columns field is updated
+-- correctly when adding a column to a table:
+create table d1847_c (a int, b int, c int);
+0 rows inserted/updated/deleted
+ij(USER1)> grant select (a) on d1847_c to first_user;
+0 rows inserted/updated/deleted
+ij(USER1)> grant update (b) on d1847_c to second_user;
+0 rows inserted/updated/deleted
+ij(USER1)> grant select (c) on d1847_c to third_user;
+0 rows inserted/updated/deleted
+ij(USER1)> select c.grantee, c.type, c.columns from sys.syscolperms c, sys.systables t
+    where c.tableid = t.tableid and t.tablename='D1847_C';
+GRANTEE                                                                                                                         |&|COLUMNS        
+--------------------------------------------------------------------------------------------------------------------------------------------------
+FIRST_USER                                                                                                                      |s|{0}            
+SECOND_USER                                                                                                                     |u|{1}            
+THIRD_USER                                                                                                                      |s|{2}            
+3 rows selected
+ij(USER1)> alter table d1847_c add column d int;
+0 rows inserted/updated/deleted
+ij(USER1)> select c.grantee, c.type, c.columns from sys.syscolperms c, sys.systables t
+    where c.tableid = t.tableid and t.tablename='D1847_C';
+GRANTEE                                                                                                                         |&|COLUMNS        
+--------------------------------------------------------------------------------------------------------------------------------------------------
+FIRST_USER                                                                                                                      |s|{0}            
+SECOND_USER                                                                                                                     |u|{1}            
+THIRD_USER                                                                                                                      |s|{2}            
+3 rows selected
 ij(USER1)> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql?view=diff&rev=492919&r1=492918&r2=492919
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql Thu Jan  4 22:04:32 2007
@@ -2043,3 +2043,16 @@
 close crs1;
 autocommit on;
 set connection user1;
+
+-- Another test for DERBY-1847: verify that columns field is updated
+-- correctly when adding a column to a table:
+create table d1847_c (a int, b int, c int);
+grant select (a) on d1847_c to first_user;
+grant update (b) on d1847_c to second_user;
+grant select (c) on d1847_c to third_user;
+select c.grantee, c.type, c.columns from sys.syscolperms c, sys.systables t
+    where c.tableid = t.tableid and t.tablename='D1847_C';
+alter table d1847_c add column d int;
+select c.grantee, c.type, c.columns from sys.syscolperms c, sys.systables t
+    where c.tableid = t.tableid and t.tablename='D1847_C';
+