#include <stddef.h>
#include <sys/types.h>
#include "mem_root_array.h"
#include "my_base.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "sql/sort_param.h"
 
Go to the source code of this file.
 | 
| bool  | filesort (THD *thd, Filesort *filesort, RowIterator *source_iterator, table_map tables_to_get_rowid_for, ha_rows num_rows_estimate, Filesort_info *fs_info, Sort_result *sort_result, ha_rows *found_rows) | 
|   | Sort a table.  More...
  | 
|   | 
| void  | filesort_free_buffers (TABLE *table, bool full) | 
|   | 
| void  | change_double_for_sort (double nr, uchar *to) | 
|   | 
| uint  | sortlength (THD *thd, st_sort_field *sortorder, uint s_length) | 
|   | Declared here so we can unit test it.  More...
  | 
|   | 
| template<bool Is_big_endian>  | 
| void  | copy_integer (uchar *to, size_t to_length, const uchar *from, size_t from_length, bool is_unsigned) | 
|   | Copies an integer value to a format comparable with memcmp().  More...
  | 
|   | 
| bool  | SortWillBeOnRowId (const TABLE *table) | 
|   | 
| static void  | copy_native_longlong (uchar *to, size_t to_length, longlong val, bool is_unsigned) | 
|   | 
◆ change_double_for_sort()
      
        
          | void change_double_for_sort  | 
          ( | 
          double  | 
          nr,  | 
        
        
           | 
           | 
          uchar *  | 
          to  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ copy_integer()
template<bool Is_big_endian> 
      
        
          | void copy_integer  | 
          ( | 
          uchar *  | 
          to,  | 
        
        
           | 
           | 
          size_t  | 
          to_length,  | 
        
        
           | 
           | 
          const uchar *  | 
          from,  | 
        
        
           | 
           | 
          size_t  | 
          from_length,  | 
        
        
           | 
           | 
          bool  | 
          is_unsigned  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Copies an integer value to a format comparable with memcmp(). 
The format is characterized by the following:
- The sign bit goes first and is unset for negative values.
 
- The representation is big endian.
 
The function template can be instantiated to copy from little or big endian values.
- Template Parameters
 - 
  
    | Is_big_endian | True if the source integer is big endian. | 
  
   
- Parameters
 - 
  
    | to | Where to write the integer.  | 
    | to_length | Size in bytes of the destination buffer.  | 
    | from | Where to read the integer.  | 
    | from_length | Size in bytes of the source integer  | 
    | is_unsigned | True if the source integer is an unsigned value.  | 
  
   
 
 
◆ copy_native_longlong()
  
  
      
        
          | static void copy_native_longlong  | 
          ( | 
          uchar *  | 
          to,  | 
         
        
           | 
           | 
          size_t  | 
          to_length,  | 
         
        
           | 
           | 
          longlong  | 
          val,  | 
         
        
           | 
           | 
          bool  | 
          is_unsigned  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inlinestatic   | 
  
 
 
◆ filesort()
Sort a table. 
Creates a set of pointers that can be used to read the rows in sorted order. This should be done with the functions in records.cc.
The result set is stored in fs_info->io_cache or fs_info->sorted_result, or left in the main filesort buffer.
- Parameters
 - 
  
     | thd | Current thread  | 
     | filesort | How to sort the table  | 
     | source_iterator | Where to read the rows to be sorted from.  | 
     | tables_to_get_rowid_for | Which tables we are responsible for getting row IDs for. Tables in this set that are not also in "tables" are ignored.  | 
     | num_rows_estimate | How many rows source_iterator is expected to produce. Only used for whether we intend to use the priority queue optimization or not; if we estimate fewer rows than we can fit into RAM, we never use the priority queue.  | 
     | fs_info | Owns the buffers for sort_result.  | 
     | sort_result | Where to store the sort result.  | 
    | [out] | found_rows | Store the number of found rows here. This is the number of found rows after applying WHERE condition. | 
  
   
- Note
 - If we sort row IDs (as opposed to addon fields), filesort() will call table->prepare_for_position().
 
- Returns
 - False if success, true if error 
 
 
 
◆ filesort_free_buffers()
      
        
          | void filesort_free_buffers  | 
          ( | 
          TABLE *  | 
          table,  | 
        
        
           | 
           | 
          bool  | 
          full  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ sortlength()
Declared here so we can unit test it. 
Declared here so we can unit test it.
- Parameters
 - 
  
    | thd | Thread handler  | 
    | sortorder | Order of items to sort  | 
    | s_length | Number of items to sort | 
  
   
- Note
 - sortorder->length is updated for each sort item.
 
- Returns
 - Total length of sort buffer in bytes 
 
 
 
◆ SortWillBeOnRowId()
      
        
          | bool SortWillBeOnRowId  | 
          ( | 
          const TABLE *  | 
          table | ) | 
           |