List:Internals« Previous MessageNext Message »
From:mikael Date:November 24 2005 11:38am
Subject:bk commit into 5.1 tree (mikron:1.1962)
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.1962 05/11/24 11:37:43 mikron@stripped +1 -0
  Review fixes

  sql/ha_partition.cc
    1.14 05/11/24 11:37:24 mikron@stripped +309 -83
    Review fixes

# 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:	mikron
# Host:	mikael-ronstr-ms-dator.local
# Root:	/Users/mikron/wl2604

--- 1.13/sql/ha_partition.cc	2005-11-23 23:14:51 +01:00
+++ 1.14/sql/ha_partition.cc	2005-11-24 11:37:24 +01:00
@@ -3481,13 +3481,26 @@
   Unordered Index Scan Routines
 ****************************************************************************/
 /*
-  These routines are used to scan partitions without considering order.
-  This is performed in two situations.
-  1) In read_multi_range this is the normal case
-  2) When performing any type of index_read, index_first, index_last where
-  all fields in the partition function is bound. In this case the index
-  scan is performed on only one partition and thus it isn't necessary to
-  perform any sort.
+  Common routine to handle index_next with unordered results
+
+  SYNOPSIS
+    handle_unordered_next()
+    out:buf                       Read row in MySQL Row Format
+    next_same                     Called from index_next_same
+
+  RETURN VALUE
+    HA_ERR_END_OF_FILE            End of scan
+    0                             Success
+    other                         Error code
+
+  DESCRIPTION
+    These routines are used to scan partitions without considering order.
+    This is performed in two situations.
+    1) In read_multi_range this is the normal case
+    2) When performing any type of index_read, index_first, index_last where
+    all fields in the partition function is bound. In this case the index
+    scan is performed on only one partition and thus it isn't necessary to
+    perform any sort.
 */
 
 int ha_partition::handle_unordered_next(byte *buf, bool next_same)
@@ -3529,8 +3542,20 @@
 
 
 /*
-  This routine is used to start the index scan on the next partition.
-  Both initial start and after completing scan on one partition.
+  Handle index_next when changing to new partition
+
+  SYNOPSIS
+    handle_unordered_scan_next_partition()
+    buf                       Read row in MySQL Row Format
+
+  RETURN VALUE
+    HA_ERR_END_OF_FILE            End of scan
+    0                             Success
+    other                         Error code
+
+  DESCRIPTION
+    This routine is used to start the index scan on the next partition.
+    Both initial start and after completing scan on one partition.
 */
 
 int ha_partition::handle_unordered_scan_next_partition(byte * buf)
@@ -3578,19 +3603,31 @@
 
 
 /*
-  This part contains the logic to handle index scans that require ordered
-  output. This includes all except those started by read_range_first with
-  the flag ordered set to FALSE. Thus most direct index_read and all
-  index_first and index_last.
-
-  We implement ordering by keeping one record plus a key buffer for each
-  partition. Every time a new entry is requested we will fetch a new
-  entry from the partition that is currently not filled with an entry.
-  Then the entry is put into its proper sort position.
-
-  Returning a record is done by getting the top record, copying the
-  record to the request buffer and setting the partition as empty on
-  entries.
+  Common routine to start index scan with ordered results
+
+  SYNOPSIS
+    handle_ordered_index_scan()
+    out:buf                       Read row in MySQL Row Format
+
+  RETURN VALUE
+    HA_ERR_END_OF_FILE            End of scan
+    0                             Success
+    other                         Error code
+
+  DESCRIPTION
+    This part contains the logic to handle index scans that require ordered
+    output. This includes all except those started by read_range_first with
+    the flag ordered set to FALSE. Thus most direct index_read and all
+    index_first and index_last.
+
+    We implement ordering by keeping one record plus a key buffer for each
+    partition. Every time a new entry is requested we will fetch a new
+    entry from the partition that is currently not filled with an entry.
+    Then the entry is put into its proper sort position.
+
+    Returning a record is done by getting the top record, copying the
+    record to the request buffer and setting the partition as empty on
+    entries.
 */
 
 int ha_partition::handle_ordered_index_scan(byte *buf)
@@ -3659,6 +3696,17 @@
 }
 
 
+/*
+  Return the top record in sort order
+
+  SYNOPSIS
+    return_top_record()
+    out:buf                  Row returned in MySQL Row Format
+
+  RETURN VALUE
+    NONE
+*/
+
 void ha_partition::return_top_record(byte *buf)
 {
   uint part_id;
@@ -3671,6 +3719,20 @@
 }
 
 
+/*
+  Common routine to handle index_next with ordered results
+
+  SYNOPSIS
+    handle_ordered_next()
+    out:buf                       Read row in MySQL Row Format
+    next_same                     Called from index_next_same
+
+  RETURN VALUE
+    HA_ERR_END_OF_FILE            End of scan
+    0                             Success
+    other                         Error code
+*/
+
 int ha_partition::handle_ordered_next(byte *buf, bool next_same)
 {
   int error;
@@ -3706,6 +3768,19 @@
 }
 
 
+/*
+  Common routine to handle index_prev with ordered results
+
+  SYNOPSIS
+    handle_ordered_prev()
+    out:buf                       Read row in MySQL Row Format
+
+  RETURN VALUE
+    HA_ERR_END_OF_FILE            End of scan
+    0                             Success
+    other                         Error code
+*/
+
 int ha_partition::handle_ordered_prev(byte *buf)
 {
   int error;
@@ -3734,6 +3809,22 @@
 }
 
 
+/*
+  Set fields in partition functions in read set for underlying handlers
+
+  SYNOPSIS
+    include_partition_fields_in_used_fields()
+
+  RETURN VALUE
+    NONE
+
+  DESCRIPTION
+    Some handlers only read fields as specified by the bitmap for the
+    read set. For partitioned handlers we always require that the
+    fields of the partition functions are read such that we can
+    calculate the partition id to place updated and deleted records.
+*/
+
 void ha_partition::include_partition_fields_in_used_fields()
 {
   DBUG_ENTER("ha_partition::include_partition_fields_in_used_fields");
@@ -3756,57 +3847,68 @@
 */
 
 /*
-  ::info() is used to return information to the optimizer.
-  Currently this table handler doesn't implement most of the fields
-  really needed. SHOW also makes use of this data
-  Another note, if your handler doesn't proved exact record count,
-  you will probably want to have the following in your code:
-  if (records < 2)
-    records = 2;
-  The reason is that the server will optimize for cases of only a single
-  record. If in a table scan you don't know the number of records
-  it will probably be better to set records to two so you can return
-  as many records as you need.
-
-  Along with records a few more variables you may wish to set are:
-    records
-    deleted
-    data_file_length
-    index_file_length
-    delete_length
-    check_time
-  Take a look at the public variables in handler.h for more information.
-
-  Called in:
-    filesort.cc
-    ha_heap.cc
-    item_sum.cc
-    opt_sum.cc
-    sql_delete.cc
-    sql_delete.cc
-    sql_derived.cc
-    sql_select.cc
-    sql_select.cc
-    sql_select.cc
-    sql_select.cc
-    sql_select.cc
-    sql_show.cc
-    sql_show.cc
-    sql_show.cc
-    sql_show.cc
-    sql_table.cc
-    sql_union.cc
-    sql_update.cc
-
-  Some flags that are not implemented
-    HA_STATUS_POS:
-      This parameter is never used from the MySQL Server. It is checked in a
-      place in MyISAM so could potentially be used by MyISAM specific programs.
-    HA_STATUS_NO_LOCK:
-    This is declared and often used. It's only used by MyISAM.
-    It means that MySQL doesn't need the absolute latest statistics
-    information. This may save the handler from doing internal locks while
-    retrieving statistics data.
+  General method to gather info from handler
+
+  SYNOPSIS
+    info()
+    flag              Specifies what info is requested
+
+  RETURN VALUE
+    NONE
+
+  DESCRIPTION
+    ::info() is used to return information to the optimizer.
+    Currently this table handler doesn't implement most of the fields
+    really needed. SHOW also makes use of this data
+    Another note, if your handler doesn't proved exact record count,
+    you will probably want to have the following in your code:
+    if (records < 2)
+      records = 2;
+    The reason is that the server will optimize for cases of only a single
+    record. If in a table scan you don't know the number of records
+    it will probably be better to set records to two so you can return
+    as many records as you need.
+
+    Along with records a few more variables you may wish to set are:
+      records
+      deleted
+      data_file_length
+      index_file_length
+      delete_length
+      check_time
+    Take a look at the public variables in handler.h for more information.
+
+    Called in:
+      filesort.cc
+      ha_heap.cc
+      item_sum.cc
+      opt_sum.cc
+      sql_delete.cc
+     sql_delete.cc
+     sql_derived.cc
+      sql_select.cc
+      sql_select.cc
+      sql_select.cc
+      sql_select.cc
+      sql_select.cc
+      sql_show.cc
+      sql_show.cc
+      sql_show.cc
+      sql_show.cc
+      sql_table.cc
+      sql_union.cc
+      sql_update.cc
+
+    Some flags that are not implemented
+      HA_STATUS_POS:
+        This parameter is never used from the MySQL Server. It is checked in a
+        place in MyISAM so could potentially be used by MyISAM specific
+        programs.
+      HA_STATUS_NO_LOCK:
+      This is declared and often used. It's only used by MyISAM.
+      It means that MySQL doesn't need the absolute latest statistics
+      information. This may save the handler from doing internal locks while
+      retrieving statistics data.
 */
 
 void ha_partition::info(uint flag)
@@ -3968,6 +4070,17 @@
 
 
 /*
+  General function to prepare handler for certain behavior
+
+  SYNOPSIS
+    extra()
+    operation              Operation type for extra call
+
+  RETURN VALUE
+    >0                     Error code
+    0                      Success
+
+  DESCRIPTION
   extra() is called whenever the server wishes to send a hint to
   the storage engine. The MyISAM engine implements the most hints.
 
@@ -4313,8 +4426,18 @@
 
 
 /*
-  This will in the future be called instead of extra(HA_EXTRA_RESET) as this
-  is such a common call
+  Special extra call to reset extra parameters
+
+  SYNOPSIS
+    reset()
+
+  RETURN VALUE
+    >0                   Error code
+    0                    Success
+
+  DESCRIPTION
+    This will in the future be called instead of extra(HA_EXTRA_RESET) as this
+    is such a common call
 */
 
 int ha_partition::reset(void)
@@ -4332,6 +4455,19 @@
 }
 
 
+/*
+  Special extra method for HA_EXTRA_CACHE with cachesize as extra parameter
+
+  SYNOPSIS
+    extra_opt()
+    operation                      Must be HA_EXTRA_CACHE
+    cachesize                      Size of cache in full table scan
+
+  RETURN VALUE
+    >0                   Error code
+    0                    Success
+*/
+
 int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize)
 {
   DBUG_ENTER("ha_partition::extra_opt()");
@@ -4341,6 +4477,17 @@
 }
 
 
+/*
+  Call extra on handler with HA_EXTRA_CACHE and cachesize
+
+  SYNOPSIS
+    prepare_extra_cache()
+    cachesize                Size of cache for full table scan
+
+  RETURN VALUE
+    NONE
+*/
+
 void ha_partition::prepare_extra_cache(uint cachesize)
 {
   DBUG_ENTER("ha_partition::prepare_extra_cache()");
@@ -4356,6 +4503,18 @@
 }
 
 
+/*
+  Call extra on all partitions
+
+  SYNOPSIS
+    loop_extra()
+    operation             extra operation type
+
+  RETURN VALUE
+    >0                    Error code
+    0                     Success
+*/
+
 int ha_partition::loop_extra(enum ha_extra_function operation)
 {
   int result= 0, tmp;
@@ -4370,6 +4529,17 @@
 }
 
 
+/*
+  Call extra(HA_EXTRA_CACHE) on next partition_id
+
+  SYNOPSIS
+    late_extra_cache()
+    partition_id               Partition id to call extra on
+
+  RETURN VALUE
+    NONE
+*/
+
 void ha_partition::late_extra_cache(uint partition_id)
 {
   handler *file;
@@ -4385,6 +4555,17 @@
 }
 
 
+/*
+  Call extra(HA_EXTRA_NO_CACHE) on next partition_id
+
+  SYNOPSIS
+    late_extra_no_cache()
+    partition_id               Partition id to call extra on
+
+  RETURN VALUE
+    NONE
+*/
+
 void ha_partition::late_extra_no_cache(uint partition_id)
 {
   handler *file;
@@ -4401,6 +4582,16 @@
                 MODULE optimiser support
 ****************************************************************************/
 
+/*
+  Get keys to use for scanning
+
+  SYNOPSIS
+    keys_to_use_for_scanning()
+
+  RETURN VALUE
+    key_map of keys usable for scanning
+*/
+
 const key_map *ha_partition::keys_to_use_for_scanning()
 {
   DBUG_ENTER("ha_partition::keys_to_use_for_scanning");
@@ -4408,6 +4599,16 @@
 }
 
 
+/*
+  Return time for a scan of the table
+
+  SYNOPSIS
+    scan_time()
+
+  RETURN VALUE
+    time for scan
+*/
+
 double ha_partition::scan_time()
 {
   double scan_time= 0;
@@ -4421,10 +4622,22 @@
 
 
 /*
-  This will be optimised later to include whether or not the index can
-  be used with partitioning. To achieve we need to add another parameter
-  that specifies how many of the index fields that are bound in the ranges.
-  Possibly added as a new call to handlers.
+  Get time to read
+
+  SYNOPSIS
+    read_time()
+    index                Index number used
+    ranges               Number of ranges
+    rows                 Number of rows
+
+  RETURN VALUE
+    time for read
+
+  DESCRIPTION
+    This will be optimised later to include whether or not the index can
+    be used with partitioning. To achieve we need to add another parameter
+    that specifies how many of the index fields that are bound in the ranges.
+    Possibly added as a new call to handlers.
 */
 
 double ha_partition::read_time(uint index, uint ranges, ha_rows rows)
@@ -4619,10 +4832,23 @@
                 MODULE compare records
 ****************************************************************************/
 /*
-  We get two references and need to check if those records are the same.
-  If they belong to different partitions we decide that they are not
-  the same record. Otherwise we use the particular handler to decide if
-  they are the same. Sort in partition id order if not equal.
+  Compare two positions
+
+  SYNOPSIS
+    cmp_ref()
+    ref1                   First position
+    ref2                   Second position
+
+  RETURN VALUE
+    <0                     ref1 < ref2
+    0                      Equal
+    >0                     ref1 > ref2
+
+  DESCRIPTION
+    We get two references and need to check if those records are the same.
+    If they belong to different partitions we decide that they are not
+    the same record. Otherwise we use the particular handler to decide if
+    they are the same. Sort in partition id order if not equal.
 */
 
 int ha_partition::cmp_ref(const byte *ref1, const byte *ref2)
Thread
bk commit into 5.1 tree (mikron:1.1962)mikael24 Nov