MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesort.h
1 /* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef FILESORT_INCLUDED
17 #define FILESORT_INCLUDED
18 
19 class SQL_SELECT;
20 
21 #include "my_global.h" /* uint, uchar */
22 #include "my_base.h" /* ha_rows */
23 #include "sql_list.h" /* Sql_alloc */
24 class SQL_SELECT;
25 class THD;
26 struct TABLE;
27 typedef struct st_sort_field SORT_FIELD;
28 typedef struct st_order ORDER;
29 
34 class Filesort: public Sql_alloc
35 {
36 public:
40  ha_rows limit;
42  SORT_FIELD *sortorder;
46  bool own_select;
48  bool using_pq;
49 
50  Filesort(ORDER *order_arg, ha_rows limit_arg, SQL_SELECT *select_arg):
51  order(order_arg),
52  limit(limit_arg),
53  sortorder(NULL),
54  select(select_arg),
55  own_select(false),
56  using_pq(false)
57  {
58  DBUG_ASSERT(order);
59  };
60 
61  ~Filesort() { cleanup(); }
62  /* Prepare ORDER BY list for sorting. */
63  uint make_sortorder();
64 
65 private:
66  void cleanup();
67 };
68 
69 ha_rows filesort(THD *thd, TABLE *table, Filesort *fsort, bool sort_positions,
70  ha_rows *examined_rows, ha_rows *found_rows);
71 void filesort_free_buffers(TABLE *table, bool full);
72 void change_double_for_sort(double nr,uchar *to);
73 
74 class Sort_param;
76 void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos);
78 uint sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
79  bool *multi_byte_charset);
80 
81 #endif /* FILESORT_INCLUDED */