List:Commits« Previous MessageNext Message »
From:Dmitry Lenev Date:December 10 2008 10:55am
Subject:bzr commit into mysql-6.1-fk branch (dlenev:2692) WL#148
View as plain text  
#At file:///home/dlenev/src/bzr/mysql-6.1-mil8-3/

 2692 Dmitry Lenev	2008-12-10
      WL#148 "Foreign keys".
      
      Milestone #8 "DML words: INSERT, UPDATE, DELETE, no EOS checks".
      
      Work in progress. After-review fixes.
modified:
  sql/fk.cc

per-file messages:
  sql/fk.cc
    Rewrote code handling MATCH FULL to make it easier for
    understanding. Removed solved questions to reviewer.
=== modified file 'sql/fk.cc'
--- a/sql/fk.cc	2008-12-09 22:01:03 +0000
+++ b/sql/fk.cc	2008-12-10 10:55:07 +0000
@@ -663,20 +663,19 @@ bool Foreign_key_child_rcontext::check_p
   }
   else
   {
-    uint null_column_count= 0;
+    bool has_null_columns= FALSE;
+    bool has_non_null_columns= FALSE;
 
     DBUG_ASSERT(fk_share->match_opt == FK_MATCH_FULL);
 
     while ((col= col_it++))
     {
       if (col->is_null())
-        null_column_count++;
-      else if (null_column_count)
-        break;
-    }
-    if (null_column_count)
-    {
-      if (null_column_count != child_columns.elements)
+        has_null_columns= TRUE;
+      else
+        has_non_null_columns= TRUE;
+
+      if (has_null_columns && has_non_null_columns)
       {
         /*
           MATCH FULL: One of columns has a non-NULL value while there
@@ -685,11 +684,13 @@ bool Foreign_key_child_rcontext::check_p
         my_error(ER_FK_CHILD_NO_MATCH_FULL, MYF(0), fk_share->name.str);
         return TRUE;
       }
-      else
-      {
-        /* MATCH FULL: all columns are NULL, no need to look for parent. */
-        return FALSE;
-      }
+    }
+
+    if (has_null_columns)
+    {
+      DBUG_ASSERT(!has_non_null_columns);
+      /* MATCH FULL: all columns are NULL, no need to look for parent. */
+      return FALSE;
     }
     /* MATCH FULL: all columns are non-NULL, further check is needed. */
   }
@@ -719,7 +720,6 @@ bool Foreign_key_child_rcontext::check_p
   }
   else
   {
-    /* QQ Should we print error to error log as we do in report_error()? */
     parent_table->file->print_error(error, MYF(0));
     return TRUE;
   }
@@ -1003,7 +1003,6 @@ bool Foreign_key_parent_rcontext::check_
   }
   else
   {
-    /* QQ Should we print error to error log as we do in report_error()? */
     child_table->file->print_error(error, MYF(0));
     return TRUE;
   }
@@ -1139,7 +1138,6 @@ bool Foreign_key_parent_rcontext::do_cas
     return FALSE;
   }
 
-  /* QQ may be should do the same thing as in report_error() ? */
   child_table->file->print_error(error, MYF(0));
 
 err_with_index_end:

Thread
bzr commit into mysql-6.1-fk branch (dlenev:2692) WL#148Dmitry Lenev10 Dec