MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:jonas.oreland Date:April 1 2005 11:11am
Subject:bk commit into 5.1-ndb tree (joreland:1.1813)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1-ndb repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1813 05/04/01 13:11:14 joreland@stripped +6 -0
  wl1870 - ndb diskdata
    1) Part 1 pof handle_size_change_after_update
    2) Fix backup of null varsize attributes

  ndb/src/kernel/blocks/dbtup/tuppage.hpp
    1.6 05/04/01 13:11:10 joreland@stripped +1 -1
    disallow 0 bytes shrink

  ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
    1.56 05/04/01 13:11:10 joreland@stripped +61 -8
    Part 1 of handle_size_change_after_update

  ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
    1.43 05/04/01 13:11:10 joreland@stripped +17 -6
    Part 1 of handle_size_change_after_update

  ndb/src/kernel/blocks/dbtup/Dbtup.hpp
    1.51 05/04/01 13:11:10 joreland@stripped +7 -3
    Part 1 of handle_size_change_after_update

  ndb/src/kernel/blocks/backup/Backup.hpp
    1.10 05/04/01 13:11:10 joreland@stripped +8 -0
    Handle null varsize attributes

  ndb/src/kernel/blocks/backup/Backup.cpp
    1.23 05/04/01 13:11:10 joreland@stripped +4 -1
    Handle null varsize attributes

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	joreland
# Host:	eel.hemma.oreland.se.ndb.mysql.com
# Root:	/home/jonas/src/mysql-5.1-ndb-dd

--- 1.5/ndb/src/kernel/blocks/dbtup/tuppage.hpp	Fri Mar  4 22:14:21 2005
+++ 1.6/ndb/src/kernel/blocks/dbtup/tuppage.hpp	Fri Apr  1 13:11:10 2005
@@ -185,7 +185,7 @@
     *pos= (idx & 0xFFFF) + (new_size << 16);
     Uint32 old_size= idx >> 16;
     
-    assert(old_size >= new_size);
+    assert(old_size > new_size);
     Uint32 shrink = old_size - new_size;
     
     free_space+= shrink;

--- 1.22/ndb/src/kernel/blocks/backup/Backup.cpp	Wed Mar  9 07:58:54 2005
+++ 1.23/ndb/src/kernel/blocks/backup/Backup.cpp	Fri Apr  1 13:11:10 2005
@@ -3509,8 +3509,11 @@
       if(null) {
 	jam();
 	ndbrequire(attr.nullable);
-	op.nullAttribute(attr.offsetNull);
 	dstSz = 0;
+	if(attr.fixed)
+	  op.nullAttribute(attr.offsetNull);
+	else
+	  op.nullVariable();
 	continue;
       }//if
       

--- 1.9/ndb/src/kernel/blocks/backup/Backup.hpp	Fri Jan 21 11:01:05 2005
+++ 1.10/ndb/src/kernel/blocks/backup/Backup.hpp	Fri Apr  1 13:11:10 2005
@@ -247,6 +247,7 @@
     /**
      * Per attribute
      */
+    void     nullVariable();
     void     nullAttribute(Uint32 nullOffset);
     Uint32 * newNullable(Uint32 attrId, Uint32 sz);
     Uint32 * newAttrib(Uint32 offset, Uint32 sz);
@@ -654,6 +655,13 @@
 Backup::OperationRecord::nullAttribute(Uint32 offsetNull){
   attrLeft --;
   BitmaskImpl::set(sz_Bitmask, dst_Bitmask, offsetNull);
+}
+
+inline
+void
+Backup::OperationRecord::nullVariable()
+{
+  attrLeft --;
 }
 
 inline

--- 1.50/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	Thu Mar 31 20:59:24 2005
+++ 1.51/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	Fri Apr  1 13:11:10 2005
@@ -1012,6 +1012,8 @@
     STATIC_CONST( DISK_ALLOC  = 0x040000 ); // Is disk part allocated
     STATIC_CONST( DISK_INLINE = 0x080000 ); // Is disk inline
     STATIC_CONST( ALLOC       = 0x100000 ); // Is record allocated now
+    STATIC_CONST( MM_SHRINK   = 0x200000 ); // Has MM part shrunk
+    STATIC_CONST( MM_GROWN    = 0x400000 ); // Has MM part grown
     
     Uint32 get_tuple_version() const { 
       return m_header_bits & TUP_VERSION_MASK;
@@ -1086,8 +1088,9 @@
   } m_var_data[2];
 
   Tuple_header *m_disk_ptr;
-  Ptr<Var_page> m_varpart_page_ptr;// could be same as header page
-  PagePtr m_disk_page_ptr;   //
+  Page* m_page_ptr_p;
+  Var_page* m_varpart_page_ptr_p;// could be same as m_page_ptr_p
+  PagePtr m_disk_page_ptr;       //
 
   bool            dirty_op;
   bool            interpreted_exec;
@@ -2389,13 +2392,14 @@
 			   Uint32 gci, Uint32 logfile_group_id);
   
   void fix_commit_order(OperationrecPtr);
-  void commit_operation(Signal*, Uint32, Tuple_header*, 
+  void commit_operation(Signal*, Uint32, Tuple_header*, Page*,
 			Operationrec*, Fragrecord*, Tablerec*);
   
   void dealloc_tuple(Signal* signal, Uint32, Page*, Tuple_header*, 
 		     Operationrec*, Fragrecord*, Tablerec*);
   
   int handle_size_change_after_update(KeyReqStruct* req_struct,
+				      Operationrec*,
 				      Fragrecord* const regFragPtr,
 				      Tablerec* const regTabPtr,
 				      Uint32 sizes[4]);

--- 1.42/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	Thu Mar 31 20:59:24 2005
+++ 1.43/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	Fri Apr  1 13:11:10 2005
@@ -194,6 +194,7 @@
 Dbtup::commit_operation(Signal* signal,
 			Uint32 gci,
 			Tuple_header* tuple_ptr, 
+			Page* page,
 			Operationrec* regOperPtr, 
 			Fragrecord* regFragPtr, 
 			Tablerec* regTabPtr)
@@ -229,10 +230,16 @@
   else 
   {
     Uint32 *var_part= copy->get_var_part_ptr(regTabPtr);
-    Uint32 sz= ((mm_vars + 1) << 1) + (((Uint16*)var_part)[mm_vars]);
-    memcpy(tuple_ptr, copy, 4*(Tuple_header::HeaderSize+fix_size)+sz);      
+    Uint32 sz= Tuple_header::HeaderSize + fix_size +
+      ((((mm_vars + 1) << 1) + (((Uint16*)var_part)[mm_vars]) + 3)>> 2);
+    memcpy(tuple_ptr, copy, 4*sz);      
+    if(copy->m_header_bits & Tuple_header::MM_SHRINK)
+    {
+      ((Var_page*)page)->shrink_entry(regOperPtr->m_tuple_location.m_page_idx, 
+				      sz);
+    } 
   }
-
+  
   if (regTabPtr->m_no_of_disk_attributes)
   {
     Local_key key;
@@ -282,10 +289,14 @@
     memcpy(tuple_ptr->get_disk_ref_ptr(regTabPtr), &key, sizeof(Local_key));
     
     copy_bits |= Tuple_header::DISK_PART;
-    copy_bits &= ~(Uint32)Tuple_header::DISK_ALLOC;
   }
+
+  
+  Uint32 clear= 
+    Tuple_header::DISK_ALLOC | Tuple_header::DISK_INLINE | 
+    Tuple_header::MM_SHRINK | Tuple_header::MM_GROWN;
+  copy_bits &= ~(Uint32)clear;
   
-  copy_bits &= ~(Uint32)Tuple_header::DISK_INLINE;
   tuple_ptr->m_header_bits= copy_bits;
   tuple_ptr->m_operation_ptr_i= save;
   
@@ -544,7 +555,7 @@
     
     if(regOperPtr.p->op_struct.op_type != ZDELETE)
     {
-      commit_operation(signal, gci, tuple_ptr, 
+      commit_operation(signal, gci, tuple_ptr, page.p,
 		       regOperPtr.p, regFragPtr.p, regTabPtr.p); 
       removeActiveOpList(regOperPtr.p, tuple_ptr);
     }

--- 1.55/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	Thu Mar 31 20:59:24 2005
+++ 1.56/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	Fri Apr  1 13:11:10 2005
@@ -991,6 +991,7 @@
 {
   PagePtr page_ptr;
   Uint32* ptr= get_ptr(&page_ptr, &regOperPtr->m_tuple_location, regTabPtr);
+  req_struct->m_page_ptr_p= page_ptr.p;
   req_struct->m_tuple_ptr= (Tuple_header*)ptr;
   
   req_struct->check_offset[MM]= regTabPtr->get_check_offset(MM);
@@ -1185,10 +1186,11 @@
   if (regTabPtr->need_shrink())
   {  
     shrink_tuple(req_struct, sizes+2, regTabPtr);
-    if (cmp[0] != cmp[1] && !handle_size_change_after_update(req_struct,
-							     regFragPtr,
-							     regTabPtr,
-							     sizes)) {
+    if (cmp[0] != cmp[1] && handle_size_change_after_update(req_struct,
+							    operPtrP,
+							    regFragPtr,
+							    regTabPtr,
+							    sizes)) {
       goto error;
     }
   }
@@ -1367,6 +1369,7 @@
     else 
     {
       jam();
+      regOperPtr.p->m_tuple_location.m_file_no= sizes[2+MM];
       if ((ptr= alloc_var_rec(regFragPtr, regTabPtr,
 			      sizes[2+MM],
 			      &regOperPtr.p->m_tuple_location,
@@ -1420,8 +1423,9 @@
     
     if (!regTabPtr->need_shrink() || cmp[0] == cmp[1])
       return 0;
-    
+
     return handle_size_change_after_update(req_struct,
+					   regOperPtr.p,
 					   regFragPtr,
 					   regTabPtr,
 					   sizes);
@@ -2460,15 +2464,17 @@
     KeyReqStruct::Var_data* dst= &req_struct->m_var_data[MM];
     if(bits & Tuple_header::CHAINED_ROW)
     {
-      src_data= get_ptr(&req_struct->m_varpart_page_ptr, 
-			* (Var_part_ref*)src_ptr);
+      Ptr<Var_page> var_page;
+      src_data= get_ptr(&var_page, * (Var_part_ref*)src_ptr);
       step= 4;
       sizes[MM]= (2 + (mm_vars << 1) + ((Uint16*)src_data)[mm_vars] + 3) >> 2;
+      req_struct->m_varpart_page_ptr_p= var_page.p;
     }
     else
     {
       step= (2 + (mm_vars << 1) + ((Uint16*)src_ptr)[mm_vars]);
       sizes[MM]= (step + 3) >> 2;
+      req_struct->m_varpart_page_ptr_p= (Var_page*)req_struct->m_page_ptr_p;
     }
     dst->m_data_ptr= (char*)(((Uint16*)dst_ptr)+mm_vars+1);
     dst->m_offset_array_ptr= req_struct->var_pos_array;
@@ -2643,11 +2649,58 @@
 
 int
 Dbtup::handle_size_change_after_update(KeyReqStruct* req_struct,
+				       Operationrec* regOperPtr,
 				       Fragrecord* regFragPtr,
 				       Tablerec* regTabPtr,
 				       Uint32 sizes[4])
 {
+  ndbrequire(sizes[1] == sizes[3]);
   ndbout_c("%d %d %d %d", sizes[0], sizes[1], sizes[2], sizes[3]);
-  abort();
+  if(sizes[MM] == sizes[2+MM])
+    ;
+  else if(sizes[MM] > sizes[2+MM])
+  {
+    ndbout_c("shrink");
+    req_struct->m_tuple_ptr->m_header_bits |= Tuple_header::MM_SHRINK;
+  }
+  else
+  {
+    printf("grow - ");
+    Var_page* pageP= req_struct->m_varpart_page_ptr_p;
+    Uint32 idx= regOperPtr->m_tuple_location.m_page_idx;
+    Uint32 add= sizes[2+MM] - sizes[MM];
+    if(pageP->free_space >= add)
+    {
+      jam();
+      if(!pageP->is_space_behind_entry(idx, add))
+      {
+	printf("extra reorg");
+	jam();
+	/**
+	 * In this case we need to reorganise the page to fit. To ensure we
+	 * don't complicate matters we make a little trick here where we
+	 * fool the reorg_page to avoid copying the entry at hand and copy
+	 * that separately at the end. This means we need to copy it out of
+	 * the page before reorg_page to save the entry contents.
+	 */
+	Uint32* copyBuffer= cinBuffer;
+	assert(sizes[MM] == pageP->get_entry_len(idx));
+	memcpy(copyBuffer, pageP->get_ptr(idx), 4*sizes[MM]);
+	pageP->set_entry_len(idx, 0);
+	pageP->free_space += sizes[MM];
+	pageP->reorg((Var_page*)ctemp_page);
+	memcpy(pageP->get_free_space_ptr(), copyBuffer, 4*sizes[MM]);
+	pageP->set_entry_offset(idx, pageP->insert_pos);
+	add += sizes[MM];
+      }
+      pageP->grow_entry(idx, add);
+      req_struct->m_tuple_ptr->m_header_bits |= Tuple_header::MM_GROWN;
+    }
+    else
+    {
+      abort();
+    }
+    ndbout_c("free: %d", pageP->free_space);
+  }
   return 0;
 }
Thread
bk commit into 5.1-ndb tree (joreland:1.1813)jonas.oreland1 Apr