My Project
filesort.h
00001 /* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 #ifndef FILESORT_INCLUDED
00017 #define FILESORT_INCLUDED
00018 
00019 class SQL_SELECT;
00020 
00021 #include "my_global.h"                          /* uint, uchar */
00022 #include "my_base.h"                            /* ha_rows */
00023 #include "sql_list.h"                           /* Sql_alloc */
00024 class SQL_SELECT;
00025 class THD;
00026 struct TABLE;
00027 typedef struct st_sort_field SORT_FIELD;
00028 typedef struct st_order ORDER;
00029 
00034 class Filesort: public Sql_alloc
00035 {
00036 public:
00038   ORDER *order;
00040   ha_rows limit;
00042   SORT_FIELD *sortorder;
00044   SQL_SELECT *select;
00046   bool own_select;
00048   bool using_pq;
00049 
00050   Filesort(ORDER *order_arg, ha_rows limit_arg, SQL_SELECT *select_arg):
00051     order(order_arg),
00052     limit(limit_arg),
00053     sortorder(NULL),
00054     select(select_arg),
00055     own_select(false), 
00056     using_pq(false)
00057   {
00058     DBUG_ASSERT(order);
00059   };
00060 
00061   ~Filesort() { cleanup(); }
00062   /* Prepare ORDER BY list for sorting. */
00063   uint make_sortorder();
00064 
00065 private:
00066   void cleanup();
00067 };
00068 
00069 ha_rows filesort(THD *thd, TABLE *table, Filesort *fsort, bool sort_positions,
00070                  ha_rows *examined_rows, ha_rows *found_rows);
00071 void filesort_free_buffers(TABLE *table, bool full);
00072 void change_double_for_sort(double nr,uchar *to);
00073 
00074 class Sort_param;
00076 void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos);
00078 uint sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
00079                 bool *multi_byte_charset);
00080 
00081 #endif /* FILESORT_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines