List:Internals« Previous MessageNext Message »
From:mikael Date:October 29 2005 5:51pm
Subject:bk commit into 5.1 tree (mronstrom:1.2051)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron 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.2051 05/10/29 19:50:50 mronstrom@stripped +1 -0
  A first step to WL #2537

  sql/sql_partition.cc
    1.32 05/10/29 19:50:20 mronstrom@stripped +53 -13
    A first step to WL #2537

# 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:	mronstrom
# Host:	c-ef09e253.1238-1-64736c10.cust.bredbandsbolaget.se
# Root:	/Users/mikron/wl2537

--- 1.31/sql/sql_partition.cc	2005-10-25 23:48:44 +02:00
+++ 1.32/sql/sql_partition.cc	2005-10-29 19:50:20 +02:00
@@ -1113,14 +1113,16 @@
   SYNOPSIS
     set_indicator_in_key_fields
     key_info                  Reference to find the key fields
+    accept_part_key           Accept only parts of a key
 */
 
-static void set_indicator_in_key_fields(KEY *key_info)
+static void set_indicator_in_key_fields(KEY *key_info, bool accept_part_key)
 {
   KEY_PART_INFO *key_part;
   uint key_parts= key_info->key_parts, i;
   for (i= 0, key_part=key_info->key_part; i < key_parts; i++, key_part++)
-    key_part->field->flags|= GET_FIXED_FIELDS_FLAG;
+    if (accept_part_key || !(key_part->key_part_flag & HA_PART_KEY_SEG))
+      key_part->field->flags|= GET_FIXED_FIELDS_FLAG;
 }
 
 
@@ -1142,6 +1144,7 @@
                                bool *some_fields)
 {
   DBUG_ENTER("check_fields_in_PF");
+
   *all_fields= TRUE;
   *some_fields= FALSE;
   do
@@ -1371,7 +1374,7 @@
 
   if (primary_key < MAX_KEY)
   {
-    set_indicator_in_key_fields(table->key_info+primary_key);
+    set_indicator_in_key_fields(table->key_info+primary_key, TRUE);
     check_fields_in_PF(table->s->part_info->full_part_field_array,
                         &all_fields, &some_fields);
     clear_indicator_in_key_fields(table->key_info+primary_key);
@@ -1411,7 +1414,7 @@
   {
     if (table->key_info[i].flags & HA_NOSAME) //Unique index
     {
-      set_indicator_in_key_fields(table->key_info+i);
+      set_indicator_in_key_fields(table->key_info+i, TRUE);
       check_fields_in_PF(table->s->part_info->full_part_field_array,
                          &all_fields, &some_fields);
       clear_indicator_in_key_fields(table->key_info+i);
@@ -1446,26 +1449,63 @@
   3) Possible if PF is a growing function of the field
   4) Possible if PF is a shrinking function of the field
   OBSERVATION:
-  1) IF f1(A) is a growing function AND f2(A) is a growing function THEN
+  1) Plus operator
+     IF f1(A) is a growing function AND f2(A) is a growing function THEN
      f1(A) + f2(A) is a growing function
-     f1(A) * f2(A) is a growing function if f1(A) >= 0 and f2(A) >= 0
-  2) IF f1(A) is a growing function and f2(A) is a shrinking function THEN
+     IF f1(A) is a shrinking function and f2(A) is a shrinking function THEN
+     f1(A) + f2(A) is a shrinking function
+  2) Minus operator
+     IF f1(A) is a growing function and f2(A) is a shrinking function THEN
+     f1(A) - f2(A) is a growing function
+     IF f1(A) is a shrinking function and f2(A) is a growing function THEN
+     f1(A) - f2(A) is a shrinking function
+  3) Division operator
+     IF f1(A) is a growing function and f2(A) is a shrinking function THEN
      f1(A) / f2(A) is a growing function if f1(A) >= 0 and f2(A) > 0
-  3) IF A is a growing function then a function f(A) that removes the
+  4) Multiplication operator
+     IF (f1(A) is a growing function AND f2(A) is a growing function) OR
+        (f1(A) is a shrinking function AND f2(A) is a shrinking function)
+     THEN
+     f1(A) * f2(A) is a growing function if f1(A) >= 0 and f2(A) >= 0 or
+     if f1(A) <= 0 and f2(A) <= 0
+  5) SHIFT LEFT operator
+     Shift left is a multiplication operator if number of shifts is > 0
+  6) SHIFT RIGHT operator
+     Shift right is a division operator if number of shifts is > 0
+  7) IF A is a growing function then a function f(A) that removes the
      least significant portion of A is a growing function
      E.g. DATE(datetime) is a growing function
      MONTH(datetime) is not a growing/shrinking function
-  4) IF f1(A) is a growing function and f2(A) is a growing function THEN
+  8) IF f1(A) is a growing function and f2(A) is a growing function THEN
      f1(f2(A)) and f2(f1(A)) are also growing functions
-  5) IF f1(A) is a shrinking function and f2(A) is a growing function THEN
+  9) IF f1(A) is a shrinking function and f2(A) is a growing function THEN
      f1(f2(A)) is a shrinking function and f2(f1(A)) is a shrinking function
-  6) f1(A) = A is a growing function
-  7) f1(A) = A*a + b (where a and b are constants) is a growing function
+  10) f1(A) = A is a growing function
+  11) f1(A) = A*a + b (where a and b are constants) is a growing function
 
   By analysing the item tree of the PF we can use these deducements and
   derive whether the PF is a growing function or a shrinking function or
   neither of it.
 
+  Now after all this theory we discover that unfortunately operators can
+  overflow. Thus the analysis above is only of value when there are no
+  overflow errors. Given that the item trees doesn't discover overflows
+  we'll skip the theory for now and leave it here as food for thought
+  for future MySQL Programmers.
+
+  In practice most people will either use a simple integer field for
+  partition function and this cannot overflow and by 10) it is a growing
+  function, thus we support that e.g. PARTITION BY RANGE(a).
+  It is also very popular with date ranges. To support this we support
+  the following function as range capable.
+  DATEDIFF
+  TIMESTAMPDIFF
+  TO_DAYS
+  YEAR
+  YEAR_WEEK
+
+  Later on I'm sure more functions can be added but these are a good start.
+
   If the PF is range capable then a flag is set on the table object
   indicating this to notify that we can use also ranges on the field
   of the PF to deduce a set of partitions if the fields of the PF were
@@ -1523,7 +1563,7 @@
   part_info->some_fields_in_PF.clear_all();
   for (i= 0; i < keys; i++)
   {
-    set_indicator_in_key_fields(table->key_info+i);
+    set_indicator_in_key_fields(table->key_info+i, FALSE);
     check_fields_in_PF(part_info->full_part_field_array,
                        &all_fields, &some_fields);
     if (all_fields)
Thread
bk commit into 5.1 tree (mronstrom:1.2051)mikael1 Nov