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 fu...@apache.org on 2006/09/28 18:28:45 UTC

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

Author: fuzzylogic
Date: Thu Sep 28 09:28:43 2006
New Revision: 450915

URL: http://svn.apache.org/viewvc?view=rev&rev=450915
Log:
DERBY-1854: Merge fix for regression caused by DERBY-655 to 10.0 branch.

Modified:
    db/derby/code/branches/10.0/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/compressTable.out
    db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/lang/compressTable.sql

Modified: db/derby/code/branches/10.0/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.0/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?view=diff&rev=450915&r1=450914&r2=450915
==============================================================================
--- db/derby/code/branches/10.0/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/branches/10.0/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Thu Sep 28 09:28:43 2006
@@ -5294,8 +5294,11 @@
 
 	/**
 	 * Update the conglomerateNumber for an array of ConglomerateDescriptors.
-	 * In case of more than one ConglomerateDescriptor, they are for duplicate
-	 * indexes sharing one conglomerate.
+	 * In case of more than one ConglomerateDescriptor, each descriptor 
+	 * should be updated separately, conglomerate id is not same for all 
+	 * the descriptors. Even when indexes are sharing the same 
+	 * conglomerate(conglomerate number), conglomerate ids are unique.
+	 *
 	 * This is useful, in 1.3, when doing a bulkInsert into an 
 	 * empty table where we insert into a new conglomerate.
 	 * (This will go away in 1.4.)
@@ -5314,38 +5317,35 @@
 		throws StandardException
 	{
 		ExecIndexRow				keyRow1 = null;
-		ExecRow[]    				rows = new ExecRow[cds.length];
+		ExecRow     				row;
 		DataValueDescriptor			conglomIDOrderable;
 		TabInfo						ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
 		SYSCONGLOMERATESRowFactory  rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();
-
-		/* Use conglomIDOrderable in both start 
-		 * and stop position for index 1 scan. 
-		 */
-		conglomIDOrderable = getValueAsDVD(cds[0].getUUID());
-
-		/* Set up the start/stop position for the scan */
-		keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
-		keyRow1.setColumn(1, conglomIDOrderable);
+		boolean[] bArray = {false, false, false};
 
 		for (int i = 0; i < cds.length; i++)
 		{
+			/* Use conglomIDOrderable in both start 
+			 * and stop position for index 1 scan. 
+			 */
+			conglomIDOrderable = getValueAsDVD(cds[i].getUUID());
+
+			/* Set up the start/stop position for the scan */
+			keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
+			keyRow1.setColumn(1, conglomIDOrderable);
+
 			cds[i].setConglomerateNumber(conglomerateNumber);
 			// build the row to be stuffed into SYSCONGLOMERATES. 
-			rows[i] = rf.makeRow(cds[i], null);
-		}
+			row = rf.makeRow(cds[i], null);
 
-		// update row in catalog (no indexes)
-		boolean[] bArray = new boolean[3];
-		for (int index = 0; index < 3; index++)
-		{
-			bArray[index] = false;
+			// update row in catalog (no indexes)
+			ti.updateRow(keyRow1, row,
+						 SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID,
+						 bArray,
+						 (int[])null,
+						 tc);
 		}
-		ti.updateRow(keyRow1, rows,
-					 SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID,
-					 bArray,
-					 (int[])null,
-					 tc);
+
 	}
 
 	

Modified: db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/compressTable.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/compressTable.out?view=diff&rev=450915&r1=450914&r2=450915
==============================================================================
--- db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/compressTable.out (original)
+++ db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/compressTable.out Thu Sep 28 09:28:43 2006
@@ -1082,4 +1082,50 @@
 0 rows inserted/updated/deleted
 ij> drop table newconglom;
 0 rows inserted/updated/deleted
+ij> -- test case for derby-1854 
+-- perform compress on a table that has same column 
+-- as a primary key and a foreign key.  
+create table users (
+ user_id int not null,
+ user_login varchar(255) not null,
+ primary key (user_id));
+0 rows inserted/updated/deleted
+ij> create table admins (
+ user_id int not null,
+ primary key (user_id),
+ constraint admin_uid_fk foreign key (user_id) references users (user_id));
+0 rows inserted/updated/deleted
+ij> insert into users values(1, 'test1');
+1 row inserted/updated/deleted
+ij> insert into admins values (1);
+1 row inserted/updated/deleted
+ij> call syscs_util.syscs_compress_table('APP', 'ADMINS', 0);
+0 rows inserted/updated/deleted
+ij> -- do consistency check on the tables.
+values SYSCS_UTIL.SYSCS_CHECK_TABLE('APP', 'USERS');
+1          
+-----------
+1          
+ij> values SYSCS_UTIL.SYSCS_CHECK_TABLE('APP', 'ADMINS');
+1          
+-----------
+1          
+ij> select * from admins;
+USER_ID    
+-----------
+1          
+ij> select * from users;
+USER_ID    |USER_LOGIN                                                                                                                                                                                                                                                     
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+1          |test1                                                                                                                                                                                                                                                          
+ij> insert into users values(2, 'test2');
+1 row inserted/updated/deleted
+ij> insert into admins values (2);
+1 row inserted/updated/deleted
+ij> drop table admins;
+0 rows inserted/updated/deleted
+ij> drop table users;
+0 rows inserted/updated/deleted
+ij> -- end derby-1854 test case. 
+;
 ij> 

Modified: db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/lang/compressTable.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/lang/compressTable.sql?view=diff&rev=450915&r1=450914&r2=450915
==============================================================================
--- db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/lang/compressTable.sql (original)
+++ db/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/lang/compressTable.sql Thu Sep 28 09:28:43 2006
@@ -452,3 +452,31 @@
 drop table indexes;
 drop table oldconglom;
 drop table newconglom;
+
+-- test case for derby-1854 
+-- perform compress on a table that has same column 
+-- as a primary key and a foreign key.  
+
+create table users (
+ user_id int not null,
+ user_login varchar(255) not null,
+ primary key (user_id));
+
+create table admins (
+ user_id int not null,
+ primary key (user_id),
+ constraint admin_uid_fk foreign key (user_id) references users (user_id));
+ 
+insert into users values(1, 'test1');
+insert into admins values (1);
+call syscs_util.syscs_compress_table('APP', 'ADMINS', 0);
+-- do consistency check on the tables.
+values SYSCS_UTIL.SYSCS_CHECK_TABLE('APP', 'USERS');
+values SYSCS_UTIL.SYSCS_CHECK_TABLE('APP', 'ADMINS');
+select * from admins; 
+select * from users;
+insert into users values(2, 'test2');
+insert into admins values (2);
+drop table admins;
+drop table users;
+-- end derby-1854 test case.