Index: java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderResultSet.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderResultSet.java	(revision 612063)
+++ java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderResultSet.java	(working copy)
@@ -151,7 +151,12 @@
 	{
 		if(isAppendable)
 		{
-			holder.CID = currentConglomId;
+            if (SanityManager.DEBUG) {
+                SanityManager.ASSERT(currentConglomId == holder.getTemporaryConglomId(),
+                        "currentConglomId(" + currentConglomId + 
+                        ") == holder.getTemporaryConglomeateId (" + 
+                        holder.getTemporaryConglomId() + ")");
+            }
 			positionIndexConglomId = pconglomId;
 			setupPositionBasedScan(numRowsOut);
 		}else
@@ -273,7 +278,7 @@
 			return currentRow;
 		}
 
-		if (holder.CID == 0)
+		if (holder.getTemporaryConglomId() == 0)
 		{
 			return (ExecRow)null;
 		}
@@ -285,7 +290,7 @@
 		{
 			scan = 
                 tc.openScan(
-                    holder.CID,
+                    holder.getTemporaryConglomId(),
                     false,					// hold
                     0, 		// open read only
                     TransactionController.MODE_TABLE,
@@ -338,7 +343,7 @@
 			scan.fetchLocation(baseRowLocation);
 			if(heapCC == null)
 			{
-				heapCC = tc.openConglomerate( holder.CID,
+                heapCC = tc.openConglomerate(holder.getTemporaryConglomId(),
 											  false,
 											  TransactionController.OPENMODE_FORUPDATE,
 											  TransactionController.MODE_TABLE,
@@ -358,11 +363,11 @@
 	{
 
 		//incase nothing is inserted yet into the temporary row holder
-		if(holder.CID ==0)
+        if (holder.getTemporaryConglomId() == 0)
 			return;
 		if(heapCC == null)
 		{
-			heapCC = tc.openConglomerate( holder.CID,
+			heapCC = tc.openConglomerate( holder.getTemporaryConglomId(),
 										  false,
 										  0,
 										  TransactionController.MODE_TABLE,
Index: java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java	(revision 612063)
+++ java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java	(working copy)
@@ -67,7 +67,7 @@
 	private int			numRowsIn;
 	protected int		state = STATE_UNINIT;
 
-	protected	long				CID;
+	private	long				    CID;
 	private boolean					conglomCreated;
 	private ConglomerateController	cc;
 	private Properties				properties;
@@ -238,8 +238,9 @@
 			//In case of unique stream we push every thing into the
 			// conglomerates for time being, we keep one row in the array for
 			// the template.
-			if(!isUniqueStream)
+            if (!isUniqueStream) {
 				return;  
+            }
 		}
 			
 		if (!conglomCreated)
@@ -490,32 +491,32 @@
 	public void truncate() throws StandardException
 	{
 		close();
-
+        if (SanityManager.DEBUG) {
+            SanityManager.ASSERT(lastArraySlot == -1);
+            SanityManager.ASSERT(state == STATE_UNINIT);
+            SanityManager.ASSERT(!conglomCreated);
+            SanityManager.ASSERT(CID == 0);
+        }
 		for (int i = 0; i < rowArray.length; i++)
 		{
 			rowArray[i] = null;
 		}
-		lastArraySlot = -1;
+
 		numRowsIn = 0;
-		state = STATE_UNINIT;
-
-		/*
-		** We are not expecting this to be called
-		** when we have a temporary conglomerate
-		** but just to be on the safe side, drop
-		** it.  We'd like do something cheaper,
-		** but there is no truncate on congloms.
-		*/
-		if (conglomCreated)
-		{
-			TransactionController tc = activation.getTransactionController();
-			tc.dropConglomerate(CID);
-			conglomCreated = false;
-		}
 	}
 
+    /**
+     * Accessor to get the id of the temporary conglomerate. Temporary 
+     * conglomerates have negative ids. An id equal to zero means that no 
+     * temporary conglomerate has been created.
+     * @return Conglomerate ID of temporary conglomerate
+     */
 	public long getTemporaryConglomId()
 	{
+        if (SanityManager.DEBUG) {
+            SanityManager.ASSERT(CID == 0 && !conglomCreated || 
+                    CID < 0 && conglomCreated);
+        }
 		return CID;
 	}
 
@@ -593,8 +594,14 @@
 		{
 			tc.dropConglomerate(CID);
 			conglomCreated = false;
-		}
-
+            CID = 0;
+		} 
+        else 
+        {
+            if (SanityManager.DEBUG) {
+                SanityManager.ASSERT(CID == 0, "CID(" + CID + ")==0");
+            }
+        }
 		state = STATE_UNINIT;
 		lastArraySlot = -1;
 	}
